@@ -1388,19 +1388,15 @@ pbkdf2_hmac_impl(PyObject *module, const char *hash_name,
1388
1388
1389
1389
#ifdef PY_OPENSSL_HAS_SCRYPT
1390
1390
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
-
1395
1391
/*[clinic input]
1396
1392
_hashlib.scrypt
1397
1393
1398
1394
password: Py_buffer
1399
1395
*
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
1404
1400
maxmem: long = 0
1405
1401
dklen: long = 64
1406
1402
@@ -1410,58 +1406,32 @@ scrypt password-based key derivation function.
1410
1406
1411
1407
static PyObject *
1412
1408
_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 ,
1414
1410
long maxmem , long dklen )
1415
- /*[clinic end generated code: output=14849e2aa2b7b46c input=48a7d63bf3f75c42 ]*/
1411
+ /*[clinic end generated code: output=d424bc3e8c6b9654 input=0c9a84230238fd79 ]*/
1416
1412
{
1417
1413
PyObject * key_obj = NULL ;
1418
1414
char * key ;
1419
1415
int retval ;
1420
- unsigned long n , r , p ;
1421
1416
1422
1417
if (password -> len > INT_MAX ) {
1423
1418
PyErr_SetString (PyExc_OverflowError ,
1424
1419
"password is too long." );
1425
1420
return NULL ;
1426
1421
}
1427
1422
1428
- if (salt -> buf == NULL ) {
1429
- PyErr_SetString (PyExc_TypeError ,
1430
- "salt is required" );
1431
- return NULL ;
1432
- }
1433
1423
if (salt -> len > INT_MAX ) {
1434
1424
PyErr_SetString (PyExc_OverflowError ,
1435
1425
"salt is too long." );
1436
1426
return NULL ;
1437
1427
}
1438
1428
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
- }
1445
1429
if (n < 2 || n & (n - 1 )) {
1446
1430
PyErr_SetString (PyExc_ValueError ,
1447
1431
"n must be a power of 2." );
1448
1432
return NULL ;
1449
1433
}
1450
1434
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
-
1465
1435
if (maxmem < 0 || maxmem > INT_MAX ) {
1466
1436
/* OpenSSL 1.1.0 restricts maxmem to 32 MiB. It may change in the
1467
1437
future. The maxmem constant is private to OpenSSL. */
0 commit comments