diff options
Diffstat (limited to 'src/lib/libcrypto/evp')
-rw-r--r-- | src/lib/libcrypto/evp/e_camellia.c | 131 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/e_old.c | 17 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/m_ecdsa.c | 148 |
3 files changed, 296 insertions, 0 deletions
diff --git a/src/lib/libcrypto/evp/e_camellia.c b/src/lib/libcrypto/evp/e_camellia.c new file mode 100644 index 0000000000..a7b40d1c60 --- /dev/null +++ b/src/lib/libcrypto/evp/e_camellia.c | |||
@@ -0,0 +1,131 @@ | |||
1 | /* crypto/evp/e_camellia.c -*- mode:C; c-file-style: "eay" -*- */ | ||
2 | /* ==================================================================== | ||
3 | * Copyright (c) 2006 The OpenSSL Project. All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in | ||
14 | * the documentation and/or other materials provided with the | ||
15 | * distribution. | ||
16 | * | ||
17 | * 3. All advertising materials mentioning features or use of this | ||
18 | * software must display the following acknowledgment: | ||
19 | * "This product includes software developed by the OpenSSL Project | ||
20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
21 | * | ||
22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
23 | * endorse or promote products derived from this software without | ||
24 | * prior written permission. For written permission, please contact | ||
25 | * openssl-core@openssl.org. | ||
26 | * | ||
27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
28 | * nor may "OpenSSL" appear in their names without prior written | ||
29 | * permission of the OpenSSL Project. | ||
30 | * | ||
31 | * 6. Redistributions of any form whatsoever must retain the following | ||
32 | * acknowledgment: | ||
33 | * "This product includes software developed by the OpenSSL Project | ||
34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
35 | * | ||
36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
48 | * ==================================================================== | ||
49 | * | ||
50 | * This product includes cryptographic software written by Eric Young | ||
51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
52 | * Hudson (tjh@cryptsoft.com). | ||
53 | * | ||
54 | */ | ||
55 | |||
56 | #include <openssl/opensslconf.h> | ||
57 | #ifndef OPENSSL_NO_CAMELLIA | ||
58 | #include <openssl/evp.h> | ||
59 | #include <openssl/err.h> | ||
60 | #include <string.h> | ||
61 | #include <assert.h> | ||
62 | #include <openssl/camellia.h> | ||
63 | #include "evp_locl.h" | ||
64 | |||
65 | static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
66 | const unsigned char *iv, int enc); | ||
67 | |||
68 | /* Camellia subkey Structure */ | ||
69 | typedef struct | ||
70 | { | ||
71 | CAMELLIA_KEY ks; | ||
72 | } EVP_CAMELLIA_KEY; | ||
73 | |||
74 | /* Attribute operation for Camellia */ | ||
75 | #define data(ctx) EVP_C_DATA(EVP_CAMELLIA_KEY,ctx) | ||
76 | |||
77 | IMPLEMENT_BLOCK_CIPHER(camellia_128, ks, Camellia, EVP_CAMELLIA_KEY, | ||
78 | NID_camellia_128, 16, 16, 16, 128, | ||
79 | 0, camellia_init_key, NULL, | ||
80 | EVP_CIPHER_set_asn1_iv, | ||
81 | EVP_CIPHER_get_asn1_iv, | ||
82 | NULL) | ||
83 | IMPLEMENT_BLOCK_CIPHER(camellia_192, ks, Camellia, EVP_CAMELLIA_KEY, | ||
84 | NID_camellia_192, 16, 24, 16, 128, | ||
85 | 0, camellia_init_key, NULL, | ||
86 | EVP_CIPHER_set_asn1_iv, | ||
87 | EVP_CIPHER_get_asn1_iv, | ||
88 | NULL) | ||
89 | IMPLEMENT_BLOCK_CIPHER(camellia_256, ks, Camellia, EVP_CAMELLIA_KEY, | ||
90 | NID_camellia_256, 16, 32, 16, 128, | ||
91 | 0, camellia_init_key, NULL, | ||
92 | EVP_CIPHER_set_asn1_iv, | ||
93 | EVP_CIPHER_get_asn1_iv, | ||
94 | NULL) | ||
95 | |||
96 | #define IMPLEMENT_CAMELLIA_CFBR(ksize,cbits) IMPLEMENT_CFBR(camellia,Camellia,EVP_CAMELLIA_KEY,ks,ksize,cbits,16) | ||
97 | |||
98 | IMPLEMENT_CAMELLIA_CFBR(128,1) | ||
99 | IMPLEMENT_CAMELLIA_CFBR(192,1) | ||
100 | IMPLEMENT_CAMELLIA_CFBR(256,1) | ||
101 | |||
102 | IMPLEMENT_CAMELLIA_CFBR(128,8) | ||
103 | IMPLEMENT_CAMELLIA_CFBR(192,8) | ||
104 | IMPLEMENT_CAMELLIA_CFBR(256,8) | ||
105 | |||
106 | |||
107 | |||
108 | /* The subkey for Camellia is generated. */ | ||
109 | static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
110 | const unsigned char *iv, int enc) | ||
111 | { | ||
112 | int ret; | ||
113 | |||
114 | ret=Camellia_set_key(key, ctx->key_len * 8, ctx->cipher_data); | ||
115 | |||
116 | if(ret < 0) | ||
117 | { | ||
118 | EVPerr(EVP_F_CAMELLIA_INIT_KEY,EVP_R_CAMELLIA_KEY_SETUP_FAILED); | ||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | return 1; | ||
123 | } | ||
124 | |||
125 | #else | ||
126 | |||
127 | # ifdef PEDANTIC | ||
128 | static void *dummy=&dummy; | ||
129 | # endif | ||
130 | |||
131 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_old.c b/src/lib/libcrypto/evp/e_old.c index 92dc498945..1642af4869 100644 --- a/src/lib/libcrypto/evp/e_old.c +++ b/src/lib/libcrypto/evp/e_old.c | |||
@@ -56,6 +56,10 @@ | |||
56 | * | 56 | * |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifdef OPENSSL_NO_DEPRECATED | ||
60 | static void *dummy = &dummy; | ||
61 | #else | ||
62 | |||
59 | #include <openssl/evp.h> | 63 | #include <openssl/evp.h> |
60 | 64 | ||
61 | /* Define some deprecated functions, so older programs | 65 | /* Define some deprecated functions, so older programs |
@@ -66,43 +70,56 @@ | |||
66 | 70 | ||
67 | #ifndef OPENSSL_NO_BF | 71 | #ifndef OPENSSL_NO_BF |
68 | #undef EVP_bf_cfb | 72 | #undef EVP_bf_cfb |
73 | const EVP_CIPHER *EVP_bf_cfb(void); | ||
69 | const EVP_CIPHER *EVP_bf_cfb(void) { return EVP_bf_cfb64(); } | 74 | const EVP_CIPHER *EVP_bf_cfb(void) { return EVP_bf_cfb64(); } |
70 | #endif | 75 | #endif |
71 | 76 | ||
72 | #ifndef OPENSSL_NO_DES | 77 | #ifndef OPENSSL_NO_DES |
73 | #undef EVP_des_cfb | 78 | #undef EVP_des_cfb |
79 | const EVP_CIPHER *EVP_des_cfb(void); | ||
74 | const EVP_CIPHER *EVP_des_cfb(void) { return EVP_des_cfb64(); } | 80 | const EVP_CIPHER *EVP_des_cfb(void) { return EVP_des_cfb64(); } |
75 | #undef EVP_des_ede3_cfb | 81 | #undef EVP_des_ede3_cfb |
82 | const EVP_CIPHER *EVP_des_ede3_cfb(void); | ||
76 | const EVP_CIPHER *EVP_des_ede3_cfb(void) { return EVP_des_ede3_cfb64(); } | 83 | const EVP_CIPHER *EVP_des_ede3_cfb(void) { return EVP_des_ede3_cfb64(); } |
77 | #undef EVP_des_ede_cfb | 84 | #undef EVP_des_ede_cfb |
85 | const EVP_CIPHER *EVP_des_ede_cfb(void); | ||
78 | const EVP_CIPHER *EVP_des_ede_cfb(void) { return EVP_des_ede_cfb64(); } | 86 | const EVP_CIPHER *EVP_des_ede_cfb(void) { return EVP_des_ede_cfb64(); } |
79 | #endif | 87 | #endif |
80 | 88 | ||
81 | #ifndef OPENSSL_NO_IDEA | 89 | #ifndef OPENSSL_NO_IDEA |
82 | #undef EVP_idea_cfb | 90 | #undef EVP_idea_cfb |
91 | const EVP_CIPHER *EVP_idea_cfb(void); | ||
83 | const EVP_CIPHER *EVP_idea_cfb(void) { return EVP_idea_cfb64(); } | 92 | const EVP_CIPHER *EVP_idea_cfb(void) { return EVP_idea_cfb64(); } |
84 | #endif | 93 | #endif |
85 | 94 | ||
86 | #ifndef OPENSSL_NO_RC2 | 95 | #ifndef OPENSSL_NO_RC2 |
87 | #undef EVP_rc2_cfb | 96 | #undef EVP_rc2_cfb |
97 | const EVP_CIPHER *EVP_rc2_cfb(void); | ||
88 | const EVP_CIPHER *EVP_rc2_cfb(void) { return EVP_rc2_cfb64(); } | 98 | const EVP_CIPHER *EVP_rc2_cfb(void) { return EVP_rc2_cfb64(); } |
89 | #endif | 99 | #endif |
90 | 100 | ||
91 | #ifndef OPENSSL_NO_CAST | 101 | #ifndef OPENSSL_NO_CAST |
92 | #undef EVP_cast5_cfb | 102 | #undef EVP_cast5_cfb |
103 | const EVP_CIPHER *EVP_cast5_cfb(void); | ||
93 | const EVP_CIPHER *EVP_cast5_cfb(void) { return EVP_cast5_cfb64(); } | 104 | const EVP_CIPHER *EVP_cast5_cfb(void) { return EVP_cast5_cfb64(); } |
94 | #endif | 105 | #endif |
95 | 106 | ||
96 | #ifndef OPENSSL_NO_RC5 | 107 | #ifndef OPENSSL_NO_RC5 |
97 | #undef EVP_rc5_32_12_16_cfb | 108 | #undef EVP_rc5_32_12_16_cfb |
109 | const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); | ||
98 | const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void) { return EVP_rc5_32_12_16_cfb64(); } | 110 | const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void) { return EVP_rc5_32_12_16_cfb64(); } |
99 | #endif | 111 | #endif |
100 | 112 | ||
101 | #ifndef OPENSSL_NO_AES | 113 | #ifndef OPENSSL_NO_AES |
102 | #undef EVP_aes_128_cfb | 114 | #undef EVP_aes_128_cfb |
115 | const EVP_CIPHER *EVP_aes_128_cfb(void); | ||
103 | const EVP_CIPHER *EVP_aes_128_cfb(void) { return EVP_aes_128_cfb128(); } | 116 | const EVP_CIPHER *EVP_aes_128_cfb(void) { return EVP_aes_128_cfb128(); } |
104 | #undef EVP_aes_192_cfb | 117 | #undef EVP_aes_192_cfb |
118 | const EVP_CIPHER *EVP_aes_192_cfb(void); | ||
105 | const EVP_CIPHER *EVP_aes_192_cfb(void) { return EVP_aes_192_cfb128(); } | 119 | const EVP_CIPHER *EVP_aes_192_cfb(void) { return EVP_aes_192_cfb128(); } |
106 | #undef EVP_aes_256_cfb | 120 | #undef EVP_aes_256_cfb |
121 | const EVP_CIPHER *EVP_aes_256_cfb(void); | ||
107 | const EVP_CIPHER *EVP_aes_256_cfb(void) { return EVP_aes_256_cfb128(); } | 122 | const EVP_CIPHER *EVP_aes_256_cfb(void) { return EVP_aes_256_cfb128(); } |
108 | #endif | 123 | #endif |
124 | |||
125 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_ecdsa.c b/src/lib/libcrypto/evp/m_ecdsa.c new file mode 100644 index 0000000000..fad270faca --- /dev/null +++ b/src/lib/libcrypto/evp/m_ecdsa.c | |||
@@ -0,0 +1,148 @@ | |||
1 | /* crypto/evp/m_ecdsa.c */ | ||
2 | /* ==================================================================== | ||
3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in | ||
14 | * the documentation and/or other materials provided with the | ||
15 | * distribution. | ||
16 | * | ||
17 | * 3. All advertising materials mentioning features or use of this | ||
18 | * software must display the following acknowledgment: | ||
19 | * "This product includes software developed by the OpenSSL Project | ||
20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
21 | * | ||
22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
23 | * endorse or promote products derived from this software without | ||
24 | * prior written permission. For written permission, please contact | ||
25 | * openssl-core@openssl.org. | ||
26 | * | ||
27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
28 | * nor may "OpenSSL" appear in their names without prior written | ||
29 | * permission of the OpenSSL Project. | ||
30 | * | ||
31 | * 6. Redistributions of any form whatsoever must retain the following | ||
32 | * acknowledgment: | ||
33 | * "This product includes software developed by the OpenSSL Project | ||
34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
35 | * | ||
36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
48 | * ==================================================================== | ||
49 | * | ||
50 | * This product includes cryptographic software written by Eric Young | ||
51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
52 | * Hudson (tjh@cryptsoft.com). | ||
53 | * | ||
54 | */ | ||
55 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
56 | * All rights reserved. | ||
57 | * | ||
58 | * This package is an SSL implementation written | ||
59 | * by Eric Young (eay@cryptsoft.com). | ||
60 | * The implementation was written so as to conform with Netscapes SSL. | ||
61 | * | ||
62 | * This library is free for commercial and non-commercial use as long as | ||
63 | * the following conditions are aheared to. The following conditions | ||
64 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
65 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
66 | * included with this distribution is covered by the same copyright terms | ||
67 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
68 | * | ||
69 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
70 | * the code are not to be removed. | ||
71 | * If this package is used in a product, Eric Young should be given attribution | ||
72 | * as the author of the parts of the library used. | ||
73 | * This can be in the form of a textual message at program startup or | ||
74 | * in documentation (online or textual) provided with the package. | ||
75 | * | ||
76 | * Redistribution and use in source and binary forms, with or without | ||
77 | * modification, are permitted provided that the following conditions | ||
78 | * are met: | ||
79 | * 1. Redistributions of source code must retain the copyright | ||
80 | * notice, this list of conditions and the following disclaimer. | ||
81 | * 2. Redistributions in binary form must reproduce the above copyright | ||
82 | * notice, this list of conditions and the following disclaimer in the | ||
83 | * documentation and/or other materials provided with the distribution. | ||
84 | * 3. All advertising materials mentioning features or use of this software | ||
85 | * must display the following acknowledgement: | ||
86 | * "This product includes cryptographic software written by | ||
87 | * Eric Young (eay@cryptsoft.com)" | ||
88 | * The word 'cryptographic' can be left out if the rouines from the library | ||
89 | * being used are not cryptographic related :-). | ||
90 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
91 | * the apps directory (application code) you must include an acknowledgement: | ||
92 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
93 | * | ||
94 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
95 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
96 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
97 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
98 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
99 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
100 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
101 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
102 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
103 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
104 | * SUCH DAMAGE. | ||
105 | * | ||
106 | * The licence and distribution terms for any publically available version or | ||
107 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
108 | * copied and put under another distribution licence | ||
109 | * [including the GNU Public Licence.] | ||
110 | */ | ||
111 | |||
112 | #include <stdio.h> | ||
113 | #include "cryptlib.h" | ||
114 | #include <openssl/evp.h> | ||
115 | #include <openssl/objects.h> | ||
116 | #include <openssl/x509.h> | ||
117 | |||
118 | #ifndef OPENSSL_NO_SHA | ||
119 | static int init(EVP_MD_CTX *ctx) | ||
120 | { return SHA1_Init(ctx->md_data); } | ||
121 | |||
122 | static int update(EVP_MD_CTX *ctx,const void *data,size_t count) | ||
123 | { return SHA1_Update(ctx->md_data,data,count); } | ||
124 | |||
125 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
126 | { return SHA1_Final(md,ctx->md_data); } | ||
127 | |||
128 | static const EVP_MD ecdsa_md= | ||
129 | { | ||
130 | NID_ecdsa_with_SHA1, | ||
131 | NID_ecdsa_with_SHA1, | ||
132 | SHA_DIGEST_LENGTH, | ||
133 | 0, | ||
134 | init, | ||
135 | update, | ||
136 | final, | ||
137 | NULL, | ||
138 | NULL, | ||
139 | EVP_PKEY_ECDSA_method, | ||
140 | SHA_CBLOCK, | ||
141 | sizeof(EVP_MD *)+sizeof(SHA_CTX), | ||
142 | }; | ||
143 | |||
144 | const EVP_MD *EVP_ecdsa(void) | ||
145 | { | ||
146 | return(&ecdsa_md); | ||
147 | } | ||
148 | #endif | ||