diff options
author | beck <> | 2017-01-29 17:49:23 +0000 |
---|---|---|
committer | beck <> | 2017-01-29 17:49:23 +0000 |
commit | 957b11334a7afb14537322f0e4795b2e368b3f59 (patch) | |
tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/asn1/tasn_dec.c | |
parent | df96e020e729c6c37a8c7fe311fdd1fe6a8718c5 (diff) | |
download | openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.gz openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.bz2 openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.zip |
Send the function codes from the error functions to the bit bucket,
as was done earlier in libssl. Thanks inoguchi@ for noticing
libssl had more reacharounds into this.
ok jsing@ inoguchi@
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_dec.c')
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_dec.c | 146 |
1 files changed, 53 insertions, 93 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index de78164995..3f680c60fd 100644 --- a/src/lib/libcrypto/asn1/tasn_dec.c +++ b/src/lib/libcrypto/asn1/tasn_dec.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tasn_dec.c,v 1.33 2016/12/30 16:04:34 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_dec.c,v 1.34 2017/01/29 17:49:22 beck Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -189,8 +189,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
189 | * template itself. | 189 | * template itself. |
190 | */ | 190 | */ |
191 | if ((tag != -1) || opt) { | 191 | if ((tag != -1) || opt) { |
192 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 192 | ASN1error(ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE); |
193 | ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE); | ||
194 | goto err; | 193 | goto err; |
195 | } | 194 | } |
196 | return asn1_template_ex_d2i(pval, in, len, | 195 | return asn1_template_ex_d2i(pval, in, len, |
@@ -206,8 +205,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
206 | ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL, | 205 | ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL, |
207 | &p, len, -1, 0, 1, ctx); | 206 | &p, len, -1, 0, 1, ctx); |
208 | if (!ret) { | 207 | if (!ret) { |
209 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 208 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
210 | ERR_R_NESTED_ASN1_ERROR); | ||
211 | goto err; | 209 | goto err; |
212 | } | 210 | } |
213 | 211 | ||
@@ -216,8 +214,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
216 | /* If OPTIONAL, assume this is OK */ | 214 | /* If OPTIONAL, assume this is OK */ |
217 | if (opt) | 215 | if (opt) |
218 | return -1; | 216 | return -1; |
219 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 217 | ASN1error(ASN1_R_MSTRING_NOT_UNIVERSAL); |
220 | ASN1_R_MSTRING_NOT_UNIVERSAL); | ||
221 | goto err; | 218 | goto err; |
222 | } | 219 | } |
223 | /* Check tag matches bit map */ | 220 | /* Check tag matches bit map */ |
@@ -225,8 +222,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
225 | /* If OPTIONAL, assume this is OK */ | 222 | /* If OPTIONAL, assume this is OK */ |
226 | if (opt) | 223 | if (opt) |
227 | return -1; | 224 | return -1; |
228 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 225 | ASN1error(ASN1_R_MSTRING_WRONG_TAG); |
229 | ASN1_R_MSTRING_WRONG_TAG); | ||
230 | goto err; | 226 | goto err; |
231 | } | 227 | } |
232 | return asn1_d2i_ex_primitive(pval, in, len, | 228 | return asn1_d2i_ex_primitive(pval, in, len, |
@@ -252,8 +248,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
252 | asn1_set_choice_selector(pval, -1, it); | 248 | asn1_set_choice_selector(pval, -1, it); |
253 | } | 249 | } |
254 | } else if (!ASN1_item_ex_new(pval, it)) { | 250 | } else if (!ASN1_item_ex_new(pval, it)) { |
255 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 251 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
256 | ERR_R_NESTED_ASN1_ERROR); | ||
257 | goto err; | 252 | goto err; |
258 | } | 253 | } |
259 | /* CHOICE type, try each possibility in turn */ | 254 | /* CHOICE type, try each possibility in turn */ |
@@ -272,8 +267,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
272 | break; | 267 | break; |
273 | /* Otherwise must be an ASN1 parsing error */ | 268 | /* Otherwise must be an ASN1 parsing error */ |
274 | errtt = tt; | 269 | errtt = tt; |
275 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 270 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
276 | ERR_R_NESTED_ASN1_ERROR); | ||
277 | goto err; | 271 | goto err; |
278 | } | 272 | } |
279 | 273 | ||
@@ -285,8 +279,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
285 | ASN1_item_ex_free(pval, it); | 279 | ASN1_item_ex_free(pval, it); |
286 | return -1; | 280 | return -1; |
287 | } | 281 | } |
288 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 282 | ASN1error(ASN1_R_NO_MATCHING_CHOICE_TYPE); |
289 | ASN1_R_NO_MATCHING_CHOICE_TYPE); | ||
290 | goto err; | 283 | goto err; |
291 | } | 284 | } |
292 | 285 | ||
@@ -310,8 +303,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
310 | ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst, | 303 | ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst, |
311 | &p, len, tag, aclass, opt, ctx); | 304 | &p, len, tag, aclass, opt, ctx); |
312 | if (!ret) { | 305 | if (!ret) { |
313 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 306 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
314 | ERR_R_NESTED_ASN1_ERROR); | ||
315 | goto err; | 307 | goto err; |
316 | } else if (ret == -1) | 308 | } else if (ret == -1) |
317 | return -1; | 309 | return -1; |
@@ -323,14 +315,12 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
323 | else | 315 | else |
324 | seq_nolen = seq_eoc; | 316 | seq_nolen = seq_eoc; |
325 | if (!cst) { | 317 | if (!cst) { |
326 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 318 | ASN1error(ASN1_R_SEQUENCE_NOT_CONSTRUCTED); |
327 | ASN1_R_SEQUENCE_NOT_CONSTRUCTED); | ||
328 | goto err; | 319 | goto err; |
329 | } | 320 | } |
330 | 321 | ||
331 | if (!*pval && !ASN1_item_ex_new(pval, it)) { | 322 | if (!*pval && !ASN1_item_ex_new(pval, it)) { |
332 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 323 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
333 | ERR_R_NESTED_ASN1_ERROR); | ||
334 | goto err; | 324 | goto err; |
335 | } | 325 | } |
336 | 326 | ||
@@ -364,8 +354,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
364 | q = p; | 354 | q = p; |
365 | if (asn1_check_eoc(&p, len)) { | 355 | if (asn1_check_eoc(&p, len)) { |
366 | if (!seq_eoc) { | 356 | if (!seq_eoc) { |
367 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 357 | ASN1error(ASN1_R_UNEXPECTED_EOC); |
368 | ASN1_R_UNEXPECTED_EOC); | ||
369 | goto err; | 358 | goto err; |
370 | } | 359 | } |
371 | len -= p - q; | 360 | len -= p - q; |
@@ -404,13 +393,12 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
404 | 393 | ||
405 | /* Check for EOC if expecting one */ | 394 | /* Check for EOC if expecting one */ |
406 | if (seq_eoc && !asn1_check_eoc(&p, len)) { | 395 | if (seq_eoc && !asn1_check_eoc(&p, len)) { |
407 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MISSING_EOC); | 396 | ASN1error(ASN1_R_MISSING_EOC); |
408 | goto err; | 397 | goto err; |
409 | } | 398 | } |
410 | /* Check all data read */ | 399 | /* Check all data read */ |
411 | if (!seq_nolen && len) { | 400 | if (!seq_nolen && len) { |
412 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 401 | ASN1error(ASN1_R_SEQUENCE_LENGTH_MISMATCH); |
413 | ASN1_R_SEQUENCE_LENGTH_MISMATCH); | ||
414 | goto err; | 402 | goto err; |
415 | } | 403 | } |
416 | 404 | ||
@@ -429,14 +417,13 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
429 | ASN1_template_free(pseqval, seqtt); | 417 | ASN1_template_free(pseqval, seqtt); |
430 | } else { | 418 | } else { |
431 | errtt = seqtt; | 419 | errtt = seqtt; |
432 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, | 420 | ASN1error(ASN1_R_FIELD_MISSING); |
433 | ASN1_R_FIELD_MISSING); | ||
434 | goto err; | 421 | goto err; |
435 | } | 422 | } |
436 | } | 423 | } |
437 | /* Save encoding */ | 424 | /* Save encoding */ |
438 | if (!asn1_enc_save(pval, *in, p - *in, it)) { | 425 | if (!asn1_enc_save(pval, *in, p - *in, it)) { |
439 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_MALLOC_FAILURE); | 426 | ASN1error(ERR_R_MALLOC_FAILURE); |
440 | goto auxerr; | 427 | goto auxerr; |
441 | } | 428 | } |
442 | *in = p; | 429 | *in = p; |
@@ -449,7 +436,7 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
449 | } | 436 | } |
450 | 437 | ||
451 | auxerr: | 438 | auxerr: |
452 | ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_AUX_ERROR); | 439 | ASN1error(ASN1_R_AUX_ERROR); |
453 | err: | 440 | err: |
454 | if (combine == 0) | 441 | if (combine == 0) |
455 | ASN1_item_ex_free(pval, it); | 442 | ASN1_item_ex_free(pval, it); |
@@ -493,21 +480,18 @@ asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, | |||
493 | &p, inlen, tt->tag, aclass, opt, ctx); | 480 | &p, inlen, tt->tag, aclass, opt, ctx); |
494 | q = p; | 481 | q = p; |
495 | if (!ret) { | 482 | if (!ret) { |
496 | ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, | 483 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
497 | ERR_R_NESTED_ASN1_ERROR); | ||
498 | return 0; | 484 | return 0; |
499 | } else if (ret == -1) | 485 | } else if (ret == -1) |
500 | return -1; | 486 | return -1; |
501 | if (!cst) { | 487 | if (!cst) { |
502 | ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, | 488 | ASN1error(ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED); |
503 | ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED); | ||
504 | return 0; | 489 | return 0; |
505 | } | 490 | } |
506 | /* We've found the field so it can't be OPTIONAL now */ | 491 | /* We've found the field so it can't be OPTIONAL now */ |
507 | ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx); | 492 | ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx); |
508 | if (!ret) { | 493 | if (!ret) { |
509 | ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, | 494 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
510 | ERR_R_NESTED_ASN1_ERROR); | ||
511 | return 0; | 495 | return 0; |
512 | } | 496 | } |
513 | /* We read the field in OK so update length */ | 497 | /* We read the field in OK so update length */ |
@@ -515,16 +499,14 @@ asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, | |||
515 | if (exp_eoc) { | 499 | if (exp_eoc) { |
516 | /* If NDEF we must have an EOC here */ | 500 | /* If NDEF we must have an EOC here */ |
517 | if (!asn1_check_eoc(&p, len)) { | 501 | if (!asn1_check_eoc(&p, len)) { |
518 | ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, | 502 | ASN1error(ASN1_R_MISSING_EOC); |
519 | ASN1_R_MISSING_EOC); | ||
520 | goto err; | 503 | goto err; |
521 | } | 504 | } |
522 | } else { | 505 | } else { |
523 | /* Otherwise we must hit the EXPLICIT tag end or its | 506 | /* Otherwise we must hit the EXPLICIT tag end or its |
524 | * an error */ | 507 | * an error */ |
525 | if (len) { | 508 | if (len) { |
526 | ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, | 509 | ASN1error(ASN1_R_EXPLICIT_LENGTH_MISMATCH); |
527 | ASN1_R_EXPLICIT_LENGTH_MISMATCH); | ||
528 | goto err; | 510 | goto err; |
529 | } | 511 | } |
530 | } | 512 | } |
@@ -574,8 +556,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, | |||
574 | ret = asn1_check_tlen(&len, NULL, NULL, &sk_eoc, NULL, | 556 | ret = asn1_check_tlen(&len, NULL, NULL, &sk_eoc, NULL, |
575 | &p, len, sktag, skaclass, opt, ctx); | 557 | &p, len, sktag, skaclass, opt, ctx); |
576 | if (!ret) { | 558 | if (!ret) { |
577 | ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, | 559 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
578 | ERR_R_NESTED_ASN1_ERROR); | ||
579 | return 0; | 560 | return 0; |
580 | } else if (ret == -1) | 561 | } else if (ret == -1) |
581 | return -1; | 562 | return -1; |
@@ -594,8 +575,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, | |||
594 | } | 575 | } |
595 | 576 | ||
596 | if (!*val) { | 577 | if (!*val) { |
597 | ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, | 578 | ASN1error(ERR_R_MALLOC_FAILURE); |
598 | ERR_R_MALLOC_FAILURE); | ||
599 | goto err; | 579 | goto err; |
600 | } | 580 | } |
601 | 581 | ||
@@ -606,8 +586,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, | |||
606 | /* See if EOC found */ | 586 | /* See if EOC found */ |
607 | if (asn1_check_eoc(&p, len)) { | 587 | if (asn1_check_eoc(&p, len)) { |
608 | if (!sk_eoc) { | 588 | if (!sk_eoc) { |
609 | ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, | 589 | ASN1error(ASN1_R_UNEXPECTED_EOC); |
610 | ASN1_R_UNEXPECTED_EOC); | ||
611 | goto err; | 590 | goto err; |
612 | } | 591 | } |
613 | len -= p - q; | 592 | len -= p - q; |
@@ -617,21 +596,18 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, | |||
617 | skfield = NULL; | 596 | skfield = NULL; |
618 | if (!ASN1_item_ex_d2i(&skfield, &p, len, | 597 | if (!ASN1_item_ex_d2i(&skfield, &p, len, |
619 | tt->item, -1, 0, 0, ctx)) { | 598 | tt->item, -1, 0, 0, ctx)) { |
620 | ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, | 599 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
621 | ERR_R_NESTED_ASN1_ERROR); | ||
622 | goto err; | 600 | goto err; |
623 | } | 601 | } |
624 | len -= p - q; | 602 | len -= p - q; |
625 | if (!sk_ASN1_VALUE_push((STACK_OF(ASN1_VALUE) *)*val, | 603 | if (!sk_ASN1_VALUE_push((STACK_OF(ASN1_VALUE) *)*val, |
626 | skfield)) { | 604 | skfield)) { |
627 | ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, | 605 | ASN1error(ERR_R_MALLOC_FAILURE); |
628 | ERR_R_MALLOC_FAILURE); | ||
629 | goto err; | 606 | goto err; |
630 | } | 607 | } |
631 | } | 608 | } |
632 | if (sk_eoc) { | 609 | if (sk_eoc) { |
633 | ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, | 610 | ASN1error(ASN1_R_MISSING_EOC); |
634 | ASN1_R_MISSING_EOC); | ||
635 | goto err; | 611 | goto err; |
636 | } | 612 | } |
637 | } else if (flags & ASN1_TFLG_IMPTAG) { | 613 | } else if (flags & ASN1_TFLG_IMPTAG) { |
@@ -639,8 +615,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, | |||
639 | ret = ASN1_item_ex_d2i(val, &p, len, | 615 | ret = ASN1_item_ex_d2i(val, &p, len, |
640 | tt->item, tt->tag, aclass, opt, ctx); | 616 | tt->item, tt->tag, aclass, opt, ctx); |
641 | if (!ret) { | 617 | if (!ret) { |
642 | ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, | 618 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
643 | ERR_R_NESTED_ASN1_ERROR); | ||
644 | goto err; | 619 | goto err; |
645 | } else if (ret == -1) | 620 | } else if (ret == -1) |
646 | return -1; | 621 | return -1; |
@@ -649,8 +624,7 @@ asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, | |||
649 | ret = ASN1_item_ex_d2i(val, &p, len, tt->item, | 624 | ret = ASN1_item_ex_d2i(val, &p, len, tt->item, |
650 | -1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx); | 625 | -1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx); |
651 | if (!ret) { | 626 | if (!ret) { |
652 | ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, | 627 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
653 | ERR_R_NESTED_ASN1_ERROR); | ||
654 | goto err; | 628 | goto err; |
655 | } else if (ret == -1) | 629 | } else if (ret == -1) |
656 | return -1; | 630 | return -1; |
@@ -681,7 +655,7 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, | |||
681 | buf.data = NULL; | 655 | buf.data = NULL; |
682 | 656 | ||
683 | if (!pval) { | 657 | if (!pval) { |
684 | ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL); | 658 | ASN1error(ASN1_R_ILLEGAL_NULL); |
685 | return 0; /* Should never happen */ | 659 | return 0; /* Should never happen */ |
686 | } | 660 | } |
687 | 661 | ||
@@ -695,21 +669,18 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, | |||
695 | /* If type is ANY need to figure out type from tag */ | 669 | /* If type is ANY need to figure out type from tag */ |
696 | unsigned char oclass; | 670 | unsigned char oclass; |
697 | if (tag >= 0) { | 671 | if (tag >= 0) { |
698 | ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, | 672 | ASN1error(ASN1_R_ILLEGAL_TAGGED_ANY); |
699 | ASN1_R_ILLEGAL_TAGGED_ANY); | ||
700 | return 0; | 673 | return 0; |
701 | } | 674 | } |
702 | if (opt) { | 675 | if (opt) { |
703 | ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, | 676 | ASN1error(ASN1_R_ILLEGAL_OPTIONAL_ANY); |
704 | ASN1_R_ILLEGAL_OPTIONAL_ANY); | ||
705 | return 0; | 677 | return 0; |
706 | } | 678 | } |
707 | p = *in; | 679 | p = *in; |
708 | ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL, | 680 | ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL, |
709 | &p, inlen, -1, 0, 0, ctx); | 681 | &p, inlen, -1, 0, 0, ctx); |
710 | if (!ret) { | 682 | if (!ret) { |
711 | ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, | 683 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
712 | ERR_R_NESTED_ASN1_ERROR); | ||
713 | return 0; | 684 | return 0; |
714 | } | 685 | } |
715 | if (oclass != V_ASN1_UNIVERSAL) | 686 | if (oclass != V_ASN1_UNIVERSAL) |
@@ -724,7 +695,7 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, | |||
724 | ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst, | 695 | ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst, |
725 | &p, inlen, tag, aclass, opt, ctx); | 696 | &p, inlen, tag, aclass, opt, ctx); |
726 | if (!ret) { | 697 | if (!ret) { |
727 | ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR); | 698 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
728 | return 0; | 699 | return 0; |
729 | } else if (ret == -1) | 700 | } else if (ret == -1) |
730 | return -1; | 701 | return -1; |
@@ -740,8 +711,7 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, | |||
740 | } | 711 | } |
741 | /* SEQUENCE and SET must be constructed */ | 712 | /* SEQUENCE and SET must be constructed */ |
742 | else if (!cst) { | 713 | else if (!cst) { |
743 | ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, | 714 | ASN1error(ASN1_R_TYPE_NOT_CONSTRUCTED); |
744 | ASN1_R_TYPE_NOT_CONSTRUCTED); | ||
745 | return 0; | 715 | return 0; |
746 | } | 716 | } |
747 | 717 | ||
@@ -770,8 +740,7 @@ asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, | |||
770 | len = buf.length; | 740 | len = buf.length; |
771 | /* Append a final null to string */ | 741 | /* Append a final null to string */ |
772 | if (!BUF_MEM_grow_clean(&buf, len + 1)) { | 742 | if (!BUF_MEM_grow_clean(&buf, len + 1)) { |
773 | ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, | 743 | ASN1error(ERR_R_MALLOC_FAILURE); |
774 | ERR_R_MALLOC_FAILURE); | ||
775 | return 0; | 744 | return 0; |
776 | } | 745 | } |
777 | buf.data[len] = 0; | 746 | buf.data[len] = 0; |
@@ -836,8 +805,7 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, | |||
836 | 805 | ||
837 | case V_ASN1_NULL: | 806 | case V_ASN1_NULL: |
838 | if (len) { | 807 | if (len) { |
839 | ASN1err(ASN1_F_ASN1_EX_C2I, | 808 | ASN1error(ASN1_R_NULL_IS_WRONG_LENGTH); |
840 | ASN1_R_NULL_IS_WRONG_LENGTH); | ||
841 | goto err; | 809 | goto err; |
842 | } | 810 | } |
843 | *pval = (ASN1_VALUE *)1; | 811 | *pval = (ASN1_VALUE *)1; |
@@ -845,8 +813,7 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, | |||
845 | 813 | ||
846 | case V_ASN1_BOOLEAN: | 814 | case V_ASN1_BOOLEAN: |
847 | if (len != 1) { | 815 | if (len != 1) { |
848 | ASN1err(ASN1_F_ASN1_EX_C2I, | 816 | ASN1error(ASN1_R_BOOLEAN_IS_WRONG_LENGTH); |
849 | ASN1_R_BOOLEAN_IS_WRONG_LENGTH); | ||
850 | goto err; | 817 | goto err; |
851 | } else { | 818 | } else { |
852 | ASN1_BOOLEAN *tbool; | 819 | ASN1_BOOLEAN *tbool; |
@@ -888,21 +855,18 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, | |||
888 | case V_ASN1_SEQUENCE: | 855 | case V_ASN1_SEQUENCE: |
889 | default: | 856 | default: |
890 | if (utype == V_ASN1_BMPSTRING && (len & 1)) { | 857 | if (utype == V_ASN1_BMPSTRING && (len & 1)) { |
891 | ASN1err(ASN1_F_ASN1_EX_C2I, | 858 | ASN1error(ASN1_R_BMPSTRING_IS_WRONG_LENGTH); |
892 | ASN1_R_BMPSTRING_IS_WRONG_LENGTH); | ||
893 | goto err; | 859 | goto err; |
894 | } | 860 | } |
895 | if (utype == V_ASN1_UNIVERSALSTRING && (len & 3)) { | 861 | if (utype == V_ASN1_UNIVERSALSTRING && (len & 3)) { |
896 | ASN1err(ASN1_F_ASN1_EX_C2I, | 862 | ASN1error(ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH); |
897 | ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH); | ||
898 | goto err; | 863 | goto err; |
899 | } | 864 | } |
900 | /* All based on ASN1_STRING and handled the same */ | 865 | /* All based on ASN1_STRING and handled the same */ |
901 | if (!*pval) { | 866 | if (!*pval) { |
902 | stmp = ASN1_STRING_type_new(utype); | 867 | stmp = ASN1_STRING_type_new(utype); |
903 | if (!stmp) { | 868 | if (!stmp) { |
904 | ASN1err(ASN1_F_ASN1_EX_C2I, | 869 | ASN1error(ERR_R_MALLOC_FAILURE); |
905 | ERR_R_MALLOC_FAILURE); | ||
906 | goto err; | 870 | goto err; |
907 | } | 871 | } |
908 | *pval = (ASN1_VALUE *)stmp; | 872 | *pval = (ASN1_VALUE *)stmp; |
@@ -918,8 +882,7 @@ asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, | |||
918 | *free_cont = 0; | 882 | *free_cont = 0; |
919 | } else { | 883 | } else { |
920 | if (!ASN1_STRING_set(stmp, cont, len)) { | 884 | if (!ASN1_STRING_set(stmp, cont, len)) { |
921 | ASN1err(ASN1_F_ASN1_EX_C2I, | 885 | ASN1error(ERR_R_MALLOC_FAILURE); |
922 | ERR_R_MALLOC_FAILURE); | ||
923 | ASN1_STRING_free(stmp); | 886 | ASN1_STRING_free(stmp); |
924 | *pval = NULL; | 887 | *pval = NULL; |
925 | goto err; | 888 | goto err; |
@@ -979,7 +942,7 @@ asn1_find_end(const unsigned char **in, long len, char inf) | |||
979 | /* Just read in a header: only care about the length */ | 942 | /* Just read in a header: only care about the length */ |
980 | if (!asn1_check_tlen(&plen, NULL, NULL, &inf, NULL, &p, len, | 943 | if (!asn1_check_tlen(&plen, NULL, NULL, &inf, NULL, &p, len, |
981 | -1, 0, 0, NULL)) { | 944 | -1, 0, 0, NULL)) { |
982 | ASN1err(ASN1_F_ASN1_FIND_END, ERR_R_NESTED_ASN1_ERROR); | 945 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
983 | return 0; | 946 | return 0; |
984 | } | 947 | } |
985 | if (inf) | 948 | if (inf) |
@@ -989,7 +952,7 @@ asn1_find_end(const unsigned char **in, long len, char inf) | |||
989 | len -= p - q; | 952 | len -= p - q; |
990 | } | 953 | } |
991 | if (expected_eoc) { | 954 | if (expected_eoc) { |
992 | ASN1err(ASN1_F_ASN1_FIND_END, ASN1_R_MISSING_EOC); | 955 | ASN1error(ASN1_R_MISSING_EOC); |
993 | return 0; | 956 | return 0; |
994 | } | 957 | } |
995 | *in = p; | 958 | *in = p; |
@@ -1033,8 +996,7 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, | |||
1033 | /* EOC is illegal outside indefinite length | 996 | /* EOC is illegal outside indefinite length |
1034 | * constructed form */ | 997 | * constructed form */ |
1035 | if (!inf) { | 998 | if (!inf) { |
1036 | ASN1err(ASN1_F_ASN1_COLLECT, | 999 | ASN1error(ASN1_R_UNEXPECTED_EOC); |
1037 | ASN1_R_UNEXPECTED_EOC); | ||
1038 | return 0; | 1000 | return 0; |
1039 | } | 1001 | } |
1040 | inf = 0; | 1002 | inf = 0; |
@@ -1043,15 +1005,14 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, | |||
1043 | 1005 | ||
1044 | if (!asn1_check_tlen(&plen, NULL, NULL, &ininf, &cst, &p, | 1006 | if (!asn1_check_tlen(&plen, NULL, NULL, &ininf, &cst, &p, |
1045 | len, tag, aclass, 0, NULL)) { | 1007 | len, tag, aclass, 0, NULL)) { |
1046 | ASN1err(ASN1_F_ASN1_COLLECT, ERR_R_NESTED_ASN1_ERROR); | 1008 | ASN1error(ERR_R_NESTED_ASN1_ERROR); |
1047 | return 0; | 1009 | return 0; |
1048 | } | 1010 | } |
1049 | 1011 | ||
1050 | /* If indefinite length constructed update max length */ | 1012 | /* If indefinite length constructed update max length */ |
1051 | if (cst) { | 1013 | if (cst) { |
1052 | if (depth >= ASN1_MAX_STRING_NEST) { | 1014 | if (depth >= ASN1_MAX_STRING_NEST) { |
1053 | ASN1err(ASN1_F_ASN1_COLLECT, | 1015 | ASN1error(ASN1_R_NESTED_ASN1_STRING); |
1054 | ASN1_R_NESTED_ASN1_STRING); | ||
1055 | return 0; | 1016 | return 0; |
1056 | } | 1017 | } |
1057 | if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, | 1018 | if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, |
@@ -1062,7 +1023,7 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, | |||
1062 | len -= p - q; | 1023 | len -= p - q; |
1063 | } | 1024 | } |
1064 | if (inf) { | 1025 | if (inf) { |
1065 | ASN1err(ASN1_F_ASN1_COLLECT, ASN1_R_MISSING_EOC); | 1026 | ASN1error(ASN1_R_MISSING_EOC); |
1066 | return 0; | 1027 | return 0; |
1067 | } | 1028 | } |
1068 | *in = p; | 1029 | *in = p; |
@@ -1076,7 +1037,7 @@ collect_data(BUF_MEM *buf, const unsigned char **p, long plen) | |||
1076 | if (buf) { | 1037 | if (buf) { |
1077 | len = buf->length; | 1038 | len = buf->length; |
1078 | if (!BUF_MEM_grow_clean(buf, len + plen)) { | 1039 | if (!BUF_MEM_grow_clean(buf, len + plen)) { |
1079 | ASN1err(ASN1_F_COLLECT_DATA, ERR_R_MALLOC_FAILURE); | 1040 | ASN1error(ERR_R_MALLOC_FAILURE); |
1080 | return 0; | 1041 | return 0; |
1081 | } | 1042 | } |
1082 | memcpy(buf->data + len, *p, plen); | 1043 | memcpy(buf->data + len, *p, plen); |
@@ -1141,8 +1102,7 @@ asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, | |||
1141 | * header can't exceed total amount of data available. | 1102 | * header can't exceed total amount of data available. |
1142 | */ | 1103 | */ |
1143 | if (!(i & 0x81) && ((plen + ctx->hdrlen) > len)) { | 1104 | if (!(i & 0x81) && ((plen + ctx->hdrlen) > len)) { |
1144 | ASN1err(ASN1_F_ASN1_CHECK_TLEN, | 1105 | ASN1error(ASN1_R_TOO_LONG); |
1145 | ASN1_R_TOO_LONG); | ||
1146 | asn1_tlc_clear(ctx); | 1106 | asn1_tlc_clear(ctx); |
1147 | return 0; | 1107 | return 0; |
1148 | } | 1108 | } |
@@ -1150,7 +1110,7 @@ asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, | |||
1150 | } | 1110 | } |
1151 | 1111 | ||
1152 | if (i & 0x80) { | 1112 | if (i & 0x80) { |
1153 | ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_BAD_OBJECT_HEADER); | 1113 | ASN1error(ASN1_R_BAD_OBJECT_HEADER); |
1154 | asn1_tlc_clear(ctx); | 1114 | asn1_tlc_clear(ctx); |
1155 | return 0; | 1115 | return 0; |
1156 | } | 1116 | } |
@@ -1162,7 +1122,7 @@ asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, | |||
1162 | if (opt) | 1122 | if (opt) |
1163 | return -1; | 1123 | return -1; |
1164 | asn1_tlc_clear(ctx); | 1124 | asn1_tlc_clear(ctx); |
1165 | ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_WRONG_TAG); | 1125 | ASN1error(ASN1_R_WRONG_TAG); |
1166 | return 0; | 1126 | return 0; |
1167 | } | 1127 | } |
1168 | /* We have a tag and class match: | 1128 | /* We have a tag and class match: |