summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/f_int.c
diff options
context:
space:
mode:
authormarkus <>2002-09-05 12:51:50 +0000
committermarkus <>2002-09-05 12:51:50 +0000
commit15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch)
treebf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/asn1/f_int.c
parent027351f729b9e837200dae6e1520cda6577ab930 (diff)
downloadopenbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/asn1/f_int.c')
-rw-r--r--src/lib/libcrypto/asn1/f_int.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 4817c45cb7..48cc3bfb90 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -58,23 +58,27 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include "buffer.h" 61#include <openssl/buffer.h>
62#include "x509.h" 62#include <openssl/asn1.h>
63 63
64int i2a_ASN1_INTEGER(bp, a) 64int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a)
65BIO *bp;
66ASN1_INTEGER *a;
67 { 65 {
68 int i,n=0; 66 int i,n=0;
69 static char *h="0123456789ABCDEF"; 67 static const char *h="0123456789ABCDEF";
70 char buf[2]; 68 char buf[2];
71 69
72 if (a == NULL) return(0); 70 if (a == NULL) return(0);
73 71
72 if (a->type & V_ASN1_NEG)
73 {
74 if (BIO_write(bp, "-", 1) != 1) goto err;
75 n = 1;
76 }
77
74 if (a->length == 0) 78 if (a->length == 0)
75 { 79 {
76 if (BIO_write(bp,"00",2) != 2) goto err; 80 if (BIO_write(bp,"00",2) != 2) goto err;
77 n=2; 81 n += 2;
78 } 82 }
79 else 83 else
80 { 84 {
@@ -96,11 +100,7 @@ err:
96 return(-1); 100 return(-1);
97 } 101 }
98 102
99int a2i_ASN1_INTEGER(bp,bs,buf,size) 103int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
100BIO *bp;
101ASN1_INTEGER *bs;
102char *buf;
103int size;
104 { 104 {
105 int ret=0; 105 int ret=0;
106 int i,j,k,m,n,again,bufsize; 106 int i,j,k,m,n,again,bufsize;
@@ -123,9 +123,18 @@ int size;
123 123
124 for (j=0; j<i; j++) 124 for (j=0; j<i; j++)
125 { 125 {
126#ifndef CHARSET_EBCDIC
126 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) || 127 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) ||
127 ((buf[j] >= 'a') && (buf[j] <= 'f')) || 128 ((buf[j] >= 'a') && (buf[j] <= 'f')) ||
128 ((buf[j] >= 'A') && (buf[j] <= 'F')))) 129 ((buf[j] >= 'A') && (buf[j] <= 'F'))))
130#else
131 /* This #ifdef is not strictly necessary, since
132 * the characters A...F a...f 0...9 are contiguous
133 * (yes, even in EBCDIC - but not the whole alphabet).
134 * Nevertheless, isxdigit() is faster.
135 */
136 if (!isxdigit(buf[j]))
137#endif
129 { 138 {
130 i=j; 139 i=j;
131 break; 140 break;
@@ -157,15 +166,15 @@ int size;
157 if (num+i > slen) 166 if (num+i > slen)
158 { 167 {
159 if (s == NULL) 168 if (s == NULL)
160 sp=(unsigned char *)Malloc( 169 sp=(unsigned char *)OPENSSL_malloc(
161 (unsigned int)num+i*2); 170 (unsigned int)num+i*2);
162 else 171 else
163 sp=(unsigned char *)Realloc(s, 172 sp=(unsigned char *)OPENSSL_realloc(s,
164 (unsigned int)num+i*2); 173 (unsigned int)num+i*2);
165 if (sp == NULL) 174 if (sp == NULL)
166 { 175 {
167 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 176 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
168 if (s != NULL) Free((char *)s); 177 if (s != NULL) OPENSSL_free(s);
169 goto err; 178 goto err;
170 } 179 }
171 s=sp; 180 s=sp;