public final class HMAC256Generator extends HMACGenerator
Modifier and Type | Class and Description |
---|---|
(package private) static class |
HMAC256Generator.HMACKey
Like SecretKeySpec but doesn't copy the key in the construtor, for speed.
|
Constructor and Description |
---|
HMAC256Generator(I2PAppContext context) |
Modifier and Type | Method and Description |
---|---|
void |
calculate(byte[] key,
byte[] data,
int offset,
int length,
byte[] target,
int targetOffset)
Calculate the HMAC of the data with the given key.
|
void |
calculate(SessionKey key,
byte[] data,
int offset,
int length,
byte[] target,
int targetOffset)
Calculate the HMAC of the data with the given key.
|
boolean |
verify(SessionKey key,
byte[] curData,
int curOffset,
int curLength,
byte[] origMAC,
int origMACOffset,
int origMACLength)
Verify the MAC inline, reducing some unnecessary memory churn.
|
acquireTmp, releaseTmp
public HMAC256Generator(I2PAppContext context)
context
- unusedpublic void calculate(SessionKey key, byte[] data, int offset, int length, byte[] target, int targetOffset)
calculate
in class HMACGenerator
target
- out parameter the first 16 bytes contain the HMAC, the last 16 bytes are zerotargetOffset
- offset into target to put the hmacUnsupportedOperationException
- if the JVM does not support itIllegalArgumentException
- for bad key or target too smallpublic void calculate(byte[] key, byte[] data, int offset, int length, byte[] target, int targetOffset)
key
- first 32 bytes used as the keyUnsupportedOperationException
- if the JVM does not support itIllegalArgumentException
- for bad key or target too smallpublic boolean verify(SessionKey key, byte[] curData, int curOffset, int curLength, byte[] origMAC, int origMACOffset, int origMACLength)
verify
in class HMACGenerator
key
- session key to verify the MAC withcurData
- MAC to verifycurOffset
- index into curData to MACcurLength
- how much data in curData do we want to run the HMAC overorigMAC
- what do we expect the MAC of curData to equalorigMACOffset
- index into origMACorigMACLength
- how much of the MAC do we want to verify, use 32 for HMAC256