diff options
Diffstat (limited to 'src/lib/libcrypto/engine/tb_ecdsa.c')
| -rw-r--r-- | src/lib/libcrypto/engine/tb_ecdsa.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/src/lib/libcrypto/engine/tb_ecdsa.c b/src/lib/libcrypto/engine/tb_ecdsa.c index 8f30e956e0..cae74317a4 100644 --- a/src/lib/libcrypto/engine/tb_ecdsa.c +++ b/src/lib/libcrypto/engine/tb_ecdsa.c | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | * are met: | 6 | * are met: |
| 7 | * | 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright | 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. | 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * | 10 | * |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in | 12 | * notice, this list of conditions and the following disclaimer in |
| @@ -62,57 +62,65 @@ | |||
| 62 | static ENGINE_TABLE *ecdsa_table = NULL; | 62 | static ENGINE_TABLE *ecdsa_table = NULL; |
| 63 | static const int dummy_nid = 1; | 63 | static const int dummy_nid = 1; |
| 64 | 64 | ||
| 65 | void ENGINE_unregister_ECDSA(ENGINE *e) | 65 | void |
| 66 | { | 66 | ENGINE_unregister_ECDSA(ENGINE *e) |
| 67 | { | ||
| 67 | engine_table_unregister(&ecdsa_table, e); | 68 | engine_table_unregister(&ecdsa_table, e); |
| 68 | } | 69 | } |
| 69 | 70 | ||
| 70 | static void engine_unregister_all_ECDSA(void) | 71 | static void |
| 71 | { | 72 | engine_unregister_all_ECDSA(void) |
| 73 | { | ||
| 72 | engine_table_cleanup(&ecdsa_table); | 74 | engine_table_cleanup(&ecdsa_table); |
| 73 | } | 75 | } |
| 74 | 76 | ||
| 75 | int ENGINE_register_ECDSA(ENGINE *e) | 77 | int |
| 76 | { | 78 | ENGINE_register_ECDSA(ENGINE *e) |
| 77 | if(e->ecdsa_meth) | 79 | { |
| 80 | if (e->ecdsa_meth) | ||
| 78 | return engine_table_register(&ecdsa_table, | 81 | return engine_table_register(&ecdsa_table, |
| 79 | engine_unregister_all_ECDSA, e, &dummy_nid, 1, 0); | 82 | engine_unregister_all_ECDSA, e, &dummy_nid, 1, 0); |
| 80 | return 1; | 83 | return 1; |
| 81 | } | 84 | } |
| 82 | 85 | ||
| 83 | void ENGINE_register_all_ECDSA(void) | 86 | void |
| 84 | { | 87 | ENGINE_register_all_ECDSA(void) |
| 88 | { | ||
| 85 | ENGINE *e; | 89 | ENGINE *e; |
| 86 | 90 | ||
| 87 | for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) | 91 | for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) |
| 88 | ENGINE_register_ECDSA(e); | 92 | ENGINE_register_ECDSA(e); |
| 89 | } | 93 | } |
| 90 | 94 | ||
| 91 | int ENGINE_set_default_ECDSA(ENGINE *e) | 95 | int |
| 92 | { | 96 | ENGINE_set_default_ECDSA(ENGINE *e) |
| 93 | if(e->ecdsa_meth) | 97 | { |
| 98 | if (e->ecdsa_meth) | ||
| 94 | return engine_table_register(&ecdsa_table, | 99 | return engine_table_register(&ecdsa_table, |
| 95 | engine_unregister_all_ECDSA, e, &dummy_nid, 1, 1); | 100 | engine_unregister_all_ECDSA, e, &dummy_nid, 1, 1); |
| 96 | return 1; | 101 | return 1; |
| 97 | } | 102 | } |
| 98 | 103 | ||
| 99 | /* Exposed API function to get a functional reference from the implementation | 104 | /* Exposed API function to get a functional reference from the implementation |
| 100 | * table (ie. try to get a functional reference from the tabled structural | 105 | * table (ie. try to get a functional reference from the tabled structural |
| 101 | * references). */ | 106 | * references). */ |
| 102 | ENGINE *ENGINE_get_default_ECDSA(void) | 107 | ENGINE * |
| 103 | { | 108 | ENGINE_get_default_ECDSA(void) |
| 109 | { | ||
| 104 | return engine_table_select(&ecdsa_table, dummy_nid); | 110 | return engine_table_select(&ecdsa_table, dummy_nid); |
| 105 | } | 111 | } |
| 106 | 112 | ||
| 107 | /* Obtains an ECDSA implementation from an ENGINE functional reference */ | 113 | /* Obtains an ECDSA implementation from an ENGINE functional reference */ |
| 108 | const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e) | 114 | const ECDSA_METHOD * |
| 109 | { | 115 | ENGINE_get_ECDSA(const ENGINE *e) |
| 116 | { | ||
| 110 | return e->ecdsa_meth; | 117 | return e->ecdsa_meth; |
| 111 | } | 118 | } |
| 112 | 119 | ||
| 113 | /* Sets an ECDSA implementation in an ENGINE structure */ | 120 | /* Sets an ECDSA implementation in an ENGINE structure */ |
| 114 | int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth) | 121 | int |
| 115 | { | 122 | ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth) |
| 123 | { | ||
| 116 | e->ecdsa_meth = ecdsa_meth; | 124 | e->ecdsa_meth = ecdsa_meth; |
| 117 | return 1; | 125 | return 1; |
| 118 | } | 126 | } |
