Package com.southernstorm.noise.protocol
Interface DHState
- 
- All Superinterfaces:
- Cloneable,- Destroyable
 - All Known Implementing Classes:
- Curve25519DHState
 
 public interface DHState extends Destroyable, Cloneable Interface to a Diffie-Hellman algorithm for the Noise protocol.
- 
- 
Method SummaryAll Methods Instance Methods Abstract 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.DHStateclone()I2PvoidcopyFrom(DHState other)Copies the key values from another DH object of the same type.voidgenerateKeyPair()Generates a new random keypair.StringgetDHName()Gets the Noise protocol name for this Diffie-Hellman algorithm.voidgetEncodedPublicKey(byte[] key, int offset)Gets the public key associated with this object.voidgetPrivateKey(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()Determine if this object contains an optional encoded public key.booleanhasPrivateKey()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.- 
Methods inherited from interface com.southernstorm.noise.protocol.Destroyabledestroy
 
- 
 
- 
- 
- 
Method Detail- 
getDHNameString getDHName() Gets the Noise protocol name for this Diffie-Hellman algorithm.- Returns:
- The algorithm name.
 
 - 
getPublicKeyLengthint getPublicKeyLength() Gets the length of public keys for this algorithm.- Returns:
- The length of public keys in bytes.
 
 - 
getPrivateKeyLengthint getPrivateKeyLength() Gets the length of private keys for this algorithm.- Returns:
- The length of private keys in bytes.
 
 - 
getSharedKeyLengthint getSharedKeyLength() Gets the length of shared keys for this algorithm.- Returns:
- The length of shared keys in bytes.
 
 - 
generateKeyPairvoid generateKeyPair() Generates a new random keypair.
 - 
getPublicKeyvoid getPublicKey(byte[] key, int offset)Gets the public key associated with this object.- Parameters:
- key- The buffer to copy the public key to.
- offset- The first offset in the key buffer to copy to.
 
 - 
setPublicKeyvoid setPublicKey(byte[] key, int offset)Sets the public key for this object.- 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.
 
 - 
getPrivateKeyvoid getPrivateKey(byte[] key, int offset)Gets the private key associated with this object.- Parameters:
- key- The buffer to copy the private key to.
- offset- The first offset in the key buffer to copy to.
 
 - 
setPrivateKey@Deprecated void setPrivateKey(byte[] key, int offset) Deprecated.use setKeys()Sets the private key for this object.- 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.
 
 - 
setKeysvoid 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.- Parameters:
- 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.
- Since:
- 0.9.48
 
 - 
setToNullPublicKeyvoid setToNullPublicKey() Sets this object to the null public key and clears the private key.
 - 
clearKeyvoid clearKey() Clears the key pair.
 - 
hasPublicKeyboolean hasPublicKey() Determine if this object contains a public key.- Returns:
- Returns true if this object contains a public key, or false if the public key has not yet been set.
 
 - 
hasPrivateKeyboolean hasPrivateKey() Determine if this object contains a private key.- Returns:
- Returns true if this object contains a private key, or false if the private key has not yet been set.
 
 - 
isNullPublicKeyboolean isNullPublicKey() Determine if the public key in this object is the special null value.- Returns:
- Returns true if the public key is the special null value, or false otherwise.
 
 - 
hasEncodedPublicKeyboolean hasEncodedPublicKey() Determine if this object contains an optional encoded public key.- 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
 
 - 
getEncodedPublicKeyvoid getEncodedPublicKey(byte[] key, int offset)Gets the public key associated with this object.- 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
 
 - 
calculatevoid calculate(byte[] sharedKey, int offset, DHState publicDH)Performs a Diffie-Hellman calculation with this object as the private key.- Parameters:
- 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.
- Throws:
- IllegalArgumentException- The publicDH object is not the same type as this object, or one of the objects does not contain a valid key.
 
 - 
copyFromvoid copyFrom(DHState other) Copies the key values from another DH object of the same type.- Parameters:
- other- The other DH object to copy from
- Throws:
- IllegalStateException- The other DH object does not have the same type as this object.
 
 - 
cloneDHState clone() throws CloneNotSupportedException I2P- Throws:
- CloneNotSupportedException
- Since:
- 0.9.44
 
 
- 
 
-