summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/f_int.c
diff options
context:
space:
mode:
authortedu <>2014-04-18 00:10:08 +0000
committertedu <>2014-04-18 00:10:08 +0000
commit07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d (patch)
tree6327d50d69a1982f840dc68fe928ea459e2c41e0 /src/lib/libcrypto/asn1/f_int.c
parent288a9e368d9d4a72792b12a00ad69e3592d94073 (diff)
downloadopenbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.tar.gz
openbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.tar.bz2
openbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.zip
putting most of the braces in the right column is the very least we can do.
Diffstat (limited to 'src/lib/libcrypto/asn1/f_int.c')
-rw-r--r--src/lib/libcrypto/asn1/f_int.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/lib/libcrypto/asn1/f_int.c b/src/lib/libcrypto/asn1/f_int.c
index 977e3d01b7..66632f2dc4 100644
--- a/src/lib/libcrypto/asn1/f_int.c
+++ b/src/lib/libcrypto/asn1/f_int.c
@@ -62,7 +62,7 @@
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63 63
64int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a) 64int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a)
65 { 65{
66 int i,n=0; 66 int i,n=0;
67 static const char *h="0123456789ABCDEF"; 67 static const char *h="0123456789ABCDEF";
68 char buf[2]; 68 char buf[2];
@@ -70,38 +70,38 @@ int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a)
70 if (a == NULL) return(0); 70 if (a == NULL) return(0);
71 71
72 if (a->type & V_ASN1_NEG) 72 if (a->type & V_ASN1_NEG)
73 { 73 {
74 if (BIO_write(bp, "-", 1) != 1) goto err; 74 if (BIO_write(bp, "-", 1) != 1) goto err;
75 n = 1; 75 n = 1;
76 } 76 }
77 77
78 if (a->length == 0) 78 if (a->length == 0)
79 { 79 {
80 if (BIO_write(bp,"00",2) != 2) goto err; 80 if (BIO_write(bp,"00",2) != 2) goto err;
81 n += 2; 81 n += 2;
82 } 82 }
83 else 83 else
84 { 84 {
85 for (i=0; i<a->length; i++) 85 for (i=0; i<a->length; i++)
86 { 86 {
87 if ((i != 0) && (i%35 == 0)) 87 if ((i != 0) && (i%35 == 0))
88 { 88 {
89 if (BIO_write(bp,"\\\n",2) != 2) goto err; 89 if (BIO_write(bp,"\\\n",2) != 2) goto err;
90 n+=2; 90 n+=2;
91 } 91 }
92 buf[0]=h[((unsigned char)a->data[i]>>4)&0x0f]; 92 buf[0]=h[((unsigned char)a->data[i]>>4)&0x0f];
93 buf[1]=h[((unsigned char)a->data[i] )&0x0f]; 93 buf[1]=h[((unsigned char)a->data[i] )&0x0f];
94 if (BIO_write(bp,buf,2) != 2) goto err; 94 if (BIO_write(bp,buf,2) != 2) goto err;
95 n+=2; 95 n+=2;
96 }
97 } 96 }
97 }
98 return(n); 98 return(n);
99err: 99err:
100 return(-1); 100 return(-1);
101 } 101}
102 102
103int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size) 103int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int 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;
107 unsigned char *s=NULL,*sp; 107 unsigned char *s=NULL,*sp;
@@ -112,7 +112,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
112 112
113 bufsize=BIO_gets(bp,buf,size); 113 bufsize=BIO_gets(bp,buf,size);
114 for (;;) 114 for (;;)
115 { 115 {
116 if (bufsize < 1) goto err_sl; 116 if (bufsize < 1) goto err_sl;
117 i=bufsize; 117 i=bufsize;
118 if (buf[i-1] == '\n') buf[--i]='\0'; 118 if (buf[i-1] == '\n') buf[--i]='\0';
@@ -122,15 +122,15 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
122 again=(buf[i-1] == '\\'); 122 again=(buf[i-1] == '\\');
123 123
124 for (j=0; j<i; j++) 124 for (j=0; j<i; j++)
125 { 125 {
126 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) || 126 if (!( ((buf[j] >= '0') && (buf[j] <= '9')) ||
127 ((buf[j] >= 'a') && (buf[j] <= 'f')) || 127 ((buf[j] >= 'a') && (buf[j] <= 'f')) ||
128 ((buf[j] >= 'A') && (buf[j] <= 'F')))) 128 ((buf[j] >= 'A') && (buf[j] <= 'F'))))
129 { 129 {
130 i=j; 130 i=j;
131 break; 131 break;
132 }
133 } 132 }
133 }
134 buf[i]='\0'; 134 buf[i]='\0';
135 /* We have now cleared all the crap off the end of the 135 /* We have now cleared all the crap off the end of the
136 * line */ 136 * line */
@@ -138,42 +138,42 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
138 138
139 bufp=(unsigned char *)buf; 139 bufp=(unsigned char *)buf;
140 if (first) 140 if (first)
141 { 141 {
142 first=0; 142 first=0;
143 if ((bufp[0] == '0') && (buf[1] == '0')) 143 if ((bufp[0] == '0') && (buf[1] == '0'))
144 { 144 {
145 bufp+=2; 145 bufp+=2;
146 i-=2; 146 i-=2;
147 }
148 } 147 }
148 }
149 k=0; 149 k=0;
150 i-=again; 150 i-=again;
151 if (i%2 != 0) 151 if (i%2 != 0)
152 { 152 {
153 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ASN1_R_ODD_NUMBER_OF_CHARS); 153 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ASN1_R_ODD_NUMBER_OF_CHARS);
154 goto err; 154 goto err;
155 } 155 }
156 i/=2; 156 i/=2;
157 if (num+i > slen) 157 if (num+i > slen)
158 { 158 {
159 if (s == NULL) 159 if (s == NULL)
160 sp=(unsigned char *)malloc( 160 sp=(unsigned char *)malloc(
161 (unsigned int)num+i*2); 161 (unsigned int)num+i*2);
162 else 162 else
163 sp=OPENSSL_realloc_clean(s,slen,num+i*2); 163 sp=OPENSSL_realloc_clean(s,slen,num+i*2);
164 if (sp == NULL) 164 if (sp == NULL)
165 { 165 {
166 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); 166 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
167 if (s != NULL) free(s); 167 if (s != NULL) free(s);
168 goto err; 168 goto err;
169 } 169 }
170 s=sp; 170 s=sp;
171 slen=num+i*2; 171 slen=num+i*2;
172 } 172 }
173 for (j=0; j<i; j++,k+=2) 173 for (j=0; j<i; j++,k+=2)
174 { 174 {
175 for (n=0; n<2; n++) 175 for (n=0; n<2; n++)
176 { 176 {
177 m=bufp[k+n]; 177 m=bufp[k+n];
178 if ((m >= '0') && (m <= '9')) 178 if ((m >= '0') && (m <= '9'))
179 m-='0'; 179 m-='0';
@@ -182,29 +182,29 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
182 else if ((m >= 'A') && (m <= 'F')) 182 else if ((m >= 'A') && (m <= 'F'))
183 m=m-'A'+10; 183 m=m-'A'+10;
184 else 184 else
185 { 185 {
186 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ASN1_R_NON_HEX_CHARACTERS); 186 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ASN1_R_NON_HEX_CHARACTERS);
187 goto err; 187 goto err;
188 } 188 }
189 s[num+j]<<=4; 189 s[num+j]<<=4;
190 s[num+j]|=m; 190 s[num+j]|=m;
191 }
192 } 191 }
192 }
193 num+=i; 193 num+=i;
194 if (again) 194 if (again)
195 bufsize=BIO_gets(bp,buf,size); 195 bufsize=BIO_gets(bp,buf,size);
196 else 196 else
197 break; 197 break;
198 } 198 }
199 bs->length=num; 199 bs->length=num;
200 bs->data=s; 200 bs->data=s;
201 ret=1; 201 ret=1;
202err: 202err:
203 if (0) 203 if (0)
204 { 204 {
205err_sl: 205err_sl:
206 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ASN1_R_SHORT_LINE); 206 ASN1err(ASN1_F_A2I_ASN1_INTEGER,ASN1_R_SHORT_LINE);
207 }
208 return(ret);
209 } 207 }
208 return(ret);
209}
210 210