Class KEM.Decapsulator
- Enclosing class:
KEM
KEM.newDecapsulator(PrivateKey) on the KEM
receiver side.
This class represents the key decapsulation function of a KEM.
An invocation of the decapsulate method recovers the
secret key from the key encapsulation message.
- Since:
- 21
-
Method Summary
Modifier and TypeMethodDescriptiondecapsulate(byte[] encapsulation) The key decapsulation function.decapsulate(byte[] encapsulation, int from, int to, String algorithm) The key decapsulation function.intReturns the size of the key encapsulation message.Returns the name of the provider.intReturns the size of the shared secret.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Method Details
-
providerName
-
decapsulate
The key decapsulation function.This method is equivalent to
decapsulate(encapsulation, 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.
- Parameters:
encapsulation- the key encapsulation message from the sender. The size must be equal to the value returned byencapsulationSize(), or aDecapsulateExceptionwill be thrown.- Returns:
- the shared secret as a
SecretKeywith an algorithm name of "Generic" - Throws:
DecapsulateException- if an error occurs during the decapsulation processNullPointerException- ifencapsulationisnull
-
decapsulate
public SecretKey decapsulate(byte[] encapsulation, int from, int to, String algorithm) throws DecapsulateException The key decapsulation function.An invocation of this method recovers the secret key from the key encapsulation message.
An implementation may choose to not support arbitrary combinations of
from,to, andalgorithm.- Parameters:
encapsulation- the key encapsulation message from the sender. The size must be equal to the value returned byencapsulationSize(), or aDecapsulateExceptionwill be thrown.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 returned. See the SecretKey Algorithms section in the Java Security Standard Algorithm Names Specification for information about standard secret key algorithm names. Specify "Generic" if the output will be used as the input keying material of a key derivation function (KDF).- Returns:
- a portion of the shared secret as a
SecretKeycontaining the bytes of the secret ranging fromfromtoto, exclusive, and an algorithm name as specified. For example,decapsulate(encapsulation, secretSize() - 16, secretSize(), "AES")uses the last 16 bytes of the shared secret as a 128-bit AES key. - Throws:
DecapsulateException- if an error occurs during the decapsulation processIndexOutOfBoundsException- iffrom < 0,from > to, orto > secretSize()NullPointerException- ifencapsulationoralgorithmisnullUnsupportedOperationException- if the combination offrom,to, andalgorithmis not supported by the decapsulator- External Specifications
-
secretSize
public int secretSize()Returns the size of the shared secret.This method can be called to find out the length of the shared secret before
decapsulateis called or if the obtainedSecretKeyis not extractable.- Returns:
- the size of the shared secret
-
encapsulationSize
public int encapsulationSize()Returns the size of the key encapsulation message.This method can be used to extract the encapsulation message from a longer byte array if no length information is provided by a higher level protocol.
- Returns:
- the size of the key encapsulation message
-