Skip to content

Commit

Permalink
Build: Don't build a libfips202.a
Browse files Browse the repository at this point in the history
The FIPS-202 code in mlkem-native is not meant as a standalone library;
instead, it only provides the minimal functionality needed to implement
ML-KEM. As such, it should not be generated as a separate library, but
directly linked into the libmlkem{XXX}.a.

This commit adjusts the build accordingly.

Signed-off-by: Hanno Becker <[email protected]>
  • Loading branch information
hanno-becker committed Dec 13, 2024
1 parent ee10493 commit 4c2bcb0
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions mk/crypto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@ ifeq ($(OPT),1)
FIPS202_SRCS += $(wildcard fips202/native/aarch64/*.S) $(wildcard fips202/native/x86_64/xkcp/*.c)
endif

$(BUILD_DIR)/libfips202.a: $(call OBJS, $(FIPS202_SRCS))
$(BUILD_DIR)/libmlkem.a: $(call OBJS, $(FIPS202_SRCS))

# all lib<scheme>.a depends on libfips202.a
define ADD_FIPS202
$(BUILD_DIR)/lib$(1).a: LDLIBS += -lfips202
# NOTE:
# - Merging multiple .a files with ar is more complex than building a single library directly from all the object files (.o). Hence, all .o files are added as dependencies here.

$(BUILD_DIR)/lib$(1).a: $(BUILD_DIR)/libfips202.a $(call OBJS, $(FIPS202_SRCS))
endef

$(foreach scheme,mlkem512 mlkem768 mlkem1024, \
$(eval $(call ADD_FIPS202,$(scheme))) \
)
$(BUILD_DIR)/libmlkem512.a: $(call OBJS, $(FIPS202_SRCS))
$(BUILD_DIR)/libmlkem768.a: $(call OBJS, $(FIPS202_SRCS))
$(BUILD_DIR)/libmlkem1024.a: $(call OBJS, $(FIPS202_SRCS))

0 comments on commit 4c2bcb0

Please sign in to comment.