| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ apt-get -yq install \ | |||
| 7 | 7 | ccache \ | |
| 8 | 8 | gdb \ | |
| 9 | 9 | lcov \ | |
| 10 | + libb2-dev \ | ||
| 10 | 11 | libbz2-dev \ | |
| 11 | 12 | libffi-dev \ | |
| 12 | 13 | libgdbm-dev \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -245,6 +245,12 @@ fractions | |||
| 245 | 245 | that an ``isinstance(some_fraction, typing.SupportsInt)`` check passes. | |
| 246 | 246 | (Contributed by Mark Dickinson in :issue:`44547`.) | |
| 247 | 247 | ||
| 248 | + hashlib | ||
| 249 | + ------- | ||
| 250 | + | ||
| 251 | + * :func:`hashlib.blake2b` and :func:`hashlib.blake2s` now prefer `libb2`_ | ||
| 252 | + over Python's vendored copy. | ||
| 253 | + (Contributed by Christian Heimes in :issue:`47095`.) | ||
| 248 | 254 | ||
| 249 | 255 | IDLE and idlelib | |
| 250 | 256 | ---------------- | |
@@ -1066,6 +1072,9 @@ Porting to Python 3.11 | |||
| 1066 | 1072 | <https://github.com/python/pythoncapi_compat>`__ to get these functions | |
| 1067 | 1073 | on old Python functions. | |
| 1068 | 1074 | ||
| 1075 | + * Distributors are encouraged to build Python with the optimized Blake2 | ||
| 1076 | + library `libb2`_. | ||
| 1077 | + | ||
| 1069 | 1078 | ||
| 1070 | 1079 | Deprecated | |
| 1071 | 1080 | ---------- | |
@@ -1145,3 +1154,6 @@ Removed | |||
| 1145 | 1154 | * Remove the ``HAVE_PY_SET_53BIT_PRECISION`` macro (moved to the internal C | |
| 1146 | 1155 | API). | |
| 1147 | 1156 | (Contributed by Victor Stinner in :issue:`45412`.) | |
| 1157 | + | ||
| 1158 | + | ||
| 1159 | + .. _libb2: https://www.blake2.net/ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2482,7 +2482,7 @@ MODULE_CMATH_DEPS=$(srcdir)/Modules/_math.h | |||
| 2482 | 2482 | MODULE_MATH_DEPS=$(srcdir)/Modules/_math.h | |
| 2483 | 2483 | MODULE_PYEXPAT_DEPS=$(LIBEXPAT_HEADERS) @LIBEXPAT_INTERNAL@ | |
| 2484 | 2484 | MODULE_UNICODEDATA_DEPS=$(srcdir)/Modules/unicodedata_db.h $(srcdir)/Modules/unicodename_db.h | |
| 2485 | - MODULE__BLAKE2_DEPS=$(srcdir)/Modules/_blake2/impl/blake2-config.h $(srcdir)/Modules/_blake2/impl/blake2-dispatch.c $(srcdir)/Modules/_blake2/impl/blake2-impl.h $(srcdir)/Modules/_blake2/impl/blake2-kat.h $(srcdir)/Modules/_blake2/impl/blake2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2b-ref.c $(srcdir)/Modules/_blake2/impl/blake2b-round.h $(srcdir)/Modules/_blake2/impl/blake2b-test.c $(srcdir)/Modules/_blake2/impl/blake2b.c $(srcdir)/Modules/_blake2/impl/blake2bp-test.c $(srcdir)/Modules/_blake2/impl/blake2bp.c $(srcdir)/Modules/_blake2/impl/blake2s-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2s-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2s-load-xop.h $(srcdir)/Modules/_blake2/impl/blake2s-ref.c $(srcdir)/Modules/_blake2/impl/blake2s-round.h $(srcdir)/Modules/_blake2/impl/blake2s-test.c $(srcdir)/Modules/_blake2/impl/blake2s.c $(srcdir)/Modules/_blake2/impl/blake2sp-test.c $(srcdir)/Modules/_blake2/impl/blake2sp.c $(srcdir)/Modules/hashlib.h | ||
| 2485 | + MODULE__BLAKE2_DEPS=$(srcdir)/Modules/_blake2/impl/blake2-config.h $(srcdir)/Modules/_blake2/impl/blake2-impl.h $(srcdir)/Modules/_blake2/impl/blake2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2b-ref.c $(srcdir)/Modules/_blake2/impl/blake2b-round.h $(srcdir)/Modules/_blake2/impl/blake2b.c $(srcdir)/Modules/_blake2/impl/blake2s-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2s-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2s-load-xop.h $(srcdir)/Modules/_blake2/impl/blake2s-ref.c $(srcdir)/Modules/_blake2/impl/blake2s-round.h $(srcdir)/Modules/_blake2/impl/blake2s.c $(srcdir)/Modules/_blake2/blake2module.h $(srcdir)/Modules/hashlib.h | ||
| 2486 | 2486 | MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h | |
| 2487 | 2487 | MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h $(LIBMPDEC_HEADERS) @LIBMPDEC_INTERNAL@ | |
| 2488 | 2488 | MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c $(LIBEXPAT_HEADERS) @LIBEXPAT_INTERNAL@ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + :mod:`hashlib`'s internal ``_blake2`` module now prefers ``libb2`` from | ||
| 2 | + https://www.blake2.net/ over Python's vendored copy of blake2. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,25 +21,23 @@ | |||
| 21 | 21 | #include "pycore_strhex.h" // _Py_strhex() | |
| 22 | 22 | ||
| 23 | 23 | #include "../hashlib.h" | |
| 24 | - #include "blake2ns.h" | ||
| 25 | - | ||
| 26 | - #define HAVE_BLAKE2B 1 | ||
| 27 | - #define BLAKE2_LOCAL_INLINE(type) Py_LOCAL_INLINE(type) | ||
| 28 | - | ||
| 29 | - #include "impl/blake2.h" | ||
| 30 | - #include "impl/blake2-impl.h" /* for secure_zero_memory() and store48() */ | ||
| 24 | + #include "blake2module.h" | ||
| 31 | 25 | ||
| 26 | + #ifndef HAVE_LIBB2 | ||
| 32 | 27 | /* pure SSE2 implementation is very slow, so only use the more optimized SSSE3+ | |
| 33 | 28 | * https://bugs.python.org/issue31834 */ | |
| 34 | 29 | #if defined(__SSSE3__) || defined(__SSE4_1__) || defined(__AVX__) || defined(__XOP__) | |
| 35 | 30 | #include "impl/blake2b.c" | |
| 36 | 31 | #else | |
| 37 | 32 | #include "impl/blake2b-ref.c" | |
| 38 | 33 | #endif | |
| 34 | + #endif // !HAVE_LIBB2 | ||
| 39 | 35 | ||
| 36 | + #define HAVE_BLAKE2B 1 | ||
| 40 | 37 | ||
| 41 | 38 | extern PyType_Spec blake2b_type_spec; | |
| 42 | 39 | ||
| 40 | + | ||
| 43 | 41 | typedef struct { | |
| 44 | 42 | PyObject_HEAD | |
| 45 | 43 | blake2b_param param; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,8 +13,7 @@ | |||
| 13 | 13 | #endif | |
| 14 | 14 | ||
| 15 | 15 | #include "Python.h" | |
| 16 | - | ||
| 17 | - #include "impl/blake2.h" | ||
| 16 | + #include "blake2module.h" | ||
| 18 | 17 | ||
| 19 | 18 | extern PyType_Spec blake2b_type_spec; | |
| 20 | 19 | extern PyType_Spec blake2s_type_spec; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,13 @@ | |||
| 1 | - /* Prefix all public blake2 symbols with PyBlake2_ | ||
| 2 | - */ | ||
| 1 | + #ifndef Py_BLAKE2MODULE_H | ||
| 2 | + #define Py_BLAKE2MODULE_H | ||
| 3 | 3 | ||
| 4 | - #ifndef Py_BLAKE2_NS | ||
| 5 | - #define Py_BLAKE2_NS | ||
| 4 | + #ifdef HAVE_LIBB2 | ||
| 5 | + #include <blake2.h> | ||
| 6 | 6 | ||
| 7 | + #else | ||
| 8 | + // use vendored copy of blake2 | ||
| 9 | + | ||
| 10 | + // Prefix all public blake2 symbols with PyBlake2_ | ||
| 7 | 11 | #define blake2b PyBlake2_blake2b | |
| 8 | 12 | #define blake2b_compress PyBlake2_blake2b_compress | |
| 9 | 13 | #define blake2b_final PyBlake2_blake2b_final | |
@@ -29,4 +33,11 @@ | |||
| 29 | 33 | #define blake2sp_init_key PyBlake2_blake2sp_init_key | |
| 30 | 34 | #define blake2sp_update PyBlake2_blake2sp_update | |
| 31 | 35 | ||
| 32 | - #endif /* Py_BLAKE2_NS */ | ||
| 36 | + #include "impl/blake2.h" | ||
| 37 | + | ||
| 38 | + #endif // HAVE_LIBB2 | ||
| 39 | + | ||
| 40 | + // for secure_zero_memory(), store32(), store48(), and store64() | ||
| 41 | + #include "impl/blake2-impl.h" | ||
| 42 | + | ||
| 43 | + #endif // Py_BLAKE2MODULE_H | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,25 +21,23 @@ | |||
| 21 | 21 | #include "pycore_strhex.h" // _Py_strhex() | |
| 22 | 22 | ||
| 23 | 23 | #include "../hashlib.h" | |
| 24 | - #include "blake2ns.h" | ||
| 25 | - | ||
| 26 | - #define HAVE_BLAKE2S 1 | ||
| 27 | - #define BLAKE2_LOCAL_INLINE(type) Py_LOCAL_INLINE(type) | ||
| 28 | - | ||
| 29 | - #include "impl/blake2.h" | ||
| 30 | - #include "impl/blake2-impl.h" /* for secure_zero_memory() and store48() */ | ||
| 24 | + #include "blake2module.h" | ||
| 31 | 25 | ||
| 26 | + #ifndef HAVE_LIBB2 | ||
| 32 | 27 | /* pure SSE2 implementation is very slow, so only use the more optimized SSSE3+ | |
| 33 | 28 | * https://bugs.python.org/issue31834 */ | |
| 34 | 29 | #if defined(__SSSE3__) || defined(__SSE4_1__) || defined(__AVX__) || defined(__XOP__) | |
| 35 | 30 | #include "impl/blake2s.c" | |
| 36 | 31 | #else | |
| 37 | 32 | #include "impl/blake2s-ref.c" | |
| 38 | 33 | #endif | |
| 34 | + #endif // !HAVE_LIBB2 | ||
| 39 | 35 | ||
| 36 | + #define HAVE_BLAKE2S 1 | ||
| 40 | 37 | ||
| 41 | 38 | extern PyType_Spec blake2s_type_spec; | |
| 42 | 39 | ||
| 40 | + | ||
| 43 | 41 | typedef struct { | |
| 44 | 42 | PyObject_HEAD | |
| 45 | 43 | blake2s_param param; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments