Top Description Inners Fields Constructors Methods
org.conscrypt

public abstract Class OpenSSLMac

extends MacSpi
Class Inheritance
Known Direct Subclasses
org.conscrypt.OpenSSLMac.HmacMD5, org.conscrypt.OpenSSLMac.HmacSHA1, org.conscrypt.OpenSSLMac.HmacSHA224, org.conscrypt.OpenSSLMac.HmacSHA256, org.conscrypt.OpenSSLMac.HmacSHA384, org.conscrypt.OpenSSLMac.HmacSHA512
Annotations
@Internal
Imports
java.nio.ByteBuffer, java.security.InvalidAlgorithmParameterException, .InvalidKeyException, .Key, .NoSuchAlgorithmException, java.security.spec.AlgorithmParameterSpec, javax.crypto.MacSpi, .SecretKey

An implementation of javax.crypto.Mac which uses BoringSSL to perform all the operations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
private NativeRef.HMAC_CTX
private final long
evp_md

Holds the EVP_MD for the hashing algorithm, e.g. EVP_get_digestbyname("sha1");

private byte[]
keyBytes

The secret key used in this keyed MAC.

private final byte[]
singleByte

Holds a dummy buffer for writing single bytes to the digest.

private final int
size

Holds the output size of the message digest.

Constructor Summary

AccessConstructor and Description
private
OpenSSLMac(long evp_md, int size)

Method Summary

Modifier and TypeMethod and Description
protected byte[]
engineDoFinal()

Implements abstract javax.crypto.MacSpi.engineDoFinal.

Completes the MAC computation and resets the MAC for further use, maintaining the secret key that the MAC was initialized with.
protected int
engineGetMacLength()

Implements abstract javax.crypto.MacSpi.engineGetMacLength.

Returns the length of the MAC in bytes.
protected void
engineInit(Key
the (secret) key.
key
,
AlgorithmParameterSpec
the algorithm parameters.
params
)

Implements abstract javax.crypto.MacSpi.engineInit.

Initializes the MAC with the given (secret) key and algorithm parameters.
protected void
engineReset()

Implements abstract javax.crypto.MacSpi.engineReset.

Resets the MAC for further use, maintaining the secret key that the MAC was initialized with.
protected void
engineUpdate(byte
the input byte to be processed.
input
)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Processes the given byte.
protected void
engineUpdate(byte[]
the input buffer.
input
,
int
the offset in input where the input starts.
offset
,
int
the number of bytes to process.
len
)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Processes the first len bytes in input, starting at offset inclusive.
protected void
engineUpdate(ByteBuffer
the ByteBuffer
input
)

Overrides javax.crypto.MacSpi.engineUpdate.

Processes input.remaining() bytes in the ByteBuffer input, starting at input.position().
private final void
Inherited from javax.crypto.MacSpi:
clone

Field Detail

ctxback to summary
private NativeRef.HMAC_CTX ctx
evp_mdback to summary
private final long evp_md

Holds the EVP_MD for the hashing algorithm, e.g. EVP_get_digestbyname("sha1");

keyBytesback to summary
private byte[] keyBytes

The secret key used in this keyed MAC.

singleByteback to summary
private final byte[] singleByte

Holds a dummy buffer for writing single bytes to the digest.

sizeback to summary
private final int size

Holds the output size of the message digest.

Constructor Detail

OpenSSLMacback to summary
private OpenSSLMac(long evp_md, int size)

Method Detail

engineDoFinalback to summary
protected byte[] engineDoFinal()

Implements abstract javax.crypto.MacSpi.engineDoFinal.

Doc from javax.crypto.MacSpi.engineDoFinal.

Completes the MAC computation and resets the MAC for further use, maintaining the secret key that the MAC was initialized with.

Returns:byte[]

the MAC result.

Annotations
@Override
engineGetMacLengthback to summary
protected int engineGetMacLength()

Implements abstract javax.crypto.MacSpi.engineGetMacLength.

Doc from javax.crypto.MacSpi.engineGetMacLength.

Returns the length of the MAC in bytes.

Returns:int

the MAC length in bytes.

Annotations
@Override
engineInitback to summary
protected void engineInit(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException

Implements abstract javax.crypto.MacSpi.engineInit.

Doc from javax.crypto.MacSpi.engineInit.

Initializes the MAC with the given (secret) key and algorithm parameters.

Parameters
key:Key

the (secret) key.

params:AlgorithmParameterSpec

the algorithm parameters.

Annotations
@Override
Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this MAC.
InvalidAlgorithmParameterException:
if the given algorithm parameters are inappropriate for this MAC.
engineResetback to summary
protected void engineReset()

Implements abstract javax.crypto.MacSpi.engineReset.

Doc from javax.crypto.MacSpi.engineReset.

Resets the MAC for further use, maintaining the secret key that the MAC was initialized with.

Annotations
@Override
engineUpdateback to summary
protected void engineUpdate(byte input)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Doc from javax.crypto.MacSpi.engineUpdate.

Processes the given byte.

Parameters
input:byte

the input byte to be processed.

Annotations
@Override
engineUpdateback to summary
protected void engineUpdate(byte[] input, int offset, int len)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Doc from javax.crypto.MacSpi.engineUpdate.

Processes the first len bytes in input, starting at offset inclusive.

Parameters
input:byte[]

the input buffer.

offset:int

the offset in input where the input starts.

len:int

the number of bytes to process.

Annotations
@Override
engineUpdateback to summary
protected void engineUpdate(ByteBuffer input)

Overrides javax.crypto.MacSpi.engineUpdate.

Doc from javax.crypto.MacSpi.engineUpdate.

Processes input.remaining() bytes in the ByteBuffer input, starting at input.position(). Upon return, the buffer's position will be equal to its limit; its limit will not have changed.

Subclasses should consider overriding this method if they can process ByteBuffers more efficiently than byte arrays.

Parameters
input:ByteBuffer

the ByteBuffer

Annotations
@Override
resetContextback to summary
private final void resetContext()
org.conscrypt back to summary

public final Class OpenSSLMac.HmacMD5

extends OpenSSLMac
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.conscrypt.OpenSSLMac:
engineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacMD5back to summary
public HmacMD5()
org.conscrypt back to summary

public final Class OpenSSLMac.HmacSHA1

extends OpenSSLMac
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.conscrypt.OpenSSLMac:
engineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA1back to summary
public HmacSHA1()
org.conscrypt back to summary

public final Class OpenSSLMac.HmacSHA224

extends OpenSSLMac
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.conscrypt.OpenSSLMac:
engineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA224back to summary
public HmacSHA224() throws NoSuchAlgorithmException
org.conscrypt back to summary

public final Class OpenSSLMac.HmacSHA256

extends OpenSSLMac
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.conscrypt.OpenSSLMac:
engineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA256back to summary
public HmacSHA256() throws NoSuchAlgorithmException
org.conscrypt back to summary

public final Class OpenSSLMac.HmacSHA384

extends OpenSSLMac
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.conscrypt.OpenSSLMac:
engineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA384back to summary
public HmacSHA384() throws NoSuchAlgorithmException
org.conscrypt back to summary

public final Class OpenSSLMac.HmacSHA512

extends OpenSSLMac
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.conscrypt.OpenSSLMac:
engineDoFinalengineGetMacLengthengineInitengineResetengineUpdateengineUpdateengineUpdate

Constructor Detail

HmacSHA512back to summary
public HmacSHA512()