Class 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 Detail

      • HKDF

        public HKDF​(I2PAppContext context)
        Thread safe, no state, can be reused
    • Method Detail

      • 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