diff options
Diffstat (limited to 'src/lib/libcrypto/pem/pem_all.c')
| -rw-r--r-- | src/lib/libcrypto/pem/pem_all.c | 480 |
1 files changed, 94 insertions, 386 deletions
diff --git a/src/lib/libcrypto/pem/pem_all.c b/src/lib/libcrypto/pem/pem_all.c index d1cda7aabe..e72b7134ce 100644 --- a/src/lib/libcrypto/pem/pem_all.c +++ b/src/lib/libcrypto/pem/pem_all.c | |||
| @@ -59,430 +59,138 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #undef SSLEAY_MACROS | 60 | #undef SSLEAY_MACROS |
| 61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 62 | #include "bio.h" | 62 | #include <openssl/bio.h> |
| 63 | #include "evp.h" | 63 | #include <openssl/evp.h> |
| 64 | #include "x509.h" | 64 | #include <openssl/x509.h> |
| 65 | #include "pkcs7.h" | 65 | #include <openssl/pkcs7.h> |
| 66 | #include "pem.h" | 66 | #include <openssl/pem.h> |
| 67 | |||
| 68 | #ifndef NO_FP_API | ||
| 69 | /* The X509 functions */ | ||
| 70 | X509 *PEM_read_X509(fp,x,cb) | ||
| 71 | FILE *fp; | ||
| 72 | X509 **x; | ||
| 73 | int (*cb)(); | ||
| 74 | { | ||
| 75 | return((X509 *)PEM_ASN1_read((char *(*)())d2i_X509, | ||
| 76 | PEM_STRING_X509,fp,(char **)x,cb)); | ||
| 77 | } | ||
| 78 | #endif | ||
| 79 | |||
| 80 | X509 *PEM_read_bio_X509(bp,x,cb) | ||
| 81 | BIO *bp; | ||
| 82 | X509 **x; | ||
| 83 | int (*cb)(); | ||
| 84 | { | ||
| 85 | return((X509 *)PEM_ASN1_read_bio((char *(*)())d2i_X509, | ||
| 86 | PEM_STRING_X509,bp,(char **)x,cb)); | ||
| 87 | } | ||
| 88 | 67 | ||
| 89 | #ifndef NO_FP_API | 68 | #ifndef OPENSSL_NO_RSA |
| 90 | int PEM_write_X509(fp,x) | 69 | static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa); |
| 91 | FILE *fp; | ||
| 92 | X509 *x; | ||
| 93 | { | ||
| 94 | return(PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, | ||
| 95 | (char *)x, NULL,NULL,0,NULL)); | ||
| 96 | } | ||
| 97 | #endif | 70 | #endif |
| 98 | 71 | #ifndef OPENSSL_NO_DSA | |
| 99 | int PEM_write_bio_X509(bp,x) | 72 | static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa); |
| 100 | BIO *bp; | ||
| 101 | X509 *x; | ||
| 102 | { | ||
| 103 | return(PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, | ||
| 104 | (char *)x, NULL,NULL,0,NULL)); | ||
| 105 | } | ||
| 106 | |||
| 107 | #ifndef NO_FP_API | ||
| 108 | /* The X509_REQ functions */ | ||
| 109 | X509_REQ *PEM_read_X509_REQ(fp,x,cb) | ||
| 110 | FILE *fp; | ||
| 111 | X509_REQ **x; | ||
| 112 | int (*cb)(); | ||
| 113 | { | ||
| 114 | return((X509_REQ *)PEM_ASN1_read((char *(*)())d2i_X509_REQ, | ||
| 115 | PEM_STRING_X509_REQ,fp,(char **)x,cb)); | ||
| 116 | } | ||
| 117 | #endif | 73 | #endif |
| 118 | 74 | ||
| 119 | X509_REQ *PEM_read_bio_X509_REQ(bp,x,cb) | 75 | IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ) |
| 120 | BIO *bp; | ||
| 121 | X509_REQ **x; | ||
| 122 | int (*cb)(); | ||
| 123 | { | ||
| 124 | return((X509_REQ *)PEM_ASN1_read_bio((char *(*)())d2i_X509_REQ, | ||
| 125 | PEM_STRING_X509_REQ,bp,(char **)x,cb)); | ||
| 126 | } | ||
| 127 | 76 | ||
| 128 | #ifndef NO_FP_API | 77 | IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ) |
| 129 | int PEM_write_X509_REQ(fp,x) | ||
| 130 | FILE *fp; | ||
| 131 | X509_REQ *x; | ||
| 132 | { | ||
| 133 | return(PEM_ASN1_write((int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp, | ||
| 134 | (char *)x, NULL,NULL,0,NULL)); | ||
| 135 | } | ||
| 136 | #endif | ||
| 137 | 78 | ||
| 138 | int PEM_write_bio_X509_REQ(bp,x) | 79 | IMPLEMENT_PEM_rw(X509_CRL, X509_CRL, PEM_STRING_X509_CRL, X509_CRL) |
| 139 | BIO *bp; | ||
| 140 | X509_REQ *x; | ||
| 141 | { | ||
| 142 | return(PEM_ASN1_write_bio((int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ, | ||
| 143 | bp,(char *)x, NULL,NULL,0,NULL)); | ||
| 144 | } | ||
| 145 | 80 | ||
| 146 | #ifndef NO_FP_API | 81 | IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7) |
| 147 | /* The X509_CRL functions */ | ||
| 148 | X509_CRL *PEM_read_X509_CRL(fp,x,cb) | ||
| 149 | FILE *fp; | ||
| 150 | X509_CRL **x; | ||
| 151 | int (*cb)(); | ||
| 152 | { | ||
| 153 | return((X509_CRL *)PEM_ASN1_read((char *(*)())d2i_X509_CRL, | ||
| 154 | PEM_STRING_X509_CRL,fp,(char **)x,cb)); | ||
| 155 | } | ||
| 156 | #endif | ||
| 157 | 82 | ||
| 158 | X509_CRL *PEM_read_bio_X509_CRL(bp,x,cb) | 83 | IMPLEMENT_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE, |
| 159 | BIO *bp; | 84 | PEM_STRING_X509, NETSCAPE_CERT_SEQUENCE) |
| 160 | X509_CRL **x; | ||
| 161 | int (*cb)(); | ||
| 162 | { | ||
| 163 | return((X509_CRL *)PEM_ASN1_read_bio((char *(*)())d2i_X509_CRL, | ||
| 164 | PEM_STRING_X509_CRL,bp,(char **)x,cb)); | ||
| 165 | } | ||
| 166 | 85 | ||
| 167 | #ifndef NO_FP_API | ||
| 168 | int PEM_write_X509_CRL(fp,x) | ||
| 169 | FILE *fp; | ||
| 170 | X509_CRL *x; | ||
| 171 | { | ||
| 172 | return(PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,fp, | ||
| 173 | (char *)x, NULL,NULL,0,NULL)); | ||
| 174 | } | ||
| 175 | #endif | ||
| 176 | |||
| 177 | int PEM_write_bio_X509_CRL(bp,x) | ||
| 178 | BIO *bp; | ||
| 179 | X509_CRL *x; | ||
| 180 | { | ||
| 181 | return(PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, | ||
| 182 | bp,(char *)x, NULL,NULL,0,NULL)); | ||
| 183 | } | ||
| 184 | 86 | ||
| 185 | #ifndef NO_RSA | 87 | #ifndef OPENSSL_NO_RSA |
| 186 | #ifndef NO_FP_API | ||
| 187 | /* The RSAPrivateKey functions */ | ||
| 188 | RSA *PEM_read_RSAPrivateKey(fp,x,cb) | ||
| 189 | FILE *fp; | ||
| 190 | RSA **x; | ||
| 191 | int (*cb)(); | ||
| 192 | { | ||
| 193 | return((RSA *)PEM_ASN1_read((char *(*)())d2i_RSAPrivateKey, | ||
| 194 | PEM_STRING_RSA,fp,(char **)x,cb)); | ||
| 195 | } | ||
| 196 | |||
| 197 | RSA *PEM_read_RSAPublicKey(fp,x,cb) | ||
| 198 | FILE *fp; | ||
| 199 | RSA **x; | ||
| 200 | int (*cb)(); | ||
| 201 | { | ||
| 202 | return((RSA *)PEM_ASN1_read((char *(*)())d2i_RSAPublicKey, | ||
| 203 | PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb)); | ||
| 204 | } | ||
| 205 | #endif | ||
| 206 | 88 | ||
| 207 | RSA *PEM_read_bio_RSAPrivateKey(bp,x,cb) | 89 | /* We treat RSA or DSA private keys as a special case. |
| 208 | BIO *bp; | 90 | * |
| 209 | RSA **x; | 91 | * For private keys we read in an EVP_PKEY structure with |
| 210 | int (*cb)(); | 92 | * PEM_read_bio_PrivateKey() and extract the relevant private |
| 211 | { | 93 | * key: this means can handle "traditional" and PKCS#8 formats |
| 212 | return((RSA *)PEM_ASN1_read_bio((char *(*)())d2i_RSAPrivateKey, | 94 | * transparently. |
| 213 | PEM_STRING_RSA,bp,(char **)x,cb)); | 95 | */ |
| 214 | } | ||
| 215 | 96 | ||
| 216 | RSA *PEM_read_bio_RSAPublicKey(bp,x,cb) | 97 | static RSA *pkey_get_rsa(EVP_PKEY *key, RSA **rsa) |
| 217 | BIO *bp; | 98 | { |
| 218 | RSA **x; | 99 | RSA *rtmp; |
| 219 | int (*cb)(); | 100 | if(!key) return NULL; |
| 220 | { | 101 | rtmp = EVP_PKEY_get1_RSA(key); |
| 221 | return((RSA *)PEM_ASN1_read_bio((char *(*)())d2i_RSAPublicKey, | 102 | EVP_PKEY_free(key); |
| 222 | PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb)); | 103 | if(!rtmp) return NULL; |
| 104 | if(rsa) { | ||
| 105 | RSA_free(*rsa); | ||
| 106 | *rsa = rtmp; | ||
| 223 | } | 107 | } |
| 108 | return rtmp; | ||
| 109 | } | ||
| 224 | 110 | ||
| 225 | #ifndef NO_FP_API | 111 | RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **rsa, pem_password_cb *cb, |
| 226 | int PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) | 112 | void *u) |
| 227 | FILE *fp; | 113 | { |
| 228 | RSA *x; | 114 | EVP_PKEY *pktmp; |
| 229 | EVP_CIPHER *enc; | 115 | pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); |
| 230 | unsigned char *kstr; | 116 | return pkey_get_rsa(pktmp, rsa); |
| 231 | int klen; | 117 | } |
| 232 | int (*cb)(); | ||
| 233 | { | ||
| 234 | return(PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp, | ||
| 235 | (char *)x,enc,kstr,klen,cb)); | ||
| 236 | } | ||
| 237 | 118 | ||
| 238 | int PEM_write_RSAPublicKey(fp,x) | 119 | #ifndef OPENSSL_NO_FP_API |
| 239 | FILE *fp; | ||
| 240 | RSA *x; | ||
| 241 | { | ||
| 242 | return(PEM_ASN1_write((int (*)())i2d_RSAPublicKey, | ||
| 243 | PEM_STRING_RSA_PUBLIC,fp, | ||
| 244 | (char *)x,NULL,NULL,0,NULL)); | ||
| 245 | } | ||
| 246 | #endif | ||
| 247 | 120 | ||
| 248 | int PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) | 121 | RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **rsa, pem_password_cb *cb, |
| 249 | BIO *bp; | 122 | void *u) |
| 250 | RSA *x; | 123 | { |
| 251 | EVP_CIPHER *enc; | 124 | EVP_PKEY *pktmp; |
| 252 | unsigned char *kstr; | 125 | pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); |
| 253 | int klen; | 126 | return pkey_get_rsa(pktmp, rsa); |
| 254 | int (*cb)(); | 127 | } |
| 255 | { | ||
| 256 | return(PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA, | ||
| 257 | bp,(char *)x,enc,kstr,klen,cb)); | ||
| 258 | } | ||
| 259 | 128 | ||
| 260 | int PEM_write_bio_RSAPublicKey(bp,x) | ||
| 261 | BIO *bp; | ||
| 262 | RSA *x; | ||
| 263 | { | ||
| 264 | return(PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, | ||
| 265 | PEM_STRING_RSA_PUBLIC, | ||
| 266 | bp,(char *)x,NULL,NULL,0,NULL)); | ||
| 267 | } | ||
| 268 | #endif /* !NO_RSA */ | ||
| 269 | |||
| 270 | #ifndef NO_DSA | ||
| 271 | #ifndef NO_FP_API | ||
| 272 | /* The DSAPrivateKey functions */ | ||
| 273 | DSA *PEM_read_DSAPrivateKey(fp,x,cb) | ||
| 274 | FILE *fp; | ||
| 275 | DSA **x; | ||
| 276 | int (*cb)(); | ||
| 277 | { | ||
| 278 | return((DSA *)PEM_ASN1_read((char *(*)())d2i_DSAPrivateKey, | ||
| 279 | PEM_STRING_DSA,fp,(char **)x,cb)); | ||
| 280 | } | ||
| 281 | #endif | 129 | #endif |
| 282 | 130 | ||
| 283 | DSA *PEM_read_bio_DSAPrivateKey(bp,x,cb) | 131 | IMPLEMENT_PEM_write_cb(RSAPrivateKey, RSA, PEM_STRING_RSA, RSAPrivateKey) |
| 284 | BIO *bp; | 132 | IMPLEMENT_PEM_rw(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, RSAPublicKey) |
| 285 | DSA **x; | 133 | IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) |
| 286 | int (*cb)(); | ||
| 287 | { | ||
| 288 | return((DSA *)PEM_ASN1_read_bio((char *(*)())d2i_DSAPrivateKey, | ||
| 289 | PEM_STRING_DSA,bp,(char **)x,cb)); | ||
| 290 | } | ||
| 291 | |||
| 292 | #ifndef NO_FP_API | ||
| 293 | int PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) | ||
| 294 | FILE *fp; | ||
| 295 | DSA *x; | ||
| 296 | EVP_CIPHER *enc; | ||
| 297 | unsigned char *kstr; | ||
| 298 | int klen; | ||
| 299 | int (*cb)(); | ||
| 300 | { | ||
| 301 | return(PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp, | ||
| 302 | (char *)x,enc,kstr,klen,cb)); | ||
| 303 | } | ||
| 304 | #endif | ||
| 305 | 134 | ||
| 306 | int PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) | ||
| 307 | BIO *bp; | ||
| 308 | DSA *x; | ||
| 309 | EVP_CIPHER *enc; | ||
| 310 | unsigned char *kstr; | ||
| 311 | int klen; | ||
| 312 | int (*cb)(); | ||
| 313 | { | ||
| 314 | return(PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA, | ||
| 315 | bp,(char *)x,enc,kstr,klen,cb)); | ||
| 316 | } | ||
| 317 | #endif | 135 | #endif |
| 318 | 136 | ||
| 319 | #ifndef NO_FP_API | 137 | #ifndef OPENSSL_NO_DSA |
| 320 | /* The PrivateKey functions */ | ||
| 321 | EVP_PKEY *PEM_read_PrivateKey(fp,x,cb) | ||
| 322 | FILE *fp; | ||
| 323 | EVP_PKEY **x; | ||
| 324 | int (*cb)(); | ||
| 325 | { | ||
| 326 | return((EVP_PKEY *)PEM_ASN1_read((char *(*)())d2i_PrivateKey, | ||
| 327 | PEM_STRING_EVP_PKEY,fp,(char **)x,cb)); | ||
| 328 | } | ||
| 329 | #endif | ||
| 330 | 138 | ||
| 331 | EVP_PKEY *PEM_read_bio_PrivateKey(bp,x,cb) | 139 | static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa) |
| 332 | BIO *bp; | 140 | { |
| 333 | EVP_PKEY **x; | 141 | DSA *dtmp; |
| 334 | int (*cb)(); | 142 | if(!key) return NULL; |
| 335 | { | 143 | dtmp = EVP_PKEY_get1_DSA(key); |
| 336 | return((EVP_PKEY *)PEM_ASN1_read_bio((char *(*)())d2i_PrivateKey, | 144 | EVP_PKEY_free(key); |
| 337 | PEM_STRING_EVP_PKEY,bp,(char **)x,cb)); | 145 | if(!dtmp) return NULL; |
| 146 | if(dsa) { | ||
| 147 | DSA_free(*dsa); | ||
| 148 | *dsa = dtmp; | ||
| 338 | } | 149 | } |
| 150 | return dtmp; | ||
| 151 | } | ||
| 339 | 152 | ||
| 340 | #ifndef NO_FP_API | 153 | DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb, |
| 341 | int PEM_write_PrivateKey(fp,x,enc,kstr,klen,cb) | 154 | void *u) |
| 342 | FILE *fp; | 155 | { |
| 343 | EVP_PKEY *x; | 156 | EVP_PKEY *pktmp; |
| 344 | EVP_CIPHER *enc; | 157 | pktmp = PEM_read_bio_PrivateKey(bp, NULL, cb, u); |
| 345 | unsigned char *kstr; | 158 | return pkey_get_dsa(pktmp, dsa); |
| 346 | int klen; | 159 | } |
| 347 | int (*cb)(); | ||
| 348 | { | ||
| 349 | return(PEM_ASN1_write((int (*)())i2d_PrivateKey, | ||
| 350 | ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), | ||
| 351 | fp,(char *)x,enc,kstr,klen,cb)); | ||
| 352 | } | ||
| 353 | #endif | ||
| 354 | 160 | ||
| 355 | int PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) | 161 | IMPLEMENT_PEM_write_cb(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) |
| 356 | BIO *bp; | 162 | IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) |
| 357 | EVP_PKEY *x; | ||
| 358 | EVP_CIPHER *enc; | ||
| 359 | unsigned char *kstr; | ||
| 360 | int klen; | ||
| 361 | int (*cb)(); | ||
| 362 | { | ||
| 363 | return(PEM_ASN1_write_bio((int (*)())i2d_PrivateKey, | ||
| 364 | ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), | ||
| 365 | bp,(char *)x,enc,kstr,klen,cb)); | ||
| 366 | } | ||
| 367 | 163 | ||
| 368 | #ifndef NO_FP_API | 164 | #ifndef OPENSSL_NO_FP_API |
| 369 | /* The PKCS7 functions */ | ||
| 370 | PKCS7 *PEM_read_PKCS7(fp,x,cb) | ||
| 371 | FILE *fp; | ||
| 372 | PKCS7 **x; | ||
| 373 | int (*cb)(); | ||
| 374 | { | ||
| 375 | return((PKCS7 *)PEM_ASN1_read((char *(*)())d2i_PKCS7, | ||
| 376 | PEM_STRING_PKCS7,fp,(char **)x,cb)); | ||
| 377 | } | ||
| 378 | #endif | ||
| 379 | 165 | ||
| 380 | PKCS7 *PEM_read_bio_PKCS7(bp,x,cb) | 166 | DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, |
| 381 | BIO *bp; | 167 | void *u) |
| 382 | PKCS7 **x; | 168 | { |
| 383 | int (*cb)(); | 169 | EVP_PKEY *pktmp; |
| 384 | { | 170 | pktmp = PEM_read_PrivateKey(fp, NULL, cb, u); |
| 385 | return((PKCS7 *)PEM_ASN1_read_bio((char *(*)())d2i_PKCS7, | 171 | return pkey_get_dsa(pktmp, dsa); |
| 386 | PEM_STRING_PKCS7,bp,(char **)x,cb)); | 172 | } |
| 387 | } | ||
| 388 | 173 | ||
| 389 | #ifndef NO_FP_API | ||
| 390 | int PEM_write_PKCS7(fp,x) | ||
| 391 | FILE *fp; | ||
| 392 | PKCS7 *x; | ||
| 393 | { | ||
| 394 | return(PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, | ||
| 395 | (char *)x, NULL,NULL,0,NULL)); | ||
| 396 | } | ||
| 397 | #endif | 174 | #endif |
| 398 | 175 | ||
| 399 | int PEM_write_bio_PKCS7(bp,x) | 176 | IMPLEMENT_PEM_rw(DSAparams, DSA, PEM_STRING_DSAPARAMS, DSAparams) |
| 400 | BIO *bp; | ||
| 401 | PKCS7 *x; | ||
| 402 | { | ||
| 403 | return(PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, | ||
| 404 | (char *)x, NULL,NULL,0,NULL)); | ||
| 405 | } | ||
| 406 | 177 | ||
| 407 | #ifndef NO_DH | ||
| 408 | #ifndef NO_FP_API | ||
| 409 | /* The DHparams functions */ | ||
| 410 | DH *PEM_read_DHparams(fp,x,cb) | ||
| 411 | FILE *fp; | ||
| 412 | DH **x; | ||
| 413 | int (*cb)(); | ||
| 414 | { | ||
| 415 | return((DH *)PEM_ASN1_read((char *(*)())d2i_DHparams, | ||
| 416 | PEM_STRING_DHPARAMS,fp,(char **)x,cb)); | ||
| 417 | } | ||
| 418 | #endif | 178 | #endif |
| 419 | 179 | ||
| 420 | DH *PEM_read_bio_DHparams(bp,x,cb) | 180 | #ifndef OPENSSL_NO_DH |
| 421 | BIO *bp; | ||
| 422 | DH **x; | ||
| 423 | int (*cb)(); | ||
| 424 | { | ||
| 425 | return((DH *)PEM_ASN1_read_bio((char *(*)())d2i_DHparams, | ||
| 426 | PEM_STRING_DHPARAMS,bp,(char **)x,cb)); | ||
| 427 | } | ||
| 428 | 181 | ||
| 429 | #ifndef NO_FP_API | 182 | IMPLEMENT_PEM_rw(DHparams, DH, PEM_STRING_DHPARAMS, DHparams) |
| 430 | int PEM_write_DHparams(fp,x) | ||
| 431 | FILE *fp; | ||
| 432 | DH *x; | ||
| 433 | { | ||
| 434 | return(PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp, | ||
| 435 | (char *)x, NULL,NULL,0,NULL)); | ||
| 436 | } | ||
| 437 | #endif | ||
| 438 | 183 | ||
| 439 | int PEM_write_bio_DHparams(bp,x) | ||
| 440 | BIO *bp; | ||
| 441 | DH *x; | ||
| 442 | { | ||
| 443 | return(PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS, | ||
| 444 | bp,(char *)x, NULL,NULL,0,NULL)); | ||
| 445 | } | ||
| 446 | #endif | 184 | #endif |
| 447 | 185 | ||
| 448 | #ifndef NO_DSA | ||
| 449 | #ifndef NO_FP_API | ||
| 450 | /* The DSAparams functions */ | ||
| 451 | DSA *PEM_read_DSAparams(fp,x,cb) | ||
| 452 | FILE *fp; | ||
| 453 | DSA **x; | ||
| 454 | int (*cb)(); | ||
| 455 | { | ||
| 456 | return((DSA *)PEM_ASN1_read((char *(*)())d2i_DSAparams, | ||
| 457 | PEM_STRING_DSAPARAMS,fp,(char **)x,cb)); | ||
| 458 | } | ||
| 459 | #endif | ||
| 460 | 186 | ||
| 461 | DSA *PEM_read_bio_DSAparams(bp,x,cb) | 187 | /* The PrivateKey case is not that straightforward. |
| 462 | BIO *bp; | 188 | * IMPLEMENT_PEM_rw_cb(PrivateKey, EVP_PKEY, PEM_STRING_EVP_PKEY, PrivateKey) |
| 463 | DSA **x; | 189 | * does not work, RSA and DSA keys have specific strings. |
| 464 | int (*cb)(); | 190 | * (When reading, parameter PEM_STRING_EVP_PKEY is a wildcard for anything |
| 465 | { | 191 | * appropriate.) |
| 466 | return((DSA *)PEM_ASN1_read_bio((char *(*)())d2i_DSAparams, | 192 | */ |
| 467 | PEM_STRING_DSAPARAMS,bp,(char **)x,cb)); | 193 | IMPLEMENT_PEM_write_cb(PrivateKey, EVP_PKEY, ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA), PrivateKey) |
| 468 | } | ||
| 469 | |||
| 470 | #ifndef NO_FP_API | ||
| 471 | int PEM_write_DSAparams(fp,x) | ||
| 472 | FILE *fp; | ||
| 473 | DSA *x; | ||
| 474 | { | ||
| 475 | return(PEM_ASN1_write((int (*)())i2d_DSAparams,PEM_STRING_DSAPARAMS,fp, | ||
| 476 | (char *)x, NULL,NULL,0,NULL)); | ||
| 477 | } | ||
| 478 | #endif | ||
| 479 | 194 | ||
| 480 | int PEM_write_bio_DSAparams(bp,x) | 195 | IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) |
| 481 | BIO *bp; | ||
| 482 | DSA *x; | ||
| 483 | { | ||
| 484 | return(PEM_ASN1_write_bio((int (*)())i2d_DSAparams,PEM_STRING_DSAPARAMS, | ||
| 485 | bp,(char *)x, NULL,NULL,0,NULL)); | ||
| 486 | } | ||
| 487 | #endif | ||
| 488 | 196 | ||
