Package com.southernstorm.noise.protocol
Class Curve25519DHState
java.lang.Object
com.southernstorm.noise.protocol.Curve25519DHState
- All Implemented Interfaces:
Destroyable,DHState,Cloneable
Implementation of the Curve25519 algorithm for the Noise protocol.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new Diffie-Hellman object for Curve25519. -
Method Summary
Modifier and TypeMethodDescriptionvoidPerforms a Diffie-Hellman calculation with this object as the private key.voidclearKey()Clears the key pair.clone()I2PvoidCopies the key values from another DH object of the same type.voiddestroy()Destroys all sensitive state in the current object.voidGenerates a new random keypair.Gets the Noise protocol name for this Diffie-Hellman algorithm.voidgetEncodedPublicKey(byte[] key, int offset) I2PvoidgetPrivateKey(byte[] key, int offset) Gets the private key associated with this object.intGets the length of private keys for this algorithm.voidgetPublicKey(byte[] key, int offset) Gets the public key associated with this object.intGets the length of public keys for this algorithm.intGets the length of shared keys for this algorithm.booleanI2PbooleanDetermine if this object contains a private key.booleanDetermine if this object contains a public key.booleanDetermine if the public key in this object is the special null value.voidsetKeys(byte[] privkey, int privoffset, byte[] pubkey, int puboffset) Sets the private and public keys for this object.voidsetPrivateKey(byte[] key, int offset) Deprecated.use setKeys()voidsetPublicKey(byte[] key, int offset) Sets the public key for this object.voidSets this object to the null public key and clears the private key.
-
Constructor Details
-
Curve25519DHState
Constructs a new Diffie-Hellman object for Curve25519.
-
-
Method Details
-
destroy
public void destroy()Description copied from interface:DestroyableDestroys all sensitive state in the current object.- Specified by:
destroyin interfaceDestroyable
-
getDHName
Description copied from interface:DHStateGets the Noise protocol name for this Diffie-Hellman algorithm. -
getPublicKeyLength
public int getPublicKeyLength()Description copied from interface:DHStateGets the length of public keys for this algorithm.- Specified by:
getPublicKeyLengthin interfaceDHState- Returns:
- The length of public keys in bytes.
-
getPrivateKeyLength
public int getPrivateKeyLength()Description copied from interface:DHStateGets the length of private keys for this algorithm.- Specified by:
getPrivateKeyLengthin interfaceDHState- Returns:
- The length of private keys in bytes.
-
generateKeyPair
public void generateKeyPair()Description copied from interface:DHStateGenerates a new random keypair.- Specified by:
generateKeyPairin interfaceDHState
-
getPublicKey
public void getPublicKey(byte[] key, int offset) Description copied from interface:DHStateGets the public key associated with this object.- Specified by:
getPublicKeyin interfaceDHState- Parameters:
key- The buffer to copy the public key to.offset- The first offset in the key buffer to copy to.
-
setPublicKey
public void setPublicKey(byte[] key, int offset) Description copied from interface:DHStateSets the public key for this object.- Specified by:
setPublicKeyin interfaceDHState- Parameters:
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.
-
getPrivateKey
public void getPrivateKey(byte[] key, int offset) Description copied from interface:DHStateGets the private key associated with this object.- Specified by:
getPrivateKeyin interfaceDHState- Parameters:
key- The buffer to copy the private key to.offset- The first offset in the key buffer to copy to.
-
setPrivateKey
Deprecated.use setKeys()Description copied from interface:DHStateSets the private key for this object.- Specified by:
setPrivateKeyin interfaceDHState- Parameters:
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.
-
setKeys
public void setKeys(byte[] privkey, int privoffset, byte[] pubkey, int puboffset) Sets the private and public keys for this object. I2P for efficiency, since setPrivateKey() calculates the public key and overwrites it. Does NOT check that the two keys match. -
setToNullPublicKey
public void setToNullPublicKey()Description copied from interface:DHStateSets this object to the null public key and clears the private key.- Specified by:
setToNullPublicKeyin interfaceDHState
-
clearKey
public void clearKey()Description copied from interface:DHStateClears the key pair. -
hasPublicKey
public boolean hasPublicKey()Description copied from interface:DHStateDetermine if this object contains a public key.- Specified by:
hasPublicKeyin interfaceDHState- Returns:
- Returns true if this object contains a public key, or false if the public key has not yet been set.
-
hasPrivateKey
public boolean hasPrivateKey()Description copied from interface:DHStateDetermine if this object contains a private key.- Specified by:
hasPrivateKeyin interfaceDHState- Returns:
- Returns true if this object contains a private key, or false if the private key has not yet been set.
-
isNullPublicKey
public boolean isNullPublicKey()Description copied from interface:DHStateDetermine if the public key in this object is the special null value.- Specified by:
isNullPublicKeyin interfaceDHState- Returns:
- Returns true if the public key is the special null value, or false otherwise.
-
hasEncodedPublicKey
public boolean hasEncodedPublicKey()I2P- Specified by:
hasEncodedPublicKeyin interfaceDHState- Returns:
- Returns true if this object contains an encoded public key, or false if the public key has not yet been set.
- Since:
- 0.9.44
-
getEncodedPublicKey
public void getEncodedPublicKey(byte[] key, int offset) I2P- Specified by:
getEncodedPublicKeyin interfaceDHState- Parameters:
key- The buffer to copy the public key to.offset- The first offset in the key buffer to copy to.- Since:
- 0.9.44
-
calculate
Description copied from interface:DHStatePerforms a Diffie-Hellman calculation with this object as the private key. -
copyFrom
Description copied from interface:DHStateCopies the key values from another DH object of the same type. -
clone
I2P- Specified by:
clonein interfaceDHState- Overrides:
clonein classObject- Throws:
CloneNotSupportedException- Since:
- 0.9.44
-