public interface DHState extends Destroyable, Cloneable
| Modifier and Type | Method and Description |
|---|---|
void | calculate(byte[] sharedKey,
int offset,
DHState publicDH)Performs a Diffie-Hellman calculation with this object as the private key. |
void | clearKey()Clears the key pair. |
DHState | clone()I2P |
void | copyFrom(DHState other)Copies the key values from another DH object of the same type. |
void | generateKeyPair()Generates a new random keypair. |
String | getDHName()Gets the Noise protocol name for this Diffie-Hellman algorithm. |
void | getEncodedPublicKey(byte[] key,
int offset)Gets the public key associated with this object. |
void | getPrivateKey(byte[] key,
int offset)Gets the private key associated with this object. |
int | getPrivateKeyLength()Gets the length of private keys for this algorithm. |
void | getPublicKey(byte[] key,
int offset)Gets the public key associated with this object. |
int | getPublicKeyLength()Gets the length of public keys for this algorithm. |
int | getSharedKeyLength()Gets the length of shared keys for this algorithm. |
boolean | hasEncodedPublicKey()Determine if this object contains an optional encoded public key. |
boolean | hasPrivateKey()Determine if this object contains a private key. |
boolean | hasPublicKey()Determine if this object contains a public key. |
boolean | isNullPublicKey()Determine if the public key in this object is the special null value. |
void | setKeys(byte[] privkey,
int privoffset,
byte[] pubkey,
int puboffset)Sets the private and public keys for this object. |
void | setPublicKey(byte[] key,
int offset)Sets the public key for this object. |
void | setToNullPublicKey()Sets this object to the null public key and clears the private key. |
destroyvoid calculate(byte[] sharedKey,
int offset,
DHState publicDH)sharedKey - Buffer to put the shared key into.offset - Offset of the first byte for the shared key.publicDH - Object that contains the public key for the calculation.IllegalArgumentException - The publicDH object is not the same
type as this object, or one of the objects does not contain a valid key.void clearKey()
DHState clone() throws CloneNotSupportedException
CloneNotSupportedExceptionvoid copyFrom(DHState other)
other - The other DH object to copy fromIllegalStateException - The other DH object does not have
the same type as this object.void generateKeyPair()
String getDHName()
void getEncodedPublicKey(byte[] key,
int offset)key - The buffer to copy the public key to.offset - The first offset in the key buffer to copy to.void getPrivateKey(byte[] key,
int offset)key - The buffer to copy the private key to.offset - The first offset in the key buffer to copy to.int getPrivateKeyLength()
void getPublicKey(byte[] key,
int offset)key - The buffer to copy the public key to.offset - The first offset in the key buffer to copy to.int getPublicKeyLength()
int getSharedKeyLength()
boolean hasEncodedPublicKey()
boolean hasPrivateKey()
boolean hasPublicKey()
boolean isNullPublicKey()
void setKeys(byte[] privkey,
int privoffset,
byte[] pubkey,
int puboffset)privkey - The buffer containing the private key.privoffset - The first offset in the buffer that contains the key.pubkey - The buffer containing the private key.puboffset - The first offset in the buffer that contains the key.void setPublicKey(byte[] key,
int offset)key - The buffer containing the public key.offset - The first offset in the buffer that contains the key.
If this object previously held a key pair, then this function
will change it into a public key only object.void setToNullPublicKey()