EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) { EVP_PKEY_ASN1_METHOD *ameth = OPENSSL_zalloc(sizeof(*ameth)); if (ameth == NULL) return NULL; ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; if (info) { ameth->info = OPENSSL_strdup(info); if (!ameth->info) goto err; } if (pem_str) { ameth->pem_str = OPENSSL_strdup(pem_str); if (!ameth->pem_str) goto err; } return ameth; err: EVP_PKEY_asn1_free(ameth); return NULL; }
EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) { EVP_PKEY_ASN1_METHOD *ameth; ameth = OPENSSL_malloc(sizeof(EVP_PKEY_ASN1_METHOD)); if (!ameth) return NULL; ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; if (info) { ameth->info = BUF_strdup(info); if (!ameth->info) goto err; } else ameth->info = NULL; if (pem_str) { ameth->pem_str = BUF_strdup(pem_str); if (!ameth->pem_str) goto err; } else ameth->pem_str = NULL; ameth->pub_decode = 0; ameth->pub_encode = 0; ameth->pub_cmp = 0; ameth->pub_print = 0; ameth->priv_decode = 0; ameth->priv_encode = 0; ameth->priv_print = 0; ameth->old_priv_encode = 0; ameth->old_priv_decode = 0; ameth->pkey_size = 0; ameth->pkey_bits = 0; ameth->param_decode = 0; ameth->param_encode = 0; ameth->param_missing = 0; ameth->param_copy = 0; ameth->param_cmp = 0; ameth->param_print = 0; ameth->pkey_free = 0; ameth->pkey_ctrl = 0; return ameth; err: EVP_PKEY_asn1_free(ameth); return NULL; }
int EVP_PKEY_asn1_add_alias(int to, int from) { EVP_PKEY_ASN1_METHOD *ameth; ameth = EVP_PKEY_asn1_new(from, ASN1_PKEY_ALIAS, NULL, NULL); if (!ameth) return 0; ameth->pkey_base_id = to; if (!EVP_PKEY_asn1_add0(ameth)) { EVP_PKEY_asn1_free(ameth); return 0; } return 1; }
void engine_pkey_asn1_meths_free(ENGINE *e) { int i; EVP_PKEY_ASN1_METHOD *pkm; if (e->pkey_asn1_meths) { const int *pknids; int npknids; npknids = e->pkey_asn1_meths(e, NULL, &pknids, 0); for (i = 0; i < npknids; i++) { if (e->pkey_asn1_meths(e, &pkm, NULL, pknids[i])) { EVP_PKEY_asn1_free(pkm); } } } }
EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) { EVP_PKEY_ASN1_METHOD *ameth = OPENSSL_zalloc(sizeof(*ameth)); if (ameth == NULL) return NULL; ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; if (info) { ameth->info = OPENSSL_strdup(info); if (!ameth->info) goto err; } /* * One of the following must be true: * * pem_str == NULL AND ASN1_PKEY_ALIAS is set * pem_str != NULL AND ASN1_PKEY_ALIAS is clear * * Anything else is an error and may lead to a corrupt ASN1 method table */ if (!((pem_str == NULL && (flags & ASN1_PKEY_ALIAS) != 0) || (pem_str != NULL && (flags & ASN1_PKEY_ALIAS) == 0))) goto err; if (pem_str) { ameth->pem_str = OPENSSL_strdup(pem_str); if (!ameth->pem_str) goto err; } return ameth; err: EVP_PKEY_asn1_free(ameth); return NULL; }