215 {
216 const unsigned char msg32[32] = {
217 'T', 'h', 'i', 's', ' ', 'i', 's', ' ',
218 'a', ' ', 'v', 'e', 'r', 'y', ' ', 's',
219 'e', 'c', 'r', 'e', 't', ' ', 'm', 'e',
220 's', 's', 'a', 'g', 'e', '.', '.', '.'
221 };
222 const unsigned char sig64[64] = {
223
224
225 0x67, 0xCB, 0x28, 0x5F, 0x9C, 0xD1, 0x94, 0xE8,
226 0x40, 0xD6, 0x29, 0x39, 0x7A, 0xF5, 0x56, 0x96,
227 0x62, 0xFD, 0xE4, 0x46, 0x49, 0x99, 0x59, 0x63,
228 0x17, 0x9A, 0x7D, 0xD1, 0x7B, 0xD2, 0x35, 0x32,
229 0x4B, 0x1B, 0x7D, 0xF3, 0x4C, 0xE1, 0xF6, 0x8E,
230 0x69, 0x4F, 0xF6, 0xF1, 0x1A, 0xC7, 0x51, 0xDD,
231 0x7D, 0xD7, 0x3E, 0x38, 0x7E, 0xE4, 0xFC, 0x86,
232 0x6E, 0x1B, 0xE8, 0xEC, 0xC7, 0xDD, 0x95, 0x57
233 };
235
236 const unsigned char sigb64[64] = {
237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
242 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
245 };
249 int recid;
250
259
260 for (recid = 0; recid < 4; recid++) {
261 int i;
262 int recid2;
263
264 unsigned char sigbder[8] = {0x30, 0x06, 0x02, 0x01, 0x04, 0x02, 0x01, 0x04};
265 unsigned char sigcder_zr[7] = {0x30, 0x05, 0x02, 0x00, 0x02, 0x01, 0x01};
266 unsigned char sigcder_zs[7] = {0x30, 0x05, 0x02, 0x01, 0x01, 0x02, 0x00};
267 unsigned char sigbderalt1[39] = {
268 0x30, 0x25, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00,
269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x04,
273 };
274 unsigned char sigbderalt2[39] = {
275 0x30, 0x25, 0x02, 0x01, 0x04, 0x02, 0x20, 0x00,
276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
280 };
281 unsigned char sigbderalt3[40] = {
282 0x30, 0x26, 0x02, 0x21, 0x00, 0x00, 0x00, 0x00,
283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
286 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x04,
287 };
288 unsigned char sigbderalt4[40] = {
289 0x30, 0x26, 0x02, 0x01, 0x04, 0x02, 0x21, 0x00,
290 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
291 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
294 };
295
296 unsigned char sigbderlong[40] = {
297 0x30, 0x26, 0x02, 0x21, 0x00, 0xFF, 0xFF, 0xFF,
298 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
299 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC,
300 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E,
301 0x8C, 0xD0, 0x36, 0x41, 0x45, 0x02, 0x01, 0x04
302 };
307 for (recid2 = 0; recid2 < 4; recid2++) {
311
314 }
315
316
319
324 sigbderalt3[4] = 1;
327 sigbderalt4[7] = 1;
330
331 sigbder[7]++;
334 sigbder[7]--;
337 for(i = 0; i < 8; i++) {
338 int c;
339 unsigned char orig = sigbder[i];
340
341 for (c = 0; c < 256; c++) {
342 if (c == orig ) {
343 continue;
344 }
345 sigbder[i] = c;
347 }
348 sigbder[i] = orig;
349 }
350 }
351
352
353 {
354
355 unsigned char sigcder[8] = {0x30, 0x06, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01};
356 unsigned char sigc64[64] = {
357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
358 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
360 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
363 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
364 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
365 };
371 sigcder[4] = 0;
372 sigc64[31] = 0;
377 sigcder[4] = 1;
378 sigcder[7] = 0;
379 sigc64[31] = 1;
380 sigc64[63] = 0;
385 }
386}
SECP256K1_API int secp256k1_ecdsa_signature_parse_der(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify(const secp256k1_context *ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msghash32, const secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)