EVP_PBE_scrypt function

  1. @RecordUse.new()
  2. @Native<Int Function(Pointer<Char>, Size, Pointer<Uint8>, Size, Uint64, Uint64, Uint64, Size, Pointer<Uint8>, Size)>(ffi.Pointer<ffi.Char>, ffi.Size, ffi.Pointer<ffi.Uint8>, ffi.Size, ffi.Uint64, ffi.Uint64, ffi.Uint64, ffi.Size, ffi.Pointer<ffi.Uint8>, ffi.Size)>(symbol: 'bssl_dart_EVP_PBE_scrypt')
int EVP_PBE_scrypt(
  1. Pointer<Char> password,
  2. int password_len,
  3. Pointer<Uint8> salt,
  4. int salt_len,
  5. int N,
  6. int r,
  7. int p,
  8. int max_mem,
  9. Pointer<Uint8> out_key,
  10. int key_len,
)

EVP_PBE_scrypt expands |password| into a secret key of length |key_len| using scrypt, as described in RFC 7914, and writes the result to |out_key|. It returns one on success and zero on allocation failure, if the memory required for the operation exceeds |max_mem|, or if any of the parameters are invalid as described below.

|N|, |r|, and |p| are as described in RFC 7914 section 6. They determine the cost of the operation. If |max_mem| is zero, a default limit of 65MiB will be used.

The parameters are considered invalid under any of the following conditions:

  • |r| or |p| are zero
  • |p| > (2^30 - 1) / |r|
  • |N| is not a power of two
  • |N| > 2^32
  • |N| > 2^(128 * |r| / 8)

Implementation

@meta.RecordUse()
@ffi.Native<
  ffi.Int Function(
    ffi.Pointer<ffi.Char>,
    ffi.Size,
    ffi.Pointer<ffi.Uint8>,
    ffi.Size,
    ffi.Uint64,
    ffi.Uint64,
    ffi.Uint64,
    ffi.Size,
    ffi.Pointer<ffi.Uint8>,
    ffi.Size,
  )
>(symbol: 'bssl_dart_EVP_PBE_scrypt')
external int EVP_PBE_scrypt(
  ffi.Pointer<ffi.Char> password,
  int password_len,
  ffi.Pointer<ffi.Uint8> salt,
  int salt_len,
  int N,
  int r,
  int p,
  int max_mem,
  ffi.Pointer<ffi.Uint8> out_key,
  int key_len,
);