public abstract class HMACGenerator extends Object
Key operations include:
Implementation Note: As of 0.9.42, this class serves
as an abstract base. See net.i2p.router.transport.udp.SSUHMACGenerator
for SSU-specific HMAC implementation and SHA256Generator for
Syndie-compatible HMAC operations.
| Constructor and Description |
|---|
HMACGenerator() |
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
acquireTmp()
32 bytes from the byte array cache.
|
abstract void |
calculate(SessionKey key,
byte[] data,
int offset,
int length,
byte[] target,
int targetOffset)
Calculate the HMAC of the data with the given key
|
protected void |
releaseTmp(byte[] tmp) |
abstract 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.
|
protected byte[] acquireTmp()
public abstract void calculate(SessionKey key, byte[] data, int offset, int length, byte[] target, int targetOffset)
key - the session keydata - the data to HMACoffset - the starting offset in datalength - the length of data to HMACtarget - out parameter the first 16 bytes contain the HMAC, the last 16 bytes are zerotargetOffset - offset into target to put the hmacIllegalArgumentException - for bad key or target too smallprotected void releaseTmp(byte[] tmp)
public abstract boolean verify(SessionKey key, byte[] curData, int curOffset, int curLength, byte[] origMAC, int origMACOffset, int origMACLength)
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 verifyIllegalArgumentException - for bad key