- Enclosing class:
- KEM
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.
- Since:
- 21
- 
Method SummaryModifier and TypeMethodDescriptionThe key encapsulation function.encapsulate(int from, int to, String algorithm) The key encapsulation function.intReturns the size of the key encapsulation message.Returns the name of the provider.intReturns the size of the shared secret.
- 
Method Details- 
providerNameReturns the name of the provider.- Returns:
- the name of the provider
 
- 
encapsulateThe key encapsulation function.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. - Returns:
- a KEM.Encapsulatedobject containing the shared secret, key encapsulation message, and optional parameters. The shared secret is aSecretKeycontaining all of the bytes of the secret, and an algorithm name of "Generic".
 
- 
encapsulateThe key encapsulation function.Each invocation of this method generates a new secret key and key encapsulation message that is returned in an KEM.Encapsulatedobject.An implementation may choose to not support arbitrary combinations of from,to, andalgorithm.- Parameters:
- from- the initial index of the shared secret byte array to be returned, inclusive
- to- the final index of the shared secret byte array to be returned, exclusive
- algorithm- the algorithm name for the secret key that is returned
- Returns:
- a KEM.Encapsulatedobject containing a portion of the shared secret, key encapsulation message, and optional parameters. The portion of the shared secret is aSecretKeycontaining the bytes of the secret ranging fromfromtoto, 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.
- Throws:
- IndexOutOfBoundsException- if- from < 0,- from > to, or- to > secretSize()
- NullPointerException- if- algorithmis- null
- UnsupportedOperationException- if the combination of- from,- to, and- algorithmis not supported by the encapsulator
 
- 
secretSizepublic int secretSize()Returns the size of the shared secret.This method can be called to find out the length of the shared secret before encapsulateis called or if the obtainedSecretKeyis not extractable.- Returns:
- the size of the shared secret
 
- 
encapsulationSizepublic int encapsulationSize()Returns the size of the key encapsulation message.This method can be called to find out the length of the encapsulation message before encapsulateis called.- Returns:
- the size of the key encapsulation message
 
 
-