1
1

Include scheme namespace in tests

Dieser Commit ist enthalten in:
Joost Rijneveld 2019-01-22 17:37:58 +01:00
Ursprung 6fcb3618c4
Commit 8228363495
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A4FE39CF49CBC553
6 geänderte Dateien mit 41 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -15,6 +15,7 @@ endif
bin/functest_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))functest.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
mkdir -p bin
$(CC) $(CFLAGS) \
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
-iquote "./common/" \
-iquote "$(SCHEME)/clean/" \
-o bin/functest_$(subst /,_,$(SCHEME)) \
@ -49,6 +50,7 @@ sanitizer: bin/sanitizer_$(subst /,_,$(SCHEME))
bin/testvectors_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))testvectors.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
mkdir -p bin
$(CC) $(CFLAGS) \
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
-iquote "./common/" \
-iquote "$(SCHEME)/clean/" \
-o bin/testvectors_$(subst /,_,$(SCHEME)) \
@ -62,6 +64,7 @@ testvectors: bin/testvectors_$(subst /,_,$(SCHEME))
bin/shared_$(subst /,_,$(SCHEME))_clean.so: $(wildcard $(SCHEME)/clean/*.c) | require_scheme
mkdir -p bin
gcc $(CFLAGS) \
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
-shared \
-fPIC \
-iquote "./common/" \

Datei anzeigen

@ -13,7 +13,7 @@ if len(sys.argv) != 2:
SCHEME = sys.argv[1]
SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768
SCHEMESHORT = SCHEME.split('/')[1].upper()
namespace = f"PQCLEAN_{SCHEMESHORT}_"
namespace = f"PQCLEAN_{SCHEMESHORT}_".replace('-', '')
# TODO can we do this using object files instead, to preserve file origin?
sharedlib = f"bin/shared_{SCHEMEFULL}_clean.so"

Datei anzeigen

@ -20,6 +20,15 @@ static int check_canary(const unsigned char *d) {
return 0;
}
// https://stackoverflow.com/a/1489985/1711232
#define PASTER(x, y) x##_##y
#define EVALUATOR(x, y) PASTER(x, y)
#define NAMESPACE(fun) EVALUATOR(PQCLEAN_NAMESPACE, fun)
#define crypto_kem_keypair NAMESPACE(crypto_kem_keypair)
#define crypto_kem_enc NAMESPACE(crypto_kem_enc)
#define crypto_kem_dec NAMESPACE(crypto_kem_dec)
static int test_keys(void) {
unsigned char key_a[CRYPTO_BYTES + 16], key_b[CRYPTO_BYTES + 16];
unsigned char pk[CRYPTO_PUBLICKEYBYTES + 16];

Datei anzeigen

@ -13,6 +13,15 @@ static void printbytes(const unsigned char *x, unsigned long long xlen) {
printf("\n");
}
// https://stackoverflow.com/a/1489985/1711232
#define PASTER(x, y) x##_##y
#define EVALUATOR(x, y) PASTER(x, y)
#define NAMESPACE(fun) EVALUATOR(PQCLEAN_NAMESPACE, fun)
#define crypto_kem_keypair NAMESPACE(crypto_kem_keypair)
#define crypto_kem_enc NAMESPACE(crypto_kem_enc)
#define crypto_kem_dec NAMESPACE(crypto_kem_dec)
int main(void) {
unsigned char key_a[CRYPTO_BYTES], key_b[CRYPTO_BYTES];
unsigned char pk[CRYPTO_PUBLICKEYBYTES];

Datei anzeigen

@ -20,6 +20,16 @@ static int check_canary(const unsigned char *d) {
return 0;
}
// https://stackoverflow.com/a/1489985/1711232
#define PASTER(x, y) x##_##y
#define EVALUATOR(x, y) PASTER(x, y)
#define NAMESPACE(fun) EVALUATOR(PQCLEAN_NAMESPACE, fun)
#define crypto_sign_keypair NAMESPACE(crypto_sign_keypair)
#define crypto_sign NAMESPACE(crypto_sign)
#define crypto_sign_open NAMESPACE(crypto_sign_open)
static int test_sign(void) {
unsigned char pk[CRYPTO_PUBLICKEYBYTES + 16];
unsigned char sk[CRYPTO_SECRETKEYBYTES + 16];

Datei anzeigen

@ -14,6 +14,15 @@ static void printbytes(const unsigned char *x, unsigned long long xlen) {
printf("\n");
}
// https://stackoverflow.com/a/1489985/1711232
#define PASTER(x, y) x##_##y
#define EVALUATOR(x, y) PASTER(x, y)
#define NAMESPACE(fun) EVALUATOR(PQCLEAN_NAMESPACE, fun)
#define crypto_sign_keypair NAMESPACE(crypto_sign_keypair)
#define crypto_sign NAMESPACE(crypto_sign)
#define crypto_sign_open NAMESPACE(crypto_sign_open)
int main(void) {
unsigned char sk[CRYPTO_SECRETKEYBYTES];
unsigned char pk[CRYPTO_PUBLICKEYBYTES];