summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_int.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_int.c')
-rw-r--r--src/lib/libcrypto/asn1/a_int.c33
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
69const ASN1_ITEM ASN1_INTEGER_it = {
70 .itype = ASN1_ITYPE_PRIMITIVE,
71 .utype = V_ASN1_INTEGER,
72 .sname = "ASN1_INTEGER",
73};
74
75ASN1_INTEGER *
76ASN1_INTEGER_new(void)
77{
78 return (ASN1_INTEGER *)ASN1_item_new(&ASN1_INTEGER_it);
79}
80
81void
82ASN1_INTEGER_free(ASN1_INTEGER *a)
83{
84 ASN1_item_free((ASN1_VALUE *)a, &ASN1_INTEGER_it);
85}
86
68static int 87static int
69ASN1_INTEGER_valid(const ASN1_INTEGER *a) 88ASN1_INTEGER_valid(const ASN1_INTEGER *a)
70{ 89{
@@ -567,6 +586,18 @@ err:
567 return (NULL); 586 return (NULL);
568} 587}
569 588
589int
590i2d_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **out)
591{
592 return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_INTEGER_it);
593}
594
595ASN1_INTEGER *
596d2i_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