class Curve25519DHState extends Object implements DHState
Constructor and Description |
---|
Curve25519DHState(X25519KeyFactory xdh)
Constructs a new Diffie-Hellman object for Curve25519.
|
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 |
destroy()
Destroys all sensitive state in the current object.
|
void |
generateKeyPair()
Generates a new random keypair.
|
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.
|
public Curve25519DHState(X25519KeyFactory xdh)
public void destroy()
Destroyable
destroy
in interface Destroyable
public String getDHName()
DHState
public int getPublicKeyLength()
DHState
getPublicKeyLength
in interface DHState
public int getPrivateKeyLength()
DHState
getPrivateKeyLength
in interface DHState
public int getSharedKeyLength()
DHState
getSharedKeyLength
in interface DHState
public void generateKeyPair()
DHState
generateKeyPair
in interface DHState
public void getPublicKey(byte[] key, int offset)
DHState
getPublicKey
in interface DHState
key
- The buffer to copy the public key to.offset
- The first offset in the key buffer to copy to.public void setPublicKey(byte[] key, int offset)
DHState
setPublicKey
in interface DHState
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.public void getPrivateKey(byte[] key, int offset)
DHState
getPrivateKey
in interface DHState
key
- The buffer to copy the private key to.offset
- The first offset in the key buffer to copy to.public void setPrivateKey(byte[] key, int offset)
DHState
setPrivateKey
in interface DHState
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.public void setToNullPublicKey()
DHState
setToNullPublicKey
in interface DHState
public void clearKey()
DHState
public boolean hasPublicKey()
DHState
hasPublicKey
in interface DHState
public boolean hasPrivateKey()
DHState
hasPrivateKey
in interface DHState
public boolean isNullPublicKey()
DHState
isNullPublicKey
in interface DHState
public void calculate(byte[] sharedKey, int offset, DHState publicDH)
DHState