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.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index f8d198efb1..21cc64bb23 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.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
64ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x) 63ASN1_INTEGER *ASN1_INTEGER_dup(ASN1_INTEGER *x)
65{ return M_ASN1_INTEGER_dup(x);} 64{ return M_ASN1_INTEGER_dup(x);}
@@ -175,12 +174,11 @@ int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
175 174
176/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */ 175/* Convert just ASN1 INTEGER content octets to ASN1_INTEGER structure */
177 176
178ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, 177ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, unsigned char **pp,
179 long len) 178 long len)
180 { 179 {
181 ASN1_INTEGER *ret=NULL; 180 ASN1_INTEGER *ret=NULL;
182 const unsigned char *p, *pend; 181 unsigned char *p,*to,*s, *pend;
183 unsigned char *to,*s;
184 int i; 182 int i;
185 183
186 if ((a == NULL) || ((*a) == NULL)) 184 if ((a == NULL) || ((*a) == NULL))
@@ -256,7 +254,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
256 *pp=pend; 254 *pp=pend;
257 return(ret); 255 return(ret);
258err: 256err:
259 ASN1err(ASN1_F_C2I_ASN1_INTEGER,i); 257 ASN1err(ASN1_F_D2I_ASN1_INTEGER,i);
260 if ((ret != NULL) && ((a == NULL) || (*a != ret))) 258 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
261 M_ASN1_INTEGER_free(ret); 259 M_ASN1_INTEGER_free(ret);
262 return(NULL); 260 return(NULL);
@@ -268,12 +266,11 @@ err:
268 * with its MSB set as negative (it doesn't add a padding zero). 266 * with its MSB set as negative (it doesn't add a padding zero).
269 */ 267 */
270 268
271ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, 269ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, unsigned char **pp,
272 long length) 270 long length)
273 { 271 {
274 ASN1_INTEGER *ret=NULL; 272 ASN1_INTEGER *ret=NULL;
275 const unsigned char *p; 273 unsigned char *p,*to,*s;
276 unsigned char *to,*s;
277 long len; 274 long len;
278 int inf,tag,xclass; 275 int inf,tag,xclass;
279 int i; 276 int i;
@@ -335,13 +332,12 @@ err:
335 332
336int ASN1_INTEGER_set(ASN1_INTEGER *a, long v) 333int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
337 { 334 {
338 int j,k; 335 int i,j,k;
339 unsigned int i;
340 unsigned char buf[sizeof(long)+1]; 336 unsigned char buf[sizeof(long)+1];
341 long d; 337 long d;
342 338
343 a->type=V_ASN1_INTEGER; 339 a->type=V_ASN1_INTEGER;
344 if (a->length < (int)(sizeof(long)+1)) 340 if (a->length < (sizeof(long)+1))
345 { 341 {
346 if (a->data != NULL) 342 if (a->data != NULL)
347 OPENSSL_free(a->data); 343 OPENSSL_free(a->data);
@@ -385,7 +381,7 @@ long ASN1_INTEGER_get(ASN1_INTEGER *a)
385 else if (i != V_ASN1_INTEGER) 381 else if (i != V_ASN1_INTEGER)
386 return -1; 382 return -1;
387 383
388 if (a->length > (int)sizeof(long)) 384 if (a->length > sizeof(long))
389 { 385 {
390 /* hmm... a bit ugly */ 386 /* hmm... a bit ugly */
391 return(0xffffffffL); 387 return(0xffffffffL);
@@ -416,8 +412,7 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
416 ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_NESTED_ASN1_ERROR); 412 ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_NESTED_ASN1_ERROR);
417 goto err; 413 goto err;
418 } 414 }
419 if (BN_is_negative(bn)) 415 if(bn->neg) ret->type = V_ASN1_NEG_INTEGER;
420 ret->type = V_ASN1_NEG_INTEGER;
421 else ret->type=V_ASN1_INTEGER; 416 else ret->type=V_ASN1_INTEGER;
422 j=BN_num_bits(bn); 417 j=BN_num_bits(bn);
423 len=((j == 0)?0:((j/8)+1)); 418 len=((j == 0)?0:((j/8)+1));
@@ -450,8 +445,7 @@ BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai, BIGNUM *bn)
450 445
451 if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL) 446 if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL)
452 ASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB); 447 ASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB);
453 else if(ai->type == V_ASN1_NEG_INTEGER) 448 else if(ai->type == V_ASN1_NEG_INTEGER) ret->neg = 1;
454 BN_set_negative(ret, 1);
455 return(ret); 449 return(ret);
456 } 450 }
457 451