#include #include #include #include #include "rng.h" #define SUCCESS 0 #define FILE_OPEN_ERROR -1 #define KYBER_SYMBYTES 32 void fprintBstr(FILE *fp, unsigned char *A, unsigned long L) { unsigned long i; for ( i=0; i for write\n", fn_ckk); return FILE_OPEN_ERROR; } // Create the indcpa_keypair file sprintf(fn_indcpa, "indcpa_keypair"); if ( (fp_indcpa = fopen(fn_indcpa, "w")) == NULL ) { printf("Couldn't open <%s> for write\n", fn_indcpa); return FILE_OPEN_ERROR; } // Create the encode file sprintf(fn_enc, "encode"); if ( (fp_enc = fopen(fn_enc, "w")) == NULL ) { printf("Couldn't open <%s> for write\n", fn_enc); return FILE_OPEN_ERROR; } // 1 .. 48 initial seed for (int i=0; i<48; i++) entropy_input[i] = i; // initialise randombytes_init(entropy_input, NULL, 256); for (int i=0; i<100; i++) { randombytes(seed, 48); for (int j=0;j<48;j++) seeds[i][j] = seed[j]; } for (int i=0; i<100; i++) { randombytes_init(seeds[i], NULL, 256); randombytes(indcpa, KYBER_SYMBYTES); randombytes(ckk, KYBER_SYMBYTES); randombytes(enc, KYBER_SYMBYTES); fprintBstr(fp_indcpa, indcpa, KYBER_SYMBYTES); fprintBstr(fp_ckk, ckk, KYBER_SYMBYTES); fprintBstr(fp_enc, enc, KYBER_SYMBYTES); } fclose(fp_indcpa); fclose(fp_ckk); fclose(fp_enc); return SUCCESS; }