Class BcTlsSecret
- java.lang.Object
-
- org.bouncycastle.tls.crypto.impl.AbstractTlsSecret
-
- org.bouncycastle.tls.crypto.impl.bc.BcTlsSecret
-
- All Implemented Interfaces:
TlsSecret
public class BcTlsSecret extends AbstractTlsSecret
BC light-weight support class for handling TLS secrets and deriving key material and other secrets from them.
-
-
Field Summary
Fields Modifier and Type Field Description protected BcTlsCryptocrypto-
Fields inherited from class org.bouncycastle.tls.crypto.impl.AbstractTlsSecret
data
-
-
Constructor Summary
Constructors Constructor Description BcTlsSecret(BcTlsCrypto crypto, byte[] data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BcTlsSecretconvert(BcTlsCrypto crypto, TlsSecret secret)TlsSecretderiveUsingPRF(int prfAlgorithm, java.lang.String label, byte[] seed, int length)Return a new secret based on applying a PRF to this one.protected AbstractTlsCryptogetCrypto()TlsSecrethkdfExpand(int cryptoHashAlgorithm, byte[] info, int length)RFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').TlsSecrethkdfExtract(int cryptoHashAlgorithm, TlsSecret ikm)RFC 5869 HKDF-Extract function, with this secret's data as the 'salt'.protected voidhmacHash(org.bouncycastle.crypto.Digest digest, byte[] secret, int secretOff, int secretLen, byte[] seed, byte[] output)protected byte[]prf(int prfAlgorithm, java.lang.String label, byte[] seed, int length)protected byte[]prf_1_0(byte[] labelSeed, int length)protected byte[]prf_1_2(int prfAlgorithm, byte[] labelSeed, int length)protected byte[]prf_SSL(byte[] seed, int length)protected voidupdateMac(org.bouncycastle.crypto.Mac mac)-
Methods inherited from class org.bouncycastle.tls.crypto.impl.AbstractTlsSecret
calculateHMAC, checkAlive, copyData, destroy, encrypt, extract, isAlive
-
-
-
-
Field Detail
-
crypto
protected final BcTlsCrypto crypto
-
-
Constructor Detail
-
BcTlsSecret
public BcTlsSecret(BcTlsCrypto crypto, byte[] data)
-
-
Method Detail
-
convert
public static BcTlsSecret convert(BcTlsCrypto crypto, TlsSecret secret)
-
deriveUsingPRF
public TlsSecret deriveUsingPRF(int prfAlgorithm, java.lang.String label, byte[] seed, int length)
Description copied from interface:TlsSecretReturn a new secret based on applying a PRF to this one.- Parameters:
prfAlgorithm- PRF algorithm to use.label- the label details.seed- the seed details.length- the size (in bytes) of the secret to generate.- Returns:
- the new secret.
-
hkdfExpand
public TlsSecret hkdfExpand(int cryptoHashAlgorithm, byte[] info, int length)
Description copied from interface:TlsSecretRFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').- Parameters:
cryptoHashAlgorithm- the hash algorithm to instantiate HMAC with. SeeCryptoHashAlgorithmfor values.info- optional context and application specific information (can be zero-length).length- length of output keying material in octets.- Returns:
- output keying material (of 'length' octets).
-
hkdfExtract
public TlsSecret hkdfExtract(int cryptoHashAlgorithm, TlsSecret ikm)
Description copied from interface:TlsSecretRFC 5869 HKDF-Extract function, with this secret's data as the 'salt'. TheTlsSecretdoes not keep a copy of the data. After this call, any attempt to use theTlsSecretwill result in anIllegalStateExceptionbeing thrown.- Parameters:
cryptoHashAlgorithm- the hash algorithm to instantiate HMAC with. SeeCryptoHashAlgorithmfor values.ikm- input keying material.- Returns:
- a pseudo-random key (of HashLen octets).
-
getCrypto
protected AbstractTlsCrypto getCrypto()
- Specified by:
getCryptoin classAbstractTlsSecret
-
hmacHash
protected void hmacHash(org.bouncycastle.crypto.Digest digest, byte[] secret, int secretOff, int secretLen, byte[] seed, byte[] output)
-
prf
protected byte[] prf(int prfAlgorithm, java.lang.String label, byte[] seed, int length)
-
prf_SSL
protected byte[] prf_SSL(byte[] seed, int length)
-
prf_1_0
protected byte[] prf_1_0(byte[] labelSeed, int length)
-
prf_1_2
protected byte[] prf_1_2(int prfAlgorithm, byte[] labelSeed, int length)
-
updateMac
protected void updateMac(org.bouncycastle.crypto.Mac mac)
-
-