summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_enum.c
diff options
context:
space:
mode:
authormiod <>2014-09-21 12:17:42 +0000
committermiod <>2014-09-21 12:17:42 +0000
commit841b225a53e89adbf4f8b877083b372f9adc0c07 (patch)
treecac4b9f258240fa0ff805f6c4c422c7dd45879df /src/lib/libcrypto/asn1/a_enum.c
parent80b8016d7545ad41a60ce062e675d55c19b94636 (diff)
downloadopenbsd-841b225a53e89adbf4f8b877083b372f9adc0c07.tar.gz
openbsd-841b225a53e89adbf4f8b877083b372f9adc0c07.tar.bz2
openbsd-841b225a53e89adbf4f8b877083b372f9adc0c07.zip
a_enum.c used to be a copy of a_int.c with s/INTEGER/ENUMERATED/g , but
some changes an a_int.c did not get applied to a_enum.c; despite style changes, make sure BN_to_ASN1_ENUMERATED() correctly handles a zero value the same way BN_to_ASN1_INTEGER() does. ok bcook@ beck@ jsing@
Diffstat (limited to 'src/lib/libcrypto/asn1/a_enum.c')
-rw-r--r--src/lib/libcrypto/asn1/a_enum.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c
index 35cb0eaff5..3c059266be 100644
--- a/src/lib/libcrypto/asn1/a_enum.c
+++ b/src/lib/libcrypto/asn1/a_enum.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_enum.c,v 1.15 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: a_enum.c,v 1.16 2014/09/21 12:17:42 miod 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 *
@@ -97,7 +97,7 @@ ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
97 d >>= 8; 97 d >>= 8;
98 } 98 }
99 j = 0; 99 j = 0;
100 for (k = i - 1; k >=0; k--) 100 for (k = i - 1; k >= 0; k--)
101 a->data[j++] = buf[k]; 101 a->data[j++] = buf[k];
102 a->length = j; 102 a->length = j;
103 return (1); 103 return (1);
@@ -119,7 +119,7 @@ ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
119 119
120 if (a->length > (int)sizeof(long)) { 120 if (a->length > (int)sizeof(long)) {
121 /* hmm... a bit ugly */ 121 /* hmm... a bit ugly */
122 return (0xffffffffL); 122 return -1;
123 } 123 }
124 if (a->data == NULL) 124 if (a->data == NULL)
125 return 0; 125 return 0;
@@ -161,8 +161,13 @@ BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
161 } 161 }
162 ret->data = new_data; 162 ret->data = new_data;
163 } 163 }
164
165 ret->length = BN_bn2bin(bn, ret->data); 164 ret->length = BN_bn2bin(bn, ret->data);
165
166 /* Correct zero case */
167 if (!ret->length) {
168 ret->data[0] = 0;
169 ret->length = 1;
170 }
166 return (ret); 171 return (ret);
167 172
168err: 173err: