Remove old unused and unmaintained demonstration code.
[openssl.git] / crypto / asn1 / ameth_lib.c
index cd0e1f8fe542f2892a539f8add22cc7c2c0916cc..7df3076e3fbdcd6ad79a92ee0e78a0ecfd27b60c 100644 (file)
 extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[];
 extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[];
 extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth;
+extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth;
 extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth;
 extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;
+extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;
 
 /* Keep this sorted in type order !! */
 static const EVP_PKEY_ASN1_METHOD *standard_methods[] = 
@@ -90,7 +92,11 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] =
 #ifndef OPENSSL_NO_EC
        &eckey_asn1_meth,
 #endif
-       &hmac_asn1_meth
+       &hmac_asn1_meth,
+       &cmac_asn1_meth,
+#ifndef OPENSSL_NO_DH
+       &dhx_asn1_meth
+#endif
        };
 
 typedef int sk_cmp_fn_type(const char * const *a, const char * const *b);
@@ -172,7 +178,6 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)
 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type)
        {
        const EVP_PKEY_ASN1_METHOD *t;
-       ENGINE *e;
 
        for (;;)
                {
@@ -184,6 +189,7 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type)
        if (pe)
                {
 #ifndef OPENSSL_NO_ENGINE
+               ENGINE *e;
                /* type will contain the final unaliased type */
                e = ENGINE_get_pkey_asn1_meth_engine(type);
                if (e)
@@ -256,7 +262,12 @@ int EVP_PKEY_asn1_add_alias(int to, int from)
        if (!ameth)
                return 0;
        ameth->pkey_base_id = to;
-       return EVP_PKEY_asn1_add0(ameth);
+       if (!EVP_PKEY_asn1_add0(ameth))
+               {
+               EVP_PKEY_asn1_free(ameth);
+               return 0;
+               }
+       return 1;
        }
 
 int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags,
@@ -291,6 +302,8 @@ EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
        if (!ameth)
                return NULL;
 
+       memset(ameth, 0, sizeof(EVP_PKEY_ASN1_METHOD));
+
        ameth->pkey_id = id;
        ameth->pkey_base_id = id;
        ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
@@ -302,7 +315,7 @@ EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
                        goto err;
                }
        else
-               ameth->info = NULL
+               ameth->info = NULL;
 
        if (pem_str)
                {
@@ -311,7 +324,7 @@ EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
                        goto err;
                }
        else
-               ameth->pem_str = NULL
+               ameth->pem_str = NULL;
 
        ameth->pub_decode = 0;
        ameth->pub_encode = 0;
@@ -325,6 +338,9 @@ EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
        ameth->old_priv_encode = 0;
        ameth->old_priv_decode = 0;
 
+       ameth->item_verify = 0;
+       ameth->item_sign = 0;
+
        ameth->pkey_size = 0;
        ameth->pkey_bits = 0;
 
@@ -376,6 +392,9 @@ void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
        dst->pkey_free = src->pkey_free;
        dst->pkey_ctrl = src->pkey_ctrl;
 
+       dst->item_sign = src->item_sign;
+       dst->item_verify = src->item_verify;
+
        }
 
 void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth)
@@ -448,3 +467,10 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
        {
        ameth->pkey_ctrl = pkey_ctrl;
        }
+
+void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
+                               int (*pkey_security_bits)(const EVP_PKEY *pk))
+       {
+       ameth->pkey_security_bits = pkey_security_bits;
+       }
+