32 #include "mphell/mphell.h" 33 #include "mphell/mphell-util.h" 39 printf(
"CTR DRBG AES 128 test \n");
47 uint8_t returned_bytes[512/8];
48 char returned_bytes_hex[512/4];
50 uint8_t entropy_byte[128];
51 uint8_t nonce_byte[64];
52 uint8_t entropy_reseed_byte[128];
53 uint8_t additionnal_input_reseed_byte[128];
54 uint8_t additionnal_input1_byte[128];
55 uint8_t additionnal_input2_byte[128];
56 uint8_t personalization_string_byte[128];
62 hex_string2bytes(entropy_reseed_byte,
"410737c3c6112b5113f0ef66b0fa6a07", 128/8);
63 hex_string2bytes(additionnal_input_reseed_byte,
"ae2ce6d1dba56775db17b8c6d9379f14", 128/8);
64 hex_string2bytes(additionnal_input1_byte,
"57866375238ea56e97dd6af8c5010618", 128/8);
65 hex_string2bytes(additionnal_input2_byte,
"34a449f860c0c18fdf854b32de572917", 128/8);
66 hex_string2bytes(personalization_string_byte,
"7ec2b597c845ae8bbb63609a80c2ab4f", 128/8);
70 drbg_instantiate(ret, &state_handle, 128,
DRBG_AES128,
DEVURANDOM, 1000, entropy_byte, 128/8, nonce_byte, 64/8, personalization_string_byte, 128/8);
73 printf(
"ERROR drbg_instantiate_test_drbg, state_handle = %d\n", state_handle);
74 printf(
"ret->info: %s\n", ret->info);
80 drbg_reseed(ret, state_handle, entropy_reseed_byte, 128/8, additionnal_input_reseed_byte, 128/8);
83 printf(
"ERROR drbg_reseed, state_handle = %d\n", state_handle);
84 printf(
"ret->info: %s\n", ret->info);
90 drbg_generate(ret, returned_bytes, state_handle, 512/8, 128, additionnal_input1_byte, 128/8);
93 printf(
"ERROR drbg_generate 1st call, state_handle = %d\n", state_handle);
94 printf(
"ret->info: %s\n", ret->info);
99 printf(
"returned_bytes_hex: %s \n", returned_bytes_hex);
103 drbg_generate(ret, returned_bytes, state_handle, 512/8, 128, additionnal_input2_byte, 128/8);
106 printf(
"ERROR drbg_generate 2nd call, state_handle = %d\n", state_handle);
107 printf(
"ret->info: %s\n", ret->info);
112 printf(
"returned_bytes_hex: %s \n", returned_bytes_hex);
118 printf(
"ERROR drbg_uninstantiate, state_handle = %d\n", state_handle);
119 printf(
"ret->info: %s\n", ret->info);
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 drbg_uninstantiate(mphell_status ret, const int8_t state_handle)
Uninstantiate a DRBG state.
void free_mphell()
Free MPHELL memory, especially the big amount of temporary memory.
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 bytes_string2hex(char *hex_string, const uint8_t *bytes_string, uint16_t length)
Convert the byte string "bytes_string" under hexadecimal form.
void drbg_generate(mphell_status ret, uint8_t *returned_bytes, const int8_t state_handle, const uint32_t requested_number_of_bytes, const uint16_t requested_security_strength, const uint8_t *additional_input, const uint64_t add_length)
"Generates pseudorandom bits upon request, using the current internal state, and generates a new inte...
void drbg_reseed(mphell_status ret, const int8_t state_handle, const uint8_t *entropy, const uint16_t entropy_length, const uint8_t *additional_input, const uint64_t add_length)
Reseed the DRBG, "acquires new entropy input and combines it with the current internal state and any ...
mphell_status_t mphell_status[1]
The status is a couple (flag, information)