APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.crypto.provider

pack-priv abstract Class TlsPrfGenerator

extends KeyGeneratorSpi
Class Inheritance
Known Direct Subclasses
com.sun.crypto.provider.TlsPrfGenerator.V12, com.sun.crypto.provider.TlsPrfGenerator.V10
Imports
java.util.Arrays, java.security.*, java.security.spec.AlgorithmParameterSpec, javax.crypto.*, javax.crypto.spec.SecretKeySpec, sun.security.internal.spec.TlsPrfParameterSpec

KeyGenerator implementation for the TLS PRF function.

This class duplicates the HMAC functionality (RFC 2104) with performance optimizations (e.g. XOR'ing keys with padding doesn't need to be redone for each HMAC operation).

Author
Andreas Sterbenz
Since
1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
TlsPrfGenerator.V10

A KeyGenerator implementation that supports TLS 1.0/1.1.

public static class
TlsPrfGenerator.V12

A KeyGenerator implementation that supports TLS 1.2.

Field Summary

Modifier and TypeField and Description
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
pack-priv static final byte[]
pack-priv static final byte[]
pack-priv static final byte[]
pack-priv static final byte[]
pack-priv static final byte[]
pack-priv static final byte[]
private static final String
private TlsPrfParameterSpec
spec

References Deprecated TlsPrfParameterSpec is deprecated or references (maybe indirectly) at least one deprecated element.
pack-priv static final byte[][]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static byte[]
concat(byte[] b1, byte[] b2)

pack-priv static byte[]
doTLS10PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength)

pack-priv static byte[]
doTLS10PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength, MessageDigest md5, MessageDigest sha)

pack-priv static byte[]
doTLS12PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength, String prfHash, int prfHashLength, int prfBlockSize)

pack-priv static byte[]
doTLS12PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength, MessageDigest mdPRF, int mdPRFLen, int mdPRFBlockSize)

protected SecretKey
engineGenerateKey0(boolean tls12)

protected void
engineInit(SecureRandom random)

Implements abstract javax.crypto.KeyGeneratorSpi.engineInit.

Initializes the key generator.

protected void
engineInit(AlgorithmParameterSpec params, SecureRandom random)

Implements abstract javax.crypto.KeyGeneratorSpi.engineInit.

Initializes the key generator with the specified parameter set and a user-provided source of randomness.

protected void
engineInit(int keysize, SecureRandom random)

Implements abstract javax.crypto.KeyGeneratorSpi.engineInit.

Initializes this key generator for a certain keysize, using the given source of randomness.

private static void
expand(MessageDigest digest, int hmacSize, byte[] secret, int secOff, int secLen, byte[] label, byte[] seed, byte[] output, byte[] pad1, byte[] pad2)

private static byte[][]
pack-priv static byte[]
genPad(byte b, int count)

Inherited from javax.crypto.KeyGeneratorSpi:
engineGenerateKey

Field Detail

B0back to summary
private static final byte[] B0
HMAC_ipad128back to summary
private static final byte[] HMAC_ipad128
HMAC_ipad64back to summary
private static final byte[] HMAC_ipad64
HMAC_opad128back to summary
private static final byte[] HMAC_opad128
HMAC_opad64back to summary
private static final byte[] HMAC_opad64
LABEL_CLIENT_WRITE_KEYback to summary
pack-priv static final byte[] LABEL_CLIENT_WRITE_KEY
LABEL_EXTENDED_MASTER_SECRETback to summary
pack-priv static final byte[] LABEL_EXTENDED_MASTER_SECRET
LABEL_IV_BLOCKback to summary
pack-priv static final byte[] LABEL_IV_BLOCK
LABEL_KEY_EXPANSIONback to summary
pack-priv static final byte[] LABEL_KEY_EXPANSION
LABEL_MASTER_SECRETback to summary
pack-priv static final byte[] LABEL_MASTER_SECRET
LABEL_SERVER_WRITE_KEYback to summary
pack-priv static final byte[] LABEL_SERVER_WRITE_KEY
MSGback to summary
private static final String MSG
specback to summary
private TlsPrfParameterSpec spec

References Deprecated

TlsPrfParameterSpec is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@SuppressWarnings:deprecation
SSL3_CONSTback to summary
pack-priv static final byte[][] SSL3_CONST

Constructor Detail

TlsPrfGeneratorback to summary
public TlsPrfGenerator()

Method Detail

concatback to summary
pack-priv static byte[] concat(byte[] b1, byte[] b2)
doTLS10PRFback to summary
pack-priv static byte[] doTLS10PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength) throws NoSuchAlgorithmException, DigestException
doTLS10PRFback to summary
pack-priv static byte[] doTLS10PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength, MessageDigest md5, MessageDigest sha) throws DigestException
doTLS12PRFback to summary
pack-priv static byte[] doTLS12PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength, String prfHash, int prfHashLength, int prfBlockSize) throws NoSuchAlgorithmException, DigestException
doTLS12PRFback to summary
pack-priv static byte[] doTLS12PRF(byte[] secret, byte[] labelBytes, byte[] seed, int outputLength, MessageDigest mdPRF, int mdPRFLen, int mdPRFBlockSize) throws DigestException
engineGenerateKey0back to summary
protected SecretKey engineGenerateKey0(boolean tls12)
engineInitback to summary
protected void engineInit(SecureRandom random)

