OLD | NEW |
1 /* crypto/bn/bn_print.c */ | 1 /* crypto/bn/bn_print.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 bn_correct_top(ret); | 288 bn_correct_top(ret); |
289 *bn=ret; | 289 *bn=ret; |
290 bn_check_top(ret); | 290 bn_check_top(ret); |
291 return(num); | 291 return(num); |
292 err: | 292 err: |
293 if (*bn == NULL) BN_free(ret); | 293 if (*bn == NULL) BN_free(ret); |
294 return(0); | 294 return(0); |
295 } | 295 } |
296 | 296 |
| 297 int BN_asc2bn(BIGNUM **bn, const char *a) |
| 298 { |
| 299 const char *p = a; |
| 300 if (*p == '-') |
| 301 p++; |
| 302 |
| 303 if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) |
| 304 { |
| 305 if (!BN_hex2bn(bn, p + 2)) |
| 306 return 0; |
| 307 } |
| 308 else |
| 309 { |
| 310 if (!BN_dec2bn(bn, p)) |
| 311 return 0; |
| 312 } |
| 313 if (*a == '-') |
| 314 (*bn)->neg = 1; |
| 315 return 1; |
| 316 } |
| 317 |
297 #ifndef OPENSSL_NO_BIO | 318 #ifndef OPENSSL_NO_BIO |
298 #ifndef OPENSSL_NO_FP_API | 319 #ifndef OPENSSL_NO_FP_API |
299 int BN_print_fp(FILE *fp, const BIGNUM *a) | 320 int BN_print_fp(FILE *fp, const BIGNUM *a) |
300 { | 321 { |
301 BIO *b; | 322 BIO *b; |
302 int ret; | 323 int ret; |
303 | 324 |
304 if ((b=BIO_new(BIO_s_file())) == NULL) | 325 if ((b=BIO_new(BIO_s_file())) == NULL) |
305 return(0); | 326 return(0); |
306 BIO_set_fp(b,fp,BIO_NOCLOSE); | 327 BIO_set_fp(b,fp,BIO_NOCLOSE); |
(...skipping 22 matching lines...) Expand all Loading... |
329 goto end; | 350 goto end; |
330 z=1; | 351 z=1; |
331 } | 352 } |
332 } | 353 } |
333 } | 354 } |
334 ret=1; | 355 ret=1; |
335 end: | 356 end: |
336 return(ret); | 357 return(ret); |
337 } | 358 } |
338 #endif | 359 #endif |
OLD | NEW |