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