File tree 1 file changed +22
-23
lines changed
1 file changed +22
-23
lines changed Original file line number Diff line number Diff line change @@ -173,48 +173,47 @@ int ECCX08Class::random(byte data[], size_t length)
173
173
174
174
int ECCX08Class::generatePrivateKey (int slot, byte publicKey[])
175
175
{
176
+ int result = 0 ;
177
+
176
178
if (!wakeup ()) {
177
179
return 0 ;
178
180
}
179
181
180
- if (!sendCommand (0x40 , 0x04 , slot)) {
181
- return 0 ;
182
- }
183
-
184
- delay (115 );
182
+ if (sendCommand (0x40 , 0x04 , slot)) {
183
+ delay (115 );
185
184
186
- if (!receiveResponse (publicKey, 64 )) {
187
- return 0 ;
185
+ if (receiveResponse (publicKey, 64 )) {
186
+ delay (1 );
187
+ result = 1 ;
188
+ }
188
189
}
189
190
190
- delay (1 );
191
-
192
191
idle ();
193
-
194
- return 1 ;
192
+ return result;
195
193
}
196
194
197
195
int ECCX08Class::generatePublicKey (int slot, byte publicKey[])
198
196
{
199
- if (!wakeup ()) {
200
- return 0 ;
201
- }
202
-
203
- if (!sendCommand (0x40 , 0x00 , slot)) {
197
+ int result = 0 ;
198
+
199
+ if (!wakeup ())
200
+ {
204
201
return 0 ;
205
202
}
206
203
207
- delay (115 );
204
+ if (sendCommand (0x40 , 0x00 , slot))
205
+ {
206
+ delay (115 );
208
207
209
- if (!receiveResponse (publicKey, 64 )) {
210
- return 0 ;
208
+ if (receiveResponse (publicKey, 64 ))
209
+ {
210
+ delay (1 );
211
+ result = 1 ;
212
+ }
211
213
}
212
214
213
- delay (1 );
214
-
215
215
idle ();
216
-
217
- return 1 ;
216
+ return result;
218
217
}
219
218
220
219
int ECCX08Class::ecdsaVerify (const byte message[], const byte signature[], const byte pubkey[])
You can’t perform that action at this time.
0 commit comments