Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

stSCrypt

RFC 7914 "The scrypt Password-Based Key Derivation Function".

  scrypt(P, S, N, r, p, dkLen) is the sequential-memory-hard PBKDF built from:
    - PBKDF2-HMAC-SHA256 (RFC 8018) for the outer/inner key stretch,
    - the Salsa20/8 core (RFC 7914 sec.3),
    - scryptBlockMix (sec.4) and the memory-hard scryptROMix (sec.5).

  The PBKDF2 steps use the library's generic RFC 8018 implementation
  (stPkcs5.tPBKDF2_HMAC with SHA-256); PBKDF2_HMAC_SHA256 below is a thin
  wrapper over it, kept exported for API compatibility. Self-test: TestSCrypt
  (the RFC 7914 sec.12 vectors, up to N=16384; the 1 GiB N=1048576 vector is
  omitted). The PBES2 wiring in the PKCS#8 / PKCS#12 layers calls SCrypt()
  directly with the scrypt-params N/r/p.

  iSCrypt / tSCrypt integrate scrypt into the stKDF class hierarchy (iPBKDF /
  tPBKDF): the inherited Iter property doubles as N (CostParameter delegates to
  it), BlockSize (r) and Parallelization (p) are additional properties, and the
  full six-parameter derivation is available as DeriveKey overloads mirroring
  the SCrypt() routine.

Classes, interfaces and records

classESCryptError

inherits from Exception

(no public members)

interfaceiSCrypt

inherits from iPBKDF

scrypt as a framework KDF. Extends iPBKDF the same way iPBKDF extends iKDF: the parameters that do not fit the DeriveKey(aPassword, aSalt, aIter, aDKLen) signature become properties. The inherited Iter property carries the scrypt cost parameter N (CostParameter below is a delegate for it), so the inherited iPBKDF.DeriveKey overloads work unchanged with aIter = N and r/p taken from the properties.

function GetBlockSize: Integer;
Getter for BlockSize.
function GetCostParameter: Integer;
Getter for CostParameter.
function GetParallelization: Integer;
Getter for Parallelization.
procedure SetBlockSize(const Value: Integer);
Setter for BlockSize.
procedure SetCostParameter(const Value: Integer);
Setter for CostParameter.
procedure SetParallelization(const Value: Integer);
Setter for Parallelization.
function DeriveKey(const aPassword, aSalt: tBytes; aN, aR, aP, aDKLen: Integer): tBytes; overload;
Full RFC 7914 derivation with the same signature as the SCrypt() routine; the derived key is returned AND kept in the inherited iSecretKey.Key / KeyLen of the instance.
procedure DeriveKey(aPassword, aSalt: iSecretKey; aN, aR, aP, aDKLen: Integer); overload;
Same, with the key material passed as iSecretKey; the derived key is available via the inherited iSecretKey.Key/KeyLen afterwards.
property BlockSize: Integer read GetBlockSize write SetBlockSize;
scrypt r: the block size factor (RFC 7914 sec.6); each ROMix block is 128*r bytes. Default 8.
property CostParameter: Integer read GetCostParameter write SetCostParameter;
scrypt N: the CPU/memory cost parameter, a power of 2 > 1; the working memory is 128*r*N bytes. This is a delegate for the inherited Iter property (same storage), under scrypt's own name for it. Default 16384.
property Parallelization: Integer read GetParallelization write SetParallelization;
scrypt p: the parallelization parameter. Default 1.

classtSCrypt

inherits from tPBKDF

implements iSCrypt

constructor Create(aAlgorithm: ObjectIdentifier); procedure DeriveKey(aPassword, aSalt: iSecretKey; aIter, aDKLen: Integer); overload; override;
iPBKDF entry point: aIter is the scrypt cost parameter N; r and p are taken from BlockSize / Parallelization.
function DeriveKey(const aPassword, aSalt: tBytes; aN, aR, aP, aDKLen: Integer): tBytes; overload; procedure DeriveKey(aPassword, aSalt: iSecretKey; aN, aR, aP, aDKLen: Integer); overload; property BlockSize: Integer read GetBlockSize write SetBlockSize; property CostParameter: Integer read GetCostParameter write SetCostParameter; property Parallelization: Integer read GetParallelization write SetParallelization;

Routines