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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
================
Target interface
================
The implementations generated by **pyecsca** provide a serial
interface somewhat adhering to the ChipWhisperer_ SimpleSerial interface.
They provide 10 commands (some may be disabled). The commands
all start with a single ASCII lowercase character and then a HEX
payload, like::
i1234deadbeef
Responses from the implementation are formatted in the same way, with
the exception of the :code:`z` response, which is inherent to the SimpleSerial
protocol and is send after every command finishes processing.
Encoding
========
Payloads
--------
Command payloads are either raw, in which case the payload is an unformatted byte string, or they are encoded.
Encoded payloads consist of a tree Name-Length-Value structure.
**Name**: Single lowercase ASCII character, if it has the MSB set, it is a node in
the tree which has children.
**Length**: Single unsigned byte.
**Value**: Either a byte string, if the node is a leaf, or a byte string which
is an encoding of one or several Name-Length-Value structures.
Points
------
Affine points are a structure of two coordinates, :code:`x` and :code:`y`.
Points in implementation defined coordinate systems have different coordinate names.
Integers
--------
Big-endian.
Commands
========
Init PRNG
---------
Seeds the PRNG, which is a KeccakWidth200-SpongePRG, see Keccak XKCP_.
- Character: :code:`i`
- Payload: Raw. Any byte string.
- Response: none
Set curve
---------
Sets the curve.
- Character: :code:`c`
- Payload: Encoded.
- :code:`p` The prime.
- :code:`n` The order of the generator.
- :code:`h` The cofactor.
- :code:`g` The generator, in affine coordinates.
- :code:`i` The neutral point, in the implementation coordinates.
- The curve parameters (e.g. :code:`a`, :code:`b` for Short Weierstrass curves).
- Response: none
Generate keypair
----------------
Generates a keypair, requires a curve setup.
- Character: :code:`g`
- Payload: none
- Response: Two responses.
- :code:`s` The generated private key.
- :code:`w` The generated public key, in affine coordinates.
- Available if the :code:`keygen` option was enabled in the configuration.
Set private key
---------------
Set the private key.
- Character: :code:`s`
- Payload: Encoded.
- :code:`s` The private key.
- Response: none
Set public key
--------------
Set the public key.
- Character: :code:`w`
- Payload: Encoded.
- :code:`w` The public key, in affine coordinates.
- Response: none
Perform scalar multiplication
-----------------------------
Perform scalar multiplication of a point.
- Character: :code:`m`
- Payload: Encoded.
- :code:`s` The scalar.
- :code:`w` The point to multiply.
- Response:
- :code:`w` The resulting point, in the implementation coordinates.
Perform ECDH
------------
Perform ECDH key agreement.
- Character: :code:`e`
- Payload: Encoded.
- :code:`w` The other public key.
- Response:
- :code:`r` The (hashed) shared secret.
- Available if the :code:`ecdh` option was enabled in the configuration.
Sign with ECDSA
---------------
Sign a message with ECDSA.
- Character: :code:`a`
- Payload: Encoded.
- :code:`d` The message to sign.
- Response:
- :code:`s` The signature, ASN.1 DER encoded SEQUENCE of two integers.
- Available if the :code:`ecdsa` option was enabled in the configuration.
Verify with ECDSA
-----------------
Verify a message signature with ECDSA.
- Character: :code:`r`
- Payload: Encoded.
- :code:`d` The message to verify.
- :code:`s` The signature, ASN.1 DER encoded SEQUENCE of two integers.
- Response:
- :code:`r` The verification result, a single byte, :code:`1` on success, :code:`0` on failure.
- Available if the :code:`ecdsa` option was enabled in the configuration.
Debug
-----
Send back the implementation configuration (model and coordinate system).
- Character: :code:`d`
- Payload: none
- Response:
- :code:`d` The model shortname and coordinate system name, ASCII, comma-separated.
Check version
-------------
ChipWhisperer command.
- Character: :code:`v`
- Payload: none
- Response: :code:`z00` always.
.. _ChipWhisperer: https://github.com/newaetech/chipwhisperer
.. _XKCP: https://github.com/XKCP/XKCP
|