diff options
| author | jsing <> | 2021-12-25 08:52:44 +0000 |
|---|---|---|
| committer | jsing <> | 2021-12-25 08:52:44 +0000 |
| commit | dec42f5ec7fdeaf3f4c15382618eec327e1c2a1c (patch) | |
| tree | deb13cf3156e23b9aed2e7ab7fcc949a90f0b8a0 /src/lib/libcrypto/asn1/a_int.c | |
| parent | b1df5c76791dd5f3fe24f1286cb7598e96a53359 (diff) | |
| download | openbsd-dec42f5ec7fdeaf3f4c15382618eec327e1c2a1c.tar.gz openbsd-dec42f5ec7fdeaf3f4c15382618eec327e1c2a1c.tar.bz2 openbsd-dec42f5ec7fdeaf3f4c15382618eec327e1c2a1c.zip | |
Consolidate code/templates for ASN.1 types.
Where an ASN.1 type has its own file, move the ASN.1 item template and
template related functions into the file.
Discussed with tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_int.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c index 9218a17c11..eac7546eac 100644 --- a/src/lib/libcrypto/asn1/a_int.c +++ b/src/lib/libcrypto/asn1/a_int.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: a_int.c,v 1.36 2021/12/25 07:48:09 jsing Exp $ */ | 1 | /* $OpenBSD: a_int.c,v 1.37 2021/12/25 08:52:44 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -61,10 +61,29 @@ | |||
| 61 | #include <string.h> | 61 | #include <string.h> |
| 62 | 62 | ||
| 63 | #include <openssl/asn1.h> | 63 | #include <openssl/asn1.h> |
| 64 | #include <openssl/asn1t.h> | ||
| 64 | #include <openssl/bn.h> | 65 | #include <openssl/bn.h> |
| 65 | #include <openssl/buffer.h> | 66 | #include <openssl/buffer.h> |
| 66 | #include <openssl/err.h> | 67 | #include <openssl/err.h> |
| 67 | 68 | ||
| 69 | const ASN1_ITEM ASN1_INTEGER_it = { | ||
| 70 | .itype = ASN1_ITYPE_PRIMITIVE, | ||
| 71 | .utype = V_ASN1_INTEGER, | ||
| 72 | .sname = "ASN1_INTEGER", | ||
| 73 | }; | ||
| 74 | |||
| 75 | ASN1_INTEGER * | ||
| 76 | ASN1_INTEGER_new(void) | ||
| 77 | { | ||
| 78 | return (ASN1_INTEGER *)ASN1_item_new(&ASN1_INTEGER_it); | ||
| 79 | } | ||
| 80 | |||
| 81 | void | ||
| 82 | ASN1_INTEGER_free(ASN1_INTEGER *a) | ||
| 83 | { | ||
| 84 | ASN1_item_free((ASN1_VALUE *)a, &ASN1_INTEGER_it); | ||
| 85 | } | ||
| 86 | |||
| 68 | static int | 87 | static int |
| 69 | ASN1_INTEGER_valid(const ASN1_INTEGER *a) | 88 | ASN1_INTEGER_valid(const ASN1_INTEGER *a) |
| 70 | { | 89 | { |
| @@ -567,6 +586,18 @@ err: | |||
| 567 | return (NULL); | 586 | return (NULL); |
| 568 | } | 587 | } |
| 569 | 588 | ||
| 589 | int | ||
| 590 | i2d_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **out) | ||
| 591 | { | ||
| 592 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_INTEGER_it); | ||
| 593 | } | ||
| 594 | |||
| 595 | ASN1_INTEGER * | ||
| 596 | d2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **in, long len) | ||
| 597 | { | ||
| 598 | return (ASN1_INTEGER *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
| 599 | &ASN1_INTEGER_it); | ||
| 600 | } | ||
| 570 | 601 | ||
| 571 | /* This is a version of d2i_ASN1_INTEGER that ignores the sign bit of | 602 | /* This is a version of d2i_ASN1_INTEGER that ignores the sign bit of |
| 572 | * ASN1 integers: some broken software can encode a positive INTEGER | 603 | * ASN1 integers: some broken software can encode a positive INTEGER |
