Class HKDF

java.lang.Object
net.i2p.crypto.HKDF

public final class HKDF
extends Object
Various flavors of HKDF using HMAC-SHA256. See RFC 5869. One or two outputs, with or without "info". All keys and outputs are exactly 32 bytes.
Since:
0.9.38
  • Constructor Summary

    Constructors 
    Constructor Description
    HKDF​(I2PAppContext context)
    Thread safe, no state, can be reused
  • Method Summary

    Modifier and Type Method Description
    void calculate​(byte[] key, byte[] data, byte[] out)
    One output, no info.
    void calculate​(byte[] key, byte[] data, byte[] out, byte[] out2, int off2)
    Two outputs, no info.
    void calculate​(byte[] key, byte[] data, String info, byte[] out)
    One output with info.
    void calculate​(byte[] key, byte[] data, String info, byte[] out, byte[] out2, int off2)
    Two outputs with info.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • calculate

      public void calculate​(byte[] key, byte[] data, byte[] out)
      One output, no info.
      Parameters:
      key - first 32 bytes used as the key
      out - must be exactly 32 bytes
    • calculate

      public void calculate​(byte[] key, byte[] data, String info, byte[] out)
      One output with info.
      Parameters:
      key - first 32 bytes used as the key
      info - non-null ASCII, "" if none
      out - must be exactly 32 bytes
    • calculate

      public void calculate​(byte[] key, byte[] data, byte[] out, byte[] out2, int off2)
      Two outputs, no info.
      Parameters:
      key - first 32 bytes used as the key
      out - 32 bytes will be copied to here
      out2 - 32 bytes will be copied to here, may be the same as out
      off2 - offset for copy to out2
    • calculate

      public void calculate​(byte[] key, byte[] data, String info, byte[] out, byte[] out2, int off2)
      Two outputs with info.
      Parameters:
      key - first 32 bytes used as the key
      info - non-null ASCII, "" if none
      out - 32 bytes will be copied to here
      out2 - 32 bytes will be copied to here, may be the same as out
      off2 - offset for copy to out2