{
    "mode": "man",
    "parameter": "EVP_KDF-SCRYPT",
    "section": "7ssl",
    "url": "https://www.chedong.com/phpMan.php/man/EVP_KDF-SCRYPT/7ssl/json",
    "generated": "2026-06-03T01:48:18Z",
    "sections": {
        "NAME": {
            "content": "EVPKDF-SCRYPT - The scrypt EVPKDF implementation\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Support for computing the scrypt password-based KDF through the EVPKDF API.\n\nThe EVPKDF-SCRYPT algorithm implements the scrypt password-based key derivation function, as\ndescribed in RFC 7914.  It is memory-hard in the sense that it deliberately requires a\nsignificant amount of RAM for efficient computation. The intention of this is to render brute\nforcing of passwords on systems that lack large amounts of main memory (such as GPUs or\nASICs) computationally infeasible.\n\nscrypt provides three work factors that can be customized: N, r and p. N, which has to be a\npositive power of two, is the general work factor and scales CPU time in an approximately\nlinear fashion. r is the block size of the internally used hash function and p is the\nparallelization factor. Both r and p need to be greater than zero. The amount of RAM that\nscrypt requires for its computation is roughly (128 * N * r * p) bytes.\n\nIn the original paper of Colin Percival (\"Stronger Key Derivation via Sequential Memory-Hard\nFunctions\", 2009), the suggested values that give a computation time of less than 5 seconds\non a 2.5 GHz Intel Core 2 Duo are N = 2^20 = 1048576, r = 8, p = 1. Consequently, the\nrequired amount of memory for this computation is roughly 1 GiB. On a more recent CPU (Intel\ni7-5930K at 3.5 GHz), this computation takes about 3 seconds. When N, r or p are not\nspecified, they default to 1048576, 8, and 1, respectively. The maximum amount of RAM that\nmay be used by scrypt defaults to 1025 MiB.\n",
            "subsections": [
                {
                    "name": "Identity",
                    "content": "\"SCRYPT\" is the name for this implementation; it can be used with the EVPKDFfetch()\nfunction.\n"
                },
                {
                    "name": "Supported parameters",
                    "content": "The supported parameters are:\n\n\"pass\" (OSSLKDFPARAMPASSWORD) <octet string>\n\"salt\" (OSSLKDFPARAMSALT) <octet string>\nThese parameters work as described in \"PARAMETERS\" in EVPKDF(3).\n\n\"n\" (OSSLKDFPARAMSCRYPTN) <unsigned integer>\n\"r\" (OSSLKDFPARAMSCRYPTR) <unsigned integer>\n\"p\" (OSSLKDFPARAMSCRYPTP) <unsigned integer>\n\"maxmembytes\" (OSSLKDFPARAMSCRYPTMAXMEM) <unsigned integer>\nThese parameters configure the scrypt work factors N, r, maxmem and p.  Both N and\nmaxmembytes are parameters of type uint64t.  Both r and p are parameters of type\nuint32t.\n\n\"properties\" (OSSLKDFPARAMPROPERTIES) <UTF8 string>\nThis can be used to set the property query string when fetching the fixed digest\ninternally. NULL is used if this value is not set.\n"
                }
            ]
        },
        "NOTES": {
            "content": "A context for scrypt can be obtained by calling:\n\nEVPKDF *kdf = EVPKDFfetch(NULL, \"SCRYPT\", NULL);\nEVPKDFCTX *kctx = EVPKDFCTXnew(kdf);\n\nThe output length of an scrypt key derivation is specified via the \"keylen\" parameter to the\nEVPKDFderive(3) function.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "This example derives a 64-byte long test vector using scrypt with the password \"password\",\nsalt \"NaCl\" and N = 1024, r = 8, p = 16.\n\nEVPKDF *kdf;\nEVPKDFCTX *kctx;\nunsigned char out[64];\nOSSLPARAM params[6], *p = params;\n\nkdf = EVPKDFfetch(NULL, \"SCRYPT\", NULL);\nkctx = EVPKDFCTXnew(kdf);\nEVPKDFfree(kdf);\n\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMPASSWORD,\n\"password\", (sizet)8);\n*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMSALT,\n\"NaCl\", (sizet)4);\n*p++ = OSSLPARAMconstructuint64(OSSLKDFPARAMSCRYPTN, (uint64t)1024);\n*p++ = OSSLPARAMconstructuint32(OSSLKDFPARAMSCRYPTR, (uint32t)8);\n*p++ = OSSLPARAMconstructuint32(OSSLKDFPARAMSCRYPTP, (uint32t)16);\n*p = OSSLPARAMconstructend();\nif (EVPKDFderive(kctx, out, sizeof(out), params) <= 0) {\nerror(\"EVPKDFderive\");\n}\n\n{\nconst unsigned char expected[sizeof(out)] = {\n0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00,\n0x78, 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe,\n0x7c, 0x6a, 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30,\n0xe7, 0x73, 0x76, 0x63, 0x4b, 0x37, 0x31, 0x62,\n0x2e, 0xaf, 0x30, 0xd9, 0x2e, 0x22, 0xa3, 0x88,\n0x6f, 0xf1, 0x09, 0x27, 0x9d, 0x98, 0x30, 0xda,\n0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, 0xee, 0x6d,\n0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, 0x40\n};\n\nassert(!memcmp(out, expected, sizeof(out)));\n}\n\nEVPKDFCTXfree(kctx);\n",
            "subsections": []
        },
        "CONFORMING TO": {
            "content": "RFC 7914\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "EVPKDF(3), EVPKDFCTXnew(3), EVPKDFCTXfree(3), EVPKDFCTXsetparams(3),\nEVPKDFderive(3), \"PARAMETERS\" in EVPKDF(3)\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.\n\nLicensed under the Apache License 2.0 (the \"License\").  You may not use this file except in\ncompliance with the License.  You can obtain a copy in the file LICENSE in the source\ndistribution or at <https://www.openssl.org/source/license.html>.\n\n\n\n3.0.2                                        2026-04-07                         EVPKDF-SCRYPT(7SSL)",
            "subsections": []
        }
    },
    "summary": "EVPKDF-SCRYPT - The scrypt EVPKDF implementation",
    "flags": [],
    "examples": [
        "This example derives a 64-byte long test vector using scrypt with the password \"password\",",
        "salt \"NaCl\" and N = 1024, r = 8, p = 16.",
        "EVPKDF *kdf;",
        "EVPKDFCTX *kctx;",
        "unsigned char out[64];",
        "OSSLPARAM params[6], *p = params;",
        "kdf = EVPKDFfetch(NULL, \"SCRYPT\", NULL);",
        "kctx = EVPKDFCTXnew(kdf);",
        "EVPKDFfree(kdf);",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMPASSWORD,",
        "\"password\", (sizet)8);",
        "*p++ = OSSLPARAMconstructoctetstring(OSSLKDFPARAMSALT,",
        "\"NaCl\", (sizet)4);",
        "*p++ = OSSLPARAMconstructuint64(OSSLKDFPARAMSCRYPTN, (uint64t)1024);",
        "*p++ = OSSLPARAMconstructuint32(OSSLKDFPARAMSCRYPTR, (uint32t)8);",
        "*p++ = OSSLPARAMconstructuint32(OSSLKDFPARAMSCRYPTP, (uint32t)16);",
        "*p = OSSLPARAMconstructend();",
        "if (EVPKDFderive(kctx, out, sizeof(out), params) <= 0) {",
        "error(\"EVPKDFderive\");",
        "const unsigned char expected[sizeof(out)] = {",
        "0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00,",
        "0x78, 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe,",
        "0x7c, 0x6a, 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30,",
        "0xe7, 0x73, 0x76, 0x63, 0x4b, 0x37, 0x31, 0x62,",
        "0x2e, 0xaf, 0x30, 0xd9, 0x2e, 0x22, 0xa3, 0x88,",
        "0x6f, 0xf1, 0x09, 0x27, 0x9d, 0x98, 0x30, 0xda,",
        "0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83, 0xee, 0x6d,",
        "0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06, 0x40",
        "};",
        "assert(!memcmp(out, expected, sizeof(out)));",
        "EVPKDFCTXfree(kctx);"
    ],
    "see_also": [
        {
            "name": "EVPKDF",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDF/3/json"
        },
        {
            "name": "EVPKDFCTXnew",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDFCTXnew/3/json"
        },
        {
            "name": "EVPKDFCTXfree",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDFCTXfree/3/json"
        },
        {
            "name": "EVPKDFCTXsetparams",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDFCTXsetparams/3/json"
        },
        {
            "name": "EVPKDFderive",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDFderive/3/json"
        },
        {
            "name": "EVPKDF",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/EVPKDF/3/json"
        }
    ]
}