1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 15:39:07 +00:00

Do the test more properly

This commit is contained in:
Thom Wiggers 2019-03-19 15:20:59 +00:00
parent 8eacafb3c9
commit e811376a95
No known key found for this signature in database
GPG Key ID: 001BB0A7CE26E363
2 changed files with 21 additions and 9 deletions

View File

@ -50,8 +50,15 @@ static int check_canary(const uint8_t *d) {
return -1; \
}
#define DEFER(x) x
#define NAMESPACE_CHECK DEFER(NAMESPACE(API_H))
// https://stackoverflow.com/a/55243651/248065
#define MY_TRUTHY_VALUE_X 1
#define CAT(x,y) CAT_(x,y)
#define CAT_(x,y) x##y
#define HAS_NAMESPACE(x) CAT(CAT(MY_TRUTHY_VALUE_,CAT(PQCLEAN_NAMESPACE,CAT(_,x))),X)
#if !HAS_NAMESPACE(API_H)
#error "namespace not properly defined for header guard"
#endif
static int test_keys(void) {
/*
@ -200,9 +207,8 @@ static int test_invalid_ciphertext(void) {
}
int main(void) {
// these two will trigger compiler errors
// Check if CRYPTO_ALGNAME is printable
puts(CRYPTO_ALGNAME);
NAMESPACE_CHECK;
int result = 0;
result += test_keys();

View File

@ -51,8 +51,16 @@ static int check_canary(const uint8_t *d) {
return -1; \
}
#define DEFER(x) x
#define NAMESPACE_CHECK DEFER(NAMESPACE(API_H))
// https://stackoverflow.com/a/55243651/248065
#define MY_TRUTHY_VALUE_X 1
#define CAT(x,y) CAT_(x,y)
#define CAT_(x,y) x##y
#define HAS_NAMESPACE(x) CAT(CAT(MY_TRUTHY_VALUE_,CAT(PQCLEAN_NAMESPACE,CAT(_,x))),X)
#if !HAS_NAMESPACE(API_H)
#error "namespace not properly defined for header guard"
#endif
static int test_sign(void) {
/*
@ -163,10 +171,8 @@ static int test_wrong_pk(void) {
}
int main(void) {
// these two will generate compile errors
// check if CRYPTO_ALGNAME is printable
puts(CRYPTO_ALGNAME);
NAMESPACE_CHECK;
int result = 0;
result += test_sign();
result += test_wrong_pk();