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_BYTES |
_data| Constructor and Description |
|---|
PublicKey() |
PublicKey(byte[] data) |
PublicKey(EncType type) |
PublicKey(EncType type,
byte[] data) |
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)
Warning - this returns true for two different classes with the same size
and same data, e.g.
|
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()
We assume the data has enough randomness in it, so use the first 4 bytes for speed.
|
int |
length()
The legal length of the byte array in this data structure
|
String |
toString() |
(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 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 PublicKeyDataFormatExceptionpublic static void clearCache()
public static PublicKey create(byte[] data, int off)
DataFormatException - if not enough bytespublic static PublicKey create(InputStream in) throws IOException
IOExceptionpublic boolean equals(Object obj)
SimpleDataStructureequals in class SimpleDataStructurepublic byte[] getPadding(KeyCertificate kcert)
IllegalArgumentException - if this is already typed to a different typepublic EncType getType()
public int getUnknownTypeCode()
public int hashCode()
SimpleDataStructurehashCode in class SimpleDataStructurepublic int length()
SimpleDataStructurelength in class SimpleDataStructurepublic String toString()
toString in class SimpleDataStructurePublicKey toTypedKey(KeyCertificate kcert)
IllegalArgumentException - if this is already typed to a different type