mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-22 23:48:58 +00:00
Include scheme namespace in tests
This commit is contained in:
parent
6fcb3618c4
commit
8228363495
3
Makefile
3
Makefile
@ -15,6 +15,7 @@ endif
|
|||||||
bin/functest_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))functest.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
|
bin/functest_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))functest.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
$(CC) $(CFLAGS) \
|
$(CC) $(CFLAGS) \
|
||||||
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
||||||
-iquote "./common/" \
|
-iquote "./common/" \
|
||||||
-iquote "$(SCHEME)/clean/" \
|
-iquote "$(SCHEME)/clean/" \
|
||||||
-o bin/functest_$(subst /,_,$(SCHEME)) \
|
-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
|
bin/testvectors_$(subst /,_,$(SCHEME)): test/$(dir $(SCHEME))testvectors.c $(wildcard $(SCHEME)/clean/*.c) $(wildcard $(SCHEME)/clean/*.h) | require_scheme
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
$(CC) $(CFLAGS) \
|
$(CC) $(CFLAGS) \
|
||||||
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
||||||
-iquote "./common/" \
|
-iquote "./common/" \
|
||||||
-iquote "$(SCHEME)/clean/" \
|
-iquote "$(SCHEME)/clean/" \
|
||||||
-o bin/testvectors_$(subst /,_,$(SCHEME)) \
|
-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
|
bin/shared_$(subst /,_,$(SCHEME))_clean.so: $(wildcard $(SCHEME)/clean/*.c) | require_scheme
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
gcc $(CFLAGS) \
|
gcc $(CFLAGS) \
|
||||||
|
-DPQCLEAN_NAMESPACE=$(shell echo PQCLEAN_$(subst -,,$(notdir $(SCHEME))) | tr a-z A-Z) \
|
||||||
-shared \
|
-shared \
|
||||||
-fPIC \
|
-fPIC \
|
||||||
-iquote "./common/" \
|
-iquote "./common/" \
|
||||||
|
@ -13,7 +13,7 @@ if len(sys.argv) != 2:
|
|||||||
SCHEME = sys.argv[1]
|
SCHEME = sys.argv[1]
|
||||||
SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768
|
SCHEMEFULL = SCHEME.replace('/', '_') # e.g. crypto_kem_kyber768
|
||||||
SCHEMESHORT = SCHEME.split('/')[1].upper()
|
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?
|
# TODO can we do this using object files instead, to preserve file origin?
|
||||||
sharedlib = f"bin/shared_{SCHEMEFULL}_clean.so"
|
sharedlib = f"bin/shared_{SCHEMEFULL}_clean.so"
|
||||||
|
@ -20,6 +20,15 @@ static int check_canary(const unsigned char *d) {
|
|||||||
return 0;
|
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) {
|
static int test_keys(void) {
|
||||||
unsigned char key_a[CRYPTO_BYTES + 16], key_b[CRYPTO_BYTES + 16];
|
unsigned char key_a[CRYPTO_BYTES + 16], key_b[CRYPTO_BYTES + 16];
|
||||||
unsigned char pk[CRYPTO_PUBLICKEYBYTES + 16];
|
unsigned char pk[CRYPTO_PUBLICKEYBYTES + 16];
|
||||||
|
@ -13,6 +13,15 @@ static void printbytes(const unsigned char *x, unsigned long long xlen) {
|
|||||||
printf("\n");
|
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) {
|
int main(void) {
|
||||||
unsigned char key_a[CRYPTO_BYTES], key_b[CRYPTO_BYTES];
|
unsigned char key_a[CRYPTO_BYTES], key_b[CRYPTO_BYTES];
|
||||||
unsigned char pk[CRYPTO_PUBLICKEYBYTES];
|
unsigned char pk[CRYPTO_PUBLICKEYBYTES];
|
||||||
|
@ -20,6 +20,16 @@ static int check_canary(const unsigned char *d) {
|
|||||||
|
|
||||||
return 0;
|
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) {
|
static int test_sign(void) {
|
||||||
unsigned char pk[CRYPTO_PUBLICKEYBYTES + 16];
|
unsigned char pk[CRYPTO_PUBLICKEYBYTES + 16];
|
||||||
unsigned char sk[CRYPTO_SECRETKEYBYTES + 16];
|
unsigned char sk[CRYPTO_SECRETKEYBYTES + 16];
|
||||||
|
@ -14,6 +14,15 @@ static void printbytes(const unsigned char *x, unsigned long long xlen) {
|
|||||||
printf("\n");
|
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) {
|
int main(void) {
|
||||||
unsigned char sk[CRYPTO_SECRETKEYBYTES];
|
unsigned char sk[CRYPTO_SECRETKEYBYTES];
|
||||||
unsigned char pk[CRYPTO_PUBLICKEYBYTES];
|
unsigned char pk[CRYPTO_PUBLICKEYBYTES];
|
||||||
|
Loading…
Reference in New Issue
Block a user