public interface DHState extends Destroyable
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.
|
void |
copyFrom(DHState other)
Copies the key values from another DH object of the same type.
|
void |
generateKeyPair()
Generates a new random keypair.
|
java.lang.String |
getDHName()
Gets the Noise protocol name for this Diffie-Hellman algorithm.
|
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 |
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 |
setPrivateKey(byte[] key,
int offset)
Sets the private key 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.
|
destroy
java.lang.String getDHName()
int getPublicKeyLength()
int getPrivateKeyLength()
int getSharedKeyLength()
void generateKeyPair()
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.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 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.void setPrivateKey(byte[] key, int offset)
key
- The buffer containing the [rivate key.offset
- The first offset in the buffer that contains the key.
If this object previously held only a public key, then
this function will change it into a key pair.void setToNullPublicKey()
void clearKey()
boolean hasPublicKey()
boolean hasPrivateKey()
boolean isNullPublicKey()
void 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.java.lang.IllegalArgumentException
- The publicDH object is not the same
type as this object, or one of the objects does not contain a valid key.void copyFrom(DHState other)
other
- The other DH object to copy fromjava.lang.IllegalStateException
- The other DH object does not have
the same type as this object.