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