Browse Source

Check if header guard is defined properly

Does this slightly uglily, but it should work.
tags/v0.0.1
Thom Wiggers 5 years ago
parent
commit
6558773b21
No known key found for this signature in database GPG Key ID: 1BB0A7CE26E363
5 changed files with 18 additions and 6 deletions
  1. +2
    -2
      crypto_kem/kyber768/clean/api.h
  2. +2
    -3
      crypto_sign/dilithium-iii/clean/api.h
  3. +1
    -1
      test/Makefile
  4. +7
    -0
      test/crypto_kem/functest.c
  5. +6
    -0
      test/crypto_sign/functest.c

+ 2
- 2
crypto_kem/kyber768/clean/api.h View File

@@ -1,5 +1,5 @@
#ifndef API_H
#define API_H
#ifndef PQCLEAN_KYBER768_CLEAN_API_H
#define PQCLEAN_KYBER768_CLEAN_API_H

#include <stdint.h>



+ 2
- 3
crypto_sign/dilithium-iii/clean/api.h View File

@@ -1,6 +1,5 @@
#ifndef API_H
#include <stdint.h>
#define API_H
#ifndef PQCLEAN_DILITHIUMIII_API_H
#define PQCLEAN_DILITHIUMIII_API_H

#include <stddef.h>
#include <stdint.h>


+ 1
- 1
test/Makefile View File

@@ -15,7 +15,7 @@ COMMON_HEADERS=$(COMMON_DIR)/fips202.h $(COMMON_DIR)/randombytes.h $(COMMON_DIR)
DEST_DIR=../bin

# 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)



+ 7
- 0
test/crypto_kem/functest.c View File

@@ -50,12 +50,16 @@ static int check_canary(const uint8_t *d) {
return -1; \
}

#define DEFER(x) x
#define NAMESPACE_CHECK DEFER(NAMESPACE(API_H))

static int test_keys(void) {
/*
* This is most likely going to be aligned by the compiler.
* 16 extra bytes for canary
* 1 extra byte for unalignment
*/

uint8_t key_a_aligned[CRYPTO_BYTES + 16 + 1];
uint8_t key_b_aligned[CRYPTO_BYTES + 16 + 1];
uint8_t pk_aligned[CRYPTO_PUBLICKEYBYTES + 16 + 1];
@@ -196,7 +200,10 @@ static int test_invalid_ciphertext(void) {
}

int main(void) {
// these two will trigger compiler errors
puts(CRYPTO_ALGNAME);
NAMESPACE_CHECK;

int result = 0;
result += test_keys();
result += test_invalid_sk_a();


+ 6
- 0
test/crypto_sign/functest.c View File

@@ -51,6 +51,9 @@ static int check_canary(const uint8_t *d) {
return -1; \
}

#define DEFER(x) x
#define NAMESPACE_CHECK DEFER(NAMESPACE(API_H))

static int test_sign(void) {
/*
* This is most likely going to be aligned by the compiler.
@@ -160,7 +163,10 @@ static int test_wrong_pk(void) {
}

int main(void) {
// these two will generate compile errors
puts(CRYPTO_ALGNAME);
NAMESPACE_CHECK;

int result = 0;
result += test_sign();
result += test_wrong_pk();


Loading…
Cancel
Save