Check if header guard is defined properly
Does this slightly uglily, but it should work.
This commit is contained in:
parent
05b0f6d9cc
commit
6558773b21
@ -1,5 +1,5 @@
|
|||||||
#ifndef API_H
|
#ifndef PQCLEAN_KYBER768_CLEAN_API_H
|
||||||
#define API_H
|
#define PQCLEAN_KYBER768_CLEAN_API_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#ifndef API_H
|
#ifndef PQCLEAN_DILITHIUMIII_API_H
|
||||||
#include <stdint.h>
|
#define PQCLEAN_DILITHIUMIII_API_H
|
||||||
#define API_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -15,7 +15,7 @@ COMMON_HEADERS=$(COMMON_DIR)/fips202.h $(COMMON_DIR)/randombytes.h $(COMMON_DIR)
|
|||||||
DEST_DIR=../bin
|
DEST_DIR=../bin
|
||||||
|
|
||||||
# This -Wall was supported by the European Commission through the ERC Starting Grant 805031 (EPOQUE)
|
# This -Wall was supported by the European Commission through the ERC Starting Grant 805031 (EPOQUE)
|
||||||
CFLAGS=-Wall -Wextra -Wpedantic -Werror -std=c99 -I$(COMMON_DIR) $(EXTRAFLAGS)
|
CFLAGS=-Wall -Wextra -Wpedantic -Werror -Wundef -std=c99 -I$(COMMON_DIR) $(EXTRAFLAGS)
|
||||||
|
|
||||||
all: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION) $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
|
all: $(DEST_DIR)/functest_$(SCHEME)_$(IMPLEMENTATION) $(DEST_DIR)/testvectors_$(SCHEME)_$(IMPLEMENTATION)
|
||||||
|
|
||||||
|
@ -50,12 +50,16 @@ static int check_canary(const uint8_t *d) {
|
|||||||
return -1; \
|
return -1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DEFER(x) x
|
||||||
|
#define NAMESPACE_CHECK DEFER(NAMESPACE(API_H))
|
||||||
|
|
||||||
static int test_keys(void) {
|
static int test_keys(void) {
|
||||||
/*
|
/*
|
||||||
* This is most likely going to be aligned by the compiler.
|
* This is most likely going to be aligned by the compiler.
|
||||||
* 16 extra bytes for canary
|
* 16 extra bytes for canary
|
||||||
* 1 extra byte for unalignment
|
* 1 extra byte for unalignment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t key_a_aligned[CRYPTO_BYTES + 16 + 1];
|
uint8_t key_a_aligned[CRYPTO_BYTES + 16 + 1];
|
||||||
uint8_t key_b_aligned[CRYPTO_BYTES + 16 + 1];
|
uint8_t key_b_aligned[CRYPTO_BYTES + 16 + 1];
|
||||||
uint8_t pk_aligned[CRYPTO_PUBLICKEYBYTES + 16 + 1];
|
uint8_t pk_aligned[CRYPTO_PUBLICKEYBYTES + 16 + 1];
|
||||||
@ -196,7 +200,10 @@ static int test_invalid_ciphertext(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
// these two will trigger compiler errors
|
||||||
puts(CRYPTO_ALGNAME);
|
puts(CRYPTO_ALGNAME);
|
||||||
|
NAMESPACE_CHECK;
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
result += test_keys();
|
result += test_keys();
|
||||||
result += test_invalid_sk_a();
|
result += test_invalid_sk_a();
|
||||||
|
@ -51,6 +51,9 @@ static int check_canary(const uint8_t *d) {
|
|||||||
return -1; \
|
return -1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DEFER(x) x
|
||||||
|
#define NAMESPACE_CHECK DEFER(NAMESPACE(API_H))
|
||||||
|
|
||||||
static int test_sign(void) {
|
static int test_sign(void) {
|
||||||
/*
|
/*
|
||||||
* This is most likely going to be aligned by the compiler.
|
* This is most likely going to be aligned by the compiler.
|
||||||
@ -160,7 +163,10 @@ static int test_wrong_pk(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
// these two will generate compile errors
|
||||||
puts(CRYPTO_ALGNAME);
|
puts(CRYPTO_ALGNAME);
|
||||||
|
NAMESPACE_CHECK;
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
result += test_sign();
|
result += test_sign();
|
||||||
result += test_wrong_pk();
|
result += test_wrong_pk();
|
||||||
|
Loading…
Reference in New Issue
Block a user