From: jsing Date: Fri, 3 Dec 2021 16:46:50 +0000 (+0000) Subject: Convert {i2d,d2i}_{,EC_,DSA_,RSA_}PUBKEY{,_bio,_fp}() to templated ASN1 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c983a0afb636a04462d8cd37c4566bcc8fb53991;p=openbsd Convert {i2d,d2i}_{,EC_,DSA_,RSA_}PUBKEY{,_bio,_fp}() to templated ASN1 These functions previously used the old ASN1_{d2i,i2d}_{bio,fp}() interfaces. ok inoguchi@ tb@ --- diff --git a/lib/libcrypto/asn1/x_pubkey.c b/lib/libcrypto/asn1/x_pubkey.c index cb16d03301d..3efe61db48f 100644 --- a/lib/libcrypto/asn1/x_pubkey.c +++ b/lib/libcrypto/asn1/x_pubkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_pubkey.c,v 1.28 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x_pubkey.c,v 1.29 2021/12/03 16:46:50 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -111,7 +111,6 @@ const ASN1_ITEM X509_PUBKEY_it = { .sname = "X509_PUBKEY", }; - X509_PUBKEY * d2i_X509_PUBKEY(X509_PUBKEY **a, const unsigned char **in, long len) { @@ -240,168 +239,473 @@ X509_PUBKEY_get(X509_PUBKEY *key) return pkey; } -/* Now two pseudo ASN1 routines that take an EVP_PKEY structure - * and encode or decode as X509_PUBKEY +/* + * Decode an X509_PUBKEY into the specified key type. */ +static int +pubkey_ex_d2i(int pkey_type, ASN1_VALUE **pval, const unsigned char **in, + long len, const ASN1_ITEM *it) +{ + const ASN1_EXTERN_FUNCS *ef = it->funcs; + const unsigned char *p = *in; + X509_PUBKEY *xpk = NULL; + ASN1_VALUE *key = NULL; + EVP_PKEY *pkey = NULL; + int ret = 0; + + if ((xpk = d2i_X509_PUBKEY(NULL, &p, len)) == NULL) + goto err; + if ((pkey = X509_PUBKEY_get(xpk)) == NULL) + goto err; + + switch (pkey_type) { + case EVP_PKEY_NONE: + key = (ASN1_VALUE *)pkey; + pkey = NULL; + break; + + case EVP_PKEY_DSA: + key = (ASN1_VALUE *)EVP_PKEY_get1_DSA(pkey); + break; + + case EVP_PKEY_RSA: + key = (ASN1_VALUE *)EVP_PKEY_get1_RSA(pkey); + break; + + case EVP_PKEY_EC: + key = (ASN1_VALUE *)EVP_PKEY_get1_EC_KEY(pkey); + break; + + default: + goto err; + } -EVP_PKEY * -d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length) -{ - X509_PUBKEY *xpk; - EVP_PKEY *pktmp; - xpk = d2i_X509_PUBKEY(NULL, pp, length); - if (!xpk) - return NULL; - pktmp = X509_PUBKEY_get(xpk); + if (key == NULL) + goto err; + + ef->asn1_ex_free(pval, it); + + *pval = key; + *in = p; + ret = 1; + + err: + EVP_PKEY_free(pkey); X509_PUBKEY_free(xpk); - if (!pktmp) - return NULL; - if (a) { - EVP_PKEY_free(*a); - *a = pktmp; - } - return pktmp; + + return ret; } -int -i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp) +/* + * Encode the specified key type into an X509_PUBKEY. + */ +static int +pubkey_ex_i2d(int pkey_type, ASN1_VALUE **pval, unsigned char **out, + const ASN1_ITEM *it) { X509_PUBKEY *xpk = NULL; - int ret; - if (!a) - return 0; - if (!X509_PUBKEY_set(&xpk, a)) - return 0; - ret = i2d_X509_PUBKEY(xpk, pp); + EVP_PKEY *pkey, *pktmp; + int ret = -1; + + if ((pkey = pktmp = EVP_PKEY_new()) == NULL) + goto err; + + switch (pkey_type) { + case EVP_PKEY_NONE: + pkey = (EVP_PKEY *)*pval; + break; + + case EVP_PKEY_DSA: + if (!EVP_PKEY_set1_DSA(pkey, (DSA *)*pval)) + goto err; + break; + + case EVP_PKEY_RSA: + if (!EVP_PKEY_set1_RSA(pkey, (RSA *)*pval)) + goto err; + break; + + case EVP_PKEY_EC: + if (!EVP_PKEY_set1_EC_KEY(pkey, (EC_KEY*)*pval)) + goto err; + break; + + default: + goto err; + } + + if (!X509_PUBKEY_set(&xpk, pkey)) + goto err; + + ret = i2d_X509_PUBKEY(xpk, out); + + err: + EVP_PKEY_free(pktmp); X509_PUBKEY_free(xpk); + return ret; } -/* The following are equivalents but which return RSA and DSA - * keys +static int +pkey_pubkey_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) +{ + if ((*pval = (ASN1_VALUE *)EVP_PKEY_new()) == NULL) + return 0; + + return 1; +} + +static void +pkey_pubkey_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) +{ + EVP_PKEY_free((EVP_PKEY *)*pval); + *pval = NULL; +} + +static int +pkey_pubkey_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) +{ + return pubkey_ex_d2i(EVP_PKEY_NONE, pval, in, len, it); +} + +static int +pkey_pubkey_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, + int tag, int aclass) +{ + return pubkey_ex_i2d(EVP_PKEY_NONE, pval, out, it); +} + +const ASN1_EXTERN_FUNCS pkey_pubkey_asn1_ff = { + .app_data = NULL, + .asn1_ex_new = pkey_pubkey_ex_new, + .asn1_ex_free = pkey_pubkey_ex_free, + .asn1_ex_clear = NULL, + .asn1_ex_d2i = pkey_pubkey_ex_d2i, + .asn1_ex_i2d = pkey_pubkey_ex_i2d, + .asn1_ex_print = NULL, +}; + +const ASN1_ITEM EVP_PKEY_PUBKEY_it = { + .itype = ASN1_ITYPE_EXTERN, + .utype = 0, + .templates = NULL, + .tcount = 0, + .funcs = &pkey_pubkey_asn1_ff, + .size = 0, + .sname = NULL, +}; + +EVP_PKEY * +d2i_PUBKEY(EVP_PKEY **pkey, const unsigned char **in, long len) +{ + return (EVP_PKEY *)ASN1_item_d2i((ASN1_VALUE **)pkey, in, len, + &EVP_PKEY_PUBKEY_it); +} + +int +i2d_PUBKEY(EVP_PKEY *pkey, unsigned char **out) +{ + return ASN1_item_i2d((ASN1_VALUE *)pkey, out, &EVP_PKEY_PUBKEY_it); +} + +EVP_PKEY * +d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **pkey) +{ + return (EVP_PKEY *)ASN1_item_d2i_bio(&EVP_PKEY_PUBKEY_it, bp, + (ASN1_VALUE **)pkey); +} + +int +i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey) +{ + return ASN1_item_i2d_bio(&EVP_PKEY_PUBKEY_it, bp, (ASN1_VALUE *)pkey); +} + +EVP_PKEY * +d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **pkey) +{ + return (EVP_PKEY *)ASN1_item_d2i_fp(&EVP_PKEY_PUBKEY_it, fp, + (ASN1_VALUE **)pkey); +} + +int +i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey) +{ + return ASN1_item_i2d_fp(&EVP_PKEY_PUBKEY_it, fp, (ASN1_VALUE *)pkey); +} + +/* + * The following are equivalents but which return RSA and DSA keys. */ #ifndef OPENSSL_NO_RSA + +static int +rsa_pubkey_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) +{ + if ((*pval = (ASN1_VALUE *)RSA_new()) == NULL) + return 0; + + return 1; +} + +static void +rsa_pubkey_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) +{ + RSA_free((RSA *)*pval); + *pval = NULL; +} + +static int +rsa_pubkey_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) +{ + return pubkey_ex_d2i(EVP_PKEY_RSA, pval, in, len, it); +} + +static int +rsa_pubkey_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, + int tag, int aclass) +{ + return pubkey_ex_i2d(EVP_PKEY_RSA, pval, out, it); +} + +const ASN1_EXTERN_FUNCS rsa_pubkey_asn1_ff = { + .app_data = NULL, + .asn1_ex_new = rsa_pubkey_ex_new, + .asn1_ex_free = rsa_pubkey_ex_free, + .asn1_ex_clear = NULL, + .asn1_ex_d2i = rsa_pubkey_ex_d2i, + .asn1_ex_i2d = rsa_pubkey_ex_i2d, + .asn1_ex_print = NULL, +}; + +const ASN1_ITEM RSA_PUBKEY_it = { + .itype = ASN1_ITYPE_EXTERN, + .utype = 0, + .templates = NULL, + .tcount = 0, + .funcs = &rsa_pubkey_asn1_ff, + .size = 0, + .sname = NULL, +}; + RSA * -d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length) +d2i_RSA_PUBKEY(RSA **rsa, const unsigned char **in, long len) { - EVP_PKEY *pkey; - RSA *key; - const unsigned char *q; - q = *pp; - pkey = d2i_PUBKEY(NULL, &q, length); - if (!pkey) - return NULL; - key = EVP_PKEY_get1_RSA(pkey); - EVP_PKEY_free(pkey); - if (!key) - return NULL; - *pp = q; - if (a) { - RSA_free(*a); - *a = key; - } - return key; + return (RSA *)ASN1_item_d2i((ASN1_VALUE **)rsa, in, len, + &RSA_PUBKEY_it); } int -i2d_RSA_PUBKEY(RSA *a, unsigned char **pp) +i2d_RSA_PUBKEY(RSA *rsa, unsigned char **out) { - EVP_PKEY *pktmp; - int ret; - if (!a) - return 0; - pktmp = EVP_PKEY_new(); - if (!pktmp) { - ASN1error(ERR_R_MALLOC_FAILURE); - return 0; - } - EVP_PKEY_set1_RSA(pktmp, a); - ret = i2d_PUBKEY(pktmp, pp); - EVP_PKEY_free(pktmp); - return ret; + return ASN1_item_i2d((ASN1_VALUE *)rsa, out, &RSA_PUBKEY_it); +} + +RSA * +d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa) +{ + return (RSA *)ASN1_item_d2i_bio(&RSA_PUBKEY_it, bp, (ASN1_VALUE **)rsa); +} + +int +i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa) +{ + return ASN1_item_i2d_bio(&RSA_PUBKEY_it, bp, (ASN1_VALUE *)rsa); +} + +RSA * +d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa) +{ + return (RSA *)ASN1_item_d2i_fp(&RSA_PUBKEY_it, fp, (ASN1_VALUE **)rsa); +} + +int +i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa) +{ + return ASN1_item_i2d_fp(&RSA_PUBKEY_it, fp, (ASN1_VALUE *)rsa); } #endif #ifndef OPENSSL_NO_DSA + +static int +dsa_pubkey_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) +{ + if ((*pval = (ASN1_VALUE *)DSA_new()) == NULL) + return 0; + + return 1; +} + +static void +dsa_pubkey_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) +{ + DSA_free((DSA *)*pval); + *pval = NULL; +} + +static int +dsa_pubkey_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) +{ + return pubkey_ex_d2i(EVP_PKEY_DSA, pval, in, len, it); +} + +static int +dsa_pubkey_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, + int tag, int aclass) +{ + return pubkey_ex_i2d(EVP_PKEY_DSA, pval, out, it); +} + +const ASN1_EXTERN_FUNCS dsa_pubkey_asn1_ff = { + .app_data = NULL, + .asn1_ex_new = dsa_pubkey_ex_new, + .asn1_ex_free = dsa_pubkey_ex_free, + .asn1_ex_clear = NULL, + .asn1_ex_d2i = dsa_pubkey_ex_d2i, + .asn1_ex_i2d = dsa_pubkey_ex_i2d, + .asn1_ex_print = NULL, +}; + +const ASN1_ITEM DSA_PUBKEY_it = { + .itype = ASN1_ITYPE_EXTERN, + .utype = 0, + .templates = NULL, + .tcount = 0, + .funcs = &dsa_pubkey_asn1_ff, + .size = 0, + .sname = NULL, +}; + DSA * -d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length) +d2i_DSA_PUBKEY(DSA **dsa, const unsigned char **in, long len) { - EVP_PKEY *pkey; - DSA *key; - const unsigned char *q; - q = *pp; - pkey = d2i_PUBKEY(NULL, &q, length); - if (!pkey) - return NULL; - key = EVP_PKEY_get1_DSA(pkey); - EVP_PKEY_free(pkey); - if (!key) - return NULL; - *pp = q; - if (a) { - DSA_free(*a); - *a = key; - } - return key; + return (DSA *)ASN1_item_d2i((ASN1_VALUE **)dsa, in, len, + &DSA_PUBKEY_it); } int -i2d_DSA_PUBKEY(DSA *a, unsigned char **pp) +i2d_DSA_PUBKEY(DSA *dsa, unsigned char **out) { - EVP_PKEY *pktmp; - int ret; - if (!a) - return 0; - pktmp = EVP_PKEY_new(); - if (!pktmp) { - ASN1error(ERR_R_MALLOC_FAILURE); - return 0; - } - EVP_PKEY_set1_DSA(pktmp, a); - ret = i2d_PUBKEY(pktmp, pp); - EVP_PKEY_free(pktmp); - return ret; + return ASN1_item_i2d((ASN1_VALUE *)dsa, out, &DSA_PUBKEY_it); +} + +DSA * +d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa) +{ + return (DSA *)ASN1_item_d2i_bio(&DSA_PUBKEY_it, bp, (ASN1_VALUE **)dsa); +} + +int +i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa) +{ + return ASN1_item_i2d_bio(&DSA_PUBKEY_it, bp, (ASN1_VALUE *)dsa); +} + +DSA * +d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa) +{ + return (DSA *)ASN1_item_d2i_fp(&DSA_PUBKEY_it, fp, (ASN1_VALUE **)dsa); } + +int +i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa) +{ + return ASN1_item_i2d_fp(&DSA_PUBKEY_it, fp, (ASN1_VALUE *)dsa); +} + #endif #ifndef OPENSSL_NO_EC + +static int +ec_pubkey_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) +{ + if ((*pval = (ASN1_VALUE *)EC_KEY_new()) == NULL) + return 0; + + return 1; +} + +static void +ec_pubkey_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) +{ + EC_KEY_free((EC_KEY *)*pval); + *pval = NULL; +} + +static int +ec_pubkey_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) +{ + return pubkey_ex_d2i(EVP_PKEY_EC, pval, in, len, it); +} + +static int +ec_pubkey_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, + int tag, int aclass) +{ + return pubkey_ex_i2d(EVP_PKEY_EC, pval, out, it); +} + +const ASN1_EXTERN_FUNCS ec_pubkey_asn1_ff = { + .app_data = NULL, + .asn1_ex_new = ec_pubkey_ex_new, + .asn1_ex_free = ec_pubkey_ex_free, + .asn1_ex_clear = NULL, + .asn1_ex_d2i = ec_pubkey_ex_d2i, + .asn1_ex_i2d = ec_pubkey_ex_i2d, + .asn1_ex_print = NULL, +}; + +const ASN1_ITEM EC_PUBKEY_it = { + .itype = ASN1_ITYPE_EXTERN, + .utype = 0, + .templates = NULL, + .tcount = 0, + .funcs = &ec_pubkey_asn1_ff, + .size = 0, + .sname = NULL, +}; + EC_KEY * -d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length) +d2i_EC_PUBKEY(EC_KEY **ec, const unsigned char **in, long len) { - EVP_PKEY *pkey; - EC_KEY *key; - const unsigned char *q; - q = *pp; - pkey = d2i_PUBKEY(NULL, &q, length); - if (!pkey) - return (NULL); - key = EVP_PKEY_get1_EC_KEY(pkey); - EVP_PKEY_free(pkey); - if (!key) - return (NULL); - *pp = q; - if (a) { - EC_KEY_free(*a); - *a = key; - } - return (key); + return (EC_KEY *)ASN1_item_d2i((ASN1_VALUE **)ec, in, len, + &EC_PUBKEY_it); } int -i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp) +i2d_EC_PUBKEY(EC_KEY *ec, unsigned char **out) { - EVP_PKEY *pktmp; - int ret; - if (!a) - return (0); - if ((pktmp = EVP_PKEY_new()) == NULL) { - ASN1error(ERR_R_MALLOC_FAILURE); - return (0); - } - EVP_PKEY_set1_EC_KEY(pktmp, a); - ret = i2d_PUBKEY(pktmp, pp); - EVP_PKEY_free(pktmp); - return (ret); + return ASN1_item_i2d((ASN1_VALUE *)ec, out, &EC_PUBKEY_it); +} + +EC_KEY * +d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **ec) +{ + return (EC_KEY *)ASN1_item_d2i_bio(&EC_PUBKEY_it, bp, (ASN1_VALUE **)ec); +} + +int +i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *ec) +{ + return ASN1_item_i2d_bio(&EC_PUBKEY_it, bp, (ASN1_VALUE *)ec); +} + +EC_KEY * +d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **ec) +{ + return (EC_KEY *)ASN1_item_d2i_fp(&EC_PUBKEY_it, fp, (ASN1_VALUE **)ec); +} + +int +i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *ec) +{ + return ASN1_item_i2d_fp(&EC_PUBKEY_it, fp, (ASN1_VALUE *)ec); } #endif diff --git a/lib/libcrypto/x509/x_all.c b/lib/libcrypto/x509/x_all.c index c06e74c9157..9bcb0c3bbef 100644 --- a/lib/libcrypto/x509/x_all.c +++ b/lib/libcrypto/x509/x_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_all.c,v 1.24 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x_all.c,v 1.25 2021/12/03 16:46:50 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -219,31 +219,6 @@ i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa) { return ASN1_item_i2d_fp(&RSAPublicKey_it, fp, rsa); } - -RSA * -d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa) -{ - return ASN1_d2i_bio_of(RSA, RSA_new, d2i_RSA_PUBKEY, bp, rsa); -} - -int -i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa) -{ - return ASN1_i2d_bio_of(RSA, i2d_RSA_PUBKEY, bp, rsa); -} - -int -i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa) -{ - return ASN1_i2d_fp((I2D_OF(void))i2d_RSA_PUBKEY, fp, rsa); -} - -RSA * -d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa) -{ - return ASN1_d2i_fp((void *(*)(void))RSA_new, - (D2I_OF(void))d2i_RSA_PUBKEY, fp, (void **)rsa); -} #endif #ifndef OPENSSL_NO_DSA @@ -270,30 +245,6 @@ i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa) { return ASN1_item_i2d_fp(&DSAPrivateKey_it, fp, dsa); } - -DSA * -d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa) -{ - return ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSA_PUBKEY, bp, dsa); -} - -int -i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa) -{ - return ASN1_i2d_bio_of(DSA, i2d_DSA_PUBKEY, bp, dsa); -} - -DSA * -d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa) -{ - return ASN1_d2i_fp_of(DSA, DSA_new, d2i_DSA_PUBKEY, fp, dsa); -} - -int -i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa) -{ - return ASN1_i2d_fp_of(DSA, i2d_DSA_PUBKEY, fp, dsa); -} #endif #ifndef OPENSSL_NO_EC @@ -320,29 +271,6 @@ i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey) { return ASN1_i2d_fp_of(EC_KEY, i2d_ECPrivateKey, fp, eckey); } - -EC_KEY * -d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey) -{ - return ASN1_d2i_bio_of(EC_KEY, EC_KEY_new, d2i_EC_PUBKEY, bp, eckey); -} - -int -i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *ecdsa) -{ - return ASN1_i2d_bio_of(EC_KEY, i2d_EC_PUBKEY, bp, ecdsa); -} -EC_KEY * -d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey) -{ - return ASN1_d2i_fp_of(EC_KEY, EC_KEY_new, d2i_EC_PUBKEY, fp, eckey); -} - -int -i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey) -{ - return ASN1_i2d_fp_of(EC_KEY, i2d_EC_PUBKEY, fp, eckey); -} #endif X509_SIG * @@ -423,30 +351,6 @@ i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey) return ASN1_i2d_fp_of(EVP_PKEY, i2d_PrivateKey, fp, pkey); } -EVP_PKEY * -d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a) -{ - return ASN1_d2i_bio_of(EVP_PKEY, EVP_PKEY_new, d2i_PUBKEY, bp, a); -} - -int -i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey) -{ - return ASN1_i2d_bio_of(EVP_PKEY, i2d_PUBKEY, bp, pkey); -} - -int -i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey) -{ - return ASN1_i2d_fp_of(EVP_PKEY, i2d_PUBKEY, fp, pkey); -} - -EVP_PKEY * -d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a) -{ - return ASN1_d2i_fp_of(EVP_PKEY, EVP_PKEY_new, d2i_PUBKEY, fp, a); -} - int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key) {