Package net.i2p.data
Class KeysAndCert
- java.lang.Object
-
- net.i2p.data.DataStructureImpl
-
- net.i2p.data.KeysAndCert
-
- All Implemented Interfaces:
Serializable
,DataStructure
- Direct Known Subclasses:
Destination
,RouterIdentity
public class KeysAndCert extends DataStructureImpl
KeysAndCert has a public key, a signing key, and a certificate. In that order. We also store a cached Hash. Implemented in 0.8.2 and retrofitted over Destination and RouterIdentity. There's actually no difference between the two of them. As of 0.9.9 this data structure is immutable after the two keys and the certificate are set; attempts to change them will throw an IllegalStateException.- Since:
- 0.8.2
- Author:
- zzz
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Certificate
_certificate
protected byte[]
_padding
protected PublicKey
_publicKey
protected SigningPublicKey
_signingKey
-
Constructor Summary
Constructors Constructor Description KeysAndCert()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Hash
calculateHash()
Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12.protected static byte[]
combinePadding(byte[] pad1, byte[] pad2)
boolean
equals(Object object)
Certificate
getCertificate()
EncType
getEncType()
Hash
getHash()
Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12.byte[]
getPadding()
PublicKey
getPublicKey()
SigningPublicKey
getSigningPublicKey()
SigType
getSigType()
int
hashCode()
the signing key has enough randomness in it to use it by itself for speedvoid
readBytes(InputStream in)
Load up the current object with data from the given stream.void
setCertificate(Certificate cert)
void
setPadding(byte[] padding)
void
setPublicKey(PublicKey key)
void
setSigningPublicKey(SigningPublicKey key)
String
toString()
void
writeBytes(OutputStream out)
Write out the data structure to the stream, using the format defined in the I2P data structure specification.-
Methods inherited from class net.i2p.data.DataStructureImpl
fromBase64, fromByteArray, read, toBase64, toByteArray
-
-
-
-
Field Detail
-
_publicKey
protected PublicKey _publicKey
-
_signingKey
protected SigningPublicKey _signingKey
-
_certificate
protected Certificate _certificate
-
_padding
protected byte[] _padding
-
-
Method Detail
-
getCertificate
public Certificate getCertificate()
-
setCertificate
public void setCertificate(Certificate cert)
- Throws:
IllegalStateException
- if was already set
-
getSigType
public SigType getSigType()
- Returns:
- null if not set or unknown
- Since:
- 0.9.17
-
getEncType
public EncType getEncType()
- Returns:
- null if not set or unknown
- Since:
- 0.9.42
-
getPublicKey
public PublicKey getPublicKey()
-
setPublicKey
public void setPublicKey(PublicKey key)
- Throws:
IllegalStateException
- if was already set
-
getSigningPublicKey
public SigningPublicKey getSigningPublicKey()
-
setSigningPublicKey
public void setSigningPublicKey(SigningPublicKey key)
- Throws:
IllegalStateException
- if was already set
-
getPadding
public byte[] getPadding()
- Since:
- 0.9.16
-
setPadding
public void setPadding(byte[] padding)
- Throws:
IllegalStateException
- if was already set- Since:
- 0.9.12
-
readBytes
public void readBytes(InputStream in) throws DataFormatException, IOException
Description copied from interface:DataStructure
Load up the current object with data from the given stream. Data loaded this way must match the I2P data structure specification. Warning - many classes will throw IllegalStateException if data is already set.- Parameters:
in
- stream to read from- Throws:
IllegalStateException
- if data already setDataFormatException
- if the data is improperly formattedIOException
- if there was a problem reading the stream
-
combinePadding
protected static byte[] combinePadding(byte[] pad1, byte[] pad2)
- Returns:
- null if both are null
- Since:
- 0.9.42
-
writeBytes
public void writeBytes(OutputStream out) throws DataFormatException, IOException
Description copied from interface:DataStructure
Write out the data structure to the stream, using the format defined in the I2P data structure specification.- Parameters:
out
- stream to write to- Throws:
DataFormatException
- if the data was incomplete or not yet ready to be writtenIOException
- if there was a problem writing to the stream
-
hashCode
public int hashCode()
the signing key has enough randomness in it to use it by itself for speed
-
calculateHash
public Hash calculateHash()
Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12. Prior to that, returned null.- Specified by:
calculateHash
in interfaceDataStructure
- Overrides:
calculateHash
in classDataStructureImpl
- Returns:
- SHA256 hash, or null if there were problems (data format or io errors)
- Throws:
IllegalStateException
-
getHash
public Hash getHash()
Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12. Prior to that, returned null.- Throws:
IllegalStateException
-
-