[3.13] gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures (GH-134713) (#134962)

OpenSSL and HACL*-based hash functions constructors now support both `data` and `string` parameters.
Previously these constructor functions inconsistently supported sometimes `data` and sometimes `string`,
while the documentation expected `data` to be given in all cases.

(cherry picked from commit c6e63d9d35)
(cherry picked from commit 379d0bc956)
This commit is contained in:
Bénédikt Tran 2025-06-01 10:27:02 +02:00 committed by GitHub
parent e69ecfee5e
commit 2c325e28c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 929 additions and 500 deletions

View file

@ -269,17 +269,24 @@ static PyType_Spec md5_type_spec = {
/*[clinic input]
_md5.md5
string: object(c_default="NULL") = b''
data: object(c_default="NULL") = b''
*
usedforsecurity: bool = True
string as string_obj: object(c_default="NULL") = None
Return a new MD5 hash object; optionally initialized with a string.
[clinic start generated code]*/
static PyObject *
_md5_md5_impl(PyObject *module, PyObject *string, int usedforsecurity)
/*[clinic end generated code: output=587071f76254a4ac input=7a144a1905636985]*/
_md5_md5_impl(PyObject *module, PyObject *data, int usedforsecurity,
PyObject *string_obj)
/*[clinic end generated code: output=d45e187d3d16f3a8 input=7ea5c5366dbb44bf]*/
{
PyObject *string;
if (_Py_hashlib_data_argument(&string, data, string_obj) < 0) {
return NULL;
}
MD5object *new;
Py_buffer buf;