{"id":3999,"date":"2022-12-20T17:28:40","date_gmt":"2022-12-20T20:28:40","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/scrypt-man7\/"},"modified":"2022-12-20T17:28:40","modified_gmt":"2022-12-20T20:28:40","slug":"scrypt-man7","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/scrypt-man7\/","title":{"rendered":"SCRYPT (man7)"},"content":{"rendered":"<h1 align=\"center\">SCRYPT<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">scrypt \u2212 EVP_PKEY scrypt KDF support<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <small>EVP_PKEY_SCRYPT<\/small> algorithm implements the scrypt password based key derivation function, as described in <small>RFC 7914.<\/small> It is memory-hard in the sense that it deliberately requires a significant amount of <small>RAM<\/small> for efficient computation. The intention of this is to render brute forcing of passwords on systems that lack large amounts of main memory (such as GPUs or ASICs) computationally infeasible.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">scrypt provides three work factors that can be customized: N, r and p. N, which has to be a positive power of two, is the general work factor and scales <small>CPU<\/small> time in an approximately linear fashion. r is the block size of the internally used hash function and p is the parallelization factor. Both r and p need to be greater than zero. The amount of <small>RAM<\/small> that scrypt requires for its computation is roughly (128 bodies manpages.csv script_extrae_body.sh script.sh usr N bodies manpages.csv script_extrae_body.sh script.sh usr r bodies manpages.csv script_extrae_body.sh script.sh usr p) bytes.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In the original paper of Colin Percival (&#8220;Stronger Key Derivation via Sequential Memory-Hard Functions&#8221;, 2009), the suggested values that give a computation time of less than 5 seconds on a 2.5 GHz Intel Core 2 Duo are N = 2^20 = 1048576, r = 8, p = 1. Consequently, the required amount of memory for this computation is roughly 1 GiB. On a more recent <small>CPU<\/small> (Intel i7\u22125930K at 3.5 GHz), this computation takes about 3 seconds. When N, r or p are not specified, they default to 1048576, 8, and 1, respectively. The default amount of <small>RAM<\/small> that may be used by scrypt defaults to 1025 MiB.<\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">A context for scrypt can be obtained by calling:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_SCRYPT, NULL);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The output length of an scrypt key derivation is specified via the length parameter to the <b>EVP_PKEY_derive<\/b>(3) function.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This example derives a 64\u2212byte long test vector using scrypt using the password &#8220;password&#8221;, salt &#8220;NaCl&#8221; and N = 1024, r = 8, p = 16.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">EVP_PKEY_CTX *pctx; <br \/> unsigned char out[64]; <br \/> size_t outlen = sizeof(out); <br \/> pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_SCRYPT, NULL); <br \/> if (EVP_PKEY_derive_init(pctx) <= 0) { <br \/> error(&#8220;EVP_PKEY_derive_init&#8221;); <br \/> } <br \/> if (EVP_PKEY_CTX_set1_pbe_pass(pctx, &#8220;password&#8221;, 8) <= 0) { <br \/> error(&#8220;EVP_PKEY_CTX_set1_pbe_pass&#8221;); <br \/> } <br \/> if (EVP_PKEY_CTX_set1_scrypt_salt(pctx, &#8220;NaCl&#8221;, 4) <= 0) { <br \/> error(&#8220;EVP_PKEY_CTX_set1_scrypt_salt&#8221;); <br \/> } <br \/> if (EVP_PKEY_CTX_set_scrypt_N(pctx, 1024) <= 0) { <br \/> error(&#8220;EVP_PKEY_CTX_set_scrypt_N&#8221;); <br \/> } <br \/> if (EVP_PKEY_CTX_set_scrypt_r(pctx, 8) <= 0) { <br \/> error(&#8220;EVP_PKEY_CTX_set_scrypt_r&#8221;); <br \/> } <br \/> if (EVP_PKEY_CTX_set_scrypt_p(pctx, 16) <= 0) { <br \/> error(&#8220;EVP_PKEY_CTX_set_scrypt_p&#8221;); <br \/> } <br \/> if (EVP_PKEY_derive(pctx, out, &#038;outlen) <= 0) { <br \/> error(&#8220;EVP_PKEY_derive&#8221;); <br \/> } <br \/> { <br \/> const unsigned char expected[sizeof(out)] = { <br \/> 0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00, <br \/> 0x78, 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe, <br \/> 0x7c, 0x6a, 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30, <br \/> 0xe7, 0x73, 0x76, 0x63, 0x4b, 0x37, 0x31, 0x62, <br \/> 0x2e, 0xaf, 0x30, 0xd9, 0x2e, 0x22, 0xa3, 0x88, <br \/> 0x6f, 0xf1, 0x09, 0x27, 0x9d, 0x98, 0x30, 0xda, <br \/> 0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, 0xee, 0x6d, <br \/> 0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, 0x40 <br \/> }; <br \/> assert(!memcmp(out, expected, sizeof(out))); <br \/> } <br \/> EVP_PKEY_CTX_free(pctx);<\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><small>RFC 7914<\/small><\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>EVP_PKEY_CTX_set1_scrypt_salt<\/b>(3), <b>EVP_PKEY_CTX_set_scrypt_N<\/b>(3), <b>EVP_PKEY_CTX_set_scrypt_r<\/b>(3), <b>EVP_PKEY_CTX_set_scrypt_p<\/b>(3), <b>EVP_PKEY_CTX_set_scrypt_maxmem_bytes<\/b>(3), <b>EVP_PKEY_CTX_new<\/b>(3), <b>EVP_PKEY_CTX_ctrl_str<\/b>(3), <b>EVP_PKEY_derive<\/b>(3)<\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright 2017\u22122019 The OpenSSL Project Authors. All Rights Reserved.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Licensed under the OpenSSL license (the &#8220;License&#8221;). You may not use this file except in compliance with the License. You can obtain a copy in the file <small>LICENSE<\/small> in the source distribution or at <https:\/\/www.openssl.org\/source\/license.html>.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  scrypt \u2212 EVP_PKEY scrypt KDF support <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[971],"tags":[973,972,1087],"class_list":["post-3999","post","type-post","status-publish","format-standard","hentry","category-7-miscelanea","tag-973","tag-man7","tag-scrypt"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3999"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3999\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}