Implements abstract javax.crypto.KeyGeneratorSpi.engineInit.

Doc from javax.crypto.KeyGeneratorSpi.engineInit.

Initializes the key generator.

engineInitback to summary
protected void engineInit(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException

Implements abstract javax.crypto.KeyGeneratorSpi.engineInit.

Doc from javax.crypto.KeyGeneratorSpi.engineInit.

Initializes the key generator with the specified parameter set and a user-provided source of randomness.

Annotations
@SuppressWarnings:deprecation
Exceptions
InvalidAlgorithmParameterException:
if params is inappropriate for this key generator
engineInitback to summary
protected void engineInit(int keysize, SecureRandom random)

Implements abstract javax.crypto.KeyGeneratorSpi.engineInit.

Doc from javax.crypto.KeyGeneratorSpi.engineInit.

Initializes this key generator for a certain keysize, using the given source of randomness.

expandback to summary
private static void expand(MessageDigest digest, int hmacSize, byte[] secret, int secOff, int secLen, byte[] label, byte[] seed, byte[] output, byte[] pad1, byte[] pad2) throws DigestException
genConstback to summary
private static byte[][] genConst()
genPadback to summary
pack-priv static byte[] genPad(byte b, int count)
com.sun.crypto.provider back to summary

public Class TlsPrfGenerator.V10

extends TlsPrfGenerator
Class Inheritance

A KeyGenerator implementation that supports TLS 1.0/1.1.

Field Summary

Inherited from com.sun.crypto.provider.TlsPrfGenerator:
LABEL_CLIENT_WRITE_KEYLABEL_EXTENDED_MASTER_SECRETLABEL_IV_BLOCKLABEL_KEY_EXPANSIONLABEL_MASTER_SECRETLABEL_SERVER_WRITE_KEYSSL3_CONST

Constructor Summary

AccessConstructor and Description
public
V10()

Method Summary

Modifier and TypeMethod and Description
protected SecretKey
engineGenerateKey()

Implements abstract javax.crypto.KeyGeneratorSpi.engineGenerateKey.

Generates a secret key.

Inherited from com.sun.crypto.provider.TlsPrfGenerator:
concatdoTLS10PRFdoTLS10PRFdoTLS12PRFdoTLS12PRFengineGenerateKey0engineInitengineInitengineInitgenPad

Constructor Detail

V10back to summary
public V10()

Method Detail

engineGenerateKeyback to summary
protected SecretKey engineGenerateKey()

Implements abstract javax.crypto.KeyGeneratorSpi.engineGenerateKey.

Doc from javax.crypto.KeyGeneratorSpi.engineGenerateKey.

Generates a secret key.

com.sun.crypto.provider back to summary

public Class TlsPrfGenerator.V12

extends TlsPrfGenerator
Class Inheritance

A KeyGenerator implementation that supports TLS 1.2.

TLS 1.2 uses a different hash algorithm than 1.0/1.1 for the PRF calculations. As of 2010, there is no PKCS11-level support for TLS 1.2 PRF calculations, and no known OS's have an internal variant we could use. Therefore, for TLS 1.2, we are updating JSSE to request a different provider algorithm: "SunTls12Prf". If we reused the name "SunTlsPrf", the PKCS11 provider would need be updated to fail correctly when presented with the wrong version number (via Provider.Service.supportsParameters()), and add the appropriate supportsParamters() checks into KeyGenerators (not currently there).

Field Summary

Inherited from com.sun.crypto.provider.TlsPrfGenerator:
LABEL_CLIENT_WRITE_KEYLABEL_EXTENDED_MASTER_SECRETLABEL_IV_BLOCKLABEL_KEY_EXPANSIONLABEL_MASTER_SECRETLABEL_SERVER_WRITE_KEYSSL3_CONST

Constructor Summary

AccessConstructor and Description
public
V12()

Method Summary

Modifier and TypeMethod and Description
protected SecretKey
engineGenerateKey()

Implements abstract javax.crypto.KeyGeneratorSpi.engineGenerateKey.

Generates a secret key.

Inherited from com.sun.crypto.provider.TlsPrfGenerator:
concatdoTLS10PRFdoTLS10PRFdoTLS12PRFdoTLS12PRFengineGenerateKey0engineInitengineInitengineInitgenPad

Constructor Detail

V12back to summary
public V12()

Method Detail

engineGenerateKeyback to summary
protected SecretKey engineGenerateKey()

Implements abstract javax.crypto.KeyGeneratorSpi.engineGenerateKey.

Doc from javax.crypto.KeyGeneratorSpi.engineGenerateKey.

Generates a secret key.