diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2006-06-05 11:52:46 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2006-06-05 11:52:46 +0000 |
commit | 01b8b3c7d2d8f835257ac1cb2512273aa27bfba8 (patch) | |
tree | fb224473dca22be551086f10ed34240c802c6335 /crypto/engine | |
parent | 8fecd4b4f1bd6f066ba0a9f96387f00ac0dd99bf (diff) |
Complete EVP_PKEY_ASN1_METHOD ENGINE support.
Diffstat (limited to 'crypto/engine')
-rw-r--r-- | crypto/engine/eng_fat.c | 11 | ||||
-rw-r--r-- | crypto/engine/eng_int.h | 1 | ||||
-rw-r--r-- | crypto/engine/eng_lib.c | 1 | ||||
-rw-r--r-- | crypto/engine/engine.h | 5 | ||||
-rw-r--r-- | crypto/engine/tb_asnmth.c | 35 |
5 files changed, 49 insertions, 4 deletions
diff --git a/crypto/engine/eng_fat.c b/crypto/engine/eng_fat.c index 41d511a033..db66e62350 100644 --- a/crypto/engine/eng_fat.c +++ b/crypto/engine/eng_fat.c @@ -89,7 +89,11 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags) #endif if((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e)) return 0; - if((flags & ENGINE_METHOD_PKEY_METHS) && !ENGINE_set_default_pkey_meths(e)) + if((flags & ENGINE_METHOD_PKEY_METHS) + && !ENGINE_set_default_pkey_meths(e)) + return 0; + if((flags & ENGINE_METHOD_PKEY_ASN1_METHS) + && !ENGINE_set_default_pkey_asn1_meths(e)) return 0; return 1; } @@ -118,7 +122,12 @@ static int int_def_cb(const char *alg, int len, void *arg) else if (!strncmp(alg, "DIGESTS", len)) *pflags |= ENGINE_METHOD_DIGESTS; else if (!strncmp(alg, "PKEY", len)) + *pflags |= + ENGINE_METHOD_PKEY_METHS|ENGINE_METHOD_PKEY_ASN1_METHS; + else if (!strncmp(alg, "PKEY_CRYPTO", len)) *pflags |= ENGINE_METHOD_PKEY_METHS; + else if (!strncmp(alg, "PKEY_ASN1", len)) + *pflags |= ENGINE_METHOD_PKEY_ASN1_METHS; else return 0; return 1; diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h index 8630597fe0..8bee5962c5 100644 --- a/crypto/engine/eng_int.h +++ b/crypto/engine/eng_int.h @@ -146,6 +146,7 @@ void engine_set_all_null(ENGINE *e); /* Free up dynamically allocated public key methods associated with ENGINE */ void engine_pkey_meths_free(ENGINE *e); +void engine_pkey_asn1_meths_free(ENGINE *e); /* This is a structure for storing implementations of various crypto * algorithms and functions. */ diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c index 6ee8a90c15..18a6664645 100644 --- a/crypto/engine/eng_lib.c +++ b/crypto/engine/eng_lib.c @@ -127,6 +127,7 @@ int engine_free_util(ENGINE *e, int locked) #endif /* Free up any dynamically allocated public key methods */ engine_pkey_meths_free(e); + engine_pkey_asn1_meths_free(e); /* Give the ENGINE a chance to do any structural cleanup corresponding * to allocation it did in its constructor (eg. unload error strings) */ if(e->destroy) diff --git a/crypto/engine/engine.h b/crypto/engine/engine.h index 803ebf31b2..9a2eb68646 100644 --- a/crypto/engine/engine.h +++ b/crypto/engine/engine.h @@ -112,6 +112,7 @@ extern "C" { #define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 #define ENGINE_METHOD_STORE (unsigned int)0x0100 #define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 +#define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 /* Obvious all-or-nothing cases. */ #define ENGINE_METHOD_ALL (unsigned int)0xFFFF #define ENGINE_METHOD_NONE (unsigned int)0x0000 @@ -510,6 +511,8 @@ const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); +const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, + const char *str, int len); const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); int ENGINE_get_flags(const ENGINE *e); @@ -558,6 +561,7 @@ ENGINE *ENGINE_get_default_RAND(void); ENGINE *ENGINE_get_cipher_engine(int nid); ENGINE *ENGINE_get_digest_engine(int nid); ENGINE *ENGINE_get_pkey_meth_engine(int nid); +ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid); /* This sets a new default ENGINE structure for performing RSA * operations. If the result is non-zero (success) then the ENGINE @@ -574,6 +578,7 @@ int ENGINE_set_default_RAND(ENGINE *e); int ENGINE_set_default_ciphers(ENGINE *e); int ENGINE_set_default_digests(ENGINE *e); int ENGINE_set_default_pkey_meths(ENGINE *e); +int ENGINE_set_default_pkey_asn1_meths(ENGINE *e); /* The combination "set" - the flags are bitwise "OR"d from the * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" diff --git a/crypto/engine/tb_asnmth.c b/crypto/engine/tb_asnmth.c index b2363a7f00..2476d05912 100644 --- a/crypto/engine/tb_asnmth.c +++ b/crypto/engine/tb_asnmth.c @@ -53,10 +53,12 @@ */ #include "eng_int.h" +#include "asn1_locl.h" -/* If this symbol is defined then ENGINE_get_pkey_asn1_meth_engine(), the function - * that is used by EVP to hook in pkey_asn1_meth code and cache defaults (etc), will - * display brief debugging summaries to stderr with the 'nid'. */ +/* If this symbol is defined then ENGINE_get_pkey_asn1_meth_engine(), the + * function that is used by EVP to hook in pkey_asn1_meth code and cache + * defaults (etc), will display brief debugging summaries to stderr with the + * 'nid'. */ /* #define ENGINE_PKEY_ASN1_METH_DEBUG */ static ENGINE_TABLE *pkey_asn1_meth_table = NULL; @@ -164,3 +166,30 @@ void engine_pkey_asn1_meths_free(ENGINE *e) } } } + +/* Find a method based on a string. This does a linear search through + * all implemented algorithms. This is OK in practice because only + * a small number of algorithms are likely to be implemented in an engine + * and it is only used for non speed critical operations. + */ + +const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, + const char *str, int len) + { + int i, nidcount; + const int *nids; + EVP_PKEY_ASN1_METHOD *ameth; + if (!e->pkey_asn1_meths) + return NULL; + if (len == -1) + len = strlen(str); + nidcount = e->pkey_asn1_meths(e, NULL, &nids, 0); + for (i = 0; i < nidcount; i++) + { + e->pkey_asn1_meths(e, &ameth, NULL, nids[i]); + if (((int)strlen(ameth->pem_str) == len) && + !strncasecmp(ameth->pem_str, str, len)) + return ameth; + } + return NULL; + } |