/* Now two pseudo ASN1 routines that take an EVP_PKEY structure and encode or decode as X509_PUBKEY  */
EVP_PKEY* d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length)
/* Now two pseudo ASN1 routines that take an EVP_PKEY structure and encode or decode as X509_PUBKEY  */
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);
    X509_PUBKEY_free(xpk);
    if (!pktmp)
        return NULL;
    if (a) {
        EVP_PKEY_free(*a);
        *a = pktmp;
    }
    return pktmp;
}