Skip to content

Commit

Permalink
src/ add sct rule to Makefiles (imported from branch merge main with …
Browse files Browse the repository at this point in the history
…sslh)
  • Loading branch information
tfaoliveira-sb committed Apr 10, 2024
1 parent 77a35c6 commit 39ebe2e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 1,8 @@
*.s
*.safety
*.safety_*
*.sct
*.sct_*
*.o
*.a
_build/
Expand Down
12 changes: 12 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 22,7 @@ SRC := .
FILTER ?= $(SRC)/crypto_%
JAZZ ?= $(filter $(FILTER), $(filter-out $(addprefix ./,$(EXCLUDE)), $(sort $(dir $(shell find $(SRC) -name '*.jazz')))))
SAFETY ?= $(addsuffix safety, $(JAZZ))
SCT ?= $(addsuffix sct, $(JAZZ))

SOURCES ?= $(filter-out ./, $(sort $(dir $(shell find $(SRC) -name 'Makefile'))))
ASM := $(shell find $(SRC) -name '*.s')
Expand Down Expand Up @@ -68,6 69,14 @@ safety: $(SAFETY)
$(SAFETY):
$(MAKE) -C $(@D) $(@F) || true

# --------------------------------------------------------------------

.PHONY: sct
sct: $(SCT)

$(SCT):
$(MAKE) -C $(@D) $(@F) || true

# --------------------------------------------------------------------
ifeq ($(CI),1)

Expand All @@ -83,6 92,9 @@ reporter_safety:
./../scripts/ci/reporter/jlog "Safety status" src/ *.safety $(CICL)
$(MAKE) $(LOGS)

reporter_sct:
./../scripts/ci/reporter/jlog "Speculative constant-time status" src/ *.sct $(CICL)

ERR := $(shell find $(BIN) -name '*.error')
CIR := $(shell find $(BIN) -name '*.log') $(ERR)

Expand Down
32 changes: 32 additions & 0 deletions src/Makefile.checksct
Original file line number Diff line number Diff line change
@@ -0,0 1,32 @@
# Notes:
# - this file defines fine-grained targets that allow checking the speculative constant-time of individual exported
# functions
# - it is meant to be included by Makefile.common

ifneq ($(OP),)

SCT_FLAGS ?=

CHECK_SCT_S = ($(JASMINC) -slice $* -checkSCT $(SCT_FLAGS) $< > $@ 2>&1) $(CIT)
CHECK_SCT = ($(JASMINC) -checkSCT $(SCT_FLAGS) $< > $@ 2>&1) $(CIT)

SCT_TARGETS = $(addsuffix .sct, $(FUNCTIONS))

sct: $(SCT_TARGETS)

$(OP).sct : $(OP).jazz $(DEPS_DIR)/$(OP).sct.d | $(DEPS_DIR) $(CI_DIR)
$(DEPS)
$(CHECK_SCT)

$(SCT_TARGETS):
%.sct : $(OP).jazz $(DEPS_DIR)/%.sct.d | $(DEPS_DIR) $(CI_DIR)
$(DEPS)
$(CHECK_SCT_S)

DEPFILES := \
$(DEPFILES) \
$(addprefix $(DEPS_DIR)/, $(addsuffix .sct.d, $(FUNCTIONS) $(OP)))

$(SCT_DIR): ; @mkdir -p $@

endif
6 changes: 5 additions & 1 deletion src/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 100,10 @@ $(EC_DIR)/%_ct.ec : %.$(JEXT) $(DEPS_DIR)/%_ct.ec.d | $(DEPS_DIR) $(EC_DIR) $(CI

include $(SRC)/Makefile.checksafety

# --------------------------------------------------------------------

include $(SRC)/Makefile.checksct

# --------------------------------------------------------------------
$(CHECKSDIR): ; @mkdir -p $@
$(DEPS_DIR): ; @mkdir -p $@
Expand Down Expand Up @@ -129,7 133,7 @@ include $(wildcard $(DEPFILES))
.PHONY: clean

clean:
@rm -fr $(DEPS_DIR) $(CHECKS_DIR) $(SAFETY_DIR) *.s *.safety* *.o *.a .jflags *.out
@rm -fr $(DEPS_DIR) $(CHECKS_DIR) $(SAFETY_DIR) *.s *.safety* *.sct* *.o *.a .jflags *.out
ifeq ($(CI),1)
@rm -fr $(CI_DIR)
endif
Expand Down

0 comments on commit 39ebe2e

Please sign in to comment.