-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverify.h
More file actions
36 lines (32 loc) · 778 Bytes
/
verify.h
File metadata and controls
36 lines (32 loc) · 778 Bytes
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
#ifndef VERIFY_H_
#define VERIFY_H_
#include <stdint.h>
#include "sample_data.h"
int sha256(const void* buffer, int buffer_size, void* hash);
int verify(const uint8_t* pub_key, const uint8_t* signature, const uint8_t* data, int data_size);
static inline int test() {
int ret = -1;
#ifdef WITH_HASH
uint8_t hash[32];
ret = sha256(data_g, 128, hash);
if (ret) {
printf("sha256 returned %d\n", ret);
return ret;
}
if (memcmp(hash, hash_g, 32) != 0) {
printf("ERR: Calculated hash is not correct\n");
return 1;
}
printf("sha256 correcly calculated\n");
#endif
#ifdef WITH_VERIFICATION
ret = verify(pub_key_g, sig_g, hash_g, 32);
if (ret) {
printf("verify returned %d\n", ret);
return ret;
}
printf("Verification passed\n");
#endif
return 0;
}
#endif