Skip to content

Commit

Permalink
gh-99108: Import MD5 and SHA1 from HACL* (#102089)
Browse files Browse the repository at this point in the history
Replaces our fallback non-OpenSSL MD5 and SHA1 implementations with those from HACL* as we've already done with SHA2.
  • Loading branch information
msprotz authored Feb 22, 2023
1 parent 96bf243 commit fcadc7e
Show file tree
Hide file tree
Showing 24 changed files with 2,498 additions and 699 deletions.
14 changes: 9 additions & 5 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -578,17 +578,21 @@ LIBEXPAT_HEADERS= \
LIBHACL_SHA2_OBJS= \
Modules/_hacl/Hacl_Streaming_SHA2.o

LIBHACL_SHA2_HEADERS= \
Modules/_hacl/Hacl_Streaming_SHA2.h \
LIBHACL_HEADERS= \
Modules/_hacl/include/krml/FStar_UInt128_Verified.h \
Modules/_hacl/include/krml/FStar_UInt_8_16_32_64.h \
Modules/_hacl/include/krml/fstar_uint128_struct_endianness.h \
Modules/_hacl/include/krml/internal/target.h \
Modules/_hacl/include/krml/lowstar_endianness.h \
Modules/_hacl/include/krml/types.h \
Modules/_hacl/internal/Hacl_SHA2_Generic.h \
Modules/_hacl/Hacl_Streaming_Types.h \
Modules/_hacl/python_hacl_namespaces.h

LIBHACL_SHA2_HEADERS= \
Modules/_hacl/Hacl_Streaming_SHA2.h \
Modules/_hacl/internal/Hacl_SHA2_Generic.h \
$(LIBHACL_HEADERS)

#########################################################################
# Rules

Expand Down Expand Up @@ -2635,8 +2639,8 @@ MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h
MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h
MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HEADERS) Modules/_hacl/Hacl_Hash_MD5.h Modules/_hacl/Hacl_Hash_MD5.c
MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HEADERS) Modules/_hacl/Hacl_Hash_SHA1.h Modules/_hacl/Hacl_Hash_SHA1.c
MODULE__SHA2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_A)
MODULE__SHA3_DEPS=$(srcdir)/Modules/_sha3/sha3.c $(srcdir)/Modules/_sha3/sha3.h $(srcdir)/Modules/hashlib.h
MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Replace builtin hashlib implementations of MD5 and SHA1 with verified ones
from the HACL* project.
4 changes: 2 additions & 2 deletions Modules/Setup
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ PYTHONPATH=$(COREPYTHONPATH)

# hashing builtins
#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
#_md5 md5module.c
#_sha1 sha1module.c
#_md5 md5module.c -I$(srcdir)/Modules/_hacl/include _hacl/libHacl_Hash_MD5.c
#_sha1 sha1module.c -I$(srcdir)/Modules/_hacl/include _hacl/libHacl_Hash_SHA1.c
#_sha2 sha2module.c -I$(srcdir)/Modules/_hacl/include Modules/_hacl/libHacl_Streaming_SHA2.a
#_sha3 _sha3/sha3module.c

Expand Down
4 changes: 2 additions & 2 deletions Modules/Setup.stdlib.in
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
@MODULE_READLINE_TRUE@readline readline.c

# hashing builtins, can be disabled with --without-builtin-hashlib-hashes
@MODULE__MD5_TRUE@_md5 md5module.c
@MODULE__SHA1_TRUE@_sha1 sha1module.c
@MODULE__MD5_TRUE@_md5 md5module.c -I$(srcdir)/Modules/_hacl/include _hacl/Hacl_Hash_MD5.c -D_BSD_SOURCE -D_DEFAULT_SOURCE
@MODULE__SHA1_TRUE@_sha1 sha1module.c -I$(srcdir)/Modules/_hacl/include _hacl/Hacl_Hash_SHA1.c -D_BSD_SOURCE -D_DEFAULT_SOURCE
@MODULE__SHA2_TRUE@_sha2 sha2module.c -I$(srcdir)/Modules/_hacl/include Modules/_hacl/libHacl_Streaming_SHA2.a
@MODULE__SHA3_TRUE@_sha3 _sha3/sha3module.c
@MODULE__BLAKE2_TRUE@_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
Expand Down
Loading

0 comments on commit fcadc7e

Please sign in to comment.