public class PublicKey extends SimpleDataStructure
PublicKey provides the encryption component of I2P's asymmetric cryptography:
Supported Algorithms:
Key Format:
Usage:
PrivateKeyDestination cryptographic identityPerformance Features:
Security Considerations:
Migration Path:
Implementation Notes:
Thread Safety:
| Modifier and Type | Field and Description |
|---|---|
static int | KEYSIZE_BYTESDefault key size in bytes (256 for ElGamal). |
_data| Constructor and Description |
|---|
PublicKey()Creates a new PublicKey with the default ElGamal type. |
PublicKey(byte[] data)Construct from raw key data. |
PublicKey(EncType type)Construct a new public key. |
PublicKey(EncType type,
byte[] data)Construct a new public key. |
PublicKey(int typeCode,
byte[] data)Unknown type only. |
PublicKey(String base64Data)Constructs from base64. |
| Modifier and Type | Method and Description |
|---|---|
static void | clearCache()Clears the public key cache. |
static PublicKey | create(byte[] data,
int off)Pull from cache or return new. |
static PublicKey | create(InputStream in)Pull from cache or return new. |
boolean | equals(Object obj)Compares this public key with another object for equality. |
byte[] | getPadding(KeyCertificate kcert)Get the portion of this (type 0) PK that is really padding based on the Key Cert type given,
if any |
EncType | getType()Gets the encryption type of this public key. |
int | getUnknownTypeCode()Gets the type code for unknown encryption types. |
int | hashCode()Hash code combining the type and data. |
int | length()Key length in bytes, determined by the encryption type. |
String | toString()String representation showing type and data size. |
(package private) PublicKey | toTypedKey(KeyCertificate kcert)Up-convert this from an untyped (type 0) PK to a typed PK based on the Key Cert given. |
calculateHash, fromBase64, fromByteArray, getData, read, readBytes, setData, toBase64, toByteArray, writeBytespublic static final int KEYSIZE_BYTES
public PublicKey()
public PublicKey(byte[] data)
data - must be non-nullpublic PublicKey(EncType type)
type - if null, type is unknownpublic PublicKey(EncType type, byte[] data)
type - if null, type is unknowndata - must be non-nullpublic PublicKey(int typeCode,
byte[] data)typeCode - must not match a known type. 1-255data - must be non-nullpublic PublicKey(String base64Data) throws DataFormatException
base64Data - a string of base64 data (the output of .toBase64() called
on a prior instance of PublicKeyDataFormatException - if the data is malformedpublic static void clearCache()
public static PublicKey create(byte[] data, int off)
data - the data to decryptoff - the offset into the datapublic static PublicKey create(InputStream in) throws IOException
in - the input streamIOException - if an I/O error occurspublic boolean equals(Object obj)
equals in class SimpleDataStructureobj - the object to comparepublic byte[] getPadding(KeyCertificate kcert)
kcert - the key certificateIllegalArgumentException - if this is already typed to a different typepublic EncType getType()
public int getUnknownTypeCode()
public int hashCode()
hashCode in class SimpleDataStructurepublic int length()
length in class SimpleDataStructurepublic String toString()
toString in class SimpleDataStructurePublicKey toTypedKey(KeyCertificate kcert)
kcert - the key certificateIllegalArgumentException - if this is already typed to a different type