1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __ATMEL_ECC_H__
20#define __ATMEL_ECC_H__
21
22#define ATMEL_ECC_PRIORITY 300
23
24#define COMMAND 0x03
25#define SLEEP_TOKEN 0x01
26#define WAKE_TOKEN_MAX_SIZE 8
27
28
29#define WORD_ADDR_SIZE 1
30#define COUNT_SIZE 1
31#define CRC_SIZE 2
32#define CMD_OVERHEAD_SIZE (COUNT_SIZE + CRC_SIZE)
33
34
35#define ATMEL_ECC_NIST_P256_N_SIZE 32
36#define ATMEL_ECC_PUBKEY_SIZE (2 * ATMEL_ECC_NIST_P256_N_SIZE)
37
38#define STATUS_RSP_SIZE 4
39#define ECDH_RSP_SIZE (32 + CMD_OVERHEAD_SIZE)
40#define GENKEY_RSP_SIZE (ATMEL_ECC_PUBKEY_SIZE + \
41 CMD_OVERHEAD_SIZE)
42#define READ_RSP_SIZE (4 + CMD_OVERHEAD_SIZE)
43#define MAX_RSP_SIZE GENKEY_RSP_SIZE
44
45
46
47
48
49
50
51
52
53
54
55
56
57struct atmel_ecc_cmd {
58 u8 word_addr;
59 u8 count;
60 u8 opcode;
61 u8 param1;
62 u16 param2;
63 u8 data[MAX_RSP_SIZE];
64 u8 msecs;
65 u16 rxsize;
66} __packed;
67
68
69#define STATUS_SIZE 0x04
70#define STATUS_NOERR 0x00
71#define STATUS_WAKE_SUCCESSFUL 0x11
72
73static const struct {
74 u8 value;
75 const char *error_text;
76} error_list[] = {
77 { 0x01, "CheckMac or Verify miscompare" },
78 { 0x03, "Parse Error" },
79 { 0x05, "ECC Fault" },
80 { 0x0F, "Execution Error" },
81 { 0xEE, "Watchdog about to expire" },
82 { 0xFF, "CRC or other communication error" },
83};
84
85
86#define CONFIG_ZONE 0
87
88
89#define RSP_DATA_IDX 1
90#define DATA_SLOT_2 2
91
92
93#define DEVICE_LOCK_ADDR 0x15
94#define LOCK_VALUE_IDX (RSP_DATA_IDX + 2)
95#define LOCK_CONFIG_IDX (RSP_DATA_IDX + 3)
96
97
98
99
100
101#define TWHI_MIN 1500
102#define TWHI_MAX 1550
103
104
105#define TWLO_USEC 60
106
107
108#define MAX_EXEC_TIME_ECDH 58
109#define MAX_EXEC_TIME_GENKEY 115
110#define MAX_EXEC_TIME_READ 1
111
112
113#define OPCODE_ECDH 0x43
114#define OPCODE_GENKEY 0x40
115#define OPCODE_READ 0x02
116
117
118#define READ_COUNT 7
119
120
121#define GENKEY_COUNT 7
122#define GENKEY_MODE_PRIVATE 0x04
123
124
125#define ECDH_COUNT 71
126#define ECDH_PREFIX_MODE 0x00
127
128#endif
129