mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-04 00:02:01 -04:00
* add bitflip test to test_sig.c Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * format code Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * - add sig->suf_cma - add command-line argument to test_sig.c (the number of bitflips) - update CROSS upstream to SUF-CMA Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * %d to %ld for size_t bitflips Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * cast argument bitflips to size_t Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * replace atoi() with strtol() Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * cast bit_index to %llu Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * update bitflip tests: - revert CROSS to EUF-CMA - add test_bitflip_message - exclude stateful signatures for now Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * remove bitflips_as_str in printf Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * test_bitflip as a single function, add support for stateful signatures Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * add OQS_TEST_CT_DECLASSIFY after test_bitflip_stfl Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * [extended tests] Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * more OQS_TEST_CT_DECLASSIFY [extended tests] Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * patch dilithium to add suf-cma Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * run copy_from_upstream.py Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * SUF-CMA in dilithium docs, run copy_from_upstream.py Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * correct sizeof in OQS_randombytes call (thank you @SWilson4!) Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * factor bitflip testing functions out into test_helpers.c Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * --allow-multiple-definition for Windows .dll in test_kem_mem Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> * --allow-multiple-definition for Windows .dll in test_sig and test_sig_stfl Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com> --------- Signed-off-by: rtjk <47841774+rtjk@users.noreply.github.com>
57 lines
1.9 KiB
C
57 lines
1.9 KiB
C
// SPDX-License-Identifier: MIT
|
|
#ifndef OQS_TEST_HELPERS_H
|
|
#define OQS_TEST_HELPERS_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
#include <oqs/sha3.h>
|
|
#include <oqs/rand_nist.h>
|
|
|
|
#ifdef OQS_ENABLE_TEST_CONSTANT_TIME
|
|
#include <valgrind/memcheck.h>
|
|
#define OQS_TEST_CT_CLASSIFY(addr, len) VALGRIND_MAKE_MEM_UNDEFINED(addr, len)
|
|
#define OQS_TEST_CT_DECLASSIFY(addr, len) VALGRIND_MAKE_MEM_DEFINED(addr, len)
|
|
#else
|
|
#define OQS_TEST_CT_CLASSIFY(addr, len)
|
|
#define OQS_TEST_CT_DECLASSIFY(addr, len)
|
|
#endif
|
|
|
|
typedef union {
|
|
OQS_SHA3_shake256_inc_ctx hqc_state;
|
|
OQS_NIST_DRBG_struct nist_state;
|
|
} OQS_KAT_PRNG_state;
|
|
|
|
typedef struct {
|
|
size_t max_kats;
|
|
OQS_KAT_PRNG_state saved_state;
|
|
// The caller should use the OQS_KAT_PRNG_* functions instead of these callbacks.
|
|
void (*seed)(const uint8_t *, const uint8_t *);
|
|
void (*get_state)(void *);
|
|
void (*set_state)(const void *);
|
|
void (*free)(OQS_KAT_PRNG_state *);
|
|
} OQS_KAT_PRNG;
|
|
|
|
OQS_KAT_PRNG *OQS_KAT_PRNG_new(const char *method_name);
|
|
|
|
void OQS_KAT_PRNG_seed(OQS_KAT_PRNG *prng, const uint8_t *seed, const uint8_t *personalization_string);
|
|
|
|
void OQS_KAT_PRNG_save_state(OQS_KAT_PRNG *prng);
|
|
|
|
void OQS_KAT_PRNG_restore_state(OQS_KAT_PRNG *prng);
|
|
|
|
void OQS_KAT_PRNG_free(OQS_KAT_PRNG *prng);
|
|
|
|
void OQS_print_hex_string(const char *label, const uint8_t *str, size_t len);
|
|
|
|
void OQS_fprintBstr(FILE *fp, const char *S, const uint8_t *A, size_t L);
|
|
|
|
OQS_STATUS flip_bit(uint8_t *array, uint64_t array_length, uint64_t bit_position);
|
|
|
|
OQS_STATUS test_sig_bitflip(OQS_SIG *sig, uint8_t *message, size_t message_len, uint8_t *signature, size_t signature_len, uint8_t *public_key, bool bitflips_all[2], size_t bitflips[2], bool use_ctx, uint8_t *ctx, size_t ctx_i);
|
|
|
|
OQS_STATUS test_sig_stfl_bitflip(OQS_SIG_STFL *sig, uint8_t *message, size_t message_len, uint8_t *signature, size_t signature_len, uint8_t *public_key, bool bitflips_all[2], size_t bitflips[2]);
|
|
|
|
#endif
|