Package com.southernstorm.noise.protocol
Class Curve25519DHState
- java.lang.Object
-
- com.southernstorm.noise.protocol.Curve25519DHState
-
-
Constructor Summary
Constructors Constructor Description Curve25519DHState(KeyFactory xdh)Constructs a new Diffie-Hellman object for Curve25519.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcalculate(byte[] sharedKey, int offset, DHState publicDH)Performs a Diffie-Hellman calculation with this object as the private key.voidclearKey()Clears the key pair.Curve25519DHStateclone()I2PvoidcopyFrom(DHState other)Copies the key values from another DH object of the same type.voiddestroy()Destroys all sensitive state in the current object.voidgenerateKeyPair()Generates a new random keypair.StringgetDHName()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.intgetPrivateKeyLength()Gets the length of private keys for this algorithm.voidgetPublicKey(byte[] key, int offset)Gets the public key associated with this object.intgetPublicKeyLength()Gets the length of public keys for this algorithm.intgetSharedKeyLength()Gets the length of shared keys for this algorithm.booleanhasEncodedPublicKey()I2PbooleanhasPrivateKey()Determine if this object contains a private key.booleanhasPublicKey()Determine if this object contains a public key.booleanisNullPublicKey()Determine 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.voidsetToNullPublicKey()Sets this object to the null public key and clears the private key.
-
-
-
Constructor Detail
-
Curve25519DHState
public Curve25519DHState(KeyFactory xdh)
Constructs a new Diffie-Hellman object for Curve25519.
-
-
Method Detail
-
destroy
public void destroy()
Description copied from interface:DestroyableDestroys all sensitive state in the current object.- Specified by:
destroyin interfaceDestroyable
-
getDHName
public String 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.
-
getSharedKeyLength
public int getSharedKeyLength()
Description copied from interface:DHStateGets the length of shared keys for this algorithm.- Specified by:
getSharedKeyLengthin interfaceDHState- Returns:
- The length of shared 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 public void setPrivateKey(byte[] key, int offset)
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
public void calculate(byte[] sharedKey, int offset, DHState publicDH)Description copied from interface:DHStatePerforms a Diffie-Hellman calculation with this object as the private key.
-
copyFrom
public void copyFrom(DHState other)
Description copied from interface:DHStateCopies the key values from another DH object of the same type.
-
clone
public Curve25519DHState clone() throws CloneNotSupportedException
I2P- Specified by:
clonein interfaceDHState- Overrides:
clonein classObject- Throws:
CloneNotSupportedException- Since:
- 0.9.44
-
-