ssl_algs.c revision 296341
1139815Simp/* ssl/ssl_algs.c */
2206361Sjoel/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
375332Sbp * All rights reserved.
475332Sbp *
575332Sbp * This package is an SSL implementation written
675332Sbp * by Eric Young (eay@cryptsoft.com).
775332Sbp * The implementation was written so as to conform with Netscapes SSL.
875332Sbp *
975332Sbp * This library is free for commercial and non-commercial use as long as
1075332Sbp * the following conditions are aheared to.  The following conditions
1175332Sbp * apply to all code found in this distribution, be it the RC4, RSA,
1275332Sbp * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1375332Sbp * included with this distribution is covered by the same copyright terms
1475332Sbp * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1575332Sbp *
1675332Sbp * Copyright remains Eric Young's, and as such any Copyright notices in
1775332Sbp * the code are not to be removed.
1875332Sbp * If this package is used in a product, Eric Young should be given attribution
1975332Sbp * as the author of the parts of the library used.
2075332Sbp * This can be in the form of a textual message at program startup or
2175332Sbp * in documentation (online or textual) provided with the package.
2275332Sbp *
2375332Sbp * Redistribution and use in source and binary forms, with or without
2475332Sbp * modification, are permitted provided that the following conditions
2575332Sbp * are met:
26116189Sobrien * 1. Redistributions of source code must retain the copyright
27116189Sobrien *    notice, this list of conditions and the following disclaimer.
28116189Sobrien * 2. Redistributions in binary form must reproduce the above copyright
29116189Sobrien *    notice, this list of conditions and the following disclaimer in the
3075332Sbp *    documentation and/or other materials provided with the distribution.
3175332Sbp * 3. All advertising materials mentioning features or use of this software
3275332Sbp *    must display the following acknowledgement:
3375332Sbp *    "This product includes cryptographic software written by
3475332Sbp *     Eric Young (eay@cryptsoft.com)"
35120492Sfjoe *    The word 'cryptographic' can be left out if the rouines from the library
36185652Sjhb *    being used are not cryptographic related :-).
37120492Sfjoe * 4. If you include any Windows specific code (or a derivative thereof) from
3875332Sbp *    the apps directory (application code) you must include an acknowledgement:
3975332Sbp *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
4075332Sbp *
4175332Sbp * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4275332Sbp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4375332Sbp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4475332Sbp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45151897Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46249132Smav * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4775332Sbp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48120492Sfjoe * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4975332Sbp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50185652Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51185652Sjhb * SUCH DAMAGE.
5275332Sbp *
5375332Sbp * The licence and distribution terms for any publically available version or
5475332Sbp * derivative of this code cannot be changed.  i.e. this code cannot simply be
5575332Sbp * copied and put under another distribution licence
5675332Sbp * [including the GNU Public Licence.]
5775332Sbp */
5875332Sbp
5975332Sbp#include <stdio.h>
6075332Sbp#include <openssl/objects.h>
6175332Sbp#include <openssl/lhash.h>
6275332Sbp#include "ssl_locl.h"
6375332Sbp
6475332Sbpint SSL_library_init(void)
6575332Sbp{
6675332Sbp
6775332Sbp#ifndef OPENSSL_NO_DES
6875332Sbp    EVP_add_cipher(EVP_des_cbc());
6975332Sbp    EVP_add_cipher(EVP_des_ede3_cbc());
7075332Sbp#endif
7175332Sbp#ifndef OPENSSL_NO_IDEA
7275332Sbp    EVP_add_cipher(EVP_idea_cbc());
7375332Sbp#endif
7475332Sbp#ifndef OPENSSL_NO_RC4
7575332Sbp    EVP_add_cipher(EVP_rc4());
7675332Sbp# if !defined(OPENSSL_NO_MD5) && (defined(__x86_64) || defined(__x86_64__))
7775332Sbp    EVP_add_cipher(EVP_rc4_hmac_md5());
7875332Sbp# endif
7975332Sbp#endif
8075332Sbp#ifndef OPENSSL_NO_RC2
8175332Sbp    EVP_add_cipher(EVP_rc2_cbc());
8275332Sbp    /*
8375332Sbp     * Not actually used for SSL/TLS but this makes PKCS#12 work if an
8475332Sbp     * application only calls SSL_library_init().
8575332Sbp     */
86185652Sjhb    EVP_add_cipher(EVP_rc2_40_cbc());
87245149Skevlo#endif
88245149Skevlo#ifndef OPENSSL_NO_AES
89245149Skevlo    EVP_add_cipher(EVP_aes_128_cbc());
9075332Sbp    EVP_add_cipher(EVP_aes_192_cbc());
91245149Skevlo    EVP_add_cipher(EVP_aes_256_cbc());
92185652Sjhb    EVP_add_cipher(EVP_aes_128_gcm());
93185652Sjhb    EVP_add_cipher(EVP_aes_256_gcm());
94185652Sjhb# if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
9575332Sbp    EVP_add_cipher(EVP_aes_128_cbc_hmac_sha1());
96185652Sjhb    EVP_add_cipher(EVP_aes_256_cbc_hmac_sha1());
97185652Sjhb# endif
9875332Sbp
9975332Sbp#endif
10075332Sbp#ifndef OPENSSL_NO_CAMELLIA
10175332Sbp    EVP_add_cipher(EVP_camellia_128_cbc());
10275332Sbp    EVP_add_cipher(EVP_camellia_256_cbc());
10375332Sbp#endif
10475332Sbp
10575332Sbp#ifndef OPENSSL_NO_SEED
10675332Sbp    EVP_add_cipher(EVP_seed_cbc());
10775332Sbp#endif
10875332Sbp
109185652Sjhb#ifndef OPENSSL_NO_MD5
11075332Sbp    EVP_add_digest(EVP_md5());
11175332Sbp    EVP_add_digest_alias(SN_md5, "ssl2-md5");
11275332Sbp    EVP_add_digest_alias(SN_md5, "ssl3-md5");
11375332Sbp#endif
11475332Sbp#ifndef OPENSSL_NO_SHA
11575332Sbp    EVP_add_digest(EVP_sha1()); /* RSA with sha1 */
11675332Sbp    EVP_add_digest_alias(SN_sha1, "ssl3-sha1");
11775332Sbp    EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA);
11875332Sbp#endif
11975332Sbp#ifndef OPENSSL_NO_SHA256
12075332Sbp    EVP_add_digest(EVP_sha224());
12175332Sbp    EVP_add_digest(EVP_sha256());
12275332Sbp#endif
12375332Sbp#ifndef OPENSSL_NO_SHA512
12475332Sbp    EVP_add_digest(EVP_sha384());
12575332Sbp    EVP_add_digest(EVP_sha512());
12675332Sbp#endif
12775332Sbp#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DSA)
12875332Sbp    EVP_add_digest(EVP_dss1()); /* DSA with sha1 */
12975332Sbp    EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2);
13075332Sbp    EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1");
13175332Sbp    EVP_add_digest_alias(SN_dsaWithSHA1, "dss1");
13275332Sbp#endif
13375332Sbp#ifndef OPENSSL_NO_ECDSA
13475332Sbp    EVP_add_digest(EVP_ecdsa());
13575332Sbp#endif
13675332Sbp    /* If you want support for phased out ciphers, add the following */
13775332Sbp#if 0
13875332Sbp    EVP_add_digest(EVP_sha());
13975332Sbp    EVP_add_digest(EVP_dss());
14075332Sbp#endif
14175332Sbp#ifndef OPENSSL_NO_COMP
14275332Sbp    /*
14375332Sbp     * This will initialise the built-in compression algorithms. The value
14475332Sbp     * returned is a STACK_OF(SSL_COMP), but that can be discarded safely
14575332Sbp     */
14675332Sbp    (void)SSL_COMP_get_compression_methods();
14775332Sbp#endif
14875332Sbp    /* initialize cipher/digest methods table */
14975332Sbp    ssl_load_ciphers();
15075332Sbp    return (1);
15175332Sbp}
15275332Sbp