Debian Codegraph @

upstream/debian-unstable/man7/EVP_KDF-SCRYPT.7ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "EVP_KDF-SCRYPT 7SSL"
58 .TH EVP_KDF-SCRYPT 7SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 EVP_KDF\-SCRYPT \- The scrypt EVP_KDF implementation
65 .SH DESCRIPTION
66 .IX Header "DESCRIPTION"
67 Support for computing the \fBscrypt\fR password-based KDF through the \fBEVP_KDF\fR
68 API.
69 .PP
70 The EVP_KDF\-SCRYPT algorithm implements the scrypt password-based key
71 derivation function, as described in RFC 7914. It is memory-hard in the sense
72 that it deliberately requires a significant amount of RAM for efficient
73 computation. The intention of this is to render brute forcing of passwords on
74 systems that lack large amounts of main memory (such as GPUs or ASICs)
75 computationally infeasible.
76 .PP
77 scrypt provides three work factors that can be customized: N, r and p. N, which
78 has to be a positive power of two, is the general work factor and scales CPU
79 time in an approximately linear fashion. r is the block size of the internally
80 used hash function and p is the parallelization factor. Both r and p need to be
81 greater than zero. The amount of RAM that scrypt requires for its computation
82 is roughly (128 * N * r * p) bytes.
83 .PP
84 In the original paper of Colin Percival ("Stronger Key Derivation via
85 Sequential Memory-Hard Functions", 2009), the suggested values that give a
86 computation time of less than 5 seconds on a 2.5 GHz Intel Core 2 Duo are N =
87 2^20 = 1048576, r = 8, p = 1. Consequently, the required amount of memory for
88 this computation is roughly 1 GiB. On a more recent CPU (Intel i7\-5930K at 3.5
89 GHz), this computation takes about 3 seconds. When N, r or p are not specified,
90 they default to 1048576, 8, and 1, respectively. The maximum amount of RAM that
91 may be used by scrypt defaults to 1025 MiB.
92 .SS Identity
93 .IX Subsection "Identity"
94 "SCRYPT" is the name for this implementation; it
95 can be used with the \fBEVP_KDF_fetch()\fR function.
96 .SS "Supported parameters"
97 .IX Subsection "Supported parameters"
98 The supported parameters are:
99 .IP """pass"" (\fBOSSL_KDF_PARAM_PASSWORD\fR) <octet string>" 4
100 .IX Item """pass"" (OSSL_KDF_PARAM_PASSWORD) <octet string>"
101 .PD 0
102 .IP """salt"" (\fBOSSL_KDF_PARAM_SALT\fR) <octet string>" 4
103 .IX Item """salt"" (OSSL_KDF_PARAM_SALT) <octet string>"
104 .PD
105 These parameters work as described in "PARAMETERS" in \fBEVP_KDF\fR\|(3).
106 .IP """n"" (\fBOSSL_KDF_PARAM_SCRYPT_N\fR) <unsigned integer>" 4
107 .IX Item """n"" (OSSL_KDF_PARAM_SCRYPT_N) <unsigned integer>"
108 .PD 0
109 .IP """r"" (\fBOSSL_KDF_PARAM_SCRYPT_R\fR) <unsigned integer>" 4
110 .IX Item """r"" (OSSL_KDF_PARAM_SCRYPT_R) <unsigned integer>"
111 .IP """p"" (\fBOSSL_KDF_PARAM_SCRYPT_P\fR) <unsigned integer>" 4
112 .IX Item """p"" (OSSL_KDF_PARAM_SCRYPT_P) <unsigned integer>"
113 .IP """maxmem_bytes"" (\fBOSSL_KDF_PARAM_SCRYPT_MAXMEM\fR) <unsigned integer>" 4
114 .IX Item """maxmem_bytes"" (OSSL_KDF_PARAM_SCRYPT_MAXMEM) <unsigned integer>"
115 .PD
116 These parameters configure the scrypt work factors N, r, maxmem and p.
117 Both N and maxmem_bytes are parameters of type \fBuint64_t\fR.
118 Both r and p are parameters of type \fBuint32_t\fR.
119 .IP """properties"" (\fBOSSL_KDF_PARAM_PROPERTIES\fR) <UTF8 string>" 4
120 .IX Item """properties"" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>"
121 This can be used to set the property query string when fetching the
122 fixed digest internally. NULL is used if this value is not set.
123 .SH NOTES
124 .IX Header "NOTES"
125 A context for scrypt can be obtained by calling:
126 .PP
127 .Vb 2
128 \& EVP_KDF *kdf = EVP_KDF_fetch(NULL, "SCRYPT", NULL);
129 \& EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
130 .Ve
131 .PP
132 The output length of an scrypt key derivation is specified via the
133 "keylen" parameter to the \fBEVP_KDF_derive\fR\|(3) function.
134 .SH EXAMPLES
135 .IX Header "EXAMPLES"
136 This example derives a 64\-byte long test vector using scrypt with the password
137 "password", salt "NaCl" and N = 1024, r = 8, p = 16.
138 .PP
139 .Vb 4
140 \& EVP_KDF *kdf;
141 \& EVP_KDF_CTX *kctx;
142 \& unsigned char out[64];
143 \& OSSL_PARAM params[6], *p = params;
144 \&
145 \& kdf = EVP_KDF_fetch(NULL, "SCRYPT", NULL);
146 \& kctx = EVP_KDF_CTX_new(kdf);
147 \& EVP_KDF_free(kdf);
148 \&
149 \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_PASSWORD,
150 \& "password", (size_t)8);
151 \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
152 \& "NaCl", (size_t)4);
153 \& *p++ = OSSL_PARAM_construct_uint64(OSSL_KDF_PARAM_SCRYPT_N, (uint64_t)1024);
154 \& *p++ = OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_SCRYPT_R, (uint32_t)8);
155 \& *p++ = OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_SCRYPT_P, (uint32_t)16);
156 \& *p = OSSL_PARAM_construct_end();
157 \& if (EVP_KDF_derive(kctx, out, sizeof(out), params) <= 0) {
158 \& error("EVP_KDF_derive");
159 \& }
160 \&
161 \& {
162 \& const unsigned char expected[sizeof(out)] = {
163 \& 0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00,
164 \& 0x78, 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe,
165 \& 0x7c, 0x6a, 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30,
166 \& 0xe7, 0x73, 0x76, 0x63, 0x4b, 0x37, 0x31, 0x62,
167 \& 0x2e, 0xaf, 0x30, 0xd9, 0x2e, 0x22, 0xa3, 0x88,
168 \& 0x6f, 0xf1, 0x09, 0x27, 0x9d, 0x98, 0x30, 0xda,
169 \& 0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, 0xee, 0x6d,
170 \& 0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, 0x40
171 \& };
172 \&
173 \& assert(!memcmp(out, expected, sizeof(out)));
174 \& }
175 \&
176 \& EVP_KDF_CTX_free(kctx);
177 .Ve
178 .SH "CONFORMING TO"
179 .IX Header "CONFORMING TO"
180 RFC 7914
181 .SH "SEE ALSO"
182 .IX Header "SEE ALSO"
183 \&\fBEVP_KDF\fR\|(3),
184 \&\fBEVP_KDF_CTX_new\fR\|(3),
185 \&\fBEVP_KDF_CTX_free\fR\|(3),
186 \&\fBEVP_KDF_CTX_set_params\fR\|(3),
187 \&\fBEVP_KDF_derive\fR\|(3),
188 "PARAMETERS" in \fBEVP_KDF\fR\|(3)
189 .SH HISTORY
190 .IX Header "HISTORY"
191 This functionality was added in OpenSSL 3.0.
192 .SH COPYRIGHT
193 .IX Header "COPYRIGHT"
194 Copyright 2017\-2021 The OpenSSL Project Authors. All Rights Reserved.
195 .PP
196 Licensed under the Apache License 2.0 (the "License"). You may not use
197 this file except in compliance with the License. You can obtain a copy
198 in the file LICENSE in the source distribution or at
199 <https://www.openssl.org/source/license.html>.