Top Description Methods
org.bouncycastle.tls.crypto

public Interface TlsSecret

Known Direct Implementers
org.bouncycastle.tls.crypto.impl.AbstractTlsSecret
Imports
java.io.IOException

Interface supporting the generation of key material and other SSL/TLS secret values from PRFs.

Method Summary

Modifier and TypeMethod and Description
public byte[]
calculateHMAC(int
the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.
cryptoHashAlgorithm
,
byte[]
array containing the input data.
buf
,
int
offset into the input array the input starts at.
off
,
int
the length of the input data.
len
)

Calculate an HMAC with this secret's data as the key.

public TlsSecret

Returns:

the new secret.
deriveUsingPRF
(int
PRF algorithm to use.
prfAlgorithm
,
String
the label details.
label
,
byte[]
the seed details.
seed
,
int
the size (in bytes) of the secret to generate.
length
)

Return a new secret based on applying a PRF to this one.

public void
destroy()

Destroy the internal state of the secret.

public byte[]

Returns:

an encrypted copy of this secret's internal data.
encrypt
(TlsEncryptor
the encryptor to use for protecting the internal data.
encryptor
)

Return an encrypted copy of the data this secret is based on.

public byte[]

Returns:

the secret's internal data.
extract
()

Return the internal data from this secret.

public TlsSecret

Returns:

output keying material (of 'length' octets).
hkdfExpand
(int
the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.
cryptoHashAlgorithm
,
byte[]
optional context and application specific information (can be zero-length).
info
,
int
length of output keying material in octets.
length
)

RFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').

public TlsSecret

Returns:

a pseudo-random key (of HashLen octets).
hkdfExtract
(int
the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.
cryptoHashAlgorithm
,
TlsSecret
input keying material.
ikm
)

RFC 5869 HKDF-Extract function, with this secret's data as the 'salt'.

public boolean

Method Detail

calculateHMACback to summary
public byte[] calculateHMAC(int cryptoHashAlgorithm, byte[] buf, int off, int len)

Calculate an HMAC with this secret's data as the key.

Parameters
cryptoHashAlgorithm:int

the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.

buf:byte[]

array containing the input data.

off:int

offset into the input array the input starts at.

len:int

the length of the input data.

deriveUsingPRFback to summary
public TlsSecret deriveUsingPRF(int prfAlgorithm, String label, byte[] seed, int length)

Return a new secret based on applying a PRF to this one.

Parameters
prfAlgorithm:int

PRF algorithm to use.

label:String

the label details.

seed:byte[]

the seed details.

length:int

the size (in bytes) of the secret to generate.

Returns:TlsSecret

the new secret.

destroyback to summary
public void destroy()

Destroy the internal state of the secret. After this call, any attempt to use the TlsSecret will result in an IllegalStateException being thrown.

encryptback to summary
public byte[] encrypt(TlsEncryptor encryptor) throws IOException

Return an encrypted copy of the data this secret is based on.

Parameters
encryptor:TlsEncryptor

the encryptor to use for protecting the internal data.

Returns:byte[]

an encrypted copy of this secret's internal data.

extractback to summary
public byte[] extract()

Return the internal data from this secret. The TlsSecret does not keep a copy of the data. After this call, any attempt to use the TlsSecret will result in an IllegalStateException being thrown.

Returns:byte[]

the secret's internal data.

hkdfExpandback to summary
public TlsSecret hkdfExpand(int cryptoHashAlgorithm, byte[] info, int length)

RFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').

Parameters
cryptoHashAlgorithm:int

the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.

info:byte[]

optional context and application specific information (can be zero-length).

length:int

length of output keying material in octets.

Returns:TlsSecret

output keying material (of 'length' octets).

hkdfExtractback to summary
public TlsSecret hkdfExtract(int cryptoHashAlgorithm, TlsSecret ikm)

RFC 5869 HKDF-Extract function, with this secret's data as the 'salt'. The TlsSecret does not keep a copy of the data. After this call, any attempt to use the TlsSecret will result in an IllegalStateException being thrown.

Parameters
cryptoHashAlgorithm:int

the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.

ikm:TlsSecret

input keying material.

Returns:TlsSecret

a pseudo-random key (of HashLen octets).

isAliveback to summary
public boolean isAlive()