KEM
public static final class KEM.Encapsulator extends Object
KEM.newEncapsulator(java.security.PublicKey)
on the KEM sender side. This class represents the key encapsulation function of a KEM. Each invocation of the encapsulate
method generates a new secret key and key encapsulation message that is returned in an KEM.Encapsulated
object.
Modifier and Type | Method | Description |
---|---|---|
KEM.Encapsulated |
encapsulate() |
The key encapsulation function. |
KEM.Encapsulated |
encapsulate |
The key encapsulation function. |
int |
encapsulationSize() |
Returns the size of the key encapsulation message. |
String |
providerName() |
Returns the name of the provider. |
int |
secretSize() |
Returns the size of the shared secret. |
public String providerName()
public KEM.Encapsulated encapsulate()
This method is equivalent to encapsulate(0, secretSize(), "Generic")
. This combination of arguments must be supported by every implementation.
The generated secret key is usually passed to a key derivation function (KDF) as the input keying material.
KEM.Encapsulated
object containing the shared secret, key encapsulation message, and optional parameters. The shared secret is a SecretKey
containing all of the bytes of the secret, and an algorithm name of "Generic".public KEM.Encapsulated encapsulate(int from, int to, String algorithm)
Each invocation of this method generates a new secret key and key encapsulation message that is returned in an KEM.Encapsulated
object.
An implementation may choose to not support arbitrary combinations of from
, to
, and algorithm
.
from
- the initial index of the shared secret byte array to be returned, inclusiveto
- the final index of the shared secret byte array to be returned, exclusivealgorithm
- the algorithm name for the secret key that is returnedKEM.Encapsulated
object containing a portion of the shared secret, key encapsulation message, and optional parameters. The portion of the shared secret is a SecretKey
containing the bytes of the secret ranging from from
to to
, exclusive, and an algorithm name as specified. For example, encapsulate(0, 16, "AES")
uses the first 16 bytes of the shared secret as a 128-bit AES key.IndexOutOfBoundsException
- if from < 0
, from > to
, or to > secretSize()
NullPointerException
- if algorithm
is null
UnsupportedOperationException
- if the combination of from
, to
, and algorithm
is not supported by the encapsulatorpublic int secretSize()
This method can be called to find out the length of the shared secret before encapsulate
is called or if the obtained SecretKey
is not extractable.
public int encapsulationSize()
This method can be called to find out the length of the encapsulation message before encapsulate
is called.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/crypto/KEM.Encapsulator.html