diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/t_pkey.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/t_pkey.c | 117 |
1 files changed, 43 insertions, 74 deletions
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c index bc518d59a2..8060115202 100644 --- a/src/lib/libcrypto/asn1/t_pkey.c +++ b/src/lib/libcrypto/asn1/t_pkey.c | |||
| @@ -58,35 +58,23 @@ | |||
| 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 "bn.h" | 62 | #include <openssl/bn.h> |
| 63 | #ifndef NO_RSA | 63 | #ifndef OPENSSL_NO_RSA |
| 64 | #include "rsa.h" | 64 | #include <openssl/rsa.h> |
| 65 | #endif | 65 | #endif |
| 66 | #ifndef NO_DH | 66 | #ifndef OPENSSL_NO_DH |
| 67 | #include "dh.h" | 67 | #include <openssl/dh.h> |
| 68 | #endif | 68 | #endif |
| 69 | #ifndef NO_DSA | 69 | #ifndef OPENSSL_NO_DSA |
| 70 | #include "dsa.h" | 70 | #include <openssl/dsa.h> |
| 71 | #endif | 71 | #endif |
| 72 | 72 | ||
| 73 | /* DHerr(DH_F_DHPARAMS_PRINT,ERR_R_MALLOC_FAILURE); | 73 | static int print(BIO *fp,const char *str,BIGNUM *num, |
| 74 | * DSAerr(DSA_F_DSAPARAMS_PRINT,ERR_R_MALLOC_FAILURE); | ||
| 75 | */ | ||
| 76 | |||
| 77 | #ifndef NOPROTO | ||
| 78 | static int print(BIO *fp,char *str,BIGNUM *num, | ||
| 79 | unsigned char *buf,int off); | 74 | unsigned char *buf,int off); |
| 80 | #else | 75 | #ifndef OPENSSL_NO_RSA |
| 81 | static int print(); | 76 | #ifndef OPENSSL_NO_FP_API |
| 82 | #endif | 77 | int RSA_print_fp(FILE *fp, const RSA *x, int off) |
| 83 | |||
| 84 | #ifndef NO_RSA | ||
| 85 | #ifndef NO_FP_API | ||
| 86 | int RSA_print_fp(fp,x,off) | ||
| 87 | FILE *fp; | ||
| 88 | RSA *x; | ||
| 89 | int off; | ||
| 90 | { | 78 | { |
| 91 | BIO *b; | 79 | BIO *b; |
| 92 | int ret; | 80 | int ret; |
| @@ -103,17 +91,15 @@ int off; | |||
| 103 | } | 91 | } |
| 104 | #endif | 92 | #endif |
| 105 | 93 | ||
| 106 | int RSA_print(bp,x,off) | 94 | int RSA_print(BIO *bp, const RSA *x, int off) |
| 107 | BIO *bp; | ||
| 108 | RSA *x; | ||
| 109 | int off; | ||
| 110 | { | 95 | { |
| 111 | char str[128],*s; | 96 | char str[128]; |
| 97 | const char *s; | ||
| 112 | unsigned char *m=NULL; | 98 | unsigned char *m=NULL; |
| 113 | int i,ret=0; | 99 | int i,ret=0; |
| 114 | 100 | ||
| 115 | i=RSA_size(x); | 101 | i=RSA_size(x); |
| 116 | m=(unsigned char *)Malloc((unsigned int)i+10); | 102 | m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10); |
| 117 | if (m == NULL) | 103 | if (m == NULL) |
| 118 | { | 104 | { |
| 119 | RSAerr(RSA_F_RSA_PRINT,ERR_R_MALLOC_FAILURE); | 105 | RSAerr(RSA_F_RSA_PRINT,ERR_R_MALLOC_FAILURE); |
| @@ -147,17 +133,14 @@ int off; | |||
| 147 | if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err; | 133 | if (!print(bp,"coefficient:",x->iqmp,m,off)) goto err; |
| 148 | ret=1; | 134 | ret=1; |
| 149 | err: | 135 | err: |
| 150 | if (m != NULL) Free((char *)m); | 136 | if (m != NULL) OPENSSL_free(m); |
| 151 | return(ret); | 137 | return(ret); |
| 152 | } | 138 | } |
| 153 | #endif /* NO_RSA */ | 139 | #endif /* OPENSSL_NO_RSA */ |
| 154 | 140 | ||
| 155 | #ifndef NO_DSA | 141 | #ifndef OPENSSL_NO_DSA |
| 156 | #ifndef NO_FP_API | 142 | #ifndef OPENSSL_NO_FP_API |
| 157 | int DSA_print_fp(fp,x,off) | 143 | int DSA_print_fp(FILE *fp, const DSA *x, int off) |
| 158 | FILE *fp; | ||
| 159 | DSA *x; | ||
| 160 | int off; | ||
| 161 | { | 144 | { |
| 162 | BIO *b; | 145 | BIO *b; |
| 163 | int ret; | 146 | int ret; |
| @@ -174,10 +157,7 @@ int off; | |||
| 174 | } | 157 | } |
| 175 | #endif | 158 | #endif |
| 176 | 159 | ||
| 177 | int DSA_print(bp,x,off) | 160 | int DSA_print(BIO *bp, const DSA *x, int off) |
| 178 | BIO *bp; | ||
| 179 | DSA *x; | ||
| 180 | int off; | ||
| 181 | { | 161 | { |
| 182 | char str[128]; | 162 | char str[128]; |
| 183 | unsigned char *m=NULL; | 163 | unsigned char *m=NULL; |
| @@ -196,7 +176,7 @@ int off; | |||
| 196 | i=BN_num_bytes(bn)*2; | 176 | i=BN_num_bytes(bn)*2; |
| 197 | else | 177 | else |
| 198 | i=256; | 178 | i=256; |
| 199 | m=(unsigned char *)Malloc((unsigned int)i+10); | 179 | m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10); |
| 200 | if (m == NULL) | 180 | if (m == NULL) |
| 201 | { | 181 | { |
| 202 | DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE); | 182 | DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE); |
| @@ -224,20 +204,17 @@ int off; | |||
| 224 | if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err; | 204 | if ((x->g != NULL) && !print(bp,"G: ",x->g,m,off)) goto err; |
| 225 | ret=1; | 205 | ret=1; |
| 226 | err: | 206 | err: |
| 227 | if (m != NULL) Free((char *)m); | 207 | if (m != NULL) OPENSSL_free(m); |
| 228 | return(ret); | 208 | return(ret); |
| 229 | } | 209 | } |
| 230 | #endif /* !NO_DSA */ | 210 | #endif /* !OPENSSL_NO_DSA */ |
| 231 | 211 | ||
| 232 | static int print(bp,number,num,buf,off) | 212 | static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf, |
| 233 | BIO *bp; | 213 | int off) |
| 234 | char *number; | ||
| 235 | BIGNUM *num; | ||
| 236 | unsigned char *buf; | ||
| 237 | int off; | ||
| 238 | { | 214 | { |
| 239 | int n,i; | 215 | int n,i; |
| 240 | char str[128],*neg; | 216 | char str[128]; |
| 217 | const char *neg; | ||
| 241 | 218 | ||
| 242 | if (num == NULL) return(1); | 219 | if (num == NULL) return(1); |
| 243 | neg=(num->neg)?"-":""; | 220 | neg=(num->neg)?"-":""; |
| @@ -282,11 +259,9 @@ int off; | |||
| 282 | return(1); | 259 | return(1); |
| 283 | } | 260 | } |
| 284 | 261 | ||
| 285 | #ifndef NO_DH | 262 | #ifndef OPENSSL_NO_DH |
| 286 | #ifndef NO_FP_API | 263 | #ifndef OPENSSL_NO_FP_API |
| 287 | int DHparams_print_fp(fp,x) | 264 | int DHparams_print_fp(FILE *fp, const DH *x) |
| 288 | FILE *fp; | ||
| 289 | DH *x; | ||
| 290 | { | 265 | { |
| 291 | BIO *b; | 266 | BIO *b; |
| 292 | int ret; | 267 | int ret; |
| @@ -303,15 +278,13 @@ DH *x; | |||
| 303 | } | 278 | } |
| 304 | #endif | 279 | #endif |
| 305 | 280 | ||
| 306 | int DHparams_print(bp,x) | 281 | int DHparams_print(BIO *bp, const DH *x) |
| 307 | BIO *bp; | ||
| 308 | DH *x; | ||
| 309 | { | 282 | { |
| 310 | unsigned char *m=NULL; | 283 | unsigned char *m=NULL; |
| 311 | int reason=ERR_R_BUF_LIB,i,ret=0; | 284 | int reason=ERR_R_BUF_LIB,i,ret=0; |
| 312 | 285 | ||
| 313 | i=BN_num_bytes(x->p); | 286 | i=BN_num_bytes(x->p); |
| 314 | m=(unsigned char *)Malloc((unsigned int)i+10); | 287 | m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10); |
| 315 | if (m == NULL) | 288 | if (m == NULL) |
| 316 | { | 289 | { |
| 317 | reason=ERR_R_MALLOC_FAILURE; | 290 | reason=ERR_R_MALLOC_FAILURE; |
| @@ -325,7 +298,7 @@ DH *x; | |||
| 325 | if (!print(bp,"generator:",x->g,m,4)) goto err; | 298 | if (!print(bp,"generator:",x->g,m,4)) goto err; |
| 326 | if (x->length != 0) | 299 | if (x->length != 0) |
| 327 | { | 300 | { |
| 328 | if (BIO_printf(bp," recomented-private-length: %d bits\n", | 301 | if (BIO_printf(bp," recommended-private-length: %d bits\n", |
| 329 | (int)x->length) <= 0) goto err; | 302 | (int)x->length) <= 0) goto err; |
| 330 | } | 303 | } |
| 331 | ret=1; | 304 | ret=1; |
| @@ -334,16 +307,14 @@ DH *x; | |||
| 334 | err: | 307 | err: |
| 335 | DHerr(DH_F_DHPARAMS_PRINT,reason); | 308 | DHerr(DH_F_DHPARAMS_PRINT,reason); |
| 336 | } | 309 | } |
| 337 | if (m != NULL) Free((char *)m); | 310 | if (m != NULL) OPENSSL_free(m); |
| 338 | return(ret); | 311 | return(ret); |
| 339 | } | 312 | } |
| 340 | #endif | 313 | #endif |
| 341 | 314 | ||
| 342 | #ifndef NO_DSA | 315 | #ifndef OPENSSL_NO_DSA |
| 343 | #ifndef NO_FP_API | 316 | #ifndef OPENSSL_NO_FP_API |
| 344 | int DSAparams_print_fp(fp,x) | 317 | int DSAparams_print_fp(FILE *fp, const DSA *x) |
| 345 | FILE *fp; | ||
| 346 | DSA *x; | ||
| 347 | { | 318 | { |
| 348 | BIO *b; | 319 | BIO *b; |
| 349 | int ret; | 320 | int ret; |
| @@ -360,15 +331,13 @@ DSA *x; | |||
| 360 | } | 331 | } |
| 361 | #endif | 332 | #endif |
| 362 | 333 | ||
| 363 | int DSAparams_print(bp,x) | 334 | int DSAparams_print(BIO *bp, const DSA *x) |
| 364 | BIO *bp; | ||
| 365 | DSA *x; | ||
| 366 | { | 335 | { |
| 367 | unsigned char *m=NULL; | 336 | unsigned char *m=NULL; |
| 368 | int reason=ERR_R_BUF_LIB,i,ret=0; | 337 | int reason=ERR_R_BUF_LIB,i,ret=0; |
| 369 | 338 | ||
| 370 | i=BN_num_bytes(x->p); | 339 | i=BN_num_bytes(x->p); |
| 371 | m=(unsigned char *)Malloc((unsigned int)i+10); | 340 | m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10); |
| 372 | if (m == NULL) | 341 | if (m == NULL) |
| 373 | { | 342 | { |
| 374 | reason=ERR_R_MALLOC_FAILURE; | 343 | reason=ERR_R_MALLOC_FAILURE; |
| @@ -383,10 +352,10 @@ DSA *x; | |||
| 383 | if (!print(bp,"g:",x->g,m,4)) goto err; | 352 | if (!print(bp,"g:",x->g,m,4)) goto err; |
| 384 | ret=1; | 353 | ret=1; |
| 385 | err: | 354 | err: |
| 386 | if (m != NULL) Free((char *)m); | 355 | if (m != NULL) OPENSSL_free(m); |
| 387 | DSAerr(DSA_F_DSAPARAMS_PRINT,reason); | 356 | DSAerr(DSA_F_DSAPARAMS_PRINT,reason); |
| 388 | return(ret); | 357 | return(ret); |
| 389 | } | 358 | } |
| 390 | 359 | ||
| 391 | #endif /* !NO_DSA */ | 360 | #endif /* !OPENSSL_NO_DSA */ |
| 392 | 361 | ||
