Package com.southernstorm.noise.protocol
Class MLKEMDHState
java.lang.Object
com.southernstorm.noise.protocol.MLKEMDHState
- All Implemented Interfaces:
Destroyable,DHState,Cloneable
Implementation of the MLKEM algorithm for the Noise protocol.
- Since:
- 0.9.67
-
Constructor Summary
ConstructorsConstructorDescriptionMLKEMDHState(boolean isAlice, String patternId) Bob local/remote or Alice remote side, do not call generateKeyPair()MLKEMDHState(KeyFactory hdh, String patternId) Alice local side -
Method Summary
Modifier and TypeMethodDescriptionvoidSide effect: If we are Bob, copies the ciphertext to our public key so it may be written out in the message.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.voidAlice local side ONLYGets the Noise protocol name for this Diffie-Hellman algorithm.voidgetEncodedPublicKey(byte[] key, int offset) Deprecated.voidgetPrivateKey(byte[] key, int offset) Deprecated.intDeprecated.voidgetPublicKey(byte[] key, int offset) Gets the public key associated with this object.intNote: Alice/Bob sizes are differentintGets 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) Deprecated.voidsetPrivateKey(byte[] key, int offset) Deprecated.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
-
MLKEMDHState
Bob local/remote or Alice remote side, do not call generateKeyPair()- Parameters:
isAlice- true for Bob remote side, false for Bob local side and Alice remote side
-
MLKEMDHState
Alice local side
-
-
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()Note: Alice/Bob sizes are different- Specified by:
getPublicKeyLengthin interfaceDHState- Returns:
- The length of public keys in bytes.
-
getPrivateKeyLength
Deprecated.Note: Alice/Bob sizes are different- Specified by:
getPrivateKeyLengthin interfaceDHState- Returns:
- 0 for Bob
-
generateKeyPair
public void generateKeyPair()Alice local side ONLY- 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
Deprecated.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.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
Deprecated.Description copied from interface:DHStateSets 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.
-
getEncodedPublicKey
Deprecated.Description copied from interface:DHStateGets the public key associated with this object.- 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.
-
calculate
Side effect: If we are Bob, copies the ciphertext to our public key so it may be written out in the message.- Specified by:
calculatein interfaceDHState- 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- on bad public key modulus
-
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
-