summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_enum.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/a_enum.c')
-rw-r--r--src/lib/libcrypto/asn1/a_enum.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c
index fe9aa13b9c..03ede68d1c 100644
--- a/src/lib/libcrypto/asn1/a_enum.c
+++ b/src/lib/libcrypto/asn1/a_enum.c
@@ -59,7 +59,6 @@
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/asn1.h> 61#include <openssl/asn1.h>
62#include <openssl/bn.h>
63 62
64/* 63/*
65 * Code for ENUMERATED type: identical to INTEGER apart from a different tag. 64 * Code for ENUMERATED type: identical to INTEGER apart from a different tag.
@@ -68,13 +67,12 @@
68 67
69int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) 68int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
70 { 69 {
71 int j,k; 70 int i,j,k;
72 unsigned int i;
73 unsigned char buf[sizeof(long)+1]; 71 unsigned char buf[sizeof(long)+1];
74 long d; 72 long d;
75 73
76 a->type=V_ASN1_ENUMERATED; 74 a->type=V_ASN1_ENUMERATED;
77 if (a->length < (int)(sizeof(long)+1)) 75 if (a->length < (sizeof(long)+1))
78 { 76 {
79 if (a->data != NULL) 77 if (a->data != NULL)
80 OPENSSL_free(a->data); 78 OPENSSL_free(a->data);
@@ -118,7 +116,7 @@ long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
118 else if (i != V_ASN1_ENUMERATED) 116 else if (i != V_ASN1_ENUMERATED)
119 return -1; 117 return -1;
120 118
121 if (a->length > (int)sizeof(long)) 119 if (a->length > sizeof(long))
122 { 120 {
123 /* hmm... a bit ugly */ 121 /* hmm... a bit ugly */
124 return(0xffffffffL); 122 return(0xffffffffL);
@@ -149,7 +147,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
149 ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED,ERR_R_NESTED_ASN1_ERROR); 147 ASN1err(ASN1_F_BN_TO_ASN1_ENUMERATED,ERR_R_NESTED_ASN1_ERROR);
150 goto err; 148 goto err;
151 } 149 }
152 if(BN_is_negative(bn)) ret->type = V_ASN1_NEG_ENUMERATED; 150 if(bn->neg) ret->type = V_ASN1_NEG_ENUMERATED;
153 else ret->type=V_ASN1_ENUMERATED; 151 else ret->type=V_ASN1_ENUMERATED;
154 j=BN_num_bits(bn); 152 j=BN_num_bits(bn);
155 len=((j == 0)?0:((j/8)+1)); 153 len=((j == 0)?0:((j/8)+1));
@@ -177,6 +175,6 @@ BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn)
177 175
178 if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL) 176 if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL)
179 ASN1err(ASN1_F_ASN1_ENUMERATED_TO_BN,ASN1_R_BN_LIB); 177 ASN1err(ASN1_F_ASN1_ENUMERATED_TO_BN,ASN1_R_BN_LIB);
180 else if(ai->type == V_ASN1_NEG_ENUMERATED) BN_set_negative(ret,1); 178 else if(ai->type == V_ASN1_NEG_ENUMERATED) ret->neg = 1;
181 return(ret); 179 return(ret);
182 } 180 }