xref: /onnv-gate/usr/src/common/openssl/crypto/engine/eng_fat.c (revision 2139:6243c3338933)
10Sstevel@tonic-gate /* crypto/engine/eng_fat.c */
20Sstevel@tonic-gate /* ====================================================================
30Sstevel@tonic-gate  * Copyright (c) 1999-2001 The OpenSSL Project.  All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
60Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
70Sstevel@tonic-gate  * are met:
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
100Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
110Sstevel@tonic-gate  *
120Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
130Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in
140Sstevel@tonic-gate  *    the documentation and/or other materials provided with the
150Sstevel@tonic-gate  *    distribution.
160Sstevel@tonic-gate  *
170Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this
180Sstevel@tonic-gate  *    software must display the following acknowledgment:
190Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
200Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
210Sstevel@tonic-gate  *
220Sstevel@tonic-gate  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
230Sstevel@tonic-gate  *    endorse or promote products derived from this software without
240Sstevel@tonic-gate  *    prior written permission. For written permission, please contact
250Sstevel@tonic-gate  *    licensing@OpenSSL.org.
260Sstevel@tonic-gate  *
270Sstevel@tonic-gate  * 5. Products derived from this software may not be called "OpenSSL"
280Sstevel@tonic-gate  *    nor may "OpenSSL" appear in their names without prior written
290Sstevel@tonic-gate  *    permission of the OpenSSL Project.
300Sstevel@tonic-gate  *
310Sstevel@tonic-gate  * 6. Redistributions of any form whatsoever must retain the following
320Sstevel@tonic-gate  *    acknowledgment:
330Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
340Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
350Sstevel@tonic-gate  *
360Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
370Sstevel@tonic-gate  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
380Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
390Sstevel@tonic-gate  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
400Sstevel@tonic-gate  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
410Sstevel@tonic-gate  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
420Sstevel@tonic-gate  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
430Sstevel@tonic-gate  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
440Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
450Sstevel@tonic-gate  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
460Sstevel@tonic-gate  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
470Sstevel@tonic-gate  * OF THE POSSIBILITY OF SUCH DAMAGE.
480Sstevel@tonic-gate  * ====================================================================
490Sstevel@tonic-gate  *
500Sstevel@tonic-gate  * This product includes cryptographic software written by Eric Young
510Sstevel@tonic-gate  * (eay@cryptsoft.com).  This product includes software written by Tim
520Sstevel@tonic-gate  * Hudson (tjh@cryptsoft.com).
530Sstevel@tonic-gate  *
540Sstevel@tonic-gate  */
55*2139Sjp161948 /* ====================================================================
56*2139Sjp161948  * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
57*2139Sjp161948  * ECDH support in OpenSSL originally developed by
58*2139Sjp161948  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
59*2139Sjp161948  */
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #include "eng_int.h"
620Sstevel@tonic-gate #include <openssl/conf.h>
630Sstevel@tonic-gate 
ENGINE_set_default(ENGINE * e,unsigned int flags)640Sstevel@tonic-gate int ENGINE_set_default(ENGINE *e, unsigned int flags)
650Sstevel@tonic-gate 	{
660Sstevel@tonic-gate 	if((flags & ENGINE_METHOD_CIPHERS) && !ENGINE_set_default_ciphers(e))
670Sstevel@tonic-gate 		return 0;
680Sstevel@tonic-gate 	if((flags & ENGINE_METHOD_DIGESTS) && !ENGINE_set_default_digests(e))
690Sstevel@tonic-gate 		return 0;
700Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
710Sstevel@tonic-gate 	if((flags & ENGINE_METHOD_RSA) && !ENGINE_set_default_RSA(e))
720Sstevel@tonic-gate 		return 0;
730Sstevel@tonic-gate #endif
740Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
750Sstevel@tonic-gate 	if((flags & ENGINE_METHOD_DSA) && !ENGINE_set_default_DSA(e))
760Sstevel@tonic-gate 		return 0;
770Sstevel@tonic-gate #endif
780Sstevel@tonic-gate #ifndef OPENSSL_NO_DH
790Sstevel@tonic-gate 	if((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
800Sstevel@tonic-gate 		return 0;
810Sstevel@tonic-gate #endif
82*2139Sjp161948 #ifndef OPENSSL_NO_ECDH
83*2139Sjp161948 	if((flags & ENGINE_METHOD_ECDH) && !ENGINE_set_default_ECDH(e))
84*2139Sjp161948 		return 0;
85*2139Sjp161948 #endif
86*2139Sjp161948 #ifndef OPENSSL_NO_ECDSA
87*2139Sjp161948 	if((flags & ENGINE_METHOD_ECDSA) && !ENGINE_set_default_ECDSA(e))
88*2139Sjp161948 		return 0;
89*2139Sjp161948 #endif
900Sstevel@tonic-gate 	if((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
910Sstevel@tonic-gate 		return 0;
920Sstevel@tonic-gate 	return 1;
930Sstevel@tonic-gate 	}
940Sstevel@tonic-gate 
950Sstevel@tonic-gate /* Set default algorithms using a string */
960Sstevel@tonic-gate 
int_def_cb(const char * alg,int len,void * arg)970Sstevel@tonic-gate static int int_def_cb(const char *alg, int len, void *arg)
980Sstevel@tonic-gate 	{
990Sstevel@tonic-gate 	unsigned int *pflags = arg;
1000Sstevel@tonic-gate 	if (!strncmp(alg, "ALL", len))
1010Sstevel@tonic-gate 		*pflags |= ENGINE_METHOD_ALL;
1020Sstevel@tonic-gate 	else if (!strncmp(alg, "RSA", len))
1030Sstevel@tonic-gate 		*pflags |= ENGINE_METHOD_RSA;
1040Sstevel@tonic-gate 	else if (!strncmp(alg, "DSA", len))
1050Sstevel@tonic-gate 		*pflags |= ENGINE_METHOD_DSA;
106*2139Sjp161948 	else if (!strncmp(alg, "ECDH", len))
107*2139Sjp161948 		*pflags |= ENGINE_METHOD_ECDH;
108*2139Sjp161948 	else if (!strncmp(alg, "ECDSA", len))
109*2139Sjp161948 		*pflags |= ENGINE_METHOD_ECDSA;
1100Sstevel@tonic-gate 	else if (!strncmp(alg, "DH", len))
1110Sstevel@tonic-gate 		*pflags |= ENGINE_METHOD_DH;
1120Sstevel@tonic-gate 	else if (!strncmp(alg, "RAND", len))
1130Sstevel@tonic-gate 		*pflags |= ENGINE_METHOD_RAND;
1140Sstevel@tonic-gate 	else if (!strncmp(alg, "CIPHERS", len))
1150Sstevel@tonic-gate 		*pflags |= ENGINE_METHOD_CIPHERS;
1160Sstevel@tonic-gate 	else if (!strncmp(alg, "DIGESTS", len))
1170Sstevel@tonic-gate 		*pflags |= ENGINE_METHOD_DIGESTS;
1180Sstevel@tonic-gate 	else
1190Sstevel@tonic-gate 		return 0;
1200Sstevel@tonic-gate 	return 1;
1210Sstevel@tonic-gate 	}
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate 
ENGINE_set_default_string(ENGINE * e,const char * def_list)1240Sstevel@tonic-gate int ENGINE_set_default_string(ENGINE *e, const char *def_list)
1250Sstevel@tonic-gate 	{
1260Sstevel@tonic-gate 	unsigned int flags = 0;
1270Sstevel@tonic-gate 	if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags))
1280Sstevel@tonic-gate 		{
1290Sstevel@tonic-gate 		ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_STRING,
1300Sstevel@tonic-gate 					ENGINE_R_INVALID_STRING);
1310Sstevel@tonic-gate 		ERR_add_error_data(2, "str=",def_list);
1320Sstevel@tonic-gate 		return 0;
1330Sstevel@tonic-gate 		}
1340Sstevel@tonic-gate 	return ENGINE_set_default(e, flags);
1350Sstevel@tonic-gate 	}
1360Sstevel@tonic-gate 
ENGINE_register_complete(ENGINE * e)1370Sstevel@tonic-gate int ENGINE_register_complete(ENGINE *e)
1380Sstevel@tonic-gate 	{
1390Sstevel@tonic-gate 	ENGINE_register_ciphers(e);
1400Sstevel@tonic-gate 	ENGINE_register_digests(e);
1410Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
1420Sstevel@tonic-gate 	ENGINE_register_RSA(e);
1430Sstevel@tonic-gate #endif
1440Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
1450Sstevel@tonic-gate 	ENGINE_register_DSA(e);
1460Sstevel@tonic-gate #endif
1470Sstevel@tonic-gate #ifndef OPENSSL_NO_DH
1480Sstevel@tonic-gate 	ENGINE_register_DH(e);
1490Sstevel@tonic-gate #endif
150*2139Sjp161948 #ifndef OPENSSL_NO_ECDH
151*2139Sjp161948 	ENGINE_register_ECDH(e);
152*2139Sjp161948 #endif
153*2139Sjp161948 #ifndef OPENSSL_NO_ECDSA
154*2139Sjp161948 	ENGINE_register_ECDSA(e);
155*2139Sjp161948 #endif
1560Sstevel@tonic-gate 	ENGINE_register_RAND(e);
1570Sstevel@tonic-gate 	return 1;
1580Sstevel@tonic-gate 	}
1590Sstevel@tonic-gate 
ENGINE_register_all_complete(void)1600Sstevel@tonic-gate int ENGINE_register_all_complete(void)
1610Sstevel@tonic-gate 	{
1620Sstevel@tonic-gate 	ENGINE *e;
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate 	for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e))
1650Sstevel@tonic-gate 		ENGINE_register_complete(e);
1660Sstevel@tonic-gate 	return 1;
1670Sstevel@tonic-gate 	}
168