summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp
diff options
context:
space:
mode:
authorryker <>1998-10-05 20:13:16 +0000
committerryker <>1998-10-05 20:13:16 +0000
commit9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4 (patch)
tree51ff319f3510104698e541954d10ad98f9125f36 /src/lib/libcrypto/evp
parent9e77c62555877f9a64805c49d0dcd7dbfbb40f4e (diff)
downloadopenbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.tar.gz
openbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.tar.bz2
openbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.zip
Import of SSLeay-0.9.0b with RSA and IDEA stubbed + OpenBSD build
functionality for shared libs. Note that routines such as sslv2_init and friends that use RSA will not work due to lack of RSA in this library. Needs documentation and help from ports for easy upgrade to full functionality where legally possible.
Diffstat (limited to 'src/lib/libcrypto/evp')
-rw-r--r--src/lib/libcrypto/evp/e_cbc_3d.c163
-rw-r--r--src/lib/libcrypto/evp/e_cbc_bf.c119
-rw-r--r--src/lib/libcrypto/evp/e_cbc_c.c119
-rw-r--r--src/lib/libcrypto/evp/e_cbc_d.c116
-rw-r--r--src/lib/libcrypto/evp/e_cbc_i.c131
-rw-r--r--src/lib/libcrypto/evp/e_cbc_r2.c136
-rw-r--r--src/lib/libcrypto/evp/e_cbc_r5.c120
-rw-r--r--src/lib/libcrypto/evp/e_cfb_3d.c166
-rw-r--r--src/lib/libcrypto/evp/e_cfb_bf.c121
-rw-r--r--src/lib/libcrypto/evp/e_cfb_c.c121
-rw-r--r--src/lib/libcrypto/evp/e_cfb_d.c118
-rw-r--r--src/lib/libcrypto/evp/e_cfb_i.c121
-rw-r--r--src/lib/libcrypto/evp/e_cfb_r2.c122
-rw-r--r--src/lib/libcrypto/evp/e_cfb_r5.c122
-rw-r--r--src/lib/libcrypto/evp/e_ecb_3d.c161
-rw-r--r--src/lib/libcrypto/evp/e_ecb_bf.c122
-rw-r--r--src/lib/libcrypto/evp/e_ecb_c.c122
-rw-r--r--src/lib/libcrypto/evp/e_ecb_d.c118
-rw-r--r--src/lib/libcrypto/evp/e_ecb_i.c133
-rw-r--r--src/lib/libcrypto/evp/e_ecb_r2.c123
-rw-r--r--src/lib/libcrypto/evp/e_ecb_r5.c123
-rw-r--r--src/lib/libcrypto/evp/e_ofb_3d.c165
-rw-r--r--src/lib/libcrypto/evp/e_ofb_bf.c122
-rw-r--r--src/lib/libcrypto/evp/e_ofb_c.c122
-rw-r--r--src/lib/libcrypto/evp/e_ofb_d.c118
-rw-r--r--src/lib/libcrypto/evp/e_ofb_i.c121
-rw-r--r--src/lib/libcrypto/evp/e_ofb_r2.c123
-rw-r--r--src/lib/libcrypto/evp/e_ofb_r5.c123
-rw-r--r--src/lib/libcrypto/evp/evp.err24
-rw-r--r--src/lib/libcrypto/evp/pk_lib.c82
30 files changed, 3697 insertions, 0 deletions
diff --git a/src/lib/libcrypto/evp/e_cbc_3d.c b/src/lib/libcrypto/evp/e_cbc_3d.c
new file mode 100644
index 0000000000..5761bf186a
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_3d.c
@@ -0,0 +1,163 @@
1/* crypto/evp/e_cbc_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_cbc_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_cbc_ede_init_key();
73static void des_cbc_ede3_init_key();
74static void des_cbc_ede_cipher();
75#endif
76
77static EVP_CIPHER d_cbc_ede_cipher2=
78 {
79 NID_des_ede_cbc,
80 8,16,8,
81 des_cbc_ede_init_key,
82 des_cbc_ede_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_get_asn1_iv,
87 EVP_CIPHER_set_asn1_iv,
88 };
89
90static EVP_CIPHER d_cbc_ede_cipher3=
91 {
92 NID_des_ede3_cbc,
93 8,24,8,
94 des_cbc_ede3_init_key,
95 des_cbc_ede_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_cbc()
104 {
105 return(&d_cbc_ede_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_cbc()
109 {
110 return(&d_cbc_ede_cipher3);
111 }
112
113static void des_cbc_ede_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 if (iv != NULL)
120 memcpy(&(ctx->oiv[0]),iv,8);
121 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
122
123 if (key != NULL)
124 {
125 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
126 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
127 memcpy( (char *)ctx->c.des_ede.ks3,
128 (char *)ctx->c.des_ede.ks1,
129 sizeof(ctx->c.des_ede.ks1));
130 }
131 }
132
133static void des_cbc_ede3_init_key(ctx,key,iv,enc)
134EVP_CIPHER_CTX *ctx;
135unsigned char *key;
136unsigned char *iv;
137int enc;
138 {
139 if (iv != NULL)
140 memcpy(&(ctx->oiv[0]),iv,8);
141 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
142
143 if (key != NULL)
144 {
145 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
146 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
147 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
148 }
149 }
150
151static void des_cbc_ede_cipher(ctx,out,in,inl)
152EVP_CIPHER_CTX *ctx;
153unsigned char *out;
154unsigned char *in;
155unsigned int inl;
156 {
157 des_ede3_cbc_encrypt(
158 (des_cblock *)in,(des_cblock *)out,
159 (long)inl, ctx->c.des_ede.ks1,
160 ctx->c.des_ede.ks2,ctx->c.des_ede.ks3,
161 (des_cblock *)&(ctx->iv[0]),
162 ctx->encrypt);
163 }
diff --git a/src/lib/libcrypto/evp/e_cbc_bf.c b/src/lib/libcrypto/evp/e_cbc_bf.c
new file mode 100644
index 0000000000..be605f4a13
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_bf.c
@@ -0,0 +1,119 @@
1/* crypto/evp/e_cbc_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_cbc_init_key();
73static void bf_cbc_cipher();
74#endif
75
76static EVP_CIPHER bfish_cbc_cipher=
77 {
78 NID_bf_cbc,
79 8,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_cbc_init_key,
81 bf_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_cbc()
90 {
91 return(&bfish_cbc_cipher);
92 }
93
94static void bf_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
105 }
106
107static void bf_cbc_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 BF_cbc_encrypt(
114 in,out,(long)inl,
115 &(ctx->c.bf_ks),&(ctx->iv[0]),
116 ctx->encrypt);
117 }
118
119#endif
diff --git a/src/lib/libcrypto/evp/e_cbc_c.c b/src/lib/libcrypto/evp/e_cbc_c.c
new file mode 100644
index 0000000000..b50c7874b3
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_c.c
@@ -0,0 +1,119 @@
1/* crypto/evp/e_cbc_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_cbc_init_key();
73static void cast_cbc_cipher();
74#endif
75
76static EVP_CIPHER cast5_cbc_cipher=
77 {
78 NID_cast5_cbc,
79 8,EVP_CAST5_KEY_SIZE,8,
80 cast_cbc_init_key,
81 cast_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_cbc()
90 {
91 return(&cast5_cbc_cipher);
92 }
93
94static void cast_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
105 }
106
107static void cast_cbc_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 CAST_cbc_encrypt(
114 in,out,(long)inl,
115 &(ctx->c.cast_ks),&(ctx->iv[0]),
116 ctx->encrypt);
117 }
118
119#endif
diff --git a/src/lib/libcrypto/evp/e_cbc_d.c b/src/lib/libcrypto/evp/e_cbc_d.c
new file mode 100644
index 0000000000..c67706e3a0
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_d.c
@@ -0,0 +1,116 @@
1/* crypto/evp/e_cbc_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_cbc_init_key();
71static void des_cbc_cipher();
72#endif
73
74static EVP_CIPHER d_cbc_cipher=
75 {
76 NID_des_cbc,
77 8,8,8,
78 des_cbc_init_key,
79 des_cbc_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_get_asn1_iv,
84 EVP_CIPHER_set_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_cbc()
88 {
89 return(&d_cbc_cipher);
90 }
91
92static void des_cbc_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 if (iv != NULL)
99 memcpy(&(ctx->oiv[0]),iv,8);
100 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
101 if (key != NULL)
102 des_set_key((des_cblock *)key,ctx->c.des_ks);
103 }
104
105static void des_cbc_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 des_ncbc_encrypt(
112 (des_cblock *)in,(des_cblock *)out,
113 (long)inl, ctx->c.des_ks,
114 (des_cblock *)&(ctx->iv[0]),
115 ctx->encrypt);
116 }
diff --git a/src/lib/libcrypto/evp/e_cbc_i.c b/src/lib/libcrypto/evp/e_cbc_i.c
new file mode 100644
index 0000000000..312ffcb721
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_i.c
@@ -0,0 +1,131 @@
1/* crypto/evp/e_cbc_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_cbc_init_key();
73static void idea_cbc_cipher();
74#endif
75
76static EVP_CIPHER i_cbc_cipher=
77 {
78 NID_idea_cbc,
79 8,16,8,
80 idea_cbc_init_key,
81 idea_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_cbc()
90 {
91 return(&i_cbc_cipher);
92 }
93
94static void idea_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 {
105 if (enc)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 else
108 {
109 IDEA_KEY_SCHEDULE tmp;
110
111 idea_set_encrypt_key(key,&tmp);
112 idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks));
113 memset((unsigned char *)&tmp,0,
114 sizeof(IDEA_KEY_SCHEDULE));
115 }
116 }
117 }
118
119static void idea_cbc_cipher(ctx,out,in,inl)
120EVP_CIPHER_CTX *ctx;
121unsigned char *out;
122unsigned char *in;
123unsigned int inl;
124 {
125 idea_cbc_encrypt(
126 in,out,(long)inl,
127 &(ctx->c.idea_ks),&(ctx->iv[0]),
128 ctx->encrypt);
129 }
130
131#endif
diff --git a/src/lib/libcrypto/evp/e_cbc_r2.c b/src/lib/libcrypto/evp/e_cbc_r2.c
new file mode 100644
index 0000000000..4f8002f16d
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_r2.c
@@ -0,0 +1,136 @@
1/* crypto/evp/e_cbc_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_cbc_init_key();
73static void rc2_cbc_cipher();
74#endif
75
76static EVP_CIPHER r2_cbc_cipher=
77 {
78 NID_rc2_cbc,
79 8,EVP_RC2_KEY_SIZE,8,
80 rc2_cbc_init_key,
81 rc2_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89static EVP_CIPHER r2_40_cbc_cipher=
90 {
91 NID_rc2_40_cbc,
92 8,5 /* 40 bit */,8,
93 rc2_cbc_init_key,
94 rc2_cbc_cipher,
95 NULL,
96 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
97 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
98 };
99
100EVP_CIPHER *EVP_rc2_cbc()
101 {
102 return(&r2_cbc_cipher);
103 }
104
105EVP_CIPHER *EVP_rc2_40_cbc()
106 {
107 return(&r2_40_cbc_cipher);
108 }
109
110static void rc2_cbc_init_key(ctx,key,iv,enc)
111EVP_CIPHER_CTX *ctx;
112unsigned char *key;
113unsigned char *iv;
114int enc;
115 {
116 if (iv != NULL)
117 memcpy(&(ctx->oiv[0]),iv,8);
118 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
119 if (key != NULL)
120 RC2_set_key(&(ctx->c.rc2_ks),EVP_CIPHER_CTX_key_length(ctx),
121 key,EVP_CIPHER_CTX_key_length(ctx)*8);
122 }
123
124static void rc2_cbc_cipher(ctx,out,in,inl)
125EVP_CIPHER_CTX *ctx;
126unsigned char *out;
127unsigned char *in;
128unsigned int inl;
129 {
130 RC2_cbc_encrypt(
131 in,out,(long)inl,
132 &(ctx->c.rc2_ks),&(ctx->iv[0]),
133 ctx->encrypt);
134 }
135
136#endif
diff --git a/src/lib/libcrypto/evp/e_cbc_r5.c b/src/lib/libcrypto/evp/e_cbc_r5.c
new file mode 100644
index 0000000000..f7d46ca91f
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_r5.c
@@ -0,0 +1,120 @@
1/* crypto/evp/e_cbc_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void r_32_12_16_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void r_32_12_16_cbc_init_key();
73static void r_32_12_16_cbc_cipher();
74#endif
75
76static EVP_CIPHER rc5_32_12_16_cbc_cipher=
77 {
78 NID_rc5_cbc,
79 8,EVP_RC5_32_12_16_KEY_SIZE,8,
80 r_32_12_16_cbc_init_key,
81 r_32_12_16_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_cbc()
90 {
91 return(&rc5_32_12_16_cbc_cipher);
92 }
93
94static void r_32_12_16_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,
105 key,RC5_12_ROUNDS);
106 }
107
108static void r_32_12_16_cbc_cipher(ctx,out,in,inl)
109EVP_CIPHER_CTX *ctx;
110unsigned char *out;
111unsigned char *in;
112unsigned int inl;
113 {
114 RC5_32_cbc_encrypt(
115 in,out,(long)inl,
116 &(ctx->c.rc5_ks),&(ctx->iv[0]),
117 ctx->encrypt);
118 }
119
120#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_3d.c b/src/lib/libcrypto/evp/e_cfb_3d.c
new file mode 100644
index 0000000000..e7e3419411
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_3d.c
@@ -0,0 +1,166 @@
1/* crypto/evp/e_cfb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_cfb_init_key();
73static void des_ede3_cfb_init_key();
74static void des_ede_cfb_cipher();
75#endif
76
77static EVP_CIPHER d_ede_cfb_cipher2=
78 {
79 NID_des_ede_cfb64,
80 1,16,8,
81 des_ede_cfb_init_key,
82 des_ede_cfb_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_set_asn1_iv,
87 EVP_CIPHER_get_asn1_iv,
88 };
89
90static EVP_CIPHER d_ede3_cfb_cipher3=
91 {
92 NID_des_ede3_cfb64,
93 1,24,8,
94 des_ede3_cfb_init_key,
95 des_ede_cfb_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_cfb()
104 {
105 return(&d_ede_cfb_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_cfb()
109 {
110 return(&d_ede3_cfb_cipher3);
111 }
112
113static void des_ede_cfb_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 ctx->num=0;
120
121 if (iv != NULL)
122 memcpy(&(ctx->oiv[0]),iv,8);
123 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
124 if (key != NULL)
125 {
126 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
127 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
128 memcpy( (char *)ctx->c.des_ede.ks3,
129 (char *)ctx->c.des_ede.ks1,
130 sizeof(ctx->c.des_ede.ks1));
131 }
132 }
133
134static void des_ede3_cfb_init_key(ctx,key,iv,enc)
135EVP_CIPHER_CTX *ctx;
136unsigned char *key;
137unsigned char *iv;
138int enc;
139 {
140 ctx->num=0;
141
142 if (iv != NULL)
143 memcpy(&(ctx->oiv[0]),iv,8);
144 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
145 if (key != NULL)
146 {
147 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
148 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
149 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
150 }
151 }
152
153static void des_ede_cfb_cipher(ctx,out,in,inl)
154EVP_CIPHER_CTX *ctx;
155unsigned char *out;
156unsigned char *in;
157unsigned int inl;
158 {
159 des_ede3_cfb64_encrypt(
160 in,out,(long)inl,
161 ctx->c.des_ede.ks1,
162 ctx->c.des_ede.ks2,
163 ctx->c.des_ede.ks3,
164 (des_cblock *)&(ctx->iv[0]),
165 &ctx->num,ctx->encrypt);
166 }
diff --git a/src/lib/libcrypto/evp/e_cfb_bf.c b/src/lib/libcrypto/evp/e_cfb_bf.c
new file mode 100644
index 0000000000..8aba2564b8
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_bf.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_cfb_init_key();
73static void bf_cfb_cipher();
74#endif
75
76static EVP_CIPHER bfish_cfb_cipher=
77 {
78 NID_bf_cfb64,
79 1,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_cfb_init_key,
81 bf_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_cfb()
90 {
91 return(&bfish_cfb_cipher);
92 }
93
94static void bf_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
107 }
108
109static void bf_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 BF_cfb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.bf_ks),
118 &(ctx->iv[0]),
119 &ctx->num,ctx->encrypt);
120 }
121#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_c.c b/src/lib/libcrypto/evp/e_cfb_c.c
new file mode 100644
index 0000000000..936df55fd8
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_c.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_cfb_init_key();
73static void cast_cfb_cipher();
74#endif
75
76static EVP_CIPHER cast5_cfb_cipher=
77 {
78 NID_cast5_cfb64,
79 1,EVP_CAST5_KEY_SIZE,8,
80 cast_cfb_init_key,
81 cast_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_cfb()
90 {
91 return(&cast5_cfb_cipher);
92 }
93
94static void cast_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
107 }
108
109static void cast_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 CAST_cfb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.cast_ks),
118 &(ctx->iv[0]),
119 &ctx->num,ctx->encrypt);
120 }
121#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_d.c b/src/lib/libcrypto/evp/e_cfb_d.c
new file mode 100644
index 0000000000..9ae4558f51
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_cfb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_cfb_init_key();
71static void des_cfb_cipher();
72#endif
73
74static EVP_CIPHER d_cfb_cipher=
75 {
76 NID_des_cfb64,
77 1,8,8,
78 des_cfb_init_key,
79 des_cfb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_set_asn1_iv,
84 EVP_CIPHER_get_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_cfb()
88 {
89 return(&d_cfb_cipher);
90 }
91
92static void des_cfb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 ctx->num=0;
99
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 des_set_key((des_cblock *)key,ctx->c.des_ks);
105 }
106
107static void des_cfb_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 des_cfb64_encrypt(
114 in,out,
115 (long)inl, ctx->c.des_ks,
116 (des_cblock *)&(ctx->iv[0]),
117 &ctx->num,ctx->encrypt);
118 }
diff --git a/src/lib/libcrypto/evp/e_cfb_i.c b/src/lib/libcrypto/evp/e_cfb_i.c
new file mode 100644
index 0000000000..9225efaa86
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_i.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_cfb_init_key();
73static void idea_cfb_cipher();
74#endif
75
76static EVP_CIPHER i_cfb_cipher=
77 {
78 NID_idea_cfb64,
79 1,IDEA_KEY_LENGTH,IDEA_BLOCK,
80 idea_cfb_init_key,
81 idea_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_cfb()
90 {
91 return(&i_cfb_cipher);
92 }
93
94static void idea_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 }
108
109static void idea_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 idea_cfb64_encrypt(
116 in,out,(long)inl,
117 &(ctx->c.idea_ks),&(ctx->iv[0]),
118 &ctx->num,ctx->encrypt);
119 }
120
121#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_r2.c b/src/lib/libcrypto/evp/e_cfb_r2.c
new file mode 100644
index 0000000000..af5a39d1f4
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_r2.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_cfb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_cfb_init_key();
73static void rc2_cfb_cipher();
74#endif
75
76static EVP_CIPHER r2_cfb_cipher=
77 {
78 NID_rc2_cfb64,
79 1,EVP_RC2_KEY_SIZE,8,
80 rc2_cfb_init_key,
81 rc2_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc2_cfb()
90 {
91 return(&r2_cfb_cipher);
92 }
93
94static void rc2_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
107 EVP_RC2_KEY_SIZE*8);
108 }
109
110static void rc2_cfb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC2_cfb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc2_ks),
119 &(ctx->iv[0]),
120 &ctx->num,ctx->encrypt);
121 }
122#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_r5.c b/src/lib/libcrypto/evp/e_cfb_r5.c
new file mode 100644
index 0000000000..a2fddaedc0
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_r5.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_cfb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_cfb_init_key();
73static void rc5_32_12_16_cfb_cipher();
74#endif
75
76static EVP_CIPHER rc5_cfb_cipher=
77 {
78 NID_rc5_cfb64,
79 1,EVP_RC5_32_12_16_KEY_SIZE,8,
80 rc5_32_12_16_cfb_init_key,
81 rc5_32_12_16_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_cfb()
90 {
91 return(&rc5_cfb_cipher);
92 }
93
94static void rc5_32_12_16_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
107 RC5_12_ROUNDS);
108 }
109
110static void rc5_32_12_16_cfb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC5_32_cfb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc5_ks),
119 &(ctx->iv[0]),
120 &ctx->num,ctx->encrypt);
121 }
122#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_3d.c b/src/lib/libcrypto/evp/e_ecb_3d.c
new file mode 100644
index 0000000000..908fc0760a
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_3d.c
@@ -0,0 +1,161 @@
1/* crypto/evp/e_ecb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_init_key();
73static void des_ede3_init_key();
74static void des_ede_cipher();
75#endif
76
77static EVP_CIPHER d_ede_cipher2=
78 {
79 NID_des_ede,
80 8,16,0,
81 des_ede_init_key,
82 des_ede_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 NULL,
87 NULL,
88 };
89
90static EVP_CIPHER d_ede3_cipher3=
91 {
92 NID_des_ede3,
93 8,24,0,
94 des_ede3_init_key,
95 des_ede_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 NULL,
100 };
101
102EVP_CIPHER *EVP_des_ede()
103 {
104 return(&d_ede_cipher2);
105 }
106
107EVP_CIPHER *EVP_des_ede3()
108 {
109 return(&d_ede3_cipher3);
110 }
111
112static void des_ede_init_key(ctx,key,iv,enc)
113EVP_CIPHER_CTX *ctx;
114unsigned char *key;
115unsigned char *iv;
116int enc;
117 {
118 if (key != NULL)
119 {
120 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
121 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
122 memcpy( (char *)ctx->c.des_ede.ks3,
123 (char *)ctx->c.des_ede.ks1,
124 sizeof(ctx->c.des_ede.ks1));
125 }
126 }
127
128static void des_ede3_init_key(ctx,key,iv,enc)
129EVP_CIPHER_CTX *ctx;
130unsigned char *key;
131unsigned char *iv;
132int enc;
133 {
134 if (key != NULL)
135 {
136 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
137 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
138 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
139 }
140 }
141
142static void des_ede_cipher(ctx,out,in,inl)
143EVP_CIPHER_CTX *ctx;
144unsigned char *out;
145unsigned char *in;
146unsigned int inl;
147 {
148 unsigned int i;
149
150 if (inl < 8) return;
151 inl-=8;
152 for (i=0; i<=inl; i+=8)
153 {
154 des_ecb3_encrypt(
155 (des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
156 ctx->c.des_ede.ks1,
157 ctx->c.des_ede.ks2,
158 ctx->c.des_ede.ks3,
159 ctx->encrypt);
160 }
161 }
diff --git a/src/lib/libcrypto/evp/e_ecb_bf.c b/src/lib/libcrypto/evp/e_ecb_bf.c
new file mode 100644
index 0000000000..142a9d3123
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_bf.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ecb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_ecb_init_key();
73static void bf_ecb_cipher();
74#endif
75
76static EVP_CIPHER bfish_ecb_cipher=
77 {
78 NID_bf_ecb,
79 8,EVP_BLOWFISH_KEY_SIZE,0,
80 bf_ecb_init_key,
81 bf_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_bf_ecb()
90 {
91 return(&bfish_ecb_cipher);
92 }
93
94static void bf_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
102 }
103
104static void bf_ecb_cipher(ctx,out,in,inl)
105EVP_CIPHER_CTX *ctx;
106unsigned char *out;
107unsigned char *in;
108unsigned int inl;
109 {
110 unsigned int i;
111
112 if (inl < 8) return;
113 inl-=8;
114 for (i=0; i<=inl; i+=8)
115 {
116 BF_ecb_encrypt(
117 &(in[i]),&(out[i]),
118 &(ctx->c.bf_ks),ctx->encrypt);
119 }
120 }
121
122#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_c.c b/src/lib/libcrypto/evp/e_ecb_c.c
new file mode 100644
index 0000000000..34e0c18296
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_c.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ecb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_ecb_init_key();
73static void cast_ecb_cipher();
74#endif
75
76static EVP_CIPHER cast5_ecb_cipher=
77 {
78 NID_cast5_ecb,
79 8,EVP_CAST5_KEY_SIZE,0,
80 cast_ecb_init_key,
81 cast_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_cast5_ecb()
90 {
91 return(&cast5_ecb_cipher);
92 }
93
94static void cast_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
102 }
103
104static void cast_ecb_cipher(ctx,out,in,inl)
105EVP_CIPHER_CTX *ctx;
106unsigned char *out;
107unsigned char *in;
108unsigned int inl;
109 {
110 unsigned int i;
111
112 if (inl < 8) return;
113 inl-=8;
114 for (i=0; i<=inl; i+=8)
115 {
116 CAST_ecb_encrypt(
117 &(in[i]),&(out[i]),
118 &(ctx->c.cast_ks),ctx->encrypt);
119 }
120 }
121
122#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_d.c b/src/lib/libcrypto/evp/e_ecb_d.c
new file mode 100644
index 0000000000..7a409d6459
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_ecb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_ecb_init_key();
71static void des_ecb_cipher();
72#endif
73
74static EVP_CIPHER d_ecb_cipher=
75 {
76 NID_des_ecb,
77 8,8,0,
78 des_ecb_init_key,
79 des_ecb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 NULL,
84 NULL,
85 };
86
87EVP_CIPHER *EVP_des_ecb()
88 {
89 return(&d_ecb_cipher);
90 }
91
92static void des_ecb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 if (key != NULL)
99 des_set_key((des_cblock *)key,ctx->c.des_ks);
100 }
101
102static void des_ecb_cipher(ctx,out,in,inl)
103EVP_CIPHER_CTX *ctx;
104unsigned char *out;
105unsigned char *in;
106unsigned int inl;
107 {
108 unsigned int i;
109
110 if (inl < 8) return;
111 inl-=8;
112 for (i=0; i<=inl; i+=8)
113 {
114 des_ecb_encrypt(
115 (des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
116 ctx->c.des_ks,ctx->encrypt);
117 }
118 }
diff --git a/src/lib/libcrypto/evp/e_ecb_i.c b/src/lib/libcrypto/evp/e_ecb_i.c
new file mode 100644
index 0000000000..e24022a12c
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_i.c
@@ -0,0 +1,133 @@
1/* crypto/evp/e_ecb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_ecb_init_key();
73static void idea_ecb_cipher();
74#endif
75
76static EVP_CIPHER i_ecb_cipher=
77 {
78 NID_idea_ecb,
79 8,16,0,
80 idea_ecb_init_key,
81 idea_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_idea_ecb()
90 {
91 return(&i_ecb_cipher);
92 }
93
94static void idea_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 {
102 if (enc)
103 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
104 else
105 {
106 IDEA_KEY_SCHEDULE tmp;
107
108 idea_set_encrypt_key(key,&tmp);
109 idea_set_decrypt_key(&tmp, &(ctx->c.idea_ks));
110 memset((unsigned char *)&tmp,0,
111 sizeof(IDEA_KEY_SCHEDULE));
112 }
113 }
114 }
115
116static void idea_ecb_cipher(ctx,out,in,inl)
117EVP_CIPHER_CTX *ctx;
118unsigned char *out;
119unsigned char *in;
120unsigned int inl;
121 {
122 unsigned int i;
123
124 if (inl < 8) return;
125 inl-=8;
126 for (i=0; i<=inl; i+=8)
127 {
128 idea_ecb_encrypt(
129 &(in[i]),&(out[i]),&(ctx->c.idea_ks));
130 }
131 }
132
133#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_r2.c b/src/lib/libcrypto/evp/e_ecb_r2.c
new file mode 100644
index 0000000000..e35b06dc6d
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_r2.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ecb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_ecb_init_key();
73static void rc2_ecb_cipher();
74#endif
75
76static EVP_CIPHER r2_ecb_cipher=
77 {
78 NID_rc2_ecb,
79 8,EVP_RC2_KEY_SIZE,0,
80 rc2_ecb_init_key,
81 rc2_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc2_ecb()
90 {
91 return(&r2_ecb_cipher);
92 }
93
94static void rc2_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
102 EVP_RC2_KEY_SIZE*8);
103 }
104
105static void rc2_ecb_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 unsigned int i;
112
113 if (inl < 8) return;
114 inl-=8;
115 for (i=0; i<=inl; i+=8)
116 {
117 RC2_ecb_encrypt(
118 &(in[i]),&(out[i]),
119 &(ctx->c.rc2_ks),ctx->encrypt);
120 }
121 }
122
123#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_r5.c b/src/lib/libcrypto/evp/e_ecb_r5.c
new file mode 100644
index 0000000000..08f4a82651
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_r5.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ecb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_ecb_init_key();
73static void rc5_32_12_16_ecb_cipher();
74#endif
75
76static EVP_CIPHER rc5_ecb_cipher=
77 {
78 NID_rc5_ecb,
79 8,EVP_RC5_32_12_16_KEY_SIZE,0,
80 rc5_32_12_16_ecb_init_key,
81 rc5_32_12_16_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_ecb()
90 {
91 return(&rc5_ecb_cipher);
92 }
93
94static void rc5_32_12_16_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
102 RC5_12_ROUNDS);
103 }
104
105static void rc5_32_12_16_ecb_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 unsigned int i;
112
113 if (inl < 8) return;
114 inl-=8;
115 for (i=0; i<=inl; i+=8)
116 {
117 RC5_32_ecb_encrypt(
118 &(in[i]),&(out[i]),
119 &(ctx->c.rc5_ks),ctx->encrypt);
120 }
121 }
122
123#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_3d.c b/src/lib/libcrypto/evp/e_ofb_3d.c
new file mode 100644
index 0000000000..c3add18e93
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_3d.c
@@ -0,0 +1,165 @@
1/* crypto/evp/e_ofb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_ofb_init_key();
73static void des_ede3_ofb_init_key();
74static void des_ede_ofb_cipher();
75#endif
76
77static EVP_CIPHER d_ede_ofb_cipher2=
78 {
79 NID_des_ede_ofb64,
80 1,16,8,
81 des_ede_ofb_init_key,
82 des_ede_ofb_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_set_asn1_iv,
87 EVP_CIPHER_get_asn1_iv,
88 };
89
90static EVP_CIPHER d_ede3_ofb_cipher3=
91 {
92 NID_des_ede3_ofb64,
93 1,24,8,
94 des_ede3_ofb_init_key,
95 des_ede_ofb_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_ofb()
104 {
105 return(&d_ede_ofb_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_ofb()
109 {
110 return(&d_ede3_ofb_cipher3);
111 }
112
113static void des_ede_ofb_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 ctx->num=0;
120
121 if (iv != NULL)
122 memcpy(&(ctx->oiv[0]),iv,8);
123 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
124 if (key != NULL)
125 {
126 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
127 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
128 memcpy( (char *)ctx->c.des_ede.ks3,
129 (char *)ctx->c.des_ede.ks1,
130 sizeof(ctx->c.des_ede.ks1));
131 }
132 }
133
134static void des_ede3_ofb_init_key(ctx,key,iv,enc)
135EVP_CIPHER_CTX *ctx;
136unsigned char *key;
137unsigned char *iv;
138int enc;
139 {
140 ctx->num=0;
141
142 if (iv != NULL)
143 memcpy(&(ctx->oiv[0]),iv,8);
144 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
145 if (key != NULL)
146 {
147 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
148 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
149 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
150 }
151 }
152
153static void des_ede_ofb_cipher(ctx,out,in,inl)
154EVP_CIPHER_CTX *ctx;
155unsigned char *out;
156unsigned char *in;
157unsigned int inl;
158 {
159 des_ede3_ofb64_encrypt(
160 in,out,
161 (long)inl,
162 ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
163 (des_cblock *)&(ctx->iv[0]),
164 &ctx->num);
165 }
diff --git a/src/lib/libcrypto/evp/e_ofb_bf.c b/src/lib/libcrypto/evp/e_ofb_bf.c
new file mode 100644
index 0000000000..492f9b9082
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_bf.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ofb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_ofb_init_key();
73static void bf_ofb_cipher();
74#endif
75
76static EVP_CIPHER bfish_ofb_cipher=
77 {
78 NID_bf_ofb64,
79 1,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_ofb_init_key,
81 bf_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_ofb()
90 {
91 return(&bfish_ofb_cipher);
92 }
93
94static void bf_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
107 }
108
109static void bf_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 BF_ofb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.bf_ks),
118 &(ctx->iv[0]),
119 &ctx->num);
120 }
121
122#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_c.c b/src/lib/libcrypto/evp/e_ofb_c.c
new file mode 100644
index 0000000000..f1eef4469c
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_c.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ofb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_ofb_init_key();
73static void cast_ofb_cipher();
74#endif
75
76static EVP_CIPHER cast5_ofb_cipher=
77 {
78 NID_cast5_ofb64,
79 1,EVP_CAST5_KEY_SIZE,8,
80 cast_ofb_init_key,
81 cast_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_ofb()
90 {
91 return(&cast5_ofb_cipher);
92 }
93
94static void cast_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
107 }
108
109static void cast_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 CAST_ofb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.cast_ks),
118 &(ctx->iv[0]),
119 &ctx->num);
120 }
121
122#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_d.c b/src/lib/libcrypto/evp/e_ofb_d.c
new file mode 100644
index 0000000000..09d4b4139d
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_ofb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_ofb_init_key();
71static void des_ofb_cipher();
72#endif
73
74static EVP_CIPHER d_ofb_cipher=
75 {
76 NID_des_ofb64,
77 1,8,8,
78 des_ofb_init_key,
79 des_ofb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_set_asn1_iv,
84 EVP_CIPHER_get_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_ofb()
88 {
89 return(&d_ofb_cipher);
90 }
91
92static void des_ofb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 ctx->num=0;
99
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 des_set_key((des_cblock *)key,ctx->c.des_ks);
105 }
106
107static void des_ofb_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 des_ofb64_encrypt(
114 in,out,
115 (long)inl, ctx->c.des_ks,
116 (des_cblock *)&(ctx->iv[0]),
117 &ctx->num);
118 }
diff --git a/src/lib/libcrypto/evp/e_ofb_i.c b/src/lib/libcrypto/evp/e_ofb_i.c
new file mode 100644
index 0000000000..96c8afd9c8
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_i.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_ofb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_ofb_init_key();
73static void idea_ofb_cipher();
74#endif
75
76static EVP_CIPHER i_ofb_cipher=
77 {
78 NID_idea_ofb64,
79 1,IDEA_KEY_LENGTH,IDEA_BLOCK,
80 idea_ofb_init_key,
81 idea_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_ofb()
90 {
91 return(&i_ofb_cipher);
92 }
93
94static void idea_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 }
108
109static void idea_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 idea_ofb64_encrypt(
116 in,out,(long)inl,
117 &(ctx->c.idea_ks),&(ctx->iv[0]),
118 &ctx->num);
119 }
120
121#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_r2.c b/src/lib/libcrypto/evp/e_ofb_r2.c
new file mode 100644
index 0000000000..0f6d729988
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_r2.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ofb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_ofb_init_key();
73static void rc2_ofb_cipher();
74#endif
75
76static EVP_CIPHER r2_ofb_cipher=
77 {
78 NID_rc2_ofb64,
79 1,EVP_RC2_KEY_SIZE,8,
80 rc2_ofb_init_key,
81 rc2_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc2_ofb()
90 {
91 return(&r2_ofb_cipher);
92 }
93
94static void rc2_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
107 EVP_RC2_KEY_SIZE*8);
108 }
109
110static void rc2_ofb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC2_ofb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc2_ks),
119 &(ctx->iv[0]),
120 &ctx->num);
121 }
122
123#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_r5.c b/src/lib/libcrypto/evp/e_ofb_r5.c
new file mode 100644
index 0000000000..db28d6c317
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_r5.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ofb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_ofb_init_key();
73static void rc5_32_12_16_ofb_cipher();
74#endif
75
76static EVP_CIPHER rc5_ofb_cipher=
77 {
78 NID_rc5_ofb64,
79 1,EVP_RC5_32_12_16_KEY_SIZE,8,
80 rc5_32_12_16_ofb_init_key,
81 rc5_32_12_16_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_ofb()
90 {
91 return(&rc5_ofb_cipher);
92 }
93
94static void rc5_32_12_16_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
107 RC5_12_ROUNDS);
108 }
109
110static void rc5_32_12_16_ofb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC5_32_ofb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc5_ks),
119 &(ctx->iv[0]),
120 &ctx->num);
121 }
122
123#endif
diff --git a/src/lib/libcrypto/evp/evp.err b/src/lib/libcrypto/evp/evp.err
new file mode 100644
index 0000000000..cfc17437bc
--- /dev/null
+++ b/src/lib/libcrypto/evp/evp.err
@@ -0,0 +1,24 @@
1/* Error codes for the EVP functions. */
2
3/* Function codes. */
4#define EVP_F_D2I_PKEY 100
5#define EVP_F_EVP_DECRYPTFINAL 101
6#define EVP_F_EVP_OPENINIT 102
7#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
8#define EVP_F_EVP_PKEY_DECRYPT 104
9#define EVP_F_EVP_PKEY_ENCRYPT 105
10#define EVP_F_EVP_PKEY_NEW 106
11#define EVP_F_EVP_SIGNFINAL 107
12#define EVP_F_EVP_VERIFYFINAL 108
13
14/* Reason codes. */
15#define EVP_R_BAD_DECRYPT 100
16#define EVP_R_DIFFERENT_KEY_TYPES 101
17#define EVP_R_IV_TOO_LARGE 102
18#define EVP_R_MISSING_PARMATERS 103
19#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
20#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
21#define EVP_R_PUBLIC_KEY_NOT_RSA 106
22#define EVP_R_UNSUPPORTED_CIPHER 107
23#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 108
24#define EVP_R_WRONG_PUBLIC_KEY_TYPE 109
diff --git a/src/lib/libcrypto/evp/pk_lib.c b/src/lib/libcrypto/evp/pk_lib.c
new file mode 100644
index 0000000000..08f9fabbae
--- /dev/null
+++ b/src/lib/libcrypto/evp/pk_lib.c
@@ -0,0 +1,82 @@
1/* crypto/evp/pk_lib.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64static LHASH *pk_md=NULL;
65
66static LHASH *pk_md=NULL;
67
68int EVP_add_pkey_md(oid,pkm,md)
69int oid;
70EVP_PKEY_METHOD *pkm;
71EVP_MD *md;
72 {
73 }
74
75EVP_add_pkey(pkm)
76EVP_PKEY_METHOD *pkm;
77 {
78 }
79
80EVP_PKEY_METHOD:q
81
82