@@ -1388,19 +1388,15 @@ pbkdf2_hmac_impl(PyObject *module, const char *hash_name,
13881388
13891389#ifdef PY_OPENSSL_HAS_SCRYPT
13901390
1391- /* XXX: Parameters salt, n, r and p should be required keyword-only parameters.
1392- They are optional in the Argument Clinic declaration only due to a
1393- limitation of PyArg_ParseTupleAndKeywords. */
1394-
13951391/*[clinic input]
13961392_hashlib.scrypt
13971393
13981394 password: Py_buffer
13991395 *
1400- salt: Py_buffer = None
1401- n as n_obj: object(subclass_of='&PyLong_Type') = None
1402- r as r_obj: object(subclass_of='&PyLong_Type') = None
1403- p as p_obj: object(subclass_of='&PyLong_Type') = None
1396+ salt: Py_buffer
1397+ n: unsigned_long
1398+ r: unsigned_long
1399+ p: unsigned_long
14041400 maxmem: long = 0
14051401 dklen: long = 64
14061402
@@ -1410,58 +1406,32 @@ scrypt password-based key derivation function.
14101406
14111407static PyObject *
14121408_hashlib_scrypt_impl (PyObject * module , Py_buffer * password , Py_buffer * salt ,
1413- PyObject * n_obj , PyObject * r_obj , PyObject * p_obj ,
1409+ unsigned long n , unsigned long r , unsigned long p ,
14141410 long maxmem , long dklen )
1415- /*[clinic end generated code: output=14849e2aa2b7b46c input=48a7d63bf3f75c42 ]*/
1411+ /*[clinic end generated code: output=d424bc3e8c6b9654 input=0c9a84230238fd79 ]*/
14161412{
14171413 PyObject * key_obj = NULL ;
14181414 char * key ;
14191415 int retval ;
1420- unsigned long n , r , p ;
14211416
14221417 if (password -> len > INT_MAX ) {
14231418 PyErr_SetString (PyExc_OverflowError ,
14241419 "password is too long." );
14251420 return NULL ;
14261421 }
14271422
1428- if (salt -> buf == NULL ) {
1429- PyErr_SetString (PyExc_TypeError ,
1430- "salt is required" );
1431- return NULL ;
1432- }
14331423 if (salt -> len > INT_MAX ) {
14341424 PyErr_SetString (PyExc_OverflowError ,
14351425 "salt is too long." );
14361426 return NULL ;
14371427 }
14381428
1439- n = PyLong_AsUnsignedLong (n_obj );
1440- if (n == (unsigned long ) -1 && PyErr_Occurred ()) {
1441- PyErr_SetString (PyExc_TypeError ,
1442- "n is required and must be an unsigned int" );
1443- return NULL ;
1444- }
14451429 if (n < 2 || n & (n - 1 )) {
14461430 PyErr_SetString (PyExc_ValueError ,
14471431 "n must be a power of 2." );
14481432 return NULL ;
14491433 }
14501434
1451- r = PyLong_AsUnsignedLong (r_obj );
1452- if (r == (unsigned long ) -1 && PyErr_Occurred ()) {
1453- PyErr_SetString (PyExc_TypeError ,
1454- "r is required and must be an unsigned int" );
1455- return NULL ;
1456- }
1457-
1458- p = PyLong_AsUnsignedLong (p_obj );
1459- if (p == (unsigned long ) -1 && PyErr_Occurred ()) {
1460- PyErr_SetString (PyExc_TypeError ,
1461- "p is required and must be an unsigned int" );
1462- return NULL ;
1463- }
1464-
14651435 if (maxmem < 0 || maxmem > INT_MAX ) {
14661436 /* OpenSSL 1.1.0 restricts maxmem to 32 MiB. It may change in the
14671437 future. The maxmem constant is private to OpenSSL. */
0 commit comments