Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.crypto
Class HMACGenerator

    java.lang.Object
      net.i2p.crypto.HMACGenerator

Direct Known Subclasses:
  HMAC256Generator

    public class HMACGenerator

extends Object

Calculate the HMAC-MD5 of a key+message. All the good stuff occurs in `I2PHMac` and `MD5Digest`.

Field Summary
`protected LinkedBlockingQueue<I2PHMac>` | `_available` set of available HMAC instances for calculate

Constructor Summary
`HMACGenerator(I2PAppContext context)`

Method Summary
`protected I2PHMac` | `acquire()`
`Hash` | `calculate(SessionKey key, byte[] data)` 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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _available

    protected final LinkedBlockingQueue<I2PHMac> _available

  set of available HMAC instances for calculate

Constructor Detail

### HMACGenerator

    public HMACGenerator(I2PAppContext context)

Method Detail

### calculate

    public Hash calculate(SessionKey key,
                          byte[] data)

  Calculate the HMAC of the data with the given key

### calculate

    public void calculate(SessionKey key,
                          byte[] data,
                          int offset,
                          int length,
                          byte[] target,
                          int targetOffset)

  Calculate the HMAC of the data with the given key

### verify

    public 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.

  Parameters:
    `key` - session key to verify the MAC with
    `curData` - MAC to verify
    `curOffset` - index into curData to MAC
    `curLength` - how much data in curData do we want to run the HMAC over
    `origMAC` - what do we expect the MAC of curData to equal
    `origMACOffset` - index into origMAC
    `origMACLength` - how much of the MAC do we want to verify

### acquire

    protected I2PHMac acquire()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD