1160814Ssimon/* ==================================================================== 2160814Ssimon * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. 3160814Ssimon * 4160814Ssimon * Redistribution and use in source and binary forms, with or without 5160814Ssimon * modification, are permitted provided that the following conditions 6160814Ssimon * are met: 7160814Ssimon * 8160814Ssimon * 1. Redistributions of source code must retain the above copyright 9296465Sdelphij * notice, this list of conditions and the following disclaimer. 10160814Ssimon * 11160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright 12160814Ssimon * notice, this list of conditions and the following disclaimer in 13160814Ssimon * the documentation and/or other materials provided with the 14160814Ssimon * distribution. 15160814Ssimon * 16160814Ssimon * 3. All advertising materials mentioning features or use of this 17160814Ssimon * software must display the following acknowledgment: 18160814Ssimon * "This product includes software developed by the OpenSSL Project 19160814Ssimon * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 20160814Ssimon * 21160814Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 22160814Ssimon * endorse or promote products derived from this software without 23160814Ssimon * prior written permission. For written permission, please contact 24160814Ssimon * licensing@OpenSSL.org. 25160814Ssimon * 26160814Ssimon * 5. Products derived from this software may not be called "OpenSSL" 27160814Ssimon * nor may "OpenSSL" appear in their names without prior written 28160814Ssimon * permission of the OpenSSL Project. 29160814Ssimon * 30160814Ssimon * 6. Redistributions of any form whatsoever must retain the following 31160814Ssimon * acknowledgment: 32160814Ssimon * "This product includes software developed by the OpenSSL Project 33160814Ssimon * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 34160814Ssimon * 35160814Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 36160814Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 38160814Ssimon * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 39160814Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40160814Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 41160814Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 42160814Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 43160814Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 44160814Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 45160814Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 46160814Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE. 47160814Ssimon * ==================================================================== 48160814Ssimon * 49160814Ssimon * This product includes cryptographic software written by Eric Young 50160814Ssimon * (eay@cryptsoft.com). This product includes software written by Tim 51160814Ssimon * Hudson (tjh@cryptsoft.com). 52160814Ssimon * 53160814Ssimon */ 54160814Ssimon 55160814Ssimon#include "eng_int.h" 56160814Ssimon 57296465Sdelphij/* 58296465Sdelphij * If this symbol is defined then ENGINE_get_default_ECDSA(), the function 59296465Sdelphij * that is used by ECDSA to hook in implementation code and cache defaults 60296465Sdelphij * (etc), will display brief debugging summaries to stderr with the 'nid'. 61296465Sdelphij */ 62160814Ssimon/* #define ENGINE_ECDSA_DEBUG */ 63160814Ssimon 64160814Ssimonstatic ENGINE_TABLE *ecdsa_table = NULL; 65160814Ssimonstatic const int dummy_nid = 1; 66160814Ssimon 67160814Ssimonvoid ENGINE_unregister_ECDSA(ENGINE *e) 68296465Sdelphij{ 69296465Sdelphij engine_table_unregister(&ecdsa_table, e); 70296465Sdelphij} 71160814Ssimon 72160814Ssimonstatic void engine_unregister_all_ECDSA(void) 73296465Sdelphij{ 74296465Sdelphij engine_table_cleanup(&ecdsa_table); 75296465Sdelphij} 76160814Ssimon 77160814Ssimonint ENGINE_register_ECDSA(ENGINE *e) 78296465Sdelphij{ 79296465Sdelphij if (e->ecdsa_meth) 80296465Sdelphij return engine_table_register(&ecdsa_table, 81296465Sdelphij engine_unregister_all_ECDSA, e, 82296465Sdelphij &dummy_nid, 1, 0); 83296465Sdelphij return 1; 84296465Sdelphij} 85160814Ssimon 86160814Ssimonvoid ENGINE_register_all_ECDSA() 87296465Sdelphij{ 88296465Sdelphij ENGINE *e; 89160814Ssimon 90296465Sdelphij for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) 91296465Sdelphij ENGINE_register_ECDSA(e); 92296465Sdelphij} 93160814Ssimon 94160814Ssimonint ENGINE_set_default_ECDSA(ENGINE *e) 95296465Sdelphij{ 96296465Sdelphij if (e->ecdsa_meth) 97296465Sdelphij return engine_table_register(&ecdsa_table, 98296465Sdelphij engine_unregister_all_ECDSA, e, 99296465Sdelphij &dummy_nid, 1, 1); 100296465Sdelphij return 1; 101296465Sdelphij} 102160814Ssimon 103296465Sdelphij/* 104296465Sdelphij * Exposed API function to get a functional reference from the implementation 105160814Ssimon * table (ie. try to get a functional reference from the tabled structural 106296465Sdelphij * references). 107296465Sdelphij */ 108160814SsimonENGINE *ENGINE_get_default_ECDSA(void) 109296465Sdelphij{ 110296465Sdelphij return engine_table_select(&ecdsa_table, dummy_nid); 111296465Sdelphij} 112160814Ssimon 113160814Ssimon/* Obtains an ECDSA implementation from an ENGINE functional reference */ 114160814Ssimonconst ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e) 115296465Sdelphij{ 116296465Sdelphij return e->ecdsa_meth; 117296465Sdelphij} 118160814Ssimon 119160814Ssimon/* Sets an ECDSA implementation in an ENGINE structure */ 120160814Ssimonint ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth) 121296465Sdelphij{ 122296465Sdelphij e->ecdsa_meth = ecdsa_meth; 123296465Sdelphij return 1; 124296465Sdelphij} 125