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_certificateprotected byte[]_paddingprotected PublicKey_publicKeyprotected SigningPublicKey_signingKey -
Constructor Summary
Constructors Constructor Description KeysAndCert() -
Method Summary
Modifier and Type Method Description HashcalculateHash()Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12.protected static byte[]combinePadding(byte[] pad1, byte[] pad2)booleanequals(Object object)CertificategetCertificate()EncTypegetEncType()HashgetHash()Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12.byte[]getPadding()PublicKeygetPublicKey()SigningPublicKeygetSigningPublicKey()SigTypegetSigType()inthashCode()the signing key has enough randomness in it to use it by itself for speedvoidreadBytes(InputStream in)Load up the current object with data from the given stream.voidsetCertificate(Certificate cert)voidsetPadding(byte[] padding)voidsetPublicKey(PublicKey key)voidsetSigningPublicKey(SigningPublicKey key)StringtoString()voidwriteBytes(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 Details
-
_publicKey
-
_signingKey
-
_certificate
-
_padding
protected byte[] _padding
-
-
Constructor Details
-
KeysAndCert
public KeysAndCert()
-
-
Method Details
-
getCertificate
-
setCertificate
- Throws:
IllegalStateException- if was already set
-
getSigType
- Returns:
- null if not set or unknown
- Since:
- 0.9.17
-
getEncType
- Returns:
- null if not set or unknown
- Since:
- 0.9.42
-
getPublicKey
-
setPublicKey
- Throws:
IllegalStateException- if was already set
-
getSigningPublicKey
-
setSigningPublicKey
- 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
Description copied from interface:DataStructureLoad 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
Description copied from interface:DataStructureWrite 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
-
equals
-
hashCode
public int hashCode()the signing key has enough randomness in it to use it by itself for speed -
toString
-
calculateHash
Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12. Prior to that, returned null.- Specified by:
calculateHashin interfaceDataStructure- Overrides:
calculateHashin classDataStructureImpl- Returns:
- SHA256 hash, or null if there were problems (data format or io errors)
- Throws:
IllegalStateException
-
getHash
Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12. Prior to that, returned null.- Throws:
IllegalStateException
-