summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/f_string.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_string.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 '')
-rw-r--r--src/lib/libcrypto/asn1/f_string.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/lib/libcrypto/asn1/f_string.c b/src/lib/libcrypto/asn1/f_string.c
index f4bee15335..7a59fa9f4f 100644
--- a/src/lib/libcrypto/asn1/f_string.c
+++ b/src/lib/libcrypto/asn1/f_string.c
@@ -62,7 +62,7 @@
62#include <openssl/asn1.h> 62#include <openssl/asn1.h>
63 63
64int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type) 64int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type)
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,32 +70,32 @@ int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type)
70 if (a == NULL) return(0); 70 if (a == NULL) return(0);
71 71
72 if (a->length == 0) 72 if (a->length == 0)
73 { 73 {
74 if (BIO_write(bp,"0",1) != 1) goto err; 74 if (BIO_write(bp,"0",1) != 1) goto err;
75 n=1; 75 n=1;
76 } 76 }
77 else 77 else
78 { 78 {
79 for (i=0; i<a->length; i++) 79 for (i=0; i<a->length; i++)
80 { 80 {
81 if ((i != 0) && (i%35 == 0)) 81 if ((i != 0) && (i%35 == 0))
82 { 82 {
83 if (BIO_write(bp,"\\\n",2) != 2) goto err; 83 if (BIO_write(bp,"\\\n",2) != 2) goto err;
84 n+=2; 84 n+=2;
85 } 85 }
86 buf[0]=h[((unsigned char)a->data[i]>>4)&0x0f]; 86 buf[0]=h[((unsigned char)a->data[i]>>4)&0x0f];
87 buf[1]=h[((unsigned char)a->data[i] )&0x0f]; 87 buf[1]=h[((unsigned char)a->data[i] )&0x0f];
88 if (BIO_write(bp,buf,2) != 2) goto err; 88 if (BIO_write(bp,buf,2) != 2) goto err;
89 n+=2; 89 n+=2;
90 }
91 } 90 }
91 }
92 return(n); 92 return(n);
93err: 93err:
94 return(-1); 94 return(-1);
95 } 95}
96 96
97int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size) 97int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
98 { 98{
99 int ret=0; 99 int ret=0;
100 int i,j,k,m,n,again,bufsize; 100 int i,j,k,m,n,again,bufsize;
101 unsigned char *s=NULL,*sp; 101 unsigned char *s=NULL,*sp;
@@ -104,14 +104,14 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
104 104
105 bufsize=BIO_gets(bp,buf,size); 105 bufsize=BIO_gets(bp,buf,size);
106 for (;;) 106 for (;;)
107 { 107 {
108 if (bufsize < 1) 108 if (bufsize < 1)
109 { 109 {
110 if (first) 110 if (first)
111 break; 111 break;
112 else 112 else
113 goto err_sl; 113 goto err_sl;
114 } 114 }
115 first=0; 115 first=0;
116 116
117 i=bufsize; 117 i=bufsize;
@@ -122,15 +122,15 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
122 again=(buf[i-1] == '\\'); 122 again=(buf[i-1] == '\\');
123 123
124 for (j=i-1; j>0; j--) 124 for (j=i-1; j>0; 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 */
@@ -141,13 +141,13 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
141 k=0; 141 k=0;
142 i-=again; 142 i-=again;
143 if (i%2 != 0) 143 if (i%2 != 0)
144 { 144 {
145 ASN1err(ASN1_F_A2I_ASN1_STRING,ASN1_R_ODD_NUMBER_OF_CHARS); 145 ASN1err(ASN1_F_A2I_ASN1_STRING,ASN1_R_ODD_NUMBER_OF_CHARS);
146 goto err; 146 goto err;
147 } 147 }
148 i/=2; 148 i/=2;
149 if (num+i > slen) 149 if (num+i > slen)
150 { 150 {
151 if (s == NULL) 151 if (s == NULL)
152 sp=(unsigned char *)malloc( 152 sp=(unsigned char *)malloc(
153 (unsigned int)num+i*2); 153 (unsigned int)num+i*2);
@@ -155,18 +155,18 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
155 sp=(unsigned char *)realloc(s, 155 sp=(unsigned char *)realloc(s,
156 (unsigned int)num+i*2); 156 (unsigned int)num+i*2);
157 if (sp == NULL) 157 if (sp == NULL)
158 { 158 {
159 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE); 159 ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE);
160 if (s != NULL) free(s); 160 if (s != NULL) free(s);
161 goto err; 161 goto err;
162 } 162 }
163 s=sp; 163 s=sp;
164 slen=num+i*2; 164 slen=num+i*2;
165 } 165 }
166 for (j=0; j<i; j++,k+=2) 166 for (j=0; j<i; j++,k+=2)
167 { 167 {
168 for (n=0; n<2; n++) 168 for (n=0; n<2; n++)
169 { 169 {
170 m=bufp[k+n]; 170 m=bufp[k+n];
171 if ((m >= '0') && (m <= '9')) 171 if ((m >= '0') && (m <= '9'))
172 m-='0'; 172 m-='0';
@@ -175,29 +175,29 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
175 else if ((m >= 'A') && (m <= 'F')) 175 else if ((m >= 'A') && (m <= 'F'))
176 m=m-'A'+10; 176 m=m-'A'+10;
177 else 177 else
178 { 178 {
179 ASN1err(ASN1_F_A2I_ASN1_STRING,ASN1_R_NON_HEX_CHARACTERS); 179 ASN1err(ASN1_F_A2I_ASN1_STRING,ASN1_R_NON_HEX_CHARACTERS);
180 goto err; 180 goto err;
181 } 181 }
182 s[num+j]<<=4; 182 s[num+j]<<=4;
183 s[num+j]|=m; 183 s[num+j]|=m;
184 }
185 } 184 }
185 }
186 num+=i; 186 num+=i;
187 if (again) 187 if (again)
188 bufsize=BIO_gets(bp,buf,size); 188 bufsize=BIO_gets(bp,buf,size);
189 else 189 else
190 break; 190 break;
191 } 191 }
192 bs->length=num; 192 bs->length=num;
193 bs->data=s; 193 bs->data=s;
194 ret=1; 194 ret=1;
195err: 195err:
196 if (0) 196 if (0)
197 { 197 {
198err_sl: 198err_sl:
199 ASN1err(ASN1_F_A2I_ASN1_STRING,ASN1_R_SHORT_LINE); 199 ASN1err(ASN1_F_A2I_ASN1_STRING,ASN1_R_SHORT_LINE);
200 }
201 return(ret);
202 } 200 }
201 return(ret);
202}
203 203