Class SSUHMACGenerator

java.lang.Object
net.i2p.crypto.HMACGenerator
net.i2p.router.transport.udp.SSUHMACGenerator

class SSUHMACGenerator extends HMACGenerator
Calculate the HMAC-MD5-128 of a key+message. All the good stuff occurs in I2PHMac Keys are always 32 bytes. This is used only by UDP. Use deprecated outside the router, this may move to router.jar. NOTE THIS IS NOT COMPATIBLE with javax.crypto.Mac.getInstance("HmacMD5") as we tell I2PHMac that the digest length is 32 bytes, so it generates a different result. Quote jrandom: "The HMAC is hardcoded to use SHA256 digest size for backwards compatability. next time we have a backwards incompatible change, we should update this." Does this mean he intended it to be compatible with MD5? See also 2005-07-05 status notes.
Since:
0.9.42 moved from net.i2p.crypto.HMACGenerator
  • Constructor Details

    • SSUHMACGenerator

      public SSUHMACGenerator()
  • Method Details

    • 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
      Specified by:
      calculate in class HMACGenerator
      Parameters:
      target - out parameter the first 16 bytes contain the HMAC, the last 16 bytes are zero
      targetOffset - offset into target to put the hmac
      Throws:
      IllegalArgumentException - for bad key or target too small
    • 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.
      Specified by:
      verify in class HMACGenerator
      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
      Throws:
      IllegalArgumentException - for bad key
    • clearCache

      public void clearCache()
      Since:
      0.9.42