-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock_hmac.c
45 lines (32 loc) · 1.45 KB
/
mock_hmac.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "hmac.h"
#include "memory_compare.h"
BYTE* HMAC_SHA2_256(BYTE key[], BYTE mes[], int size, rom_ext_manifest_t __current_rom_ext_mf) {
int __expected_size =
sizeof(__current_rom_ext_mf.pub_signature_key) + sizeof(__current_rom_ext_mf.image_length) + __current_rom_ext_mf.image_length;
__CPROVER_assert(cmp_key(
mes,
&__current_rom_ext_mf.pub_signature_key,
sizeof(__current_rom_ext_mf.pub_signature_key)) == 0,
"PROPERTY 4: Message contains the key");
__CPROVER_assert(cmp_image_len(
mes + sizeof(__current_rom_ext_mf.pub_signature_key),
&__current_rom_ext_mf.image_length,
sizeof(__current_rom_ext_mf.image_length)) == 0,
"PROPERTY 4: Message contains the Image length");
__CPROVER_assert(cmp_image_code(
mes + sizeof(__current_rom_ext_mf.pub_signature_key) + sizeof(__current_rom_ext_mf.image_length),
__current_rom_ext_mf.image_code,
__current_rom_ext_mf.image_length) == 0,
"PROPERTY 4: Message contains the Image code");
__CPROVER_assert(size == __expected_size,
"PROPERTY 4: Message size parameter is as expected.");
__CPROVER_assert(__CPROVER_OBJECT_SIZE(mes) == __expected_size,
"PROPERTY 4: Size of message is as expected.");
char* hash = malloc(256 / 8); //model it to be ok for PROPERTY 5
__CPROVER_assert(__CPROVER_OBJECT_SIZE(hash) == 256 / 8,
"PROPERTY 3: Hash is 256 bits");
__CPROVER_assert(__CPROVER_r_ok(hash, 256 / 8),
"PROPERTY 3: hash is in readable address");
__REACHABILITY_CHECK
return hash;
}