X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fasn1%2Fi2d_pr.c;h=e398b6266612ead688d0325ae443a32e0178492d;hp=b6b821d73c71c222d13d66925552d604381cc465;hb=46a6cec6998b84d85240dfb99af235c8a0854a31;hpb=58964a492275ca9a59a0cd9c8155cb2491b4b909 diff --git a/crypto/asn1/i2d_pr.c b/crypto/asn1/i2d_pr.c index b6b821d73c..e398b62666 100644 --- a/crypto/asn1/i2d_pr.c +++ b/crypto/asn1/i2d_pr.c @@ -58,28 +58,22 @@ #include #include "cryptlib.h" -#include "bn.h" -#include "evp.h" -#include "objects.h" +#include +#include +#include "asn1_locl.h" -int i2d_PrivateKey(a,pp) -EVP_PKEY *a; -unsigned char **pp; +int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp) { -#ifndef NO_RSA - if (a->type == EVP_PKEY_RSA) + if (a->ameth && a->ameth->old_priv_encode) { - return(i2d_RSAPrivateKey(a->pkey.rsa,pp)); + return a->ameth->old_priv_encode(a, pp); } - else -#endif -#ifndef NO_DSA - if (a->type == EVP_PKEY_DSA) - { - return(i2d_DSAPrivateKey(a->pkey.dsa,pp)); - } -#endif - + if (a->ameth && a->ameth->priv_encode) { + PKCS8_PRIV_KEY_INFO *p8 = EVP_PKEY2PKCS8(a); + int ret = i2d_PKCS8_PRIV_KEY_INFO(p8,pp); + PKCS8_PRIV_KEY_INFO_free(p8); + return ret; + } ASN1err(ASN1_F_I2D_PRIVATEKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); return(-1); }