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

pack-priv final Class SslMacCore

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer, java.security.*, java.security.spec.AlgorithmParameterSpec, javax.crypto.MacSpi, .SecretKey

This file contains the code for the SslMacMD5 and SslMacSHA1 implementations. The SSL 3.0 MAC is a variation of the HMAC algorithm. Note that we don't implement Cloneable as that is not needed for SSL.
Author
Andreas Sterbenz
Since
1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Field Summary

Modifier and TypeField and Description
private boolean
private final MessageDigest
private final byte[]
private final byte[]
private byte[]

Constructor Summary

AccessConstructor and Description
pack-priv
SslMacCore(String digestAlgorithm, byte[] pad1, byte[] pad2)

Standard constructor, creates a new SslMacCore instance instantiating a MessageDigest of the specified name.

Method Summary

Modifier and TypeMethod and Description
pack-priv byte[]

Returns:

the Mac result.
doFinal
()

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

pack-priv int

Returns:

the Mac length in bytes.
getDigestLength
()

Returns the length of the Mac in bytes.

pack-priv void
init(Key
the secret key.
key
,
AlgorithmParameterSpec
the algorithm parameters.
params
)

Initializes the Mac with the given secret key and algorithm parameters.

pack-priv void
reset()

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

pack-priv void
update(byte
the input byte to be processed.
input
)

Processes the given byte.

pack-priv void
update(byte[]
the input buffer.
input
,
int
the offset in input where the input starts.
offset
,
int
the number of bytes to process.
len
)

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

pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

firstback to summary
private boolean first
mdback to summary
private final MessageDigest md
pad1back to summary
private final byte[] pad1
pad2back to summary
private final byte[] pad2
secretback to summary
private byte[] secret

Constructor Detail

SslMacCoreback to summary
pack-priv SslMacCore(String digestAlgorithm, byte[] pad1, byte[] pad2) throws NoSuchAlgorithmException

Standard constructor, creates a new SslMacCore instance instantiating a MessageDigest of the specified name.

Method Detail

doFinalback to summary
pack-priv byte[] doFinal()

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.

getDigestLengthback to summary
pack-priv int getDigestLength()

Returns the length of the Mac in bytes.

Returns:int

the Mac length in bytes.

initback to summary
pack-priv void init(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException

Initializes the Mac with the given secret key and algorithm parameters.

Parameters
key:Key

the secret key.

params:AlgorithmParameterSpec

the algorithm parameters.

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this MAC.
InvalidAlgorithmParameterException:
if the given algorithm parameters are inappropriate for this MAC.
resetback to summary
pack-priv void reset()

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

updateback to summary
pack-priv void update(byte input)

Processes the given byte.

Parameters
input:byte

the input byte to be processed.

updateback to summary
pack-priv void update(byte[] input, int offset, int len)

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

Parameters
input:byte[]

the input buffer.

offset:int

the offset in input where the input starts.

len:int

the number of bytes to process.

updateback to summary
pack-priv void update(ByteBuffer input)
com.sun.crypto.provider back to summary

public final Class SslMacCore.SslMacMD5

extends MacSpi
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SslMacCore
pack-priv static final byte[]
pack-priv static final byte[]

Constructor Summary

AccessConstructor and Description
public

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 key, AlgorithmParameterSpec 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 input)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Processes the given byte.

protected void
engineUpdate(byte[] input, int offset, int len)

Implements abstract javax.crypto.MacSpi.engineUpdate.

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

protected void
engineUpdate(ByteBuffer input)

Overrides javax.crypto.MacSpi.engineUpdate.

Processes input.remaining() bytes in the ByteBuffer input, starting at input.position().

Inherited from javax.crypto.MacSpi:
clone

Field Detail

coreback to summary
private final SslMacCore core
md5Pad1back to summary
pack-priv static final byte[] md5Pad1
md5Pad2back to summary
pack-priv static final byte[] md5Pad2

Constructor Detail

SslMacMD5back to summary
public SslMacMD5() throws NoSuchAlgorithmException

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.

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.

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.

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.

engineUpdateback to summary
protected void engineUpdate(byte input)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Doc from javax.crypto.MacSpi.engineUpdate.

Processes the given byte.

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.

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.

com.sun.crypto.provider back to summary

public final Class SslMacCore.SslMacSHA1

extends MacSpi
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SslMacCore
pack-priv static final byte[]
pack-priv static final byte[]

Constructor Summary

AccessConstructor and Description
public

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 key, AlgorithmParameterSpec 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 input)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Processes the given byte.

protected void
engineUpdate(byte[] input, int offset, int len)

Implements abstract javax.crypto.MacSpi.engineUpdate.

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

protected void
engineUpdate(ByteBuffer input)

Overrides javax.crypto.MacSpi.engineUpdate.

Processes input.remaining() bytes in the ByteBuffer input, starting at input.position().

Inherited from javax.crypto.MacSpi:
clone

Field Detail

coreback to summary
private final SslMacCore core
shaPad1back to summary
pack-priv static final byte[] shaPad1
shaPad2back to summary
pack-priv static final byte[] shaPad2

Constructor Detail

SslMacSHA1back to summary
public SslMacSHA1() throws NoSuchAlgorithmException

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.

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.

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.

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.

engineUpdateback to summary
protected void engineUpdate(byte input)

Implements abstract javax.crypto.MacSpi.engineUpdate.

Doc from javax.crypto.MacSpi.engineUpdate.

Processes the given byte.

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.

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.