APIdia Launch Partner
Top Description Inners Constructors Methods
sun.security.ssl

public Class DHasKEM

extends Object
implements KEMSpi
Class Inheritance
All Implemented Interfaces
javax.crypto.KEMSpi
Imports
sun.security.util.ArrayUtil, .CurveDB, .ECUtil, .NamedCurve, javax.crypto.DecapsulateException, .KEM, .KEMSpi, .KeyAgreement, .SecretKey, java.io.IOException, java.math.BigInteger, java.security.*, java.security.interfaces.ECKey, .ECPublicKey, .XECKey, .XECPublicKey, java.security.spec.AlgorithmParameterSpec, .ECPoint, .ECPublicKeySpec, .InvalidKeySpecException, .KeySpec, .NamedParameterSpec, .XECPublicKeySpec, java.util.Arrays

The DHasKEM class presents a KEM abstraction layer over traditional DH-based key exchange, which can be used for either straight ECDH/XDH or TLS hybrid key exchanges. This class can be alongside standard full post-quantum KEMs when hybrid implementations are required.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static enum

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public KEMSpi.DecapsulatorSpi
engineNewDecapsulator(PrivateKey privateKey, AlgorithmParameterSpec spec)

Implements javax.crypto.KEMSpi.engineNewDecapsulator.

Creates a KEM decapsulator on the KEM receiver side.

public KEMSpi.EncapsulatorSpi
engineNewEncapsulator(PublicKey publicKey, AlgorithmParameterSpec spec, SecureRandom secureRandom)

Implements javax.crypto.KEMSpi.engineNewEncapsulator.

Creates a KEM encapsulator on the KEM sender side.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DHasKEMback to summary
public DHasKEM()

Method Detail

engineNewDecapsulatorback to summary
public KEMSpi.DecapsulatorSpi engineNewDecapsulator(PrivateKey privateKey, AlgorithmParameterSpec spec) throws InvalidKeyException

Implements javax.crypto.KEMSpi.engineNewDecapsulator.

Doc from javax.crypto.KEMSpi.engineNewDecapsulator.

Creates a KEM decapsulator on the KEM receiver side.

Annotations
@Override
Exceptions
InvalidKeyException:
if privateKey is null or invalid
engineNewEncapsulatorback to summary
public KEMSpi.EncapsulatorSpi engineNewEncapsulator(PublicKey publicKey, AlgorithmParameterSpec spec, SecureRandom secureRandom) throws InvalidKeyException

Implements javax.crypto.KEMSpi.engineNewEncapsulator.

Doc from javax.crypto.KEMSpi.engineNewEncapsulator.

Creates a KEM encapsulator on the KEM sender side.

Annotations
@Override
Exceptions
InvalidKeyException:
if publicKey is null or invalid
sun.security.ssl back to summary

private final Class DHasKEM.Handler

extends Object
implements EncapsulatorSpi, DecapsulatorSpi
Class Inheritance
All Implemented Interfaces
javax.crypto.KEMSpi.DecapsulatorSpi, javax.crypto.KEMSpi.EncapsulatorSpi

Field Summary

Modifier and TypeField and Description
private final DHasKEM.Params
private final PublicKey
private final PrivateKey
private final SecureRandom

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public SecretKey
engineDecapsulate(byte[] encapsulation, int from, int to, String algorithm)

Implements javax.crypto.KEMSpi.DecapsulatorSpi.engineDecapsulate.

The key decapsulation function.

public KEM.Encapsulated
engineEncapsulate(int from, int to, String algorithm)

Implements javax.crypto.KEMSpi.EncapsulatorSpi.engineEncapsulate.

The key encapsulation function.

public int
public int
private DHasKEM.Params
private SecretKey
sub(SecretKey key, int from, int to)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

paramsback to summary
private final DHasKEM.Params params
pkRback to summary
private final PublicKey pkR
skRback to summary
private final PrivateKey skR
srback to summary
private final SecureRandom sr

Constructor Detail

Handlerback to summary
pack-priv Handler(PublicKey pk, PrivateKey sk, SecureRandom sr) throws InvalidKeyException

Method Detail

engineDecapsulateback to summary
public SecretKey engineDecapsulate(byte[] encapsulation, int from, int to, String algorithm) throws DecapsulateException

Implements javax.crypto.KEMSpi.DecapsulatorSpi.engineDecapsulate.

Doc from javax.crypto.KEMSpi.DecapsulatorSpi.engineDecapsulate.

The key decapsulation function.

An invocation of this method recovers the secret key from the key encapsulation message.

An implementation must support the case where from is 0, to is the same as the return value of secretSize(), and algorithm is "Generic".

Annotations
@Override
Exceptions
DecapsulateException:
if an error occurs during the decapsulation process
engineEncapsulateback to summary
public KEM.Encapsulated engineEncapsulate(int from, int to, String algorithm)

Implements javax.crypto.KEMSpi.EncapsulatorSpi.engineEncapsulate.

Doc from javax.crypto.KEMSpi.EncapsulatorSpi.engineEncapsulate.

The key encapsulation function.

Each invocation of this method must generate a new secret key and key encapsulation message that is returned in an KEM.Encapsulated object.

An implementation must support the case where from is 0, to is the same as the return value of secretSize(), and algorithm is "Generic".

Annotations
@Override
engineEncapsulationSizeback to summary
public int engineEncapsulationSize()

Implements javax.crypto.KEMSpi.EncapsulatorSpi.engineEncapsulationSize, javax.crypto.KEMSpi.DecapsulatorSpi.engineEncapsulationSize.

Doc from javax.crypto.KEMSpi.EncapsulatorSpi.engineEncapsulationSize.

Returns the size of the key encapsulation message.

Annotations
@Override
engineSecretSizeback to summary
public int engineSecretSize()

Implements javax.crypto.KEMSpi.EncapsulatorSpi.engineSecretSize, javax.crypto.KEMSpi.DecapsulatorSpi.engineSecretSize.

Doc from javax.crypto.KEMSpi.EncapsulatorSpi.engineSecretSize.

Returns the size of the shared secret.

Annotations
@Override
paramsFromKeyback to summary
private DHasKEM.Params paramsFromKey(Key k) throws InvalidKeyException
subback to summary
private SecretKey sub(SecretKey key, int from, int to)
sun.security.ssl back to summary

private final Enum DHasKEM.Params

extends Enum<DHasKEM.Params>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String
private final String
public static final DHasKEM.Params
public static final DHasKEM.Params
public static final DHasKEM.Params
private final int
private final int
private final AlgorithmParameterSpec
public static final DHasKEM.Params
public static final DHasKEM.Params

Constructor Summary

AccessConstructor and Description
private
Params(int secretLen, int publicKeyLen, String kaAlgorithm, String keyAlgorithm, AlgorithmParameterSpec spec)

Method Summary

Modifier and TypeMethod and Description
private PublicKey
DeserializePublicKey(byte[] data)

private SecretKey
DH(String alg, PrivateKey skE, PublicKey pkR)

private KeyPair
private boolean
isEC()

private byte[]
public static DHasKEM.Params
public static DHasKEM.Params[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

kaAlgorithmback to summary
private final String kaAlgorithm
keyAlgorithmback to summary
private final String keyAlgorithm
P256back to summary
public static final DHasKEM.Params P256
P384back to summary
public static final DHasKEM.Params P384
P521back to summary
public static final DHasKEM.Params P521
publicKeyLenback to summary
private final int publicKeyLen
secretLenback to summary
private final int secretLen
specback to summary
private final AlgorithmParameterSpec spec
X25519back to summary
public static final DHasKEM.Params X25519
X448back to summary
public static final DHasKEM.Params X448

Constructor Detail

Paramsback to summary
private Params(int secretLen, int publicKeyLen, String kaAlgorithm, String keyAlgorithm, AlgorithmParameterSpec spec)

Method Detail

DeserializePublicKeyback to summary
private PublicKey DeserializePublicKey(byte[] data) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException
DHback to summary
private SecretKey DH(String alg, PrivateKey skE, PublicKey pkR) throws NoSuchAlgorithmException, InvalidKeyException
generateKeyPairback to summary
private KeyPair generateKeyPair(SecureRandom sr)
isECback to summary
private boolean isEC()
SerializePublicKeyback to summary
private byte[] SerializePublicKey(PublicKey k)
valueOfback to summary
public static DHasKEM.Params valueOf(String name)
valuesback to summary
public static DHasKEM.Params[] values()