10Sstevel@tonic-gate /* ====================================================================
20Sstevel@tonic-gate * Copyright (c) 2000 The OpenSSL Project. All rights reserved.
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
50Sstevel@tonic-gate * modification, are permitted provided that the following conditions
60Sstevel@tonic-gate * are met:
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
90Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
100Sstevel@tonic-gate *
110Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
120Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in
130Sstevel@tonic-gate * the documentation and/or other materials provided with the
140Sstevel@tonic-gate * distribution.
150Sstevel@tonic-gate *
160Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this
170Sstevel@tonic-gate * software must display the following acknowledgment:
180Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project
190Sstevel@tonic-gate * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
200Sstevel@tonic-gate *
210Sstevel@tonic-gate * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
220Sstevel@tonic-gate * endorse or promote products derived from this software without
230Sstevel@tonic-gate * prior written permission. For written permission, please contact
240Sstevel@tonic-gate * licensing@OpenSSL.org.
250Sstevel@tonic-gate *
260Sstevel@tonic-gate * 5. Products derived from this software may not be called "OpenSSL"
270Sstevel@tonic-gate * nor may "OpenSSL" appear in their names without prior written
280Sstevel@tonic-gate * permission of the OpenSSL Project.
290Sstevel@tonic-gate *
300Sstevel@tonic-gate * 6. Redistributions of any form whatsoever must retain the following
310Sstevel@tonic-gate * acknowledgment:
320Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project
330Sstevel@tonic-gate * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
340Sstevel@tonic-gate *
350Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
360Sstevel@tonic-gate * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
370Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
380Sstevel@tonic-gate * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
390Sstevel@tonic-gate * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
400Sstevel@tonic-gate * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
410Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
420Sstevel@tonic-gate * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
430Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
440Sstevel@tonic-gate * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
450Sstevel@tonic-gate * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
460Sstevel@tonic-gate * OF THE POSSIBILITY OF SUCH DAMAGE.
470Sstevel@tonic-gate * ====================================================================
480Sstevel@tonic-gate *
490Sstevel@tonic-gate * This product includes cryptographic software written by Eric Young
500Sstevel@tonic-gate * (eay@cryptsoft.com). This product includes software written by Tim
510Sstevel@tonic-gate * Hudson (tjh@cryptsoft.com).
520Sstevel@tonic-gate *
530Sstevel@tonic-gate */
540Sstevel@tonic-gate
550Sstevel@tonic-gate #include "eng_int.h"
560Sstevel@tonic-gate
570Sstevel@tonic-gate /* If this symbol is defined then ENGINE_get_default_DSA(), the function that is
580Sstevel@tonic-gate * used by DSA to hook in implementation code and cache defaults (etc), will
590Sstevel@tonic-gate * display brief debugging summaries to stderr with the 'nid'. */
600Sstevel@tonic-gate /* #define ENGINE_DSA_DEBUG */
610Sstevel@tonic-gate
620Sstevel@tonic-gate static ENGINE_TABLE *dsa_table = NULL;
630Sstevel@tonic-gate static const int dummy_nid = 1;
640Sstevel@tonic-gate
ENGINE_unregister_DSA(ENGINE * e)650Sstevel@tonic-gate void ENGINE_unregister_DSA(ENGINE *e)
660Sstevel@tonic-gate {
670Sstevel@tonic-gate engine_table_unregister(&dsa_table, e);
680Sstevel@tonic-gate }
690Sstevel@tonic-gate
engine_unregister_all_DSA(void)700Sstevel@tonic-gate static void engine_unregister_all_DSA(void)
710Sstevel@tonic-gate {
720Sstevel@tonic-gate engine_table_cleanup(&dsa_table);
730Sstevel@tonic-gate }
740Sstevel@tonic-gate
ENGINE_register_DSA(ENGINE * e)750Sstevel@tonic-gate int ENGINE_register_DSA(ENGINE *e)
760Sstevel@tonic-gate {
770Sstevel@tonic-gate if(e->dsa_meth)
780Sstevel@tonic-gate return engine_table_register(&dsa_table,
790Sstevel@tonic-gate engine_unregister_all_DSA, e, &dummy_nid, 1, 0);
800Sstevel@tonic-gate return 1;
810Sstevel@tonic-gate }
820Sstevel@tonic-gate
ENGINE_register_all_DSA()830Sstevel@tonic-gate void ENGINE_register_all_DSA()
840Sstevel@tonic-gate {
850Sstevel@tonic-gate ENGINE *e;
860Sstevel@tonic-gate
870Sstevel@tonic-gate for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
880Sstevel@tonic-gate ENGINE_register_DSA(e);
890Sstevel@tonic-gate }
900Sstevel@tonic-gate
ENGINE_set_default_DSA(ENGINE * e)910Sstevel@tonic-gate int ENGINE_set_default_DSA(ENGINE *e)
920Sstevel@tonic-gate {
930Sstevel@tonic-gate if(e->dsa_meth)
940Sstevel@tonic-gate return engine_table_register(&dsa_table,
95*2139Sjp161948 engine_unregister_all_DSA, e, &dummy_nid, 1, 1);
960Sstevel@tonic-gate return 1;
970Sstevel@tonic-gate }
980Sstevel@tonic-gate
990Sstevel@tonic-gate /* Exposed API function to get a functional reference from the implementation
1000Sstevel@tonic-gate * table (ie. try to get a functional reference from the tabled structural
1010Sstevel@tonic-gate * references). */
ENGINE_get_default_DSA(void)1020Sstevel@tonic-gate ENGINE *ENGINE_get_default_DSA(void)
1030Sstevel@tonic-gate {
1040Sstevel@tonic-gate return engine_table_select(&dsa_table, dummy_nid);
1050Sstevel@tonic-gate }
1060Sstevel@tonic-gate
1070Sstevel@tonic-gate /* Obtains an DSA implementation from an ENGINE functional reference */
ENGINE_get_DSA(const ENGINE * e)1080Sstevel@tonic-gate const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e)
1090Sstevel@tonic-gate {
1100Sstevel@tonic-gate return e->dsa_meth;
1110Sstevel@tonic-gate }
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate /* Sets an DSA implementation in an ENGINE structure */
ENGINE_set_DSA(ENGINE * e,const DSA_METHOD * dsa_meth)1140Sstevel@tonic-gate int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth)
1150Sstevel@tonic-gate {
1160Sstevel@tonic-gate e->dsa_meth = dsa_meth;
1170Sstevel@tonic-gate return 1;
1180Sstevel@tonic-gate }
119