Update to Python 3.4 beta 1.

- Refreshed patches: 102 (lib64), 111 (no static lib), 125 (less verbose COUNT
ALLOCS), 141 (fix COUNT_ALLOCS in test_module), 146 (hashlib fips),
157 (UID+GID overflows), 173 (ENOPROTOOPT in bind_port)
- Removed patch 00187 (remove pthread atfork; upstreamed)
This commit is contained in:
Slavek Kabrda 2013-11-27 13:03:43 +01:00
commit bf35167937
9 changed files with 139 additions and 246 deletions

View file

@ -1,5 +1,5 @@
--- Python-3.4.0a4/Lib/hashlib.py.hashlib-fips 2013-11-07 13:29:43.046881440 +0100
+++ Python-3.4.0a4/Lib/hashlib.py 2013-11-07 13:42:04.438486289 +0100
--- Python-3.4.0b1/Lib/hashlib.py.hashlib-fips 2013-11-24 21:36:54.000000000 +0100
+++ Python-3.4.0b1/Lib/hashlib.py 2013-11-27 11:45:17.073617547 +0100
@@ -23,6 +23,16 @@
Choose your hash function wisely. Some have known collision weaknesses.
sha384 and sha512 will be slow on 32 bit platforms.
@ -17,27 +17,7 @@
Hash objects have these methods:
- update(arg): Update the hash object with the bytes in arg. Repeated calls
are equivalent to a single call with the concatenation of all
@@ -64,6 +74,19 @@
'algorithms_available', 'pbkdf2_hmac')
+import functools
+def __ignore_usedforsecurity(func):
+ """Used for sha3_* functions. Until OpenSSL implements them, we want
+ to use them from Python _sha3 module, but we want them to accept
+ usedforsecurity argument too."""
+ # TODO: remove this function when OpenSSL implements sha3
+ @functools.wraps(func)
+ def inner(*args, **kwargs):
+ if 'usedforsecurity' in kwargs:
+ kwargs.pop('usedforsecurity')
+ return func(*args, **kwargs)
+ return inner
+
def __get_builtin_constructor(name):
try:
if name in ('SHA1', 'sha1'):
@@ -109,34 +132,41 @@
@@ -108,34 +118,41 @@
f = getattr(_hashlib, 'openssl_' + name)
# Allow the C module to raise ValueError. The function will be
# defined but the hash not actually available thanks to OpenSSL.
@ -92,7 +72,7 @@
try:
import _hashlib
new = __hash_new
@@ -216,7 +246,10 @@
@@ -215,7 +232,10 @@
# try them all, some may not work due to the OpenSSL
# version not supporting that algorithm.
try:
@ -104,13 +84,13 @@
except ValueError:
import logging
logging.exception('code for hash %s was not found.', __func_name)
@@ -224,3 +257,4 @@
@@ -223,3 +243,4 @@
# Cleanup locals()
del __always_supported, __func_name, __get_hash
del __py_new, __hash_new, __get_openssl_constructor
+del __ignore_usedforsecurity
--- Python-3.4.0a4/Lib/test/test_hashlib.py.hashlib-fips 2013-11-07 13:43:08.763454594 +0100
+++ Python-3.4.0a4/Lib/test/test_hashlib.py 2013-11-07 13:55:23.233038101 +0100
--- Python-3.4.0b1/Lib/test/test_hashlib.py.hashlib-fips 2013-11-24 21:36:55.000000000 +0100
+++ Python-3.4.0b1/Lib/test/test_hashlib.py 2013-11-27 11:55:42.769601363 +0100
@@ -26,6 +26,20 @@
c_hashlib = import_fresh_module('hashlib', fresh=['_hashlib'])
py_hashlib = import_fresh_module('hashlib', blocked=['_hashlib'])
@ -164,32 +144,37 @@
constructors.add(_test_algorithm_via_hashlib_new)
_hashlib = self._conditional_import_module('_hashlib')
@@ -82,22 +106,9 @@
@@ -82,27 +106,13 @@
for algorithm, constructors in self.constructors_to_test.items():
constructor = getattr(_hashlib, 'openssl_'+algorithm, None)
if constructor:
- constructors.add(constructor)
+ constructors.add(suppress_fips(constructor))
def add_builtin_constructor(name):
constructor = getattr(hashlib, "__get_builtin_constructor")(name)
self.constructors_to_test[name].add(constructor)
- _md5 = self._conditional_import_module('_md5')
- if _md5:
- self.constructors_to_test['md5'].add(_md5.md5)
- add_builtin_constructor('md5')
- _sha1 = self._conditional_import_module('_sha1')
- if _sha1:
- self.constructors_to_test['sha1'].add(_sha1.sha1)
- add_builtin_constructor('sha1')
- _sha256 = self._conditional_import_module('_sha256')
- if _sha256:
- self.constructors_to_test['sha224'].add(_sha256.sha224)
- self.constructors_to_test['sha256'].add(_sha256.sha256)
- add_builtin_constructor('sha224')
- add_builtin_constructor('sha256')
- _sha512 = self._conditional_import_module('_sha512')
- if _sha512:
- self.constructors_to_test['sha384'].add(_sha512.sha384)
- self.constructors_to_test['sha512'].add(_sha512.sha512)
- add_builtin_constructor('sha384')
- add_builtin_constructor('sha512')
- _sha3 = self._conditional_import_module('_sha3')
+ # TODO: remove this after sha3 is available through OpenSSL
_sha3 = self._conditional_import_module('_sha3')
if _sha3:
self.constructors_to_test['sha3_224'].add(_sha3.sha3_224)
@@ -547,6 +558,65 @@
add_builtin_constructor('sha3_224')
add_builtin_constructor('sha3_256')
@@ -558,6 +568,65 @@
self.assertEqual(expected_hash, hasher.hexdigest())
@ -255,7 +240,7 @@
class KDFTests(unittest.TestCase):
@@ -628,6 +698,7 @@
@@ -639,6 +708,7 @@
with self.assertRaisesRegex(ValueError, 'unsupported hash type'):
pbkdf2('unknown', b'pass', b'salt', 1)
@ -263,8 +248,8 @@
def test_pbkdf2_hmac_py(self):
self._test_pbkdf2_hmac(py_hashlib.pbkdf2_hmac)
--- Python-3.4.0a4/Modules/_hashopenssl.c.hashlib-fips 2013-11-07 13:55:47.466025086 +0100
+++ Python-3.4.0a4/Modules/_hashopenssl.c 2013-11-07 14:14:32.745272791 +0100
--- Python-3.4.0b1/Modules/_hashopenssl.c.hashlib-fips 2013-11-24 21:36:56.000000000 +0100
+++ Python-3.4.0b1/Modules/_hashopenssl.c 2013-11-27 12:01:57.443537463 +0100
@@ -19,6 +19,8 @@
@ -298,7 +283,7 @@
DEFINE_CONSTS_FOR_NEW(md5)
DEFINE_CONSTS_FOR_NEW(sha1)
@@ -125,6 +135,48 @@
@@ -97,6 +107,48 @@
}
}
@ -347,7 +332,7 @@
/* Internal methods for a hash object */
static void
@@ -309,15 +361,16 @@
@@ -281,15 +333,16 @@
static int
EVP_tp_init(EVPobject *self, PyObject *args, PyObject *kwds)
{
@ -367,7 +352,7 @@
return -1;
}
@@ -338,7 +391,12 @@
@@ -310,7 +363,12 @@
PyBuffer_Release(&view);
return -1;
}
@ -381,7 +366,7 @@
self->name = name_obj;
Py_INCREF(self->name);
@@ -422,7 +480,8 @@
@@ -394,7 +452,8 @@
static PyObject *
EVPnew(PyObject *name_obj,
const EVP_MD *digest, const EVP_MD_CTX *initial_ctx,
@ -391,7 +376,7 @@
{
EVPobject *self;
@@ -437,7 +495,12 @@
@@ -409,7 +468,12 @@
if (initial_ctx) {
EVP_MD_CTX_copy(&self->ctx, initial_ctx);
} else {
@ -405,7 +390,7 @@
}
if (cp && len) {
@@ -461,21 +524,29 @@
@@ -433,21 +497,29 @@
An optional string argument may be provided and will be\n\
automatically hashed.\n\
\n\
@ -439,7 +424,7 @@
return NULL;
}
@@ -489,7 +560,8 @@
@@ -461,7 +533,8 @@
digest = EVP_get_digestbyname(name);
@ -449,7 +434,7 @@
if (data_obj)
PyBuffer_Release(&view);
@@ -744,57 +816,115 @@
@@ -742,57 +815,115 @@
/*
@ -602,11 +587,12 @@
GEN_CONSTRUCTOR(md5)
GEN_CONSTRUCTOR(sha1)
@@ -845,12 +974,10 @@
@@ -843,13 +974,10 @@
{
PyObject *m, *openssl_md_meth_names;
- OpenSSL_add_all_digests();
- ERR_load_crypto_strings();
+ SSL_load_error_strings();
+ SSL_library_init();