Package net.i2p.data
Class PublicKey
- java.lang.Object
-
- net.i2p.data.DataStructureImpl
-
- net.i2p.data.SimpleDataStructure
-
- net.i2p.data.PublicKey
-
- All Implemented Interfaces:
Serializable
,DataStructure
public class PublicKey extends SimpleDataStructure
Defines the PublicKey as defined by the I2P data structure spec. A public key is 256byte Integer. The public key represents only the exponent, not the primes, which are constant and defined in the crypto spec. As of release 0.9.38, keys of arbitrary length and type are supported. See EncType.- Author:
- jrandom
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
KEYSIZE_BYTES
-
Fields inherited from class net.i2p.data.SimpleDataStructure
_data
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clearCache()
static PublicKey
create(byte[] data, int off)
Pull from cache or return new.static PublicKey
create(InputStream in)
Pull from cache or return newEncType
getType()
int
getUnknownTypeCode()
Only valid if getType() returns nullint
length()
The legal length of the byte array in this data structureString
toString()
-
Methods inherited from class net.i2p.data.SimpleDataStructure
calculateHash, equals, fromBase64, fromByteArray, getData, hashCode, readBytes, setData, toBase64, toByteArray, writeBytes
-
Methods inherited from class net.i2p.data.DataStructureImpl
read
-
-
-
-
Constructor Detail
-
PublicKey
public PublicKey()
-
PublicKey
public PublicKey(EncType type)
- Parameters:
type
- if null, type is unknown- Since:
- 0.9.38
-
PublicKey
public PublicKey(byte[] data)
- Parameters:
data
- must be non-null
-
PublicKey
public PublicKey(EncType type, byte[] data)
- Parameters:
type
- if null, type is unknowndata
- must be non-null- Since:
- 0.9.38
-
PublicKey
public PublicKey(int typeCode, byte[] data)
Unknown type only.- Parameters:
typeCode
- must not match a known type. 1-255data
- must be non-null- Since:
- 0.9.38
-
PublicKey
public PublicKey(String base64Data) throws DataFormatException
Constructs from base64. ElGamal only.- Parameters:
base64Data
- a string of base64 data (the output of .toBase64() called on a prior instance of PublicKey- Throws:
DataFormatException
-
-
Method Detail
-
create
public static PublicKey create(byte[] data, int off)
Pull from cache or return new. Deprecated - used only by deprecated Destination.readBytes(data, off)- Throws:
ArrayIndexOutOfBoundsException
- if not enough bytes, FIXME should throw DataFormatException- Since:
- 0.8.3
-
create
public static PublicKey create(InputStream in) throws IOException
Pull from cache or return new- Throws:
IOException
- Since:
- 0.8.3
-
length
public int length()
Description copied from class:SimpleDataStructure
The legal length of the byte array in this data structure- Specified by:
length
in classSimpleDataStructure
-
getType
public EncType getType()
- Returns:
- null if unknown
- Since:
- 0.9.38
-
getUnknownTypeCode
public int getUnknownTypeCode()
Only valid if getType() returns null- Since:
- 0.9.38
-
clearCache
public static void clearCache()
- Since:
- 0.9.17
-
toString
public String toString()
- Overrides:
toString
in classSimpleDataStructure
- Since:
- 0.9.38
-
-