diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/t_pkey.c')
-rw-r--r-- | src/lib/libcrypto/asn1/t_pkey.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c index b3f8364012..e1c5e5ae13 100644 --- a/src/lib/libcrypto/asn1/t_pkey.c +++ b/src/lib/libcrypto/asn1/t_pkey.c | |||
@@ -130,14 +130,10 @@ int RSA_print(BIO *bp, const RSA *x, int off) | |||
130 | goto err; | 130 | goto err; |
131 | } | 131 | } |
132 | 132 | ||
133 | if (off) | ||
134 | { | ||
135 | if (off > 128) off=128; | ||
136 | memset(str,' ',off); | ||
137 | } | ||
138 | if (x->d != NULL) | 133 | if (x->d != NULL) |
139 | { | 134 | { |
140 | if (off && (BIO_write(bp,str,off) <= 0)) goto err; | 135 | if(!BIO_indent(bp,off,128)) |
136 | goto err; | ||
141 | if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->n)) | 137 | if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->n)) |
142 | <= 0) goto err; | 138 | <= 0) goto err; |
143 | } | 139 | } |
@@ -183,7 +179,6 @@ int DSA_print_fp(FILE *fp, const DSA *x, int off) | |||
183 | 179 | ||
184 | int DSA_print(BIO *bp, const DSA *x, int off) | 180 | int DSA_print(BIO *bp, const DSA *x, int off) |
185 | { | 181 | { |
186 | char str[128]; | ||
187 | unsigned char *m=NULL; | 182 | unsigned char *m=NULL; |
188 | int ret=0; | 183 | int ret=0; |
189 | size_t buf_len=0,i; | 184 | size_t buf_len=0,i; |
@@ -210,14 +205,10 @@ int DSA_print(BIO *bp, const DSA *x, int off) | |||
210 | goto err; | 205 | goto err; |
211 | } | 206 | } |
212 | 207 | ||
213 | if (off) | ||
214 | { | ||
215 | if (off > 128) off=128; | ||
216 | memset(str,' ',off); | ||
217 | } | ||
218 | if (x->priv_key != NULL) | 208 | if (x->priv_key != NULL) |
219 | { | 209 | { |
220 | if (off && (BIO_write(bp,str,off) <= 0)) goto err; | 210 | if(!BIO_indent(bp,off,128)) |
211 | goto err; | ||
221 | if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->p)) | 212 | if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->p)) |
222 | <= 0) goto err; | 213 | <= 0) goto err; |
223 | } | 214 | } |
@@ -240,17 +231,12 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf, | |||
240 | int off) | 231 | int off) |
241 | { | 232 | { |
242 | int n,i; | 233 | int n,i; |
243 | char str[128]; | ||
244 | const char *neg; | 234 | const char *neg; |
245 | 235 | ||
246 | if (num == NULL) return(1); | 236 | if (num == NULL) return(1); |
247 | neg=(num->neg)?"-":""; | 237 | neg=(num->neg)?"-":""; |
248 | if (off) | 238 | if(!BIO_indent(bp,off,128)) |
249 | { | 239 | return 0; |
250 | if (off > 128) off=128; | ||
251 | memset(str,' ',off); | ||
252 | if (BIO_write(bp,str,off) <= 0) return(0); | ||
253 | } | ||
254 | 240 | ||
255 | if (BN_num_bytes(num) <= BN_BYTES) | 241 | if (BN_num_bytes(num) <= BN_BYTES) |
256 | { | 242 | { |
@@ -274,9 +260,9 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf, | |||
274 | { | 260 | { |
275 | if ((i%15) == 0) | 261 | if ((i%15) == 0) |
276 | { | 262 | { |
277 | str[0]='\n'; | 263 | if(BIO_puts(bp,"\n") <= 0 |
278 | memset(&(str[1]),' ',off+4); | 264 | || !BIO_indent(bp,off+4,128)) |
279 | if (BIO_write(bp,str,off+1+4) <= 0) return(0); | 265 | return 0; |
280 | } | 266 | } |
281 | if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":") | 267 | if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":") |
282 | <= 0) return(0); | 268 | <= 0) return(0); |