Modifier and Type | Field and Description |
---|---|
static char |
SEPARATOR
Character, separating algorithm name and algorithm parameter
|
static java.lang.String |
STR_SEPARATOR
String, separating algorithm name and algorithm parameter
|
Constructor and Description |
---|
Mac(MacInterface internal)
ctor.
|
Modifier and Type | Method and Description |
---|---|
void |
clean()
clean all important content.
|
java.lang.Object |
clone() |
byte[] |
doFinal()
Finishes the MAC operation.
|
byte[] |
doFinal(byte[] bytes)
Processes the given array of bytes and finishes the MAC operation.
|
void |
doFinal(byte[] bytes,
int offset)
Finishes the MAC operation.
|
java.lang.String |
getAlgorithm()
get algorithm name.
|
static Mac |
getInstance(java.lang.String algorithm)
Algorithm factory, create object by algorithm name.
|
static Mac |
getInstance(java.lang.String algorithm,
java.security.Provider provider)
Algorithm factory, create object by algorithm name.
|
static Mac |
getInstance(java.lang.String algorithm,
java.lang.String provider)
Algorithm factory, create object by algorithm name.
|
int |
getMacLength()
returns mac value length in bytes.
|
java.security.Provider |
getProvider()
unused.
|
void |
init(java.security.Key key)
Initializes this Mac object with the given key.
|
void |
init(java.security.Key key,
java.security.spec.AlgorithmParameterSpec param)
Initializes this Mac object with the given key and algorithm parameters.
|
void |
reset()
Resets this Mac object.
|
java.lang.String |
toString() |
void |
update(byte b)
Processes the given byte.
|
void |
update(byte[] bytes)
Processes the given array of bytes.
|
void |
update(byte[] bytes,
int offset,
int length)
Processes the first length bytes in bytes, starting at offset inclusive.
|
void |
update(java.nio.ByteBuffer input)
Processes input.remaining() bytes in the ByteBuffer input, starting at input.position().
|
public static final char SEPARATOR
public static final java.lang.String STR_SEPARATOR
public Mac(MacInterface internal)
internal
- implementation.public static Mac getInstance(java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
Mac.getInstance(String)
.
Algorithm parameter can be set here "GOST28147/1.2.643.2.2.31.1".algorithm
- algorithm name.java.security.NoSuchAlgorithmException
- if the specified algorithm is not availablepublic static Mac getInstance(java.lang.String algorithm, java.lang.String provider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
Mac.getInstance(String)
.
Algorithm parameter can be set here "GOST28147/1.2.643.2.2.31.1".algorithm
- algorithm name.provider
- unusedjava.security.NoSuchAlgorithmException
- if the specified algorithm is not availablejava.security.NoSuchProviderException
- if the specified provider is not availablepublic static Mac getInstance(java.lang.String algorithm, java.security.Provider provider) throws java.security.NoSuchAlgorithmException
Mac.getInstance(String)
.
Algorithm parameter can be set here "GOST28147/1.2.643.2.2.31.1".algorithm
- algorithm name.provider
- unusedjava.security.NoSuchAlgorithmException
- if the specified algorithm is not availablepublic java.security.Provider getProvider()
public java.lang.String getAlgorithm()
public int getMacLength()
public void init(java.security.Key key) throws java.security.InvalidKeyException
key
- symmetric secret key.java.security.InvalidKeyException
- if the given key is inappropriate for initializing this MACpublic void init(java.security.Key key, java.security.spec.AlgorithmParameterSpec param) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
key
- symmetric secret key.param
- the algorithm parameters.java.security.InvalidKeyException
- if the given key is inappropriate for initializing this MAC.java.security.InvalidAlgorithmParameterException
- if the given algorithm parameters are inappropriate for this MAC.public void update(byte b) throws java.lang.IllegalStateException
b
- the input byte to be processed.java.lang.IllegalStateException
- if this Mac has not been initialized.public void update(byte[] bytes) throws java.lang.IllegalStateException
bytes
- the array of bytes to be processed.java.lang.IllegalStateException
- if this Mac has not been initialized.public void update(byte[] bytes, int offset, int length) throws java.lang.IllegalStateException
bytes
- the input buffer.offset
- the offset in bytes where the input starts.length
- the number of bytes to process.java.lang.IllegalStateException
- if this Mac has not been initialized.public void update(java.nio.ByteBuffer input)
input
- the ByteBufferpublic byte[] doFinal() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if this Mac has not been initialized.public void doFinal(byte[] bytes, int offset) throws javax.crypto.ShortBufferException, java.lang.IllegalStateException
bytes
- the buffer where the MAC result is storedoffset
- the offset in output where the MAC is storedjavax.crypto.ShortBufferException
- if the given output buffer is too small to hold the resultjava.lang.IllegalStateException
- if this Mac has not been initialized.public byte[] doFinal(byte[] bytes) throws java.lang.IllegalStateException
bytes
- data bytesjava.lang.IllegalStateException
- if this Mac has not been initialized.public void reset()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public java.lang.String toString()
toString
in class java.lang.Object