Definition stream_dummy (result: string) (n: nat) : option bool :=
let hex := bytesToBits (hexstring_to_Zlist result) in
if nth_ok n hex false then Some (nth n hex false)
else None.
Definition get_nonce_dummy (result: string) (_: unit) := hexstring_to_Zlist result.
Fixpoint DRBG_generate_check (state_handle: DRBG_state_handle) (internal_states: list (string * string * string * string)) (returned_bits: string) :=
match internal_states with
| [] => True
| (key, v, additional_input, entropy_input_reseed)::[] =>
let test_HMAC256_DRBG_reseed_function := HMAC256_DRBG_reseed_function 32 32 256 in
let test_HMAC256_DRBG_generate_function := HMAC256_DRBG_generate_function test_HMAC256_DRBG_reseed_function 1024 128 128 in
let key := hexstring_to_Zlist key in
let value := hexstring_to_Zlist v in
let additional_input := hexstring_to_Zlist additional_input in
let returned_bits := hexstring_to_Zlist returned_bits in
match test_HMAC256_DRBG_generate_function (stream_dummy entropy_input_reseed) state_handle 128 256 true additional_input with
| ENTROPY.success (returned_bits', ((value', key', _), _, _)) _ => listZ_eq value value' = true /\ listZ_eq key key' = true /\ listZ_eq returned_bits returned_bits' = true
| ENTROPY.error _ _ => False
end
| (key, v, additional_input, entropy_input_reseed)::tl =>
let test_HMAC256_DRBG_reseed_function := HMAC256_DRBG_reseed_function 32 32 256 in
let test_HMAC256_DRBG_generate_function := HMAC256_DRBG_generate_function test_HMAC256_DRBG_reseed_function 1024 128 128 in
let key := hexstring_to_Zlist key in
let value := hexstring_to_Zlist v in
let additional_input := hexstring_to_Zlist additional_input in
match test_HMAC256_DRBG_generate_function (stream_dummy entropy_input_reseed) state_handle 128 256 true additional_input with
| ENTROPY.success (_, ((value', key', x), y, z)) _ => listZ_eq value value' = true /\ listZ_eq key key' = true /\ DRBG_generate_check ((value', key', x), y, z) tl returned_bits
| ENTROPY.error _ _ => False
end
end.
Definition DRBG_check (entropy_input nonce key value personalization_string: string) (internal_states: list (string * string * string * string)) (returned_bits: string) :=
let key := hexstring_to_Zlist key in
let value := hexstring_to_Zlist value in
let personalization_string := hexstring_to_Zlist personalization_string in
match HMAC256_DRBG_instantiate_function 32 32 (get_nonce_dummy nonce) 256 256 true (stream_dummy entropy_input) 256 true personalization_string with
| ENTROPY.success ((value', key', x), y, z) _ => listZ_eq value value' = true /\ listZ_eq key key' = true /\ DRBG_generate_check ((value', key', x), y, z) internal_states returned_bits
| _ => False
end.
vm_compute. repeat (split;auto). Qed.
vm_compute. repeat (split;auto). Qed.
vm_compute. repeat (split;auto). Qed.

Lemma test_with_additional_input_and_personalization0:
DRBG_check
"4294671d493dc085b5184607d7de2ff2b6aceb734a1b026f6cfee7c5a90f03da"
"d071544e599235d5eb38b64b551d2a6e"
"3ab4e27f331bf194cec5762baf84b7fb16e7cf81d69635c48b96febdfb809c18"
"7a232bc40bdd9c92ddaffbe76aa322ba1a47234d227060d8ac187e680780c02a"
"63bc769ae1d95a98bde870e4db7776297041d37c8a5c688d4e024b78d83f4d78"
[
("6acd0c98e1f7340bd7ab4a594960b63357bd19b99471cc8ea34817af77259880"%string, "db7c92e4c55c43b370b81a6024f0e14675a86c9667412b10ce5d1ea76259c1e4"%string, "28848becd3f47696f124f4b14853a456156f69be583a7d4682cff8d44b39e1d3"%string, "db9b4790b62336fbb9a684b82947065393eeef8f57bd2477141ad17e776dac34"%string);
("2bcafedb81361b2cf44555d3739fdff9dcd6315dd861bb640e812ddcb26045a5"%string, "48e842ba5cb7784211bdc0c19eedec0e23cdfa6c81ad56a7e993eee15a604e2e"%string, "8bfce0b7132661c3cd78175d83926f643e36f7608eec2c5dac3ddcbacc8c2182"%string, "4a9abe80f6f522f29878bedf8245b27940a76471006fb4a4110beb4decb6c341"%string)
]
"e580dc969194b2b18a97478aef9d1a72390aff14562747bf080d741527a6655ce7fc135325b457483a9f9c70f91165a811cf4524b50d51199a0df3bd60d12abac27d0bf6618e6b114e05420352e23f3603dfe8a225dc19b3d1fff1dc245dc6b1df24c741744bec3f9437dbbf222df84881a457a589e7815ef132f686b760f012"%string.