summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/idea
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2016-07-23 19:31:36 +0000
committercvs2svn <admin@example.com>2016-07-23 19:31:36 +0000
commit86c49b31af735796dfde37aa29473a30d36367db (patch)
treee9a354a92a348338fe2b361e2eda703cae23cfab /src/lib/libcrypto/idea
parent19d5fe348e8926bac4521c5807aa64c45b8f7a41 (diff)
downloadopenbsd-OPENBSD_6_0_BASE.tar.gz
openbsd-OPENBSD_6_0_BASE.tar.bz2
openbsd-OPENBSD_6_0_BASE.zip
This commit was manufactured by cvs2git to create tag 'OPENBSD_6_0_BASE'.OPENBSD_6_0_BASE
Diffstat (limited to 'src/lib/libcrypto/idea')
-rw-r--r--src/lib/libcrypto/idea/i_cbc.c168
-rw-r--r--src/lib/libcrypto/idea/i_cfb64.c122
-rw-r--r--src/lib/libcrypto/idea/i_ecb.c83
-rw-r--r--src/lib/libcrypto/idea/i_ofb64.c111
-rw-r--r--src/lib/libcrypto/idea/i_skey.c157
-rw-r--r--src/lib/libcrypto/idea/idea.h100
-rw-r--r--src/lib/libcrypto/idea/idea_lcl.h150
7 files changed, 0 insertions, 891 deletions
diff --git a/src/lib/libcrypto/idea/i_cbc.c b/src/lib/libcrypto/idea/i_cbc.c
deleted file mode 100644
index 5bb9640c34..0000000000
--- a/src/lib/libcrypto/idea/i_cbc.c
+++ /dev/null
@@ -1,168 +0,0 @@
1/* $OpenBSD: i_cbc.c,v 1.3 2014/10/28 07:35:58 jsg Exp $ */
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 <openssl/idea.h>
60#include "idea_lcl.h"
61
62void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
63 IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int encrypt)
64 {
65 unsigned long tin0,tin1;
66 unsigned long tout0,tout1,xor0,xor1;
67 long l=length;
68 unsigned long tin[2];
69
70 if (encrypt)
71 {
72 n2l(iv,tout0);
73 n2l(iv,tout1);
74 iv-=8;
75 for (l-=8; l>=0; l-=8)
76 {
77 n2l(in,tin0);
78 n2l(in,tin1);
79 tin0^=tout0;
80 tin1^=tout1;
81 tin[0]=tin0;
82 tin[1]=tin1;
83 idea_encrypt(tin,ks);
84 tout0=tin[0]; l2n(tout0,out);
85 tout1=tin[1]; l2n(tout1,out);
86 }
87 if (l != -8)
88 {
89 n2ln(in,tin0,tin1,l+8);
90 tin0^=tout0;
91 tin1^=tout1;
92 tin[0]=tin0;
93 tin[1]=tin1;
94 idea_encrypt(tin,ks);
95 tout0=tin[0]; l2n(tout0,out);
96 tout1=tin[1]; l2n(tout1,out);
97 }
98 l2n(tout0,iv);
99 l2n(tout1,iv);
100 }
101 else
102 {
103 n2l(iv,xor0);
104 n2l(iv,xor1);
105 iv-=8;
106 for (l-=8; l>=0; l-=8)
107 {
108 n2l(in,tin0); tin[0]=tin0;
109 n2l(in,tin1); tin[1]=tin1;
110 idea_encrypt(tin,ks);
111 tout0=tin[0]^xor0;
112 tout1=tin[1]^xor1;
113 l2n(tout0,out);
114 l2n(tout1,out);
115 xor0=tin0;
116 xor1=tin1;
117 }
118 if (l != -8)
119 {
120 n2l(in,tin0); tin[0]=tin0;
121 n2l(in,tin1); tin[1]=tin1;
122 idea_encrypt(tin,ks);
123 tout0=tin[0]^xor0;
124 tout1=tin[1]^xor1;
125 l2nn(tout0,tout1,out,l+8);
126 xor0=tin0;
127 xor1=tin1;
128 }
129 l2n(xor0,iv);
130 l2n(xor1,iv);
131 }
132 tin0=tin1=tout0=tout1=xor0=xor1=0;
133 tin[0]=tin[1]=0;
134 }
135
136void idea_encrypt(unsigned long *d, IDEA_KEY_SCHEDULE *key)
137 {
138 IDEA_INT *p;
139 unsigned long x1,x2,x3,x4,t0,t1,ul;
140
141 x2=d[0];
142 x1=(x2>>16);
143 x4=d[1];
144 x3=(x4>>16);
145
146 p= &(key->data[0][0]);
147
148 E_IDEA(0);
149 E_IDEA(1);
150 E_IDEA(2);
151 E_IDEA(3);
152 E_IDEA(4);
153 E_IDEA(5);
154 E_IDEA(6);
155 E_IDEA(7);
156
157 x1&=0xffff;
158 idea_mul(x1,x1,*p,ul); p++;
159
160 t0= x3+ *(p++);
161 t1= x2+ *(p++);
162
163 x4&=0xffff;
164 idea_mul(x4,x4,*p,ul);
165
166 d[0]=(t0&0xffff)|((x1&0xffff)<<16);
167 d[1]=(x4&0xffff)|((t1&0xffff)<<16);
168 }
diff --git a/src/lib/libcrypto/idea/i_cfb64.c b/src/lib/libcrypto/idea/i_cfb64.c
deleted file mode 100644
index b979aaef86..0000000000
--- a/src/lib/libcrypto/idea/i_cfb64.c
+++ /dev/null
@@ -1,122 +0,0 @@
1/* $OpenBSD: i_cfb64.c,v 1.3 2014/10/28 07:35:58 jsg Exp $ */
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 <openssl/idea.h>
60#include "idea_lcl.h"
61
62/* The input and output encrypted as though 64bit cfb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66
67void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,
68 long length, IDEA_KEY_SCHEDULE *schedule,
69 unsigned char *ivec, int *num, int encrypt)
70 {
71 unsigned long v0,v1,t;
72 int n= *num;
73 long l=length;
74 unsigned long ti[2];
75 unsigned char *iv,c,cc;
76
77 iv=(unsigned char *)ivec;
78 if (encrypt)
79 {
80 while (l--)
81 {
82 if (n == 0)
83 {
84 n2l(iv,v0); ti[0]=v0;
85 n2l(iv,v1); ti[1]=v1;
86 idea_encrypt((unsigned long *)ti,schedule);
87 iv=(unsigned char *)ivec;
88 t=ti[0]; l2n(t,iv);
89 t=ti[1]; l2n(t,iv);
90 iv=(unsigned char *)ivec;
91 }
92 c= *(in++)^iv[n];
93 *(out++)=c;
94 iv[n]=c;
95 n=(n+1)&0x07;
96 }
97 }
98 else
99 {
100 while (l--)
101 {
102 if (n == 0)
103 {
104 n2l(iv,v0); ti[0]=v0;
105 n2l(iv,v1); ti[1]=v1;
106 idea_encrypt((unsigned long *)ti,schedule);
107 iv=(unsigned char *)ivec;
108 t=ti[0]; l2n(t,iv);
109 t=ti[1]; l2n(t,iv);
110 iv=(unsigned char *)ivec;
111 }
112 cc= *(in++);
113 c=iv[n];
114 iv[n]=cc;
115 *(out++)=c^cc;
116 n=(n+1)&0x07;
117 }
118 }
119 v0=v1=ti[0]=ti[1]=t=c=cc=0;
120 *num=n;
121 }
122
diff --git a/src/lib/libcrypto/idea/i_ecb.c b/src/lib/libcrypto/idea/i_ecb.c
deleted file mode 100644
index dac456cdc5..0000000000
--- a/src/lib/libcrypto/idea/i_ecb.c
+++ /dev/null
@@ -1,83 +0,0 @@
1/* $OpenBSD: i_ecb.c,v 1.3 2014/07/09 11:10:51 bcook Exp $ */
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 <openssl/idea.h>
60#include "idea_lcl.h"
61#include <openssl/opensslv.h>
62
63const char *idea_options(void)
64 {
65 if (sizeof(short) != sizeof(IDEA_INT))
66 return("idea(int)");
67 else
68 return("idea(short)");
69 }
70
71void idea_ecb_encrypt(const unsigned char *in, unsigned char *out,
72 IDEA_KEY_SCHEDULE *ks)
73 {
74 unsigned long l0,l1,d[2];
75
76 n2l(in,l0); d[0]=l0;
77 n2l(in,l1); d[1]=l1;
78 idea_encrypt(d,ks);
79 l0=d[0]; l2n(l0,out);
80 l1=d[1]; l2n(l1,out);
81 l0=l1=d[0]=d[1]=0;
82 }
83
diff --git a/src/lib/libcrypto/idea/i_ofb64.c b/src/lib/libcrypto/idea/i_ofb64.c
deleted file mode 100644
index 376dad9f6d..0000000000
--- a/src/lib/libcrypto/idea/i_ofb64.c
+++ /dev/null
@@ -1,111 +0,0 @@
1/* $OpenBSD: i_ofb64.c,v 1.3 2014/10/28 07:35:58 jsg Exp $ */
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 <openssl/idea.h>
60#include "idea_lcl.h"
61
62/* The input and output encrypted as though 64bit ofb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,
67 long length, IDEA_KEY_SCHEDULE *schedule,
68 unsigned char *ivec, int *num)
69 {
70 unsigned long v0,v1,t;
71 int n= *num;
72 long l=length;
73 unsigned char d[8];
74 char *dp;
75 unsigned long ti[2];
76 unsigned char *iv;
77 int save=0;
78
79 iv=(unsigned char *)ivec;
80 n2l(iv,v0);
81 n2l(iv,v1);
82 ti[0]=v0;
83 ti[1]=v1;
84 dp=(char *)d;
85 l2n(v0,dp);
86 l2n(v1,dp);
87 while (l--)
88 {
89 if (n == 0)
90 {
91 idea_encrypt((unsigned long *)ti,schedule);
92 dp=(char *)d;
93 t=ti[0]; l2n(t,dp);
94 t=ti[1]; l2n(t,dp);
95 save++;
96 }
97 *(out++)= *(in++)^d[n];
98 n=(n+1)&0x07;
99 }
100 if (save)
101 {
102 v0=ti[0];
103 v1=ti[1];
104 iv=(unsigned char *)ivec;
105 l2n(v0,iv);
106 l2n(v1,iv);
107 }
108 t=v0=v1=ti[0]=ti[1]=0;
109 *num=n;
110 }
111
diff --git a/src/lib/libcrypto/idea/i_skey.c b/src/lib/libcrypto/idea/i_skey.c
deleted file mode 100644
index 2824d2618e..0000000000
--- a/src/lib/libcrypto/idea/i_skey.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/* $OpenBSD: i_skey.c,v 1.4 2014/10/28 07:35:58 jsg Exp $ */
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 <openssl/crypto.h>
60#include <openssl/idea.h>
61#include "idea_lcl.h"
62
63static IDEA_INT inverse(unsigned int xin);
64void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks)
65 {
66 int i;
67 IDEA_INT *kt,*kf,r0,r1,r2;
68
69 kt= &(ks->data[0][0]);
70 n2s(key,kt[0]); n2s(key,kt[1]); n2s(key,kt[2]); n2s(key,kt[3]);
71 n2s(key,kt[4]); n2s(key,kt[5]); n2s(key,kt[6]); n2s(key,kt[7]);
72
73 kf=kt;
74 kt+=8;
75 for (i=0; i<6; i++)
76 {
77 r2= kf[1];
78 r1= kf[2];
79 *(kt++)= ((r2<<9) | (r1>>7))&0xffff;
80 r0= kf[3];
81 *(kt++)= ((r1<<9) | (r0>>7))&0xffff;
82 r1= kf[4];
83 *(kt++)= ((r0<<9) | (r1>>7))&0xffff;
84 r0= kf[5];
85 *(kt++)= ((r1<<9) | (r0>>7))&0xffff;
86 r1= kf[6];
87 *(kt++)= ((r0<<9) | (r1>>7))&0xffff;
88 r0= kf[7];
89 *(kt++)= ((r1<<9) | (r0>>7))&0xffff;
90 r1= kf[0];
91 if (i >= 5) break;
92 *(kt++)= ((r0<<9) | (r1>>7))&0xffff;
93 *(kt++)= ((r1<<9) | (r2>>7))&0xffff;
94 kf+=8;
95 }
96 }
97
98void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk)
99 {
100 int r;
101 IDEA_INT *fp,*tp,t;
102
103 tp= &(dk->data[0][0]);
104 fp= &(ek->data[8][0]);
105 for (r=0; r<9; r++)
106 {
107 *(tp++)=inverse(fp[0]);
108 *(tp++)=((int)(0x10000L-fp[2])&0xffff);
109 *(tp++)=((int)(0x10000L-fp[1])&0xffff);
110 *(tp++)=inverse(fp[3]);
111 if (r == 8) break;
112 fp-=6;
113 *(tp++)=fp[4];
114 *(tp++)=fp[5];
115 }
116
117 tp= &(dk->data[0][0]);
118 t=tp[1];
119 tp[1]=tp[2];
120 tp[2]=t;
121
122 t=tp[49];
123 tp[49]=tp[50];
124 tp[50]=t;
125 }
126
127/* taken directly from the 'paper' I'll have a look at it later */
128static IDEA_INT inverse(unsigned int xin)
129 {
130 long n1,n2,q,r,b1,b2,t;
131
132 if (xin == 0)
133 b2=0;
134 else
135 {
136 n1=0x10001;
137 n2=xin;
138 b2=1;
139 b1=0;
140
141 do {
142 r=(n1%n2);
143 q=(n1-r)/n2;
144 if (r == 0)
145 { if (b2 < 0) b2=0x10001+b2; }
146 else
147 {
148 n1=n2;
149 n2=r;
150 t=b2;
151 b2=b1-q*b2;
152 b1=t;
153 }
154 } while (r != 0);
155 }
156 return((IDEA_INT)b2);
157 }
diff --git a/src/lib/libcrypto/idea/idea.h b/src/lib/libcrypto/idea/idea.h
deleted file mode 100644
index f76bcaeba5..0000000000
--- a/src/lib/libcrypto/idea/idea.h
+++ /dev/null
@@ -1,100 +0,0 @@
1/* $OpenBSD: idea.h,v 1.10 2014/06/12 15:49:29 deraadt Exp $ */
2/* Copyright (C) 1995-1997 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 HEADER_IDEA_H
60#define HEADER_IDEA_H
61
62#include <openssl/opensslconf.h> /* IDEA_INT, OPENSSL_NO_IDEA */
63
64#ifdef OPENSSL_NO_IDEA
65#error IDEA is disabled.
66#endif
67
68#define IDEA_ENCRYPT 1
69#define IDEA_DECRYPT 0
70
71#define IDEA_BLOCK 8
72#define IDEA_KEY_LENGTH 16
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78typedef struct idea_key_st
79 {
80 IDEA_INT data[9][6];
81 } IDEA_KEY_SCHEDULE;
82
83const char *idea_options(void);
84void idea_ecb_encrypt(const unsigned char *in, unsigned char *out,
85 IDEA_KEY_SCHEDULE *ks);
86void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
87void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
88void idea_cbc_encrypt(const unsigned char *in, unsigned char *out,
89 long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc);
90void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,
91 long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
92 int *num,int enc);
93void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,
94 long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num);
95void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);
96#ifdef __cplusplus
97}
98#endif
99
100#endif
diff --git a/src/lib/libcrypto/idea/idea_lcl.h b/src/lib/libcrypto/idea/idea_lcl.h
deleted file mode 100644
index e46c960875..0000000000
--- a/src/lib/libcrypto/idea/idea_lcl.h
+++ /dev/null
@@ -1,150 +0,0 @@
1/* $OpenBSD: idea_lcl.h,v 1.3 2015/02/07 13:19:15 doug Exp $ */
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/* The new form of this macro (check if the a*b == 0) was suggested by
60 * Colin Plumb <colin@nyx10.cs.du.edu> */
61/* Removal of the inner if from from Wei Dai 24/4/96 */
62#define idea_mul(r,a,b,ul) \
63ul=(unsigned long)a*b; \
64if (ul != 0) \
65 { \
66 r=(ul&0xffff)-(ul>>16); \
67 r-=((r)>>16); \
68 } \
69else \
70 r=(-(int)a-b+1); /* assuming a or b is 0 and in range */
71
72/* 7/12/95 - Many thanks to Rhys Weatherley <rweather@us.oracle.com>
73 * for pointing out that I was assuming little endian
74 * byte order for all quantities what idea
75 * actually used bigendian. No where in the spec does it mention
76 * this, it is all in terms of 16 bit numbers and even the example
77 * does not use byte streams for the input example :-(.
78 * If you byte swap each pair of input, keys and iv, the functions
79 * would produce the output as the old version :-(.
80 */
81
82/* NOTE - c is not incremented as per n2l */
83#define n2ln(c,l1,l2,n) { \
84 c+=n; \
85 l1=l2=0; \
86 switch (n) { \
87 case 8: l2 =((unsigned long)(*(--(c)))) ; \
88 case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
89 case 6: l2|=((unsigned long)(*(--(c))))<<16; \
90 case 5: l2|=((unsigned long)(*(--(c))))<<24; \
91 case 4: l1 =((unsigned long)(*(--(c)))) ; \
92 case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
93 case 2: l1|=((unsigned long)(*(--(c))))<<16; \
94 case 1: l1|=((unsigned long)(*(--(c))))<<24; \
95 } \
96 }
97
98/* NOTE - c is not incremented as per l2n */
99#define l2nn(l1,l2,c,n) { \
100 c+=n; \
101 switch (n) { \
102 case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
103 case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
104 case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
105 case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
106 case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
107 case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
108 case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
109 case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
110 } \
111 }
112
113#undef n2l
114#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
115 l|=((unsigned long)(*((c)++)))<<16L, \
116 l|=((unsigned long)(*((c)++)))<< 8L, \
117 l|=((unsigned long)(*((c)++))))
118
119#undef l2n
120#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
121 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
122 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
123 *((c)++)=(unsigned char)(((l) )&0xff))
124
125#undef s2n
126#define s2n(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
127 *((c)++)=(unsigned char)(((l)>> 8L)&0xff))
128
129#undef n2s
130#define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \
131 l|=((IDEA_INT)(*((c)++))) )
132
133#define E_IDEA(num) \
134 x1&=0xffff; \
135 idea_mul(x1,x1,*p,ul); p++; \
136 x2+= *(p++); \
137 x3+= *(p++); \
138 x4&=0xffff; \
139 idea_mul(x4,x4,*p,ul); p++; \
140 t0=(x1^x3)&0xffff; \
141 idea_mul(t0,t0,*p,ul); p++; \
142 t1=(t0+(x2^x4))&0xffff; \
143 idea_mul(t1,t1,*p,ul); p++; \
144 t0+=t1; \
145 x1^=t1; \
146 x4^=t0; \
147 ul=x2^t0; /* do the swap to x3 */ \
148 x2=x3^t1; \
149 x3=ul;
150