Skip to content

Commit 22b2267

Browse files
committed
Build HACL* SHA2 as a static library.
1 parent 81e3aa8 commit 22b2267

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

Makefile.pre.in

+31-2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ ENSUREPIP= @ENSUREPIP@
207207
# Internal static libraries
208208
LIBMPDEC_A= Modules/_decimal/libmpdec/libmpdec.a
209209
LIBEXPAT_A= Modules/expat/libexpat.a
210+
LIBHACL_A= Modules/_hacl/libHacl_Streaming_SHA2.a
210211

211212
# Module state, compiler flags and linker flags
212213
# Empty CFLAGS and LDFLAGS are omitted.
@@ -571,6 +572,23 @@ LIBEXPAT_HEADERS= \
571572
Modules/expat/xmltok.h \
572573
Modules/expat/xmltok_impl.h
573574

575+
##########################################################################
576+
# hashlib's HACL* library
577+
578+
LIBHACL_OBJS= \
579+
Modules/_hacl/Hacl_Streaming_SHA2.o
580+
581+
LIBHACL_HEADERS= \
582+
Modules/_hacl/Hacl_Streaming_SHA2.h \
583+
Modules/_hacl/include/krml/FStar_UInt128_Verified.h \
584+
Modules/_hacl/include/krml/FStar_UInt_8_16_32_64.h \
585+
Modules/_hacl/include/krml/fstar_uint128_struct_endianness.h \
586+
Modules/_hacl/include/krml/internal/target.h \
587+
Modules/_hacl/include/krml/lowstar_endianness.h \
588+
Modules/_hacl/include/krml/types.h \
589+
Modules/_hacl/internal/Hacl_SHA2_Generic.h \
590+
Modules/_hacl/python_hacl_namespaces.h
591+
574592
#########################################################################
575593
# Rules
576594

@@ -890,6 +908,17 @@ $(LIBEXPAT_A): $(LIBEXPAT_OBJS)
890908
-rm -f $@
891909
$(AR) $(ARFLAGS) $@ $(LIBEXPAT_OBJS)
892910

911+
##########################################################################
912+
# Build HACL* static libraries for hashlib: libHacl_Streaming_SHA2.a
913+
LIBHACL_CFLAGS=-I$(srcdir)/Modules/_hacl/include -D_BSD_SOURCE -D_DEFAULT_SOURCE $(PY_STDMODULE_CFLAGS) $(CCSHARED)
914+
915+
Modules/_hacl/Hacl_Streaming_SHA2.o: $(srcdir)/Modules/_hacl/Hacl_Streaming_SHA2.c $(LIBHACL_HEADERS)
916+
$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Streaming_SHA2.c
917+
918+
$(LIBHACL_A): $(LIBHACL_OBJS)
919+
-rm -f $@
920+
$(AR) $(ARFLAGS) $@ $(LIBHACL_OBJS)
921+
893922
# create relative links from build/lib.platform/egg.so to Modules/egg.so
894923
# pybuilddir.txt is created too late. We cannot use it in Makefile
895924
# targets. ln --relative is not portable.
@@ -2606,9 +2635,9 @@ MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
26062635
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
26072636
MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h
26082637
MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h
2609-
MODULE__SHA256_DEPS=$(srcdir)/Modules/hashlib.h $(srcdir)/Modules/_hacl/include/krml/FStar_UInt_8_16_32_64.h $(srcdir)/Modules/_hacl/include/krml/lowstar_endianness.h $(srcdir)/Modules/_hacl/include/krml/internal/target.h $(srcdir)/Modules/_hacl/Hacl_Streaming_SHA2.h
2638+
MODULE__SHA256_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HEADERS) $(LIBHACL_A)
26102639
MODULE__SHA3_DEPS=$(srcdir)/Modules/_sha3/sha3.c $(srcdir)/Modules/_sha3/sha3.h $(srcdir)/Modules/hashlib.h
2611-
MODULE__SHA512_DEPS=$(srcdir)/Modules/hashlib.h $(srcdir)/Modules/_hacl/include/krml/FStar_UInt_8_16_32_64.h $(srcdir)/Modules/_hacl/include/krml/lowstar_endianness.h $(srcdir)/Modules/_hacl/include/krml/internal/target.h $(srcdir)/Modules/_hacl/Hacl_Streaming_SHA2.h
2640+
MODULE__SHA512_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HEADERS) $(LIBHACL_A)
26122641
MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c
26132642
MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data.h $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h
26142643
MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/_testcapi/testcapi_long.h $(srcdir)/Modules/_testcapi/parts.h

Modules/Setup.stdlib.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
# hashing builtins, can be disabled with --without-builtin-hashlib-hashes
8080
@MODULE__MD5_TRUE@_md5 md5module.c
8181
@MODULE__SHA1_TRUE@_sha1 sha1module.c
82-
@MODULE__SHA256_TRUE@_sha256 sha256module.c _hacl/Hacl_Streaming_SHA2.c
83-
@MODULE__SHA512_TRUE@_sha512 sha512module.c _hacl/Hacl_Streaming_SHA2.c
82+
@MODULE__SHA256_TRUE@_sha256 sha256module.c -I$(srcdir)/Modules/_hacl/include -LModules/_hacl -lHacl_Streaming_SHA2
83+
@MODULE__SHA512_TRUE@_sha512 sha512module.c -I$(srcdir)/Modules/_hacl/include -LModules/_hacl -lHacl_Streaming_SHA2
8484
@MODULE__SHA3_TRUE@_sha3 _sha3/sha3module.c
8585
@MODULE__BLAKE2_TRUE@_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
8686

Modules/_hacl/include/python_hacl_namespaces.h renamed to Modules/_hacl/python_hacl_namespaces.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define Hacl_Streaming_SHA2_init_224 python_hashlib_Hacl_Streaming_SHA2_init_224
2626
#define Hacl_Streaming_SHA2_init_512 python_hashlib_Hacl_Streaming_SHA2_init_512
2727
#define Hacl_Streaming_SHA2_init_384 python_hashlib_Hacl_Streaming_SHA2_init_384
28+
#define Hacl_SHA2_Scalar32_sha512_init python_hashlib_Hacl_SHA2_Scalar32_sha512_init
2829
#define Hacl_Streaming_SHA2_update_256 python_hashlib_Hacl_Streaming_SHA2_update_256
2930
#define Hacl_Streaming_SHA2_update_224 python_hashlib_Hacl_Streaming_SHA2_update_224
3031
#define Hacl_Streaming_SHA2_update_512 python_hashlib_Hacl_Streaming_SHA2_update_512

0 commit comments

Comments
 (0)