mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-29 19:01:22 +00:00
4054af0c42
* Sebastian's HQC merge request * Clean up changes to common infrastructure * Fix Bitmask macro It assumed that ``unsigned long`` was 64 bit * Remove maxlen from nistseedexpander It's a complicated thing to handle because the value is larger than size_t supports on 32-bit platforms * Initialize buffers to help linter * Add Nistseedexpander test * Resolve UB in gf2x.c Some of the shifts could be larger than WORD_SIZE_BITS, ie. larger than the width of uint64_t. This apparently on Intel gets interpreted as the shift mod 64, but on ARM something else happened. * Fix Windows complaints * rename log, exp which appear to be existing functions on MS * Solve endianness problems * remove all spaces before ';' * Fix duplicate consistency * Fix duplicate consistency * Fix complaints by MSVC about narrowing int * Add nistseedexpander.obj to COMMON_OBJECTS_NOPATH * astyle format util.[ch] * add util.h to makefile * Sort includes in util.h * Fix more Windows MSVC complaints Co-authored-by: Sebastian Verschoor <sebastian@zeroknowledge.me> Co-authored-by: Thom Wiggers <thom@thomwiggers.nl>
34 lines
818 B
C
34 lines
818 B
C
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
#include "nistseedexpander.h"
|
|
|
|
|
|
const uint8_t seed[32] = {0};
|
|
const uint8_t expected_result[27] = { 0x55, 0x98, 0x87, 0xae, 0x24, 0x28, 0x5d, 0x7e, 0x42, 0x02, 0x74, 0x27, 0x73, 0x31, 0x03, 0xf6, 0xaf, 0x2e, 0xb6, 0xf1, 0xec, 0xfe, 0xdf, 0xfb, 0xd3, 0x50, 0x31, };
|
|
|
|
int test_seedexpander() {
|
|
AES_XOF_struct state;
|
|
uint8_t result[27] = {0};
|
|
|
|
seedexpander_init(&state, seed, seed, 28);
|
|
seedexpander(&state, result, 27);
|
|
|
|
if (memcmp(expected_result, result, 27) != 0) {
|
|
printf("Got\tExpected\n");
|
|
for(size_t i = 0; i < 27; i++) {
|
|
printf("0x%02x\t0x%02x\n", result[i], expected_result[i]);
|
|
}
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
int main(void) {
|
|
|
|
return test_seedexpander();
|
|
}
|