xref: /dflybsd-src/crypto/libressl/ssl/ssl_algs.c (revision f5b1c8a1e6dbe9333aed363dba27c2ff58be6174)
1*f5b1c8a1SJohn Marino /* $OpenBSD: ssl_algs.c,v 1.21 2014/11/18 05:33:43 miod Exp $ */
2*f5b1c8a1SJohn Marino /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3*f5b1c8a1SJohn Marino  * All rights reserved.
4*f5b1c8a1SJohn Marino  *
5*f5b1c8a1SJohn Marino  * This package is an SSL implementation written
6*f5b1c8a1SJohn Marino  * by Eric Young (eay@cryptsoft.com).
7*f5b1c8a1SJohn Marino  * The implementation was written so as to conform with Netscapes SSL.
8*f5b1c8a1SJohn Marino  *
9*f5b1c8a1SJohn Marino  * This library is free for commercial and non-commercial use as long as
10*f5b1c8a1SJohn Marino  * the following conditions are aheared to.  The following conditions
11*f5b1c8a1SJohn Marino  * apply to all code found in this distribution, be it the RC4, RSA,
12*f5b1c8a1SJohn Marino  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13*f5b1c8a1SJohn Marino  * included with this distribution is covered by the same copyright terms
14*f5b1c8a1SJohn Marino  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15*f5b1c8a1SJohn Marino  *
16*f5b1c8a1SJohn Marino  * Copyright remains Eric Young's, and as such any Copyright notices in
17*f5b1c8a1SJohn Marino  * the code are not to be removed.
18*f5b1c8a1SJohn Marino  * If this package is used in a product, Eric Young should be given attribution
19*f5b1c8a1SJohn Marino  * as the author of the parts of the library used.
20*f5b1c8a1SJohn Marino  * This can be in the form of a textual message at program startup or
21*f5b1c8a1SJohn Marino  * in documentation (online or textual) provided with the package.
22*f5b1c8a1SJohn Marino  *
23*f5b1c8a1SJohn Marino  * Redistribution and use in source and binary forms, with or without
24*f5b1c8a1SJohn Marino  * modification, are permitted provided that the following conditions
25*f5b1c8a1SJohn Marino  * are met:
26*f5b1c8a1SJohn Marino  * 1. Redistributions of source code must retain the copyright
27*f5b1c8a1SJohn Marino  *    notice, this list of conditions and the following disclaimer.
28*f5b1c8a1SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
29*f5b1c8a1SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
30*f5b1c8a1SJohn Marino  *    documentation and/or other materials provided with the distribution.
31*f5b1c8a1SJohn Marino  * 3. All advertising materials mentioning features or use of this software
32*f5b1c8a1SJohn Marino  *    must display the following acknowledgement:
33*f5b1c8a1SJohn Marino  *    "This product includes cryptographic software written by
34*f5b1c8a1SJohn Marino  *     Eric Young (eay@cryptsoft.com)"
35*f5b1c8a1SJohn Marino  *    The word 'cryptographic' can be left out if the rouines from the library
36*f5b1c8a1SJohn Marino  *    being used are not cryptographic related :-).
37*f5b1c8a1SJohn Marino  * 4. If you include any Windows specific code (or a derivative thereof) from
38*f5b1c8a1SJohn Marino  *    the apps directory (application code) you must include an acknowledgement:
39*f5b1c8a1SJohn Marino  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40*f5b1c8a1SJohn Marino  *
41*f5b1c8a1SJohn Marino  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42*f5b1c8a1SJohn Marino  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43*f5b1c8a1SJohn Marino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44*f5b1c8a1SJohn Marino  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45*f5b1c8a1SJohn Marino  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46*f5b1c8a1SJohn Marino  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47*f5b1c8a1SJohn Marino  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48*f5b1c8a1SJohn Marino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49*f5b1c8a1SJohn Marino  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50*f5b1c8a1SJohn Marino  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51*f5b1c8a1SJohn Marino  * SUCH DAMAGE.
52*f5b1c8a1SJohn Marino  *
53*f5b1c8a1SJohn Marino  * The licence and distribution terms for any publically available version or
54*f5b1c8a1SJohn Marino  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55*f5b1c8a1SJohn Marino  * copied and put under another distribution licence
56*f5b1c8a1SJohn Marino  * [including the GNU Public Licence.]
57*f5b1c8a1SJohn Marino  */
58*f5b1c8a1SJohn Marino 
59*f5b1c8a1SJohn Marino #include <stdio.h>
60*f5b1c8a1SJohn Marino 
61*f5b1c8a1SJohn Marino #include <openssl/lhash.h>
62*f5b1c8a1SJohn Marino #include <openssl/objects.h>
63*f5b1c8a1SJohn Marino 
64*f5b1c8a1SJohn Marino #include "ssl_locl.h"
65*f5b1c8a1SJohn Marino 
66*f5b1c8a1SJohn Marino int
67*f5b1c8a1SJohn Marino SSL_library_init(void)
68*f5b1c8a1SJohn Marino {
69*f5b1c8a1SJohn Marino 
70*f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_DES
71*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_des_cbc());
72*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_des_ede3_cbc());
73*f5b1c8a1SJohn Marino #endif
74*f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_IDEA
75*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_idea_cbc());
76*f5b1c8a1SJohn Marino #endif
77*f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_RC4
78*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_rc4());
79*f5b1c8a1SJohn Marino #if !defined(OPENSSL_NO_MD5) && (defined(__x86_64) || defined(__x86_64__))
80*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_rc4_hmac_md5());
81*f5b1c8a1SJohn Marino #endif
82*f5b1c8a1SJohn Marino #endif
83*f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_RC2
84*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_rc2_cbc());
85*f5b1c8a1SJohn Marino 	/* Not actually used for SSL/TLS but this makes PKCS#12 work
86*f5b1c8a1SJohn Marino 	 * if an application only calls SSL_library_init().
87*f5b1c8a1SJohn Marino 	 */
88*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_rc2_40_cbc());
89*f5b1c8a1SJohn Marino #endif
90*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_aes_128_cbc());
91*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_aes_192_cbc());
92*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_aes_256_cbc());
93*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_aes_128_gcm());
94*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_aes_256_gcm());
95*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_aes_128_cbc_hmac_sha1());
96*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_aes_256_cbc_hmac_sha1());
97*f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_CAMELLIA
98*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_camellia_128_cbc());
99*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_camellia_256_cbc());
100*f5b1c8a1SJohn Marino #endif
101*f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_GOST
102*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_gost2814789_cfb64());
103*f5b1c8a1SJohn Marino 	EVP_add_cipher(EVP_gost2814789_cnt());
104*f5b1c8a1SJohn Marino #endif
105*f5b1c8a1SJohn Marino 
106*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_md5());
107*f5b1c8a1SJohn Marino 	EVP_add_digest_alias(SN_md5, "ssl2-md5");
108*f5b1c8a1SJohn Marino 	EVP_add_digest_alias(SN_md5, "ssl3-md5");
109*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_sha1()); /* RSA with sha1 */
110*f5b1c8a1SJohn Marino 	EVP_add_digest_alias(SN_sha1, "ssl3-sha1");
111*f5b1c8a1SJohn Marino 	EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA);
112*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_sha224());
113*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_sha256());
114*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_sha384());
115*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_sha512());
116*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_dss1()); /* DSA with sha1 */
117*f5b1c8a1SJohn Marino 	EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2);
118*f5b1c8a1SJohn Marino 	EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1");
119*f5b1c8a1SJohn Marino 	EVP_add_digest_alias(SN_dsaWithSHA1, "dss1");
120*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_ecdsa());
121*f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_GOST
122*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_gostr341194());
123*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_gost2814789imit());
124*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_streebog256());
125*f5b1c8a1SJohn Marino 	EVP_add_digest(EVP_streebog512());
126*f5b1c8a1SJohn Marino #endif
127*f5b1c8a1SJohn Marino 	/* initialize cipher/digest methods table */
128*f5b1c8a1SJohn Marino 	ssl_load_ciphers();
129*f5b1c8a1SJohn Marino 	return (1);
130*f5b1c8a1SJohn Marino }
131*f5b1c8a1SJohn Marino 
132