supercop

Basic CLI for supercop
git clone git://git.finwo.net/app/supercop
Log | Files | Refs | README | LICENSE

commit 943d268d31434e07e658940513cc93fdc4820d28
parent 2f0807b8bc863d4af63377efc3aff1da232e5d20
Author: Yersa Nordman <yersa@finwo.nl>
Date:   Sun, 29 Jan 2023 21:19:17 +0100

Now using dep package manager for fetching dependencies

Diffstat:
M.gitignore | 2+-
MMakefile | 37+++++++------------------------------
Apackage.ini | 6++++++
Dpatch/ed25519/00-single-file-compile.patch | 156-------------------------------------------------------------------------------
Msrc/main.c | 4++--
5 files changed, 16 insertions(+), 189 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,4 +1,4 @@ *.o *.asc -lib/ +/lib/ /supercop diff --git a/Makefile b/Makefile @@ -1,5 +1,9 @@ include config.mk +SRC:= +SRC+=$(wildcard src/*.c) +SRC+=$(wildcard src/*/*.c) +SRC+=$(wildcard src/*/*/*.c) # Ourselves MTUNE?=native @@ -9,29 +13,11 @@ CFLAGS+=-D VERSION=\"$(VERSION)\" CFLAGS+=-mtune=$(MTUNE) -march=$(MARCH) CFLAGS+=-O2 -pipe CFLAGS+=-Wall + INCLUDES?= INCLUDES+=-Isrc -SRC:= -SRC+=$(wildcard src/*.c) -SRC+=$(wildcard src/*/*.c) -SRC+=$(wildcard src/*/*/*.c) -# lib/argparse -INCLUDES+=-Ilib/argparse -SRC+=lib/argparse/argparse.c - -# lib/ed25519 -INCLUDES+=-Ilib/ed25519/src -# SRC+=lib/ed25519/src/add_scalar.c -SRC+=lib/ed25519/src/fe.c -SRC+=lib/ed25519/src/ge.c -SRC+=lib/ed25519/src/key_exchange.c -SRC+=lib/ed25519/src/keypair.c -SRC+=lib/ed25519/src/sc.c -SRC+=lib/ed25519/src/seed.c -SRC+=lib/ed25519/src/sha512.c -SRC+=lib/ed25519/src/sign.c -SRC+=lib/ed25519/src/verify.c +include lib/.dep/config.mk # Map SRC into OBJ OBJ:=$(patsubst %.c,%.o,$(SRC)) @@ -42,7 +28,7 @@ default: supercop README.md: man --html=cat ./man/supercop.1 > README.md -supercop: lib/argparse lib/ed25519 $(OBJ) +supercop: $(OBJ) $(CC) $(CFLAGS) $(INCLUDES) -o $@ $(OBJ) .PHONY: small @@ -53,15 +39,6 @@ static: %.o: %.c $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ -lib/argparse: - mkdir -p lib/argparse - curl -sL https://github.com/cofyc/argparse/archive/refs/heads/master.tar.gz | tar xzv -C lib/argparse --strip-components=1 - -lib/ed25519: - mkdir -p lib/ed25519 - curl -sL https://github.com/orlp/ed25519/archive/refs/heads/master.tar.gz | tar xzv -C lib/ed25519 --strip-components=1 - bash -c 'cd lib/ed25519 && patch -p1 < ../../patch/ed25519/00-single-file-compile.patch' - .PHONY: install install: supercop install -d ${DESTDIR}${PREFIX}/bin diff --git a/package.ini b/package.ini @@ -0,0 +1,6 @@ +[dependencies] +cofyc/argparse=https://raw.githubusercontent.com/finwo/dep-repository/main/cofyc/argparse/package.ini +orlp/ed25519=https://raw.githubusercontent.com/finwo/dep-repository/main/orlp/ed25519/package.ini +[package] +deps=lib +name=finwo/supercop-cli diff --git a/patch/ed25519/00-single-file-compile.patch b/patch/ed25519/00-single-file-compile.patch @@ -1,156 +0,0 @@ -diff --git a/src/sc.c b/src/sc.c -index ca5bad2..3d2ab56 100644 ---- a/src/sc.c -+++ b/src/sc.c -@@ -1,7 +1,7 @@ - #include "fixedint.h" - #include "sc.h" - --static uint64_t load_3(const unsigned char *in) { -+static uint64_t sc_load_3(const unsigned char *in) { - uint64_t result; - - result = (uint64_t) in[0]; -@@ -11,7 +11,7 @@ static uint64_t load_3(const unsigned char *in) { - return result; - } - --static uint64_t load_4(const unsigned char *in) { -+static uint64_t sc_load_4(const unsigned char *in) { - uint64_t result; - - result = (uint64_t) in[0]; -@@ -33,30 +33,30 @@ Output: - */ - - void sc_reduce(unsigned char *s) { -- int64_t s0 = 2097151 & load_3(s); -- int64_t s1 = 2097151 & (load_4(s + 2) >> 5); -- int64_t s2 = 2097151 & (load_3(s + 5) >> 2); -- int64_t s3 = 2097151 & (load_4(s + 7) >> 7); -- int64_t s4 = 2097151 & (load_4(s + 10) >> 4); -- int64_t s5 = 2097151 & (load_3(s + 13) >> 1); -- int64_t s6 = 2097151 & (load_4(s + 15) >> 6); -- int64_t s7 = 2097151 & (load_3(s + 18) >> 3); -- int64_t s8 = 2097151 & load_3(s + 21); -- int64_t s9 = 2097151 & (load_4(s + 23) >> 5); -- int64_t s10 = 2097151 & (load_3(s + 26) >> 2); -- int64_t s11 = 2097151 & (load_4(s + 28) >> 7); -- int64_t s12 = 2097151 & (load_4(s + 31) >> 4); -- int64_t s13 = 2097151 & (load_3(s + 34) >> 1); -- int64_t s14 = 2097151 & (load_4(s + 36) >> 6); -- int64_t s15 = 2097151 & (load_3(s + 39) >> 3); -- int64_t s16 = 2097151 & load_3(s + 42); -- int64_t s17 = 2097151 & (load_4(s + 44) >> 5); -- int64_t s18 = 2097151 & (load_3(s + 47) >> 2); -- int64_t s19 = 2097151 & (load_4(s + 49) >> 7); -- int64_t s20 = 2097151 & (load_4(s + 52) >> 4); -- int64_t s21 = 2097151 & (load_3(s + 55) >> 1); -- int64_t s22 = 2097151 & (load_4(s + 57) >> 6); -- int64_t s23 = (load_4(s + 60) >> 3); -+ int64_t s0 = 2097151 & sc_load_3(s); -+ int64_t s1 = 2097151 & (sc_load_4(s + 2) >> 5); -+ int64_t s2 = 2097151 & (sc_load_3(s + 5) >> 2); -+ int64_t s3 = 2097151 & (sc_load_4(s + 7) >> 7); -+ int64_t s4 = 2097151 & (sc_load_4(s + 10) >> 4); -+ int64_t s5 = 2097151 & (sc_load_3(s + 13) >> 1); -+ int64_t s6 = 2097151 & (sc_load_4(s + 15) >> 6); -+ int64_t s7 = 2097151 & (sc_load_3(s + 18) >> 3); -+ int64_t s8 = 2097151 & sc_load_3(s + 21); -+ int64_t s9 = 2097151 & (sc_load_4(s + 23) >> 5); -+ int64_t s10 = 2097151 & (sc_load_3(s + 26) >> 2); -+ int64_t s11 = 2097151 & (sc_load_4(s + 28) >> 7); -+ int64_t s12 = 2097151 & (sc_load_4(s + 31) >> 4); -+ int64_t s13 = 2097151 & (sc_load_3(s + 34) >> 1); -+ int64_t s14 = 2097151 & (sc_load_4(s + 36) >> 6); -+ int64_t s15 = 2097151 & (sc_load_3(s + 39) >> 3); -+ int64_t s16 = 2097151 & sc_load_3(s + 42); -+ int64_t s17 = 2097151 & (sc_load_4(s + 44) >> 5); -+ int64_t s18 = 2097151 & (sc_load_3(s + 47) >> 2); -+ int64_t s19 = 2097151 & (sc_load_4(s + 49) >> 7); -+ int64_t s20 = 2097151 & (sc_load_4(s + 52) >> 4); -+ int64_t s21 = 2097151 & (sc_load_3(s + 55) >> 1); -+ int64_t s22 = 2097151 & (sc_load_4(s + 57) >> 6); -+ int64_t s23 = (sc_load_4(s + 60) >> 3); - int64_t carry0; - int64_t carry1; - int64_t carry2; -@@ -360,42 +360,42 @@ Output: - */ - - void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c) { -- int64_t a0 = 2097151 & load_3(a); -- int64_t a1 = 2097151 & (load_4(a + 2) >> 5); -- int64_t a2 = 2097151 & (load_3(a + 5) >> 2); -- int64_t a3 = 2097151 & (load_4(a + 7) >> 7); -- int64_t a4 = 2097151 & (load_4(a + 10) >> 4); -- int64_t a5 = 2097151 & (load_3(a + 13) >> 1); -- int64_t a6 = 2097151 & (load_4(a + 15) >> 6); -- int64_t a7 = 2097151 & (load_3(a + 18) >> 3); -- int64_t a8 = 2097151 & load_3(a + 21); -- int64_t a9 = 2097151 & (load_4(a + 23) >> 5); -- int64_t a10 = 2097151 & (load_3(a + 26) >> 2); -- int64_t a11 = (load_4(a + 28) >> 7); -- int64_t b0 = 2097151 & load_3(b); -- int64_t b1 = 2097151 & (load_4(b + 2) >> 5); -- int64_t b2 = 2097151 & (load_3(b + 5) >> 2); -- int64_t b3 = 2097151 & (load_4(b + 7) >> 7); -- int64_t b4 = 2097151 & (load_4(b + 10) >> 4); -- int64_t b5 = 2097151 & (load_3(b + 13) >> 1); -- int64_t b6 = 2097151 & (load_4(b + 15) >> 6); -- int64_t b7 = 2097151 & (load_3(b + 18) >> 3); -- int64_t b8 = 2097151 & load_3(b + 21); -- int64_t b9 = 2097151 & (load_4(b + 23) >> 5); -- int64_t b10 = 2097151 & (load_3(b + 26) >> 2); -- int64_t b11 = (load_4(b + 28) >> 7); -- int64_t c0 = 2097151 & load_3(c); -- int64_t c1 = 2097151 & (load_4(c + 2) >> 5); -- int64_t c2 = 2097151 & (load_3(c + 5) >> 2); -- int64_t c3 = 2097151 & (load_4(c + 7) >> 7); -- int64_t c4 = 2097151 & (load_4(c + 10) >> 4); -- int64_t c5 = 2097151 & (load_3(c + 13) >> 1); -- int64_t c6 = 2097151 & (load_4(c + 15) >> 6); -- int64_t c7 = 2097151 & (load_3(c + 18) >> 3); -- int64_t c8 = 2097151 & load_3(c + 21); -- int64_t c9 = 2097151 & (load_4(c + 23) >> 5); -- int64_t c10 = 2097151 & (load_3(c + 26) >> 2); -- int64_t c11 = (load_4(c + 28) >> 7); -+ int64_t a0 = 2097151 & sc_load_3(a); -+ int64_t a1 = 2097151 & (sc_load_4(a + 2) >> 5); -+ int64_t a2 = 2097151 & (sc_load_3(a + 5) >> 2); -+ int64_t a3 = 2097151 & (sc_load_4(a + 7) >> 7); -+ int64_t a4 = 2097151 & (sc_load_4(a + 10) >> 4); -+ int64_t a5 = 2097151 & (sc_load_3(a + 13) >> 1); -+ int64_t a6 = 2097151 & (sc_load_4(a + 15) >> 6); -+ int64_t a7 = 2097151 & (sc_load_3(a + 18) >> 3); -+ int64_t a8 = 2097151 & sc_load_3(a + 21); -+ int64_t a9 = 2097151 & (sc_load_4(a + 23) >> 5); -+ int64_t a10 = 2097151 & (sc_load_3(a + 26) >> 2); -+ int64_t a11 = (sc_load_4(a + 28) >> 7); -+ int64_t b0 = 2097151 & sc_load_3(b); -+ int64_t b1 = 2097151 & (sc_load_4(b + 2) >> 5); -+ int64_t b2 = 2097151 & (sc_load_3(b + 5) >> 2); -+ int64_t b3 = 2097151 & (sc_load_4(b + 7) >> 7); -+ int64_t b4 = 2097151 & (sc_load_4(b + 10) >> 4); -+ int64_t b5 = 2097151 & (sc_load_3(b + 13) >> 1); -+ int64_t b6 = 2097151 & (sc_load_4(b + 15) >> 6); -+ int64_t b7 = 2097151 & (sc_load_3(b + 18) >> 3); -+ int64_t b8 = 2097151 & sc_load_3(b + 21); -+ int64_t b9 = 2097151 & (sc_load_4(b + 23) >> 5); -+ int64_t b10 = 2097151 & (sc_load_3(b + 26) >> 2); -+ int64_t b11 = (sc_load_4(b + 28) >> 7); -+ int64_t c0 = 2097151 & sc_load_3(c); -+ int64_t c1 = 2097151 & (sc_load_4(c + 2) >> 5); -+ int64_t c2 = 2097151 & (sc_load_3(c + 5) >> 2); -+ int64_t c3 = 2097151 & (sc_load_4(c + 7) >> 7); -+ int64_t c4 = 2097151 & (sc_load_4(c + 10) >> 4); -+ int64_t c5 = 2097151 & (sc_load_3(c + 13) >> 1); -+ int64_t c6 = 2097151 & (sc_load_4(c + 15) >> 6); -+ int64_t c7 = 2097151 & (sc_load_3(c + 18) >> 3); -+ int64_t c8 = 2097151 & sc_load_3(c + 21); -+ int64_t c9 = 2097151 & (sc_load_4(c + 23) >> 5); -+ int64_t c10 = 2097151 & (sc_load_3(c + 26) >> 2); -+ int64_t c11 = (sc_load_4(c + 28) >> 7); - int64_t s0; - int64_t s1; - int64_t s2; diff --git a/src/main.c b/src/main.c @@ -17,8 +17,8 @@ extern "C" { #endif -#include "../lib/argparse/argparse.h" -#include "../lib/ed25519/src/ed25519.h" +#include "cofyc/argparse.h" +#include "orlp/ed25519.h" #include "fmt/common.h" #include "keypair/keypair.h"