Interface KeyDerivation.Lazy

All Known Implementing Classes:
LazySodium, LazySodiumJava
Enclosing interface:
KeyDerivation

public static interface KeyDerivation.Lazy
  • Method Summary

    Modifier and Type
    Method
    Description
    cryptoKdfDeriveFromKey(int lengthOfSubKey, long subKeyId, String context, Key masterKey)
    Derive a subkey from a master key.
    Auto generates a master key and returns it in string format.
  • Method Details

    • cryptoKdfKeygen

      Key cryptoKdfKeygen()
      Auto generates a master key and returns it in string format. The reason why this does not return a string via the normal 'masterKey.getBytes()' is because the resulting string is mangled.
      Returns:
      A master Key.
    • cryptoKdfDeriveFromKey

      Key cryptoKdfDeriveFromKey(int lengthOfSubKey, long subKeyId, String context, Key masterKey) throws SodiumException
      Derive a subkey from a master key.
      Parameters:
      lengthOfSubKey - The length of the subkey. Should be from KeyDerivation.BYTES_MIN to KeyDerivation.BYTES_MAX.
      subKeyId - The ID of the subkey.
      context - The context of the subkey. Must be KeyDerivation.CONTEXT_BYTES.
      masterKey - The generated master key from cryptoKdfKeygen().
      Returns:
      A subkey that's gone through Helpers.Lazy.sodiumBin2Hex(byte[]).
      Throws:
      SodiumException - If any of the lengths were not correct.