From 3e4585c8fd0b23f884d775462736502599146af6 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Tue, 28 Mar 2006 14:35:32 +0000 Subject: New utility pkeyparam. Enhance and bugfix algorithm specific parameter functions to support it. --- crypto/pem/pem.h | 3 +++ crypto/pem/pem_lib.c | 14 ++++++++++++++ crypto/pem/pem_pkey.c | 6 +++--- 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'crypto/pem') diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h index b273007c0e..e4c91adf58 100644 --- a/crypto/pem/pem.h +++ b/crypto/pem/pem.h @@ -673,6 +673,9 @@ EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, vo int PEM_write_PKCS8PrivateKey(FILE *fp,EVP_PKEY *x,const EVP_CIPHER *enc, char *kstr,int klen, pem_password_cb *cd, void *u); +EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); +int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x); + #endif /* SSLEAY_MACROS */ diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c index 22793fada0..9631ee2d5d 100644 --- a/crypto/pem/pem_lib.c +++ b/crypto/pem/pem_lib.c @@ -204,6 +204,20 @@ static int check_pem(const char *nm, const char *name) return 0; } + if(!strcmp(name,PEM_STRING_PARAMETERS)) + { + int slen; + const EVP_PKEY_ASN1_METHOD *ameth; + slen = pem_check_suffix(nm, "PARAMETERS"); + if (slen > 0) + { + ameth = EVP_PKEY_asn1_find_str(nm, slen); + if (ameth && ameth->param_decode) + return 1; + } + return 0; + } + /* Permit older strings */ if(!strcmp(nm,PEM_STRING_X509_OLD) && diff --git a/crypto/pem/pem_pkey.c b/crypto/pem/pem_pkey.c index b9067e0745..7747a057f4 100644 --- a/crypto/pem/pem_pkey.c +++ b/crypto/pem/pem_pkey.c @@ -149,7 +149,7 @@ int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, pem_str,bp,(char *)x,enc,kstr,klen,cb,u); } -EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u) +EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x) { char *nm=NULL; const unsigned char *p=NULL; @@ -159,7 +159,7 @@ EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, vo EVP_PKEY *ret=NULL; if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_PARAMETERS, - bp, cb, u)) + bp, 0, NULL)) return NULL; p = data; @@ -192,7 +192,7 @@ err: return(ret); } -int PEM_write_bio_Paramters(BIO *bp, EVP_PKEY *x) +int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x) { char pem_str[80]; if (!x->ameth || !x->ameth->param_encode) -- cgit v1.2.3