diff options
Diffstat (limited to 'lib/libcrypto')
-rw-r--r-- | lib/libcrypto/engine/tb_asnmth.c | 167 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_cipher.c | 97 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_dh.c | 68 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_digest.c | 97 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_dsa.c | 68 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_ecdh.c | 68 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_ecdsa.c | 68 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_pkmeth.c | 114 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_rand.c | 68 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_rsa.c | 68 | ||||
-rw-r--r-- | lib/libcrypto/engine/tb_store.c | 68 |
11 files changed, 516 insertions, 435 deletions
diff --git a/lib/libcrypto/engine/tb_asnmth.c b/lib/libcrypto/engine/tb_asnmth.c index 75090339f7a..bd62f292c9a 100644 --- a/lib/libcrypto/engine/tb_asnmth.c +++ b/lib/libcrypto/engine/tb_asnmth.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -64,109 +64,115 @@ static ENGINE_TABLE *pkey_asn1_meth_table = NULL; -void ENGINE_unregister_pkey_asn1_meths(ENGINE *e) - { +void +ENGINE_unregister_pkey_asn1_meths(ENGINE *e) +{ engine_table_unregister(&pkey_asn1_meth_table, e); - } +} -static void engine_unregister_all_pkey_asn1_meths(void) - { +static void +engine_unregister_all_pkey_asn1_meths(void) +{ engine_table_cleanup(&pkey_asn1_meth_table); - } +} -int ENGINE_register_pkey_asn1_meths(ENGINE *e) - { - if(e->pkey_asn1_meths) - { +int +ENGINE_register_pkey_asn1_meths(ENGINE *e) +{ + if (e->pkey_asn1_meths) { const int *nids; int num_nids = e->pkey_asn1_meths(e, NULL, &nids, 0); - if(num_nids > 0) + if (num_nids > 0) return engine_table_register(&pkey_asn1_meth_table, - engine_unregister_all_pkey_asn1_meths, e, nids, - num_nids, 0); - } - return 1; + engine_unregister_all_pkey_asn1_meths, e, nids, + num_nids, 0); } + return 1; +} -void ENGINE_register_all_pkey_asn1_meths(void) - { +void +ENGINE_register_all_pkey_asn1_meths(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_pkey_asn1_meths(e); - } +} -int ENGINE_set_default_pkey_asn1_meths(ENGINE *e) - { - if(e->pkey_asn1_meths) - { +int +ENGINE_set_default_pkey_asn1_meths(ENGINE *e) +{ + if (e->pkey_asn1_meths) { const int *nids; int num_nids = e->pkey_asn1_meths(e, NULL, &nids, 0); - if(num_nids > 0) + if (num_nids > 0) return engine_table_register(&pkey_asn1_meth_table, - engine_unregister_all_pkey_asn1_meths, e, nids, - num_nids, 1); - } - return 1; + engine_unregister_all_pkey_asn1_meths, e, nids, + num_nids, 1); } + return 1; +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references) for a given pkey_asn1_meth 'nid' */ -ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid) - { +ENGINE * +ENGINE_get_pkey_asn1_meth_engine(int nid) +{ return engine_table_select(&pkey_asn1_meth_table, nid); - } +} /* Obtains a pkey_asn1_meth implementation from an ENGINE functional reference */ -const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid) - { +const EVP_PKEY_ASN1_METHOD * +ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid) +{ EVP_PKEY_ASN1_METHOD *ret; ENGINE_PKEY_ASN1_METHS_PTR fn = ENGINE_get_pkey_asn1_meths(e); - if(!fn || !fn(e, &ret, NULL, nid)) - { + + if (!fn || !fn(e, &ret, NULL, nid)) { ENGINEerr(ENGINE_F_ENGINE_GET_PKEY_ASN1_METH, - ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); + ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); return NULL; - } - return ret; } + return ret; +} /* Gets the pkey_asn1_meth callback from an ENGINE structure */ -ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e) - { +ENGINE_PKEY_ASN1_METHS_PTR +ENGINE_get_pkey_asn1_meths(const ENGINE *e) +{ return e->pkey_asn1_meths; - } +} /* Sets the pkey_asn1_meth callback in an ENGINE structure */ -int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f) - { +int +ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f) +{ e->pkey_asn1_meths = f; return 1; - } +} /* Internal function to free up EVP_PKEY_ASN1_METHOD structures before an * ENGINE is destroyed */ -void engine_pkey_asn1_meths_free(ENGINE *e) - { +void +engine_pkey_asn1_meths_free(ENGINE *e) +{ int i; EVP_PKEY_ASN1_METHOD *pkm; - if (e->pkey_asn1_meths) - { + + 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])) - { + for (i = 0; i < npknids; i++) { + if (e->pkey_asn1_meths(e, &pkm, NULL, pknids[i])) { EVP_PKEY_asn1_free(pkm); - } } } } +} /* Find a method based on a string. This does a linear search through * all implemented algorithms. This is OK in practice because only @@ -174,60 +180,60 @@ void engine_pkey_asn1_meths_free(ENGINE *e) * and it is not used for speed critical operations. */ -const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, - const char *str, int len) - { +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++) - { + 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)) + if (((int)strlen(ameth->pem_str) == len) && + !strncasecmp(ameth->pem_str, str, len)) return ameth; - } - return NULL; } + return NULL; +} -typedef struct - { +typedef struct { ENGINE *e; const EVP_PKEY_ASN1_METHOD *ameth; const char *str; int len; - } ENGINE_FIND_STR; +} ENGINE_FIND_STR; -static void look_str_cb(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg) - { +static void +look_str_cb(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg) +{ ENGINE_FIND_STR *lk = arg; int i; + if (lk->ameth) return; - for (i = 0; i < sk_ENGINE_num(sk); i++) - { + for (i = 0; i < sk_ENGINE_num(sk); i++) { ENGINE *e = sk_ENGINE_value(sk, i); EVP_PKEY_ASN1_METHOD *ameth; e->pkey_asn1_meths(e, &ameth, NULL, nid); - if (((int)strlen(ameth->pem_str) == lk->len) && - !strncasecmp(ameth->pem_str, lk->str, lk->len)) - { + if (((int)strlen(ameth->pem_str) == lk->len) && + !strncasecmp(ameth->pem_str, lk->str, lk->len)) { lk->e = e; lk->ameth = ameth; return; - } } } +} -const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, - const char *str, int len) - { +const EVP_PKEY_ASN1_METHOD * +ENGINE_pkey_asn1_find_str(ENGINE **pe, const char *str, int len) +{ ENGINE_FIND_STR fstr; + fstr.e = NULL; fstr.ameth = NULL; fstr.str = str; @@ -235,12 +241,11 @@ const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); engine_table_doall(pkey_asn1_meth_table, look_str_cb, &fstr); /* If found obtain a structural reference to engine */ - if (fstr.e) - { + if (fstr.e) { fstr.e->struct_ref++; engine_ref_debug(fstr.e, 0, 1) - } + } *pe = fstr.e; CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); return fstr.ameth; - } +} diff --git a/lib/libcrypto/engine/tb_cipher.c b/lib/libcrypto/engine/tb_cipher.c index 8d45a9a9cf4..3218f5d86f2 100644 --- a/lib/libcrypto/engine/tb_cipher.c +++ b/lib/libcrypto/engine/tb_cipher.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -61,83 +61,90 @@ static ENGINE_TABLE *cipher_table = NULL; -void ENGINE_unregister_ciphers(ENGINE *e) - { +void +ENGINE_unregister_ciphers(ENGINE *e) +{ engine_table_unregister(&cipher_table, e); - } +} -static void engine_unregister_all_ciphers(void) - { +static void +engine_unregister_all_ciphers(void) +{ engine_table_cleanup(&cipher_table); - } +} -int ENGINE_register_ciphers(ENGINE *e) - { - if(e->ciphers) - { +int +ENGINE_register_ciphers(ENGINE *e) +{ + if (e->ciphers) { const int *nids; int num_nids = e->ciphers(e, NULL, &nids, 0); - if(num_nids > 0) + if (num_nids > 0) return engine_table_register(&cipher_table, - engine_unregister_all_ciphers, e, nids, - num_nids, 0); - } - return 1; + engine_unregister_all_ciphers, e, nids, + num_nids, 0); } + return 1; +} -void ENGINE_register_all_ciphers(void) - { +void +ENGINE_register_all_ciphers(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_ciphers(e); - } +} -int ENGINE_set_default_ciphers(ENGINE *e) - { - if(e->ciphers) - { +int +ENGINE_set_default_ciphers(ENGINE *e) +{ + if (e->ciphers) { const int *nids; int num_nids = e->ciphers(e, NULL, &nids, 0); - if(num_nids > 0) + if (num_nids > 0) return engine_table_register(&cipher_table, - engine_unregister_all_ciphers, e, nids, - num_nids, 1); - } - return 1; + engine_unregister_all_ciphers, e, nids, + num_nids, 1); } + return 1; +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references) for a given cipher 'nid' */ -ENGINE *ENGINE_get_cipher_engine(int nid) - { +ENGINE * +ENGINE_get_cipher_engine(int nid) +{ return engine_table_select(&cipher_table, nid); - } +} /* Obtains a cipher implementation from an ENGINE functional reference */ -const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid) - { +const EVP_CIPHER * +ENGINE_get_cipher(ENGINE *e, int nid) +{ const EVP_CIPHER *ret; ENGINE_CIPHERS_PTR fn = ENGINE_get_ciphers(e); - if(!fn || !fn(e, &ret, NULL, nid)) - { + + if (!fn || !fn(e, &ret, NULL, nid)) { ENGINEerr(ENGINE_F_ENGINE_GET_CIPHER, - ENGINE_R_UNIMPLEMENTED_CIPHER); + ENGINE_R_UNIMPLEMENTED_CIPHER); return NULL; - } - return ret; } + return ret; +} /* Gets the cipher callback from an ENGINE structure */ -ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e) - { +ENGINE_CIPHERS_PTR +ENGINE_get_ciphers(const ENGINE *e) +{ return e->ciphers; - } +} /* Sets the cipher callback in an ENGINE structure */ -int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f) - { +int +ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f) +{ e->ciphers = f; return 1; - } +} diff --git a/lib/libcrypto/engine/tb_dh.c b/lib/libcrypto/engine/tb_dh.c index 78515aeaa0c..6e3ee6dd7ce 100644 --- a/lib/libcrypto/engine/tb_dh.c +++ b/lib/libcrypto/engine/tb_dh.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -62,57 +62,65 @@ static ENGINE_TABLE *dh_table = NULL; static const int dummy_nid = 1; -void ENGINE_unregister_DH(ENGINE *e) - { +void +ENGINE_unregister_DH(ENGINE *e) +{ engine_table_unregister(&dh_table, e); - } +} -static void engine_unregister_all_DH(void) - { +static void +engine_unregister_all_DH(void) +{ engine_table_cleanup(&dh_table); - } +} -int ENGINE_register_DH(ENGINE *e) - { - if(e->dh_meth) +int +ENGINE_register_DH(ENGINE *e) +{ + if (e->dh_meth) return engine_table_register(&dh_table, - engine_unregister_all_DH, e, &dummy_nid, 1, 0); + engine_unregister_all_DH, e, &dummy_nid, 1, 0); return 1; - } +} -void ENGINE_register_all_DH(void) - { +void +ENGINE_register_all_DH(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_DH(e); - } +} -int ENGINE_set_default_DH(ENGINE *e) - { - if(e->dh_meth) +int +ENGINE_set_default_DH(ENGINE *e) +{ + if (e->dh_meth) return engine_table_register(&dh_table, - engine_unregister_all_DH, e, &dummy_nid, 1, 1); + engine_unregister_all_DH, e, &dummy_nid, 1, 1); return 1; - } +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ -ENGINE *ENGINE_get_default_DH(void) - { +ENGINE * +ENGINE_get_default_DH(void) +{ return engine_table_select(&dh_table, dummy_nid); - } +} /* Obtains an DH implementation from an ENGINE functional reference */ -const DH_METHOD *ENGINE_get_DH(const ENGINE *e) - { +const DH_METHOD * +ENGINE_get_DH(const ENGINE *e) +{ return e->dh_meth; - } +} /* Sets an DH implementation in an ENGINE structure */ -int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth) - { +int +ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth) +{ e->dh_meth = dh_meth; return 1; - } +} diff --git a/lib/libcrypto/engine/tb_digest.c b/lib/libcrypto/engine/tb_digest.c index d1bb90aedd6..6a7167e0713 100644 --- a/lib/libcrypto/engine/tb_digest.c +++ b/lib/libcrypto/engine/tb_digest.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -61,83 +61,90 @@ static ENGINE_TABLE *digest_table = NULL; -void ENGINE_unregister_digests(ENGINE *e) - { +void +ENGINE_unregister_digests(ENGINE *e) +{ engine_table_unregister(&digest_table, e); - } +} -static void engine_unregister_all_digests(void) - { +static void +engine_unregister_all_digests(void) +{ engine_table_cleanup(&digest_table); - } +} -int ENGINE_register_digests(ENGINE *e) - { - if(e->digests) - { +int +ENGINE_register_digests(ENGINE *e) +{ + if (e->digests) { const int *nids; int num_nids = e->digests(e, NULL, &nids, 0); - if(num_nids > 0) + if (num_nids > 0) return engine_table_register(&digest_table, - engine_unregister_all_digests, e, nids, - num_nids, 0); - } - return 1; + engine_unregister_all_digests, e, nids, + num_nids, 0); } + return 1; +} -void ENGINE_register_all_digests(void) - { +void +ENGINE_register_all_digests(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_digests(e); - } +} -int ENGINE_set_default_digests(ENGINE *e) - { - if(e->digests) - { +int +ENGINE_set_default_digests(ENGINE *e) +{ + if (e->digests) { const int *nids; int num_nids = e->digests(e, NULL, &nids, 0); - if(num_nids > 0) + if (num_nids > 0) return engine_table_register(&digest_table, - engine_unregister_all_digests, e, nids, - num_nids, 1); - } - return 1; + engine_unregister_all_digests, e, nids, + num_nids, 1); } + return 1; +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references) for a given digest 'nid' */ -ENGINE *ENGINE_get_digest_engine(int nid) - { +ENGINE * +ENGINE_get_digest_engine(int nid) +{ return engine_table_select(&digest_table, nid); - } +} /* Obtains a digest implementation from an ENGINE functional reference */ -const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid) - { +const EVP_MD * +ENGINE_get_digest(ENGINE *e, int nid) +{ const EVP_MD *ret; ENGINE_DIGESTS_PTR fn = ENGINE_get_digests(e); - if(!fn || !fn(e, &ret, NULL, nid)) - { + + if (!fn || !fn(e, &ret, NULL, nid)) { ENGINEerr(ENGINE_F_ENGINE_GET_DIGEST, - ENGINE_R_UNIMPLEMENTED_DIGEST); + ENGINE_R_UNIMPLEMENTED_DIGEST); return NULL; - } - return ret; } + return ret; +} /* Gets the digest callback from an ENGINE structure */ -ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e) - { +ENGINE_DIGESTS_PTR +ENGINE_get_digests(const ENGINE *e) +{ return e->digests; - } +} /* Sets the digest callback in an ENGINE structure */ -int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f) - { +int +ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f) +{ e->digests = f; return 1; - } +} diff --git a/lib/libcrypto/engine/tb_dsa.c b/lib/libcrypto/engine/tb_dsa.c index 6731aad1da7..0abc4bc7fbd 100644 --- a/lib/libcrypto/engine/tb_dsa.c +++ b/lib/libcrypto/engine/tb_dsa.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -62,57 +62,65 @@ static ENGINE_TABLE *dsa_table = NULL; static const int dummy_nid = 1; -void ENGINE_unregister_DSA(ENGINE *e) - { +void +ENGINE_unregister_DSA(ENGINE *e) +{ engine_table_unregister(&dsa_table, e); - } +} -static void engine_unregister_all_DSA(void) - { +static void +engine_unregister_all_DSA(void) +{ engine_table_cleanup(&dsa_table); - } +} -int ENGINE_register_DSA(ENGINE *e) - { - if(e->dsa_meth) +int +ENGINE_register_DSA(ENGINE *e) +{ + if (e->dsa_meth) return engine_table_register(&dsa_table, - engine_unregister_all_DSA, e, &dummy_nid, 1, 0); + engine_unregister_all_DSA, e, &dummy_nid, 1, 0); return 1; - } +} -void ENGINE_register_all_DSA(void) - { +void +ENGINE_register_all_DSA(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_DSA(e); - } +} -int ENGINE_set_default_DSA(ENGINE *e) - { - if(e->dsa_meth) +int +ENGINE_set_default_DSA(ENGINE *e) +{ + if (e->dsa_meth) return engine_table_register(&dsa_table, - engine_unregister_all_DSA, e, &dummy_nid, 1, 1); + engine_unregister_all_DSA, e, &dummy_nid, 1, 1); return 1; - } +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ -ENGINE *ENGINE_get_default_DSA(void) - { +ENGINE * +ENGINE_get_default_DSA(void) +{ return engine_table_select(&dsa_table, dummy_nid); - } +} /* Obtains an DSA implementation from an ENGINE functional reference */ -const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e) - { +const DSA_METHOD * +ENGINE_get_DSA(const ENGINE *e) +{ return e->dsa_meth; - } +} /* Sets an DSA implementation in an ENGINE structure */ -int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth) - { +int +ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth) +{ e->dsa_meth = dsa_meth; return 1; - } +} diff --git a/lib/libcrypto/engine/tb_ecdh.c b/lib/libcrypto/engine/tb_ecdh.c index 57354b8c110..0abeee163e1 100644 --- a/lib/libcrypto/engine/tb_ecdh.c +++ b/lib/libcrypto/engine/tb_ecdh.c @@ -21,7 +21,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -77,57 +77,65 @@ static ENGINE_TABLE *ecdh_table = NULL; static const int dummy_nid = 1; -void ENGINE_unregister_ECDH(ENGINE *e) - { +void +ENGINE_unregister_ECDH(ENGINE *e) +{ engine_table_unregister(&ecdh_table, e); - } +} -static void engine_unregister_all_ECDH(void) - { +static void +engine_unregister_all_ECDH(void) +{ engine_table_cleanup(&ecdh_table); - } +} -int ENGINE_register_ECDH(ENGINE *e) - { - if(e->ecdh_meth) +int +ENGINE_register_ECDH(ENGINE *e) +{ + if (e->ecdh_meth) return engine_table_register(&ecdh_table, - engine_unregister_all_ECDH, e, &dummy_nid, 1, 0); + engine_unregister_all_ECDH, e, &dummy_nid, 1, 0); return 1; - } +} -void ENGINE_register_all_ECDH(void) - { +void +ENGINE_register_all_ECDH(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_ECDH(e); - } +} -int ENGINE_set_default_ECDH(ENGINE *e) - { - if(e->ecdh_meth) +int +ENGINE_set_default_ECDH(ENGINE *e) +{ + if (e->ecdh_meth) return engine_table_register(&ecdh_table, - engine_unregister_all_ECDH, e, &dummy_nid, 1, 1); + engine_unregister_all_ECDH, e, &dummy_nid, 1, 1); return 1; - } +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ -ENGINE *ENGINE_get_default_ECDH(void) - { +ENGINE * +ENGINE_get_default_ECDH(void) +{ return engine_table_select(&ecdh_table, dummy_nid); - } +} /* Obtains an ECDH implementation from an ENGINE functional reference */ -const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e) - { +const ECDH_METHOD * +ENGINE_get_ECDH(const ENGINE *e) +{ return e->ecdh_meth; - } +} /* Sets an ECDH implementation in an ENGINE structure */ -int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth) - { +int +ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth) +{ e->ecdh_meth = ecdh_meth; return 1; - } +} diff --git a/lib/libcrypto/engine/tb_ecdsa.c b/lib/libcrypto/engine/tb_ecdsa.c index 8f30e956e07..cae74317a43 100644 --- a/lib/libcrypto/engine/tb_ecdsa.c +++ b/lib/libcrypto/engine/tb_ecdsa.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -62,57 +62,65 @@ static ENGINE_TABLE *ecdsa_table = NULL; static const int dummy_nid = 1; -void ENGINE_unregister_ECDSA(ENGINE *e) - { +void +ENGINE_unregister_ECDSA(ENGINE *e) +{ engine_table_unregister(&ecdsa_table, e); - } +} -static void engine_unregister_all_ECDSA(void) - { +static void +engine_unregister_all_ECDSA(void) +{ engine_table_cleanup(&ecdsa_table); - } +} -int ENGINE_register_ECDSA(ENGINE *e) - { - if(e->ecdsa_meth) +int +ENGINE_register_ECDSA(ENGINE *e) +{ + if (e->ecdsa_meth) return engine_table_register(&ecdsa_table, - engine_unregister_all_ECDSA, e, &dummy_nid, 1, 0); + engine_unregister_all_ECDSA, e, &dummy_nid, 1, 0); return 1; - } +} -void ENGINE_register_all_ECDSA(void) - { +void +ENGINE_register_all_ECDSA(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_ECDSA(e); - } +} -int ENGINE_set_default_ECDSA(ENGINE *e) - { - if(e->ecdsa_meth) +int +ENGINE_set_default_ECDSA(ENGINE *e) +{ + if (e->ecdsa_meth) return engine_table_register(&ecdsa_table, - engine_unregister_all_ECDSA, e, &dummy_nid, 1, 1); + engine_unregister_all_ECDSA, e, &dummy_nid, 1, 1); return 1; - } +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ -ENGINE *ENGINE_get_default_ECDSA(void) - { +ENGINE * +ENGINE_get_default_ECDSA(void) +{ return engine_table_select(&ecdsa_table, dummy_nid); - } +} /* Obtains an ECDSA implementation from an ENGINE functional reference */ -const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e) - { +const ECDSA_METHOD * +ENGINE_get_ECDSA(const ENGINE *e) +{ return e->ecdsa_meth; - } +} /* Sets an ECDSA implementation in an ENGINE structure */ -int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth) - { +int +ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth) +{ e->ecdsa_meth = ecdsa_meth; return 1; - } +} diff --git a/lib/libcrypto/engine/tb_pkmeth.c b/lib/libcrypto/engine/tb_pkmeth.c index 7a59744102f..7834a225998 100644 --- a/lib/libcrypto/engine/tb_pkmeth.c +++ b/lib/libcrypto/engine/tb_pkmeth.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -62,106 +62,112 @@ static ENGINE_TABLE *pkey_meth_table = NULL; -void ENGINE_unregister_pkey_meths(ENGINE *e) - { +void +ENGINE_unregister_pkey_meths(ENGINE *e) +{ engine_table_unregister(&pkey_meth_table, e); - } +} -static void engine_unregister_all_pkey_meths(void) - { +static void +engine_unregister_all_pkey_meths(void) +{ engine_table_cleanup(&pkey_meth_table); - } +} -int ENGINE_register_pkey_meths(ENGINE *e) - { - if(e->pkey_meths) - { +int +ENGINE_register_pkey_meths(ENGINE *e) +{ + if (e->pkey_meths) { const int *nids; int num_nids = e->pkey_meths(e, NULL, &nids, 0); - if(num_nids > 0) + if (num_nids > 0) return engine_table_register(&pkey_meth_table, - engine_unregister_all_pkey_meths, e, nids, - num_nids, 0); - } - return 1; + engine_unregister_all_pkey_meths, e, nids, + num_nids, 0); } + return 1; +} -void ENGINE_register_all_pkey_meths(void) - { +void +ENGINE_register_all_pkey_meths(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_pkey_meths(e); - } +} -int ENGINE_set_default_pkey_meths(ENGINE *e) - { - if(e->pkey_meths) - { +int +ENGINE_set_default_pkey_meths(ENGINE *e) +{ + if (e->pkey_meths) { const int *nids; int num_nids = e->pkey_meths(e, NULL, &nids, 0); - if(num_nids > 0) + if (num_nids > 0) return engine_table_register(&pkey_meth_table, - engine_unregister_all_pkey_meths, e, nids, - num_nids, 1); - } - return 1; + engine_unregister_all_pkey_meths, e, nids, + num_nids, 1); } + return 1; +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references) for a given pkey_meth 'nid' */ -ENGINE *ENGINE_get_pkey_meth_engine(int nid) - { +ENGINE * +ENGINE_get_pkey_meth_engine(int nid) +{ return engine_table_select(&pkey_meth_table, nid); - } +} /* Obtains a pkey_meth implementation from an ENGINE functional reference */ -const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid) - { +const EVP_PKEY_METHOD * +ENGINE_get_pkey_meth(ENGINE *e, int nid) +{ EVP_PKEY_METHOD *ret; ENGINE_PKEY_METHS_PTR fn = ENGINE_get_pkey_meths(e); - if(!fn || !fn(e, &ret, NULL, nid)) - { + + if (!fn || !fn(e, &ret, NULL, nid)) { ENGINEerr(ENGINE_F_ENGINE_GET_PKEY_METH, - ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); + ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); return NULL; - } - return ret; } + return ret; +} /* Gets the pkey_meth callback from an ENGINE structure */ -ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e) - { +ENGINE_PKEY_METHS_PTR +ENGINE_get_pkey_meths(const ENGINE *e) +{ return e->pkey_meths; - } +} /* Sets the pkey_meth callback in an ENGINE structure */ -int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f) - { +int +ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f) +{ e->pkey_meths = f; return 1; - } +} /* Internal function to free up EVP_PKEY_METHOD structures before an * ENGINE is destroyed */ -void engine_pkey_meths_free(ENGINE *e) - { +void +engine_pkey_meths_free(ENGINE *e) +{ int i; EVP_PKEY_METHOD *pkm; - if (e->pkey_meths) - { + + if (e->pkey_meths) { const int *pknids; int npknids; npknids = e->pkey_meths(e, NULL, &pknids, 0); - for (i = 0; i < npknids; i++) - { - if (e->pkey_meths(e, &pkm, NULL, pknids[i])) - { + for (i = 0; i < npknids; i++) { + if (e->pkey_meths(e, &pkm, NULL, pknids[i])) { EVP_PKEY_meth_free(pkm); - } } } } +} diff --git a/lib/libcrypto/engine/tb_rand.c b/lib/libcrypto/engine/tb_rand.c index 3745ae7abd2..b99f3baba32 100644 --- a/lib/libcrypto/engine/tb_rand.c +++ b/lib/libcrypto/engine/tb_rand.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -62,57 +62,65 @@ static ENGINE_TABLE *rand_table = NULL; static const int dummy_nid = 1; -void ENGINE_unregister_RAND(ENGINE *e) - { +void +ENGINE_unregister_RAND(ENGINE *e) +{ engine_table_unregister(&rand_table, e); - } +} -static void engine_unregister_all_RAND(void) - { +static void +engine_unregister_all_RAND(void) +{ engine_table_cleanup(&rand_table); - } +} -int ENGINE_register_RAND(ENGINE *e) - { - if(e->rand_meth) +int +ENGINE_register_RAND(ENGINE *e) +{ + if (e->rand_meth) return engine_table_register(&rand_table, - engine_unregister_all_RAND, e, &dummy_nid, 1, 0); + engine_unregister_all_RAND, e, &dummy_nid, 1, 0); return 1; - } +} -void ENGINE_register_all_RAND(void) - { +void +ENGINE_register_all_RAND(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_RAND(e); - } +} -int ENGINE_set_default_RAND(ENGINE *e) - { - if(e->rand_meth) +int +ENGINE_set_default_RAND(ENGINE *e) +{ + if (e->rand_meth) return engine_table_register(&rand_table, - engine_unregister_all_RAND, e, &dummy_nid, 1, 1); + engine_unregister_all_RAND, e, &dummy_nid, 1, 1); return 1; - } +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ -ENGINE *ENGINE_get_default_RAND(void) - { +ENGINE * +ENGINE_get_default_RAND(void) +{ return engine_table_select(&rand_table, dummy_nid); - } +} /* Obtains an RAND implementation from an ENGINE functional reference */ -const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e) - { +const RAND_METHOD * +ENGINE_get_RAND(const ENGINE *e) +{ return e->rand_meth; - } +} /* Sets an RAND implementation in an ENGINE structure */ -int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth) - { +int +ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth) +{ e->rand_meth = rand_meth; return 1; - } +} diff --git a/lib/libcrypto/engine/tb_rsa.c b/lib/libcrypto/engine/tb_rsa.c index 2f4928fd665..846c1144359 100644 --- a/lib/libcrypto/engine/tb_rsa.c +++ b/lib/libcrypto/engine/tb_rsa.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -62,57 +62,65 @@ static ENGINE_TABLE *rsa_table = NULL; static const int dummy_nid = 1; -void ENGINE_unregister_RSA(ENGINE *e) - { +void +ENGINE_unregister_RSA(ENGINE *e) +{ engine_table_unregister(&rsa_table, e); - } +} -static void engine_unregister_all_RSA(void) - { +static void +engine_unregister_all_RSA(void) +{ engine_table_cleanup(&rsa_table); - } +} -int ENGINE_register_RSA(ENGINE *e) - { - if(e->rsa_meth) +int +ENGINE_register_RSA(ENGINE *e) +{ + if (e->rsa_meth) return engine_table_register(&rsa_table, - engine_unregister_all_RSA, e, &dummy_nid, 1, 0); + engine_unregister_all_RSA, e, &dummy_nid, 1, 0); return 1; - } +} -void ENGINE_register_all_RSA(void) - { +void +ENGINE_register_all_RSA(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_RSA(e); - } +} -int ENGINE_set_default_RSA(ENGINE *e) - { - if(e->rsa_meth) +int +ENGINE_set_default_RSA(ENGINE *e) +{ + if (e->rsa_meth) return engine_table_register(&rsa_table, - engine_unregister_all_RSA, e, &dummy_nid, 1, 1); + engine_unregister_all_RSA, e, &dummy_nid, 1, 1); return 1; - } +} /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ -ENGINE *ENGINE_get_default_RSA(void) - { +ENGINE * +ENGINE_get_default_RSA(void) +{ return engine_table_select(&rsa_table, dummy_nid); - } +} /* Obtains an RSA implementation from an ENGINE functional reference */ -const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e) - { +const RSA_METHOD * +ENGINE_get_RSA(const ENGINE *e) +{ return e->rsa_meth; - } +} /* Sets an RSA implementation in an ENGINE structure */ -int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth) - { +int +ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth) +{ e->rsa_meth = rsa_meth; return 1; - } +} diff --git a/lib/libcrypto/engine/tb_store.c b/lib/libcrypto/engine/tb_store.c index bd853733ea7..81b3f7b27e9 100644 --- a/lib/libcrypto/engine/tb_store.c +++ b/lib/libcrypto/engine/tb_store.c @@ -6,7 +6,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -62,62 +62,70 @@ static ENGINE_TABLE *store_table = NULL; static const int dummy_nid = 1; -void ENGINE_unregister_STORE(ENGINE *e) - { +void +ENGINE_unregister_STORE(ENGINE *e) +{ engine_table_unregister(&store_table, e); - } +} -static void engine_unregister_all_STORE(void) - { +static void +engine_unregister_all_STORE(void) +{ engine_table_cleanup(&store_table); - } +} -int ENGINE_register_STORE(ENGINE *e) - { - if(e->store_meth) +int +ENGINE_register_STORE(ENGINE *e) +{ + if (e->store_meth) return engine_table_register(&store_table, - engine_unregister_all_STORE, e, &dummy_nid, 1, 0); + engine_unregister_all_STORE, e, &dummy_nid, 1, 0); return 1; - } +} -void ENGINE_register_all_STORE(void) - { +void +ENGINE_register_all_STORE(void) +{ ENGINE *e; - for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) + for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) ENGINE_register_STORE(e); - } +} /* The following two functions are removed because they're useless. */ #if 0 -int ENGINE_set_default_STORE(ENGINE *e) - { - if(e->store_meth) +int +ENGINE_set_default_STORE(ENGINE *e) +{ + if (e->store_meth) return engine_table_register(&store_table, - engine_unregister_all_STORE, e, &dummy_nid, 1, 1); + engine_unregister_all_STORE, e, &dummy_nid, 1, 1); return 1; - } +} #endif #if 0 /* Exposed API function to get a functional reference from the implementation * table (ie. try to get a functional reference from the tabled structural * references). */ -ENGINE *ENGINE_get_default_STORE(void) - { +ENGINE * +ENGINE_get_default_STORE(void) +{ return engine_table_select(&store_table, dummy_nid); - } +} #endif /* Obtains an STORE implementation from an ENGINE functional reference */ -const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e) - { +const STORE_METHOD * +ENGINE_get_STORE(const ENGINE *e) +{ return e->store_meth; - } +} /* Sets an STORE implementation in an ENGINE structure */ -int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth) - { +int +ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth) +{ e->store_meth = store_meth; return 1; - } +} |