-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdemo.c
51 lines (45 loc) · 1.31 KB
/
demo.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
46
47
48
49
50
51
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "p256.h"
static void test(void)
{
char *msg = "hi\n";
unsigned char sig[64] = {
/* r */
0x6c,0x98,0xb6,0x80,0x9f,0x6e,0x2c,0x73,
0x95,0xc6,0xc9,0xf1,0x8a,0x30,0x28,0x21,
0xc5,0xf6,0x03,0x69,0xd3,0xab,0xd1,0x92,
0xe9,0xe5,0xc4,0xf6,0x07,0xd5,0x18,0xd3,
/* s */
0x4a,0x9d,0x74,0xa0,0xf4,0x4c,0x61,0x03,
0x13,0x30,0xa7,0xe3,0xf2,0x79,0x08,0xf5,
0xc5,0x89,0xfe,0x64,0x27,0xdb,0x7c,0x3f,
0x3f,0x74,0x09,0x55,0x9e,0x50,0x0c,0x3c
};
const unsigned char pk[] = {
/* constant */ 0x04,
/* x-coord */
0x56,0x16,0xab,0x0d,0xf8,0x5a,0xc8,0x9c,
0xc8,0x53,0xb8,0x4e,0x53,0xca,0xb5,0x35,
0x22,0x4a,0x7d,0xbc,0x39,0x27,0x02,0x76,
0xdd,0xa8,0x00,0x85,0x3e,0xe8,0xae,0x9b,
/* y-coord */
0x68,0xb9,0x53,0x59,0x70,0x4f,0x87,0xe0,
0x23,0x42,0x4d,0x5d,0x84,0x2f,0x08,0x21,
0xd8,0x8c,0xe0,0x1f,0xb6,0xa8,0x1a,0x6a,
0x1c,0x87,0x8a,0x81,0x13,0x0c,0x61,0x68
};
if (p256_verify((uint8_t *)msg, strlen(msg), sig, pk) != P256_SUCCESS) {
printf("error\n");
} else {
printf("OK\n");
}
return;
}
int main(int argc, char **argv)
{
(void)argc;
(void)argv;
test();
}