32 #include "mphell/mphell.h" 33 #include "mphell/mphell-util.h" 39 printf(
"CTR DRBG AES 128 test \n");
49 uint8_t returned_bytes[512/8];
50 char returned_bytes_hex[512/4];
52 uint8_t additionnal_input_reseed_byte[128];
53 uint8_t additionnal_input1_byte[128];
54 uint8_t additionnal_input2_byte[128];
55 uint8_t personalization_string_byte[128];
59 hex_string2bytes(personalization_string_byte,
"7ec2b597c845ae8bbb63609a80c2ab4f", 128/8);
60 hex_string2bytes(additionnal_input_reseed_byte,
"ae2ce6d1dba56775db17b8c6d9379f14", 128/8);
61 hex_string2bytes(additionnal_input1_byte,
"57866375238ea56e97dd6af8c5010618", 128/8);
68 printf(
"ERROR random_instantiate, state_handle = %d\n", random_working_state->
state_handle);
69 printf(
"ret->info: %s\n", ret->info);
79 printf(
"ERROR random_reseed, state_handle = %d\n", random_working_state->
state_handle);
80 printf(
"ret->info: %s\n", ret->info);
86 random_generate(ret, returned_bytes, random_working_state, 512/8, 128, additionnal_input1_byte, 128/8);
90 printf(
"ERROR random_generate 1st call, state_handle = %d\n", random_working_state->
state_handle);
91 printf(
"ret->info: %s\n", ret->info);
96 printf(
"returned_bytes_hex: %s \n", returned_bytes_hex);
103 printf(
"ERROR random_uninstantiate, state_handle = %d\n", random_working_state->
state_handle);
104 printf(
"ret->info: %s\n", ret->info);
108 free(random_working_state);
void hex_string2bytes(uint8_t *bytes_string, const char *hex_string, uint16_t length)
Convert the hexadecimal string "hex_string" under bytes string form.
void free_mphell()
Free MPHELL memory, especially the big amount of temporary memory.
void random_generate(mphell_status ret, uint8_t *returned_bytes, random_state working_state, const uint32_t requested_number_of_bytes, const uint16_t requested_security_strength, const uint8_t *additional_input, const uint64_t add_length)
Gererate an array of random bits.
void init_mphell(const uint16_t security_strength, const random_type type, const entropy_type entropy)
Initialise MPHELL with security_strength bits of security (for random number only).
void random_reseed(mphell_status ret, random_state working_state, const uint16_t entropy_length, const entropy_type entropy_src, const uint8_t *additional_input, const uint64_t add_length)
Reseed the DRBG (if you want to reseed it before it does by itself)
void bytes_string2hex(char *hex_string, const uint8_t *bytes_string, uint16_t length)
Convert the byte string "bytes_string" under hexadecimal form.
void random_instantiate(mphell_status ret, random_state initial_state, const uint16_t requested_instantiation_security_strength, const uint8_t *personalization_string, const uint64_t pers_length, const random_type type, const entropy_type entropy, uint64_t reseed_interval)
Instantiate one random state.
mphell_status_t mphell_status[1]
The status is a couple (flag, information)
void random_uninstantiate(mphell_status ret, random_state working_state)
Uninstantiate a random state.