Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: p-256 #761

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ charset = utf-8
indent_style = tab
indent_size = 8

[lib/p256-m/*.[ch]]
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab

Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pwd := $(shell pwd)
PREFIX ?= /usr/local
# VERSION is set in src/Makefile
# Targets to be build in this order
BUILDS := apply-patches milagro lua54 embed-lua quantum-proof ed25519-donna mimalloc
BUILDS := apply-patches milagro lua54 embed-lua quantum-proof ed25519-donna mimalloc p256-m

# DESTDIR is supported by install target

Expand Down Expand Up @@ -103,6 +103,16 @@ cortex-lua54:
LDFLAGS="${ldflags}" AR="${ar}" RANLIB=${ranlib} \
$(MAKE) -C ${pwd}/lib/lua54/src ${platform}

p256-m-debug: p256-m
p256-m:
@echo "-- Building p256-m (${system})"
CC="${gcc}" \
LD=${ld} \
AR=${ar} \
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${MAKE} -C ${pwd}/lib/p256-m p256-native.o

milagro-debug: milagro
milagro:
@echo "-- Building milagro (${system})"
Expand Down Expand Up @@ -190,6 +200,7 @@ clean:
$(MAKE) clean -C ${pwd}/lib/pqclean
rm -rf ${pwd}/lib/milagro-crypto-c/build
rm -rf ${pwd}/lib/mimalloc/build
rm -f ${pwd}/lib/p256-m/p256-native.o
$(MAKE) clean -C ${pwd}/src
if [ -d "bindings" ]; then $(MAKE) clean -C ${pwd}/bindings; fi
rm -f ${extras}/index.*
Expand Down
1 change: 1 addition & 0 deletions build/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ldadd += ${milib}/libamcl_core.a
ldadd += ${pwd}/lib/pqclean/libqpz.a
ldadd += ${pwd}/lib/ed25519-donna/libed25519.a
ldadd += ${pwd}/lib/mimalloc/build/libmimalloc-static.a
ldadd += ${pwd}/lib/p256-m/p256-native.o

# ----------------
# zenroom defaults
Expand Down
10 changes: 10 additions & 0 deletions lib/p256-m/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
benchmark
test-openbox
test-closedbox
test-data.h
*.o
*.s
*.dump
*.sizes
*.su
*.dfinish
2 changes: 2 additions & 0 deletions lib/p256-m/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Unless specifically indicated otherwise in a file, files are licensed
under the Apache 2.0 license, as can be found in apache-2.0.txt.
47 changes: 47 additions & 0 deletions lib/p256-m/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Usage:
# - 'make' runs the test suites on the host
# - 'make all' also prints code size on stack usage (main development target)
# it leaves a variety of dumps around for inspection if desired
# - 'make clean' removes files generated by 'make all' and coverage.sh.

TESTOPEN=test-openbox
TESTCLOSED=test-closedbox
TESTDATA=test-data.h
TESTLIB=p256-native.o
SRC=p256-m.c
HDR=p256-m.h

CC=gcc
CFLAGS=-Werror --std=c99 -Os
CFLAGS_SAN=
# CC=clang
# CFLAGS=-Werror -Weverything --std=c99 -Os
# CFLAGS_SAN=-fsanitize=address -fsanitize=undefined

runtest: $(TESTCLOSED) $(TESTOPEN)
./$(TESTCLOSED)
./$(TESTOPEN)

$(TESTLIB): $(SRC) $(HDR)
$(CC) $(CFLAGS) $(CFLAGS_SAN) $< -c -o $@

$(TESTCLOSED): test-closedbox.c $(TESTLIB) $(TESTDATA) $(HDR)
$(CC) $(CFLAGS) $(CFLAGS_SAN) $< $(TESTLIB) -o $@

$(TESTOPEN): test-openbox.c $(TESTDATA) $(SRC)
$(CC) $(CFLAGS) $(CFLAGS_SAN) $< -o $@

$(TESTDATA): gen-test-data.py p256.py
python3 $< > $@

all: runtest
./sizes.sh
./stack.sh

clean:
rm -f $(TESTCLOSED) $(TESTOPEN) $(TESTDATA)
rm -f *.s *.o *.dump *.sizes *.su *.dfinish
rm -f *.gcda *.gcno *.info *.html
rm -rf cov-closed cov-open

.PHONY: runtest clean all
Loading
Loading