Commit cc3c6377 authored by Mike Hamburg's avatar Mike Hamburg

Changes to the eBAT build system, to bring the code and package

closer to how DJB expects them.
parent 3c30fb4e
......@@ -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::
......
/**
* @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
/**
* @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
/**
* @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
);
}
......@@ -7,51 +7,12 @@
* @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;
}
#include <string.h>
#include "api.h"
#include "crypto_sign.h"
static inline int crypto_dh_keypair (
int crypto_sign_keypair (
unsigned char pk[SECRETKEY_BYTES],
unsigned char sk[PUBLICKEY_BYTES]
) {
......@@ -66,7 +27,7 @@ static inline int crypto_dh_keypair (
return ret;
}
static inline int crypto_sign (
int crypto_sign (
unsigned char *sm,
unsigned long long *smlen,
const unsigned char *m,
......@@ -86,7 +47,7 @@ static inline int crypto_sign (
return ret ? -1 : 0;
}
static inline int crypto_sign_open (
int crypto_sign_open (
unsigned char *m,
unsigned long long *mlen,
const unsigned char *sm,
......@@ -103,16 +64,3 @@ static inline int crypto_sign_open (
}
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
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment