closer to how DJB expects them.master
@@ -30,6 +30,8 @@ LANGFLAGS = -std=c99 -fno-strict-aliasing | |||
GENFLAGS = -ffunction-sections -fdata-sections -fvisibility=hidden -fomit-frame-pointer -fPIC | |||
OFLAGS = -O3 | |||
TODAY = $(shell date "+%Y-%m-%d") | |||
ifneq (,$(findstring arm,$(MACHINE))) | |||
ifneq (,$(findstring neon,$(ARCH))) | |||
ARCHFLAGS += -mfpu=neon | |||
@@ -68,7 +70,8 @@ TESTCOMPONENTS=build/test.o build/test_scalarmul.o build/test_sha512.o \ | |||
BENCHCOMPONENTS=build/bench.o | |||
BATNAME=build/ed448goldilocks | |||
BATBASE=ed448goldilocks-bats-$(TODAY) | |||
BATNAME=build/$(BATBASE) | |||
all: lib build/test build/bench | |||
@@ -124,15 +127,21 @@ bat: $(BATNAME) | |||
$(BATNAME): include/* src/* src/*/* test/batarch.map | |||
rm -fr $@ | |||
(while read arch where; do \ | |||
mkdir -p $@/`basename $$arch`; \ | |||
cp include/*.h src/*.c src/include/*.h src/$$where/*.c src/$$where/*.h $@/`basename $$arch`; \ | |||
perl -p -i -e 's/.*endif.*GOLDILOCKS_CONFIG_H/#define SUPERCOP_WONT_LET_ME_OPEN_FILES 1\n\n$$&/' $@/`basename $$arch`/config.h; \ | |||
perl -p -i -e 's/SYSNAME/'`basename $(BATNAME)`_`basename $$arch`'/g' $@/`basename $$arch`/api.h; \ | |||
done \ | |||
) < test/batarch.map | |||
echo 'Mike Hamburg' > $@/designers | |||
echo 'Ed448-Goldilocks sign and dh' > $@/description | |||
for prim in dh sign; do \ | |||
targ="$@/crypto_$$prim/ed448goldilocks"; \ | |||
(while read arch where; do \ | |||
mkdir -p $$targ/`basename $$arch`; \ | |||
cp include/*.h src/*.c src/include/*.h src/bat/$$prim.c src/$$where/*.c src/$$where/*.h $$targ/`basename $$arch`; \ | |||
cp src/bat/api_$$prim.h $$targ/`basename $$arch`/api.h; \ | |||
perl -p -i -e 's/.*endif.*GOLDILOCKS_CONFIG_H/#define SUPERCOP_WONT_LET_ME_OPEN_FILES 1\n\n$$&/' $$targ/`basename $$arch`/config.h; \ | |||
perl -p -i -e 's/SYSNAME/'`basename $(BATNAME)`_`basename $$arch`'/g' $$targ/`basename $$arch`/api.h; \ | |||
perl -p -i -e 's/__TODAY__/'$(TODAY)'/g' $$targ/`basename $$arch`/api.h; \ | |||
done \ | |||
) < test/batarch.map; \ | |||
echo 'Mike Hamburg' > $$targ/designers; \ | |||
echo 'Ed448-Goldilocks sign and dh' > $$targ/description; \ | |||
done | |||
(cd build && tar czf $(BATBASE).tgz $(BATBASE) ) | |||
todo:: | |||
@@ -0,0 +1,24 @@ | |||
/** | |||
* @file sizes.h | |||
* @copyright | |||
* Copyright (c) 2014 Cryptography Research, Inc. \n | |||
* Released under the MIT License. See LICENSE.txt for license information. | |||
* @author Mike Hamburg | |||
* @brief BATMAN / SUPERCOP glue for benchmarking. | |||
*/ | |||
#include <string.h> | |||
#include "goldilocks.h" | |||
#define PUBLICKEY_BYTES GOLDI_PUBLIC_KEY_BYTES | |||
#define SECRETKEY_BYTES GOLDI_PRIVATE_KEY_BYTES | |||
#define SHAREDSECRET_BYTES GOLDI_SHARED_SECRET_BYTES | |||
#define CRYPTO_PUBLICKEYBYTES PUBLICKEY_BYTES | |||
#define CRYPTO_SECRETKEYBYTES SECRETKEY_BYTES | |||
#define CRYPTO_BYTES SHAREDSECRET_BYTES | |||
#define PRIVATEKEY_BYTES SECRETKEY_BYTES | |||
#define CRYPTO_VERSION "__TODAY__" | |||
#define CRYPTO_DETERMINISTIC 1 | |||
@@ -0,0 +1,24 @@ | |||
/** | |||
* @file sizes.h | |||
* @copyright | |||
* Copyright (c) 2014 Cryptography Research, Inc. \n | |||
* Released under the MIT License. See LICENSE.txt for license information. | |||
* @author Mike Hamburg | |||
* @brief BATMAN / SUPERCOP glue for benchmarking. | |||
*/ | |||
#include <string.h> | |||
#include "goldilocks.h" | |||
#define PUBLICKEY_BYTES GOLDI_PUBLIC_KEY_BYTES | |||
#define SECRETKEY_BYTES GOLDI_PRIVATE_KEY_BYTES | |||
#define SIGNATURE_BYTES GOLDI_SIGNATURE_BYTES | |||
#define CRYPTO_PUBLICKEYBYTES PUBLICKEY_BYTES | |||
#define CRYPTO_SECRETKEYBYTES SECRETKEY_BYTES | |||
#define CRYPTO_BYTES SIGNATURE_BYTES | |||
#define PRIVATEKEY_BYTES SECRETKEY_BYTES | |||
#define CRYPTO_VERSION "__TODAY__" | |||
#define CRYPTO_DETERMINISTIC 1 | |||
@@ -0,0 +1,40 @@ | |||
/** | |||
* @file sizes.h | |||
* @copyright | |||
* Copyright (c) 2014 Cryptography Research, Inc. \n | |||
* Released under the MIT License. See LICENSE.txt for license information. | |||
* @author Mike Hamburg | |||
* @brief BATMAN / SUPERCOP glue for benchmarking. | |||
*/ | |||
#include <string.h> | |||
#include <stdlib.h> | |||
#include "api.h" | |||
#include "crypto_dh.h" | |||
int crypto_dh_keypair ( | |||
unsigned char pk[SECRETKEY_BYTES], | |||
unsigned char sk[PUBLICKEY_BYTES] | |||
) { | |||
int ret; | |||
ret = goldilocks_init(); | |||
if (ret && ret != GOLDI_EALREADYINIT) | |||
return ret; | |||
if ((ret = goldilocks_keygen( | |||
(struct goldilocks_private_key_t *)sk, | |||
(struct goldilocks_public_key_t *)pk | |||
))) abort(); | |||
return ret; | |||
} | |||
int crypto_dh ( | |||
unsigned char s[SHAREDSECRET_BYTES], | |||
const unsigned char pk[PUBLICKEY_BYTES], | |||
const unsigned char sk[SECRETKEY_BYTES] | |||
) { | |||
return goldilocks_shared_secret ( | |||
s, | |||
(const struct goldilocks_private_key_t *)sk, | |||
(const struct goldilocks_public_key_t *)pk | |||
); | |||
} |
@@ -0,0 +1,66 @@ | |||
/** | |||
* @file sizes.h | |||
* @copyright | |||
* Copyright (c) 2014 Cryptography Research, Inc. \n | |||
* Released under the MIT License. See LICENSE.txt for license information. | |||
* @author Mike Hamburg | |||
* @brief BATMAN / SUPERCOP glue for benchmarking. | |||
*/ | |||
#include <stdlib.h> | |||
#include <string.h> | |||
#include "api.h" | |||
#include "crypto_sign.h" | |||
int crypto_sign_keypair ( | |||
unsigned char pk[SECRETKEY_BYTES], | |||
unsigned char sk[PUBLICKEY_BYTES] | |||
) { | |||
int ret; | |||
ret = goldilocks_init(); | |||
if (ret && ret != GOLDI_EALREADYINIT) | |||
return ret; | |||
if ((ret = goldilocks_keygen( | |||
(struct goldilocks_private_key_t *)sk, | |||
(struct goldilocks_public_key_t *)pk | |||
))) abort(); | |||
return ret; | |||
} | |||
int crypto_sign ( | |||
unsigned char *sm, | |||
unsigned long long *smlen, | |||
const unsigned char *m, | |||
unsigned long long mlen, | |||
const unsigned char sk[SECRETKEY_BYTES] | |||
) { | |||
unsigned char sig[SIGNATURE_BYTES]; | |||
int ret = goldilocks_sign( | |||
sig, m, mlen, | |||
(const struct goldilocks_private_key_t *)sk | |||
); | |||
if (!ret) { | |||
memmove(sm + SIGNATURE_BYTES, m, mlen); | |||
memcpy(sm, sig, SIGNATURE_BYTES); | |||
*smlen = mlen + SIGNATURE_BYTES; | |||
} | |||
return ret ? -1 : 0; | |||
} | |||
int crypto_sign_open ( | |||
unsigned char *m, | |||
unsigned long long *mlen, | |||
const unsigned char *sm, | |||
unsigned long long smlen, | |||
const unsigned char pk[PUBLICKEY_BYTES] | |||
) { | |||
int ret = goldilocks_verify( | |||
sm, sm + SIGNATURE_BYTES, smlen - SIGNATURE_BYTES, | |||
(const struct goldilocks_public_key_t *)pk | |||
); | |||
if (!ret) { | |||
*mlen = smlen - SIGNATURE_BYTES; | |||
memmove(m, sm + SIGNATURE_BYTES, *mlen); | |||
} | |||
return ret ? -1 : 0; | |||
} |
@@ -1,118 +0,0 @@ | |||
/** | |||
* @file sizes.h | |||
* @copyright | |||
* Copyright (c) 2014 Cryptography Research, Inc. \n | |||
* Released under the MIT License. See LICENSE.txt for license information. | |||
* @author Mike Hamburg | |||
* @brief BATMAN / SUPERCOP glue for benchmarking. | |||
*/ | |||
#include <string.h> | |||
#include <stdlib.h> | |||
#include "goldilocks.h" | |||
#define PUBLICKEY_BYTES GOLDI_PUBLIC_KEY_BYTES | |||
#define SECRETKEY_BYTES GOLDI_PRIVATE_KEY_BYTES | |||
#define SIGNATURE_BYTES GOLDI_SIGNATURE_BYTES | |||
#define SHAREDSECRET_BYTES GOLDI_SHARED_SECRET_BYTES | |||
#define crypto_dh_SYSNAME_PUBLICKEYBYTES PUBLICKEY_BYTES | |||
#define crypto_dh_SYSNAME_SECRETKEYBYTES SECRETKEY_BYTES | |||
#define PRIVATEKEY_BYTES SECRETKEY_BYTES | |||
#define crypto_dh_SYSNAME_BYTES SHAREDSECRET_BYTES | |||
#define crypto_dh_SYSNAME_IMPLEMENTATION "AMD64" | |||
#define crypto_dh_SYSNAME_VERSION "2014-07-11" | |||
#define crypto_sign_SYSNAME_PUBLICKEYBYTES PUBLICKEY_BYTES | |||
#define crypto_sign_SYSNAME_SECRETKEYBYTES SECRETKEY_BYTES | |||
#define crypto_sign_SYSNAME_IMPLEMENTATION "AMD64" | |||
#define crypto_sign_SYSNAME_VERSION "2014-07-11" | |||
#define crypto_sign_SYSNAME_BYTES SIGNATURE_BYTES | |||
#define crypto_dh_SYSNAME_keypair crypto_dh_keypair | |||
#define crypto_dh_SYSNAME crypto_dh | |||
#define crypto_sign_SYSNAME_keypair crypto_dh_keypair | |||
#define crypto_sign_SYSNAME crypto_sign | |||
#define crypto_sign_SYSNAME_open crypto_sign_open | |||
#define CRYPTO_DETERMINISTIC 1 | |||
/* | |||
#ifndef LOOPS | |||
#define LOOPS 512 | |||
#endif | |||
*/ | |||
static inline int timingattacks(void) { return 0; } | |||
static inline int copyrightclaims(void) { return 0; } | |||
static inline int patentclaims(void) { | |||
/* Until the end of July 2014, point compression | |||
* is patented. */ | |||
return 20; | |||
} | |||
static inline int crypto_dh_keypair ( | |||
unsigned char pk[SECRETKEY_BYTES], | |||
unsigned char sk[PUBLICKEY_BYTES] | |||
) { | |||
int ret; | |||
ret = goldilocks_init(); | |||
if (ret && ret != GOLDI_EALREADYINIT) | |||
return ret; | |||
if ((ret = goldilocks_keygen( | |||
(struct goldilocks_private_key_t *)sk, | |||
(struct goldilocks_public_key_t *)pk | |||
))) abort(); | |||
return ret; | |||
} | |||
static inline int crypto_sign ( | |||
unsigned char *sm, | |||
unsigned long long *smlen, | |||
const unsigned char *m, | |||
unsigned long long mlen, | |||
const unsigned char sk[SECRETKEY_BYTES] | |||
) { | |||
unsigned char sig[SIGNATURE_BYTES]; | |||
int ret = goldilocks_sign( | |||
sig, m, mlen, | |||
(const struct goldilocks_private_key_t *)sk | |||
); | |||
if (!ret) { | |||
memmove(sm + SIGNATURE_BYTES, m, mlen); | |||
memcpy(sm, sig, SIGNATURE_BYTES); | |||
*smlen = mlen + SIGNATURE_BYTES; | |||
} | |||
return ret ? -1 : 0; | |||
} | |||
static inline int crypto_sign_open ( | |||
unsigned char *m, | |||
unsigned long long *mlen, | |||
const unsigned char *sm, | |||
unsigned long long smlen, | |||
const unsigned char pk[PUBLICKEY_BYTES] | |||
) { | |||
int ret = goldilocks_verify( | |||
sm, sm + SIGNATURE_BYTES, smlen - SIGNATURE_BYTES, | |||
(const struct goldilocks_public_key_t *)pk | |||
); | |||
if (!ret) { | |||
*mlen = smlen - SIGNATURE_BYTES; | |||
memmove(m, sm + SIGNATURE_BYTES, *mlen); | |||
} | |||
return ret ? -1 : 0; | |||
} | |||
static inline int crypto_dh ( | |||
unsigned char s[SHAREDSECRET_BYTES], | |||
const unsigned char pk[PUBLICKEY_BYTES], | |||
const unsigned char sk[SECRETKEY_BYTES] | |||
) { | |||
return goldilocks_shared_secret ( | |||
s, | |||
(const struct goldilocks_private_key_t *)sk, | |||
(const struct goldilocks_public_key_t *)pk | |||
); | |||
} | |||