Top Description Inners Constructors Methods
org.apache.sshd.common.kex

pack-priv final Class MLKEM

extends Object
Class Inheritance
Imports
java.util.Arrays, .Objects, org.apache.sshd.common.OptionalFeature, org.apache.sshd.common.random.JceRandom, org.bouncycastle.crypto.AsymmetricCipherKeyPair, .SecretWithEncapsulation, org.bouncycastle.pqc.crypto.mlkem.MLKEMExtractor, .MLKEMGenerator, .MLKEMKeyGenerationParameters, .MLKEMKeyPairGenerator, .MLKEMParameters, .MLKEMPrivateKeyParameters, .MLKEMPublicKeyParameters

An implementation of the mlkem768 key encapsulation method (KEM), formerly known as Kyber, using Bouncy Castle. But see appendix C of FIPS 203 ("Differences From the CRYSTALS-Kyber Submission").

NIST specifies that they removed a hash in the encapsulation/decapsulation methods.

See Also
NIST FIPS 203

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static enum
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static KeyEncapsulationMethod.Client
pack-priv static KeyEncapsulationMethod.Server
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MLKEMback to summary
private MLKEM()

Method Detail

getClientback to summary
pack-priv static KeyEncapsulationMethod.Client getClient(MLKEM.Parameters parameters)
getServerback to summary
pack-priv static KeyEncapsulationMethod.Server getServer(MLKEM.Parameters parameters)
org.apache.sshd.common.kex back to summary

private Class MLKEM.Client

extends Object
implements Client
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.kex.KeyEncapsulationMethod.Client

Field Summary

Modifier and TypeField and Description
private MLKEMExtractor
private final MLKEM.Parameters
private MLKEMPublicKeyParameters

Constructor Summary

AccessConstructor and Description
pack-priv
Client(MLKEM.Parameters parameters)

Method Summary

Modifier and TypeMethod and Description
public byte[]
extractSecret(byte[]
ciphertext to process.
encapsulated
)

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.extractSecret.

Extracts the secret from an encapsulation ciphertext.

public int
public byte[]
public void
init()

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.init.

Initializes the KEM and generates a new key pair.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

extractorback to summary
private MLKEMExtractor extractor
parametersback to summary
private final MLKEM.Parameters parameters
publicKeyback to summary
private MLKEMPublicKeyParameters publicKey

Constructor Detail

Clientback to summary
pack-priv Client(MLKEM.Parameters parameters)

Method Detail

extractSecretback to summary
public byte[] extractSecret(byte[] encapsulated)

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.extractSecret.

Doc from org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.extractSecret.

Extracts the secret from an encapsulation ciphertext.

Parameters
encapsulated:byte[]

ciphertext to process.

Returns:byte[]

the secret from an encapsulation ciphertext.

Annotations
@Override
getEncapsulationLengthback to summary
public int getEncapsulationLength()

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.getEncapsulationLength.

Doc from org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.getEncapsulationLength.

Gets the required encapsulation length in bytes.

Returns:int

the length required for a valid encapsulation ciphertext.

Annotations
@Override
getPublicKeyback to summary
public byte[] getPublicKey()

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.getPublicKey.

Doc from org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.getPublicKey.

Gets the KEM public key.

Returns:byte[]

the KEM public key.

Annotations
@Override
initback to summary
public void init()

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.init.

Doc from org.apache.sshd.common.kex.KeyEncapsulationMethod.Client.init.

Initializes the KEM and generates a new key pair.

Annotations
@Override
org.apache.sshd.common.kex back to summary

pack-priv sealed Enum MLKEM.Parameters

extends Enum<MLKEM.Parameters>
implements OptionalFeature
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.OptionalFeature

Field Summary

Modifier and TypeField and Description
public static final MLKEM.Parameters
public static final MLKEM.Parameters
private final int

Constructor Summary

AccessConstructor and Description
private
Parameters(int publicKeySize)

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract Object
pack-priv int
public boolean
public static MLKEM.Parameters
public static MLKEM.Parameters[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

mlkem1024back to summary
public static final MLKEM.Parameters mlkem1024
mlkem768back to summary
public static final MLKEM.Parameters mlkem768
publicKeySizeback to summary
private final int publicKeySize

Constructor Detail

Parametersback to summary
private Parameters(int publicKeySize)

Method Detail

getMLKEMParametersback to summary
pack-priv abstract Object getMLKEMParameters()
getPublicKeySizeback to summary
pack-priv int getPublicKeySize()
isSupportedback to summary
public boolean isSupported()

Implements org.apache.sshd.common.OptionalFeature.isSupported.

Annotations
@Override
valueOfback to summary
public static MLKEM.Parameters valueOf(String name)
valuesback to summary
public static MLKEM.Parameters[] values()
org.apache.sshd.common.kex back to summary

private Class MLKEM.Server

extends Object
implements Server
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.kex.KeyEncapsulationMethod.Server

Field Summary

Modifier and TypeField and Description
private final MLKEM.Parameters
private SecretWithEncapsulation

Constructor Summary

AccessConstructor and Description
pack-priv
Server(MLKEM.Parameters parameters)

Method Summary

Modifier and TypeMethod and Description
public byte[]
public int
getPublicKeyLength()

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.getPublicKeyLength.

Retrieves the required length of the KEM public key, in bytes.

public byte[]
public byte[]
init(byte[]
data received from the client, expected to contain the public key at the start
publicKey
)

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.init.

Initializes the KEM with a public key received from a client and prepares an encapsulated secret.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parametersback to summary
private final MLKEM.Parameters parameters
valueback to summary
private SecretWithEncapsulation value

Constructor Detail

Serverback to summary
pack-priv Server(MLKEM.Parameters parameters)

Method Detail

getEncapsulationback to summary
public byte[] getEncapsulation()

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.getEncapsulation.

Doc from org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.getEncapsulation.

Retrieves the encapsulation of the secret.

Returns:byte[]

the encapsulation of the secret that may be sent to the client

Annotations
@Override
getPublicKeyLengthback to summary
public int getPublicKeyLength()

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.getPublicKeyLength.

Doc from org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.getPublicKeyLength.

Retrieves the required length of the KEM public key, in bytes.

Returns:int

the length of the key

Annotations
@Override
getSecretback to summary
public byte[] getSecret()

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.getSecret.

Doc from org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.getSecret.

Retrieves the secret.

Returns:byte[]

the secret, not encapsulated

Annotations
@Override
initback to summary
public byte[] init(byte[] publicKey)

Implements org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.init.

Doc from org.apache.sshd.common.kex.KeyEncapsulationMethod.Server.init.

Initializes the KEM with a public key received from a client and prepares an encapsulated secret.

Parameters
publicKey:byte[]

data received from the client, expected to contain the public key at the start

Returns:byte[]

the remaining bytes of publicKey after the public key

Annotations
@Override