Skip to content

Commit

Permalink
mirage-crypto-ec: ECDSA and curves P-224, P-256, P-384, P-521
Browse files Browse the repository at this point in the history
This includes:
- ECDSA implementation with blinding
- tests from RFC 6979 (deterministic k)
- wycheproof tests for ECDH and ECDSA (commit 2196000605e45d91097147c9c71f26b72af58003)
- ec/native contains a Makefile which runs the extraction (using fiat-crypto's word-by-word-montgomery)
  • Loading branch information
hannesm committed Mar 5, 2021
1 parent a85f4fc commit 1243e85
Show file tree
Hide file tree
Showing 67 changed files with 151,810 additions and 4,444 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Expand Up @@ -30,7 +30,8 @@ jobs:
opam pin add -n mirage-crypto-rng-mirage.dev .
opam pin add -n mirage-crypto-rng-async.dev .
opam pin add -n mirage-crypto-pk.dev .
opam depext -y mirage-crypto mirage-crypto-rng mirage-crypto-rng-mirage mirage-crypto-pk
opam pin add -n mirage-crypto-ec.dev .
opam depext -y mirage-crypto mirage-crypto-rng mirage-crypto-rng-mirage mirage-crypto-pk mirage-crypto-ec
opam install -t --deps-only .
- name: Build
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/windows.yml
Expand Up @@ -29,11 +29,12 @@ jobs:
opam pin add -n mirage-crypto-rng.dev .
opam pin add -n mirage-crypto-rng-mirage.dev .
opam pin add -n mirage-crypto-pk.dev .
opam depext -y mirage-crypto mirage-crypto-rng mirage-crypto-rng-mirage mirage-crypto-pk
opam install -t --deps-only mirage-crypto mirage-crypto-rng mirage-crypto-rng-mirage mirage-crypto-pk
opam pin add -n mirage-crypto-ec.dev .
opam depext -y mirage-crypto mirage-crypto-rng mirage-crypto-rng-mirage mirage-crypto-pk mirage-crypto-ec
opam install -t --deps-only mirage-crypto mirage-crypto-rng mirage-crypto-rng-mirage mirage-crypto-pk mirage-crypto-ec
- name: Build
run: opam exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk
run: opam exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec

- name: Test
run: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk
run: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -6,7 +6,7 @@ services:
os: linux
env:
global:
- PINS="mirage-crypto:. mirage-crypto-rng:. mirage-crypto-rng-mirage:. mirage-crypto-pk:. mirage-crypto-rng-async:."
- PINS="mirage-crypto:. mirage-crypto-rng:. mirage-crypto-rng-mirage:. mirage-crypto-pk:. mirage-crypto-rng-async:. mirage-crypto-ec:."
- PACKAGE="mirage-crypto-pk"
- TESTS=true
- DISTRO=alpine
Expand Down
2 changes: 1 addition & 1 deletion ec-freestanding/Makefile
Expand Up @@ -14,7 +14,7 @@ FREESTANDING_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --c
DISCOVER_CFLAGS := $(shell sed 's/^(\(.*\))$$/\1/' ../ec/cflags_optimized.sexp | tr -d '"')
CFLAGS := -O3 -I../ec/native -I../src/native $(DISCOVER_CFLAGS) $(FREESTANDING_CFLAGS)

OBJS=p256_stubs.o
OBJS=p224_stubs.o np224_stubs.o p256_stubs.o np256_stubs.o p384_stubs.o np384_stubs.o p521_stubs.o np521_stubs.o

libmirage_crypto_ec_freestanding_stubs.a: $(OBJS)
$(AR) r $@ $^
Expand Down
3 changes: 2 additions & 1 deletion ec-freestanding/dune
Expand Up @@ -2,7 +2,8 @@

(rule
(deps ../ec/cflags_optimized.sexp ../src/native/mirage_crypto.h
../src/native/bitfn.h Makefile p256_stubs.c)
../src/native/bitfn.h Makefile p224_stubs.c np224_stubs.c p256_stubs.c
np256_stubs.c p384_stubs.c np384_stubs.c p521_stubs.c np521_stubs.c)
(targets libmirage_crypto_ec_freestanding_stubs.a)
(action
(no-infer
Expand Down
31 changes: 7 additions & 24 deletions ec/dune
@@ -1,39 +1,22 @@
(library
(name mirage_crypto_ec)
(public_name mirage-crypto-ec)
(libraries cstruct eqaf.cstruct hex)
(libraries cstruct eqaf.cstruct hex mirage-crypto mirage-crypto-rng)
(foreign_stubs
(language c)
(names p256_stubs)
(names p224_stubs np224_stubs p256_stubs np256_stubs p384_stubs np384_stubs
p521_stubs np521_stubs)
(flags
(:standard -I../src/native)
(:include cflags_optimized.sexp))))

(env
(dev
(c_flags (-Werror))))

(include_subdirs unqualified)

(rule
(targets cflags_optimized.sexp)
(action
(run ../config/cfg.exe)))

(rule
(targets upstream_p256_32)
(action
(bash
"wget https://raw.githubusercontent.com/mit-plv/fiat-crypto/ecdfd03c636ab63e167fbe4fc4d7ab0ed5d9db74/p256_32.c -O %{targets}")))

(rule
(targets upstream_p256_64)
(action
(bash
"wget https://raw.githubusercontent.com/mit-plv/fiat-crypto/ecdfd03c636ab63e167fbe4fc4d7ab0ed5d9db74/p256_64.c -O %{targets}")))

(rule
(alias check_vendors)
(action
(diff native/p256_32.h upstream_p256_32)))

(rule
(alias check_vendors)
(action
(diff native/p256_64.h upstream_p256_64)))
21 changes: 0 additions & 21 deletions ec/error.ml

This file was deleted.

12 changes: 0 additions & 12 deletions ec/error.mli

This file was deleted.

65 changes: 0 additions & 65 deletions ec/field_element.ml

This file was deleted.

63 changes: 0 additions & 63 deletions ec/field_element.mli

This file was deleted.

0 comments on commit 1243e85

Please sign in to comment.