1 /*[clinic input] 2 preserve 3 [clinic start generated code]*/ 4 5 #if (OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_SCRYPT) && !defined(LIBRESSL_VERSION_NUMBER)) 6 7 PyDoc_STRVAR(_hashlib_scrypt__doc__, 8 "scrypt($module, /, password, *, salt=None, n=None, r=None, p=None,\n" 9 " maxmem=0, dklen=64)\n" 10 "--\n" 11 "\n" 12 "scrypt password-based key derivation function."); 13 14 #define _HASHLIB_SCRYPT_METHODDEF \ 15 {"scrypt", (PyCFunction)_hashlib_scrypt, METH_FASTCALL, _hashlib_scrypt__doc__}, 16 17 static PyObject * 18 _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer *salt, 19 PyObject *n_obj, PyObject *r_obj, PyObject *p_obj, 20 long maxmem, long dklen); 21 22 static PyObject * 23 _hashlib_scrypt(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) 24 { 25 PyObject *return_value = NULL; 26 static const char * const _keywords[] = {"password", "salt", "n", "r", "p", "maxmem", "dklen", NULL}; 27 static _PyArg_Parser _parser = {"y*|$y*O!O!O!ll:scrypt", _keywords, 0}; 28 Py_buffer password = {NULL, NULL}; 29 Py_buffer salt = {NULL, NULL}; 30 PyObject *n_obj = Py_None; 31 PyObject *r_obj = Py_None; 32 PyObject *p_obj = Py_None; 33 long maxmem = 0; 34 long dklen = 64; 35 36 if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, 37 &password, &salt, &PyLong_Type, &n_obj, &PyLong_Type, &r_obj, &PyLong_Type, &p_obj, &maxmem, &dklen)) { 38 goto exit; 39 } 40 return_value = _hashlib_scrypt_impl(module, &password, &salt, n_obj, r_obj, p_obj, maxmem, dklen); 41 42 exit: 43 /* Cleanup for password */ 44 if (password.obj) { 45 PyBuffer_Release(&password); 46 } 47 /* Cleanup for salt */ 48 if (salt.obj) { 49 PyBuffer_Release(&salt); 50 } 51 52 return return_value; 53 } 54 55 #endif /* (OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_SCRYPT) && !defined(LIBRESSL_VERSION_NUMBER)) */ 56 57 #ifndef _HASHLIB_SCRYPT_METHODDEF 58 #define _HASHLIB_SCRYPT_METHODDEF 59 #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */ 60 /*[clinic end generated code: output=118cd7036fa0fb52 input=a9049054013a1b77]*/ 61