diff options
author | beck <> | 2023-07-07 12:51:58 +0000 |
---|---|---|
committer | beck <> | 2023-07-07 12:51:58 +0000 |
commit | a9cdc101468391df513beb27c13bf27170418093 (patch) | |
tree | 4959b4936ded67fb6b286e463fbc27eee245ce20 /src | |
parent | 5c0527aa790cba96ac1060e17d6a3909694d8e4e (diff) | |
download | openbsd-a9cdc101468391df513beb27c13bf27170418093.tar.gz openbsd-a9cdc101468391df513beb27c13bf27170418093.tar.bz2 openbsd-a9cdc101468391df513beb27c13bf27170418093.zip |
Hit idea with the loving mallet of knfmt
ok knfmt
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/idea/i_cbc.c | 186 | ||||
-rw-r--r-- | src/lib/libcrypto/idea/i_cfb64.c | 113 | ||||
-rw-r--r-- | src/lib/libcrypto/idea/i_ecb.c | 53 | ||||
-rw-r--r-- | src/lib/libcrypto/idea/i_ofb64.c | 89 | ||||
-rw-r--r-- | src/lib/libcrypto/idea/i_skey.c | 182 | ||||
-rw-r--r-- | src/lib/libcrypto/idea/idea.h | 29 | ||||
-rw-r--r-- | src/lib/libcrypto/idea/idea_local.h | 127 |
7 files changed, 399 insertions, 380 deletions
diff --git a/src/lib/libcrypto/idea/i_cbc.c b/src/lib/libcrypto/idea/i_cbc.c index e382a0a69e..a9de41d647 100644 --- a/src/lib/libcrypto/idea/i_cbc.c +++ b/src/lib/libcrypto/idea/i_cbc.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: i_cbc.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ | 1 | /* $OpenBSD: i_cbc.c,v 1.5 2023/07/07 12:51:58 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 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 | 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 | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 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. | 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 | 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. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 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: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 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 | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 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 | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -59,91 +59,96 @@ | |||
59 | #include <openssl/idea.h> | 59 | #include <openssl/idea.h> |
60 | #include "idea_local.h" | 60 | #include "idea_local.h" |
61 | 61 | ||
62 | void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, | 62 | void |
63 | IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int encrypt) | 63 | idea_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, |
64 | { | 64 | IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int encrypt) |
65 | unsigned long tin0,tin1; | 65 | { |
66 | unsigned long tout0,tout1,xor0,xor1; | 66 | unsigned long tin0, tin1; |
67 | long l=length; | 67 | unsigned long tout0, tout1, xor0, xor1; |
68 | long l = length; | ||
68 | unsigned long tin[2]; | 69 | unsigned long tin[2]; |
69 | 70 | ||
70 | if (encrypt) | 71 | if (encrypt) { |
72 | n2l(iv, tout0); | ||
73 | n2l(iv, tout1); | ||
74 | iv -= 8; | ||
75 | for (l -= 8; l >= 0; l -= 8) | ||
71 | { | 76 | { |
72 | n2l(iv,tout0); | 77 | n2l(in, tin0); |
73 | n2l(iv,tout1); | 78 | n2l(in, tin1); |
74 | iv-=8; | 79 | tin0 ^= tout0; |
75 | for (l-=8; l>=0; l-=8) | 80 | tin1 ^= tout1; |
76 | { | 81 | tin[0] = tin0; |
77 | n2l(in,tin0); | 82 | tin[1] = tin1; |
78 | n2l(in,tin1); | 83 | idea_encrypt(tin, ks); |
79 | tin0^=tout0; | 84 | tout0 = tin[0]; |
80 | tin1^=tout1; | 85 | l2n(tout0, out); |
81 | tin[0]=tin0; | 86 | tout1 = tin[1]; |
82 | tin[1]=tin1; | 87 | l2n(tout1, out); |
83 | idea_encrypt(tin,ks); | 88 | } |
84 | tout0=tin[0]; l2n(tout0,out); | 89 | if (l != -8) { |
85 | tout1=tin[1]; l2n(tout1,out); | 90 | n2ln(in, tin0, tin1, l + 8); |
86 | } | 91 | tin0 ^= tout0; |
87 | if (l != -8) | 92 | tin1 ^= tout1; |
88 | { | 93 | tin[0] = tin0; |
89 | n2ln(in,tin0,tin1,l+8); | 94 | tin[1] = tin1; |
90 | tin0^=tout0; | 95 | idea_encrypt(tin, ks); |
91 | tin1^=tout1; | 96 | tout0 = tin[0]; |
92 | tin[0]=tin0; | 97 | l2n(tout0, out); |
93 | tin[1]=tin1; | 98 | tout1 = tin[1]; |
94 | idea_encrypt(tin,ks); | 99 | l2n(tout1, out); |
95 | tout0=tin[0]; l2n(tout0,out); | ||
96 | tout1=tin[1]; l2n(tout1,out); | ||
97 | } | ||
98 | l2n(tout0,iv); | ||
99 | l2n(tout1,iv); | ||
100 | } | 100 | } |
101 | else | 101 | l2n(tout0, iv); |
102 | l2n(tout1, iv); | ||
103 | } else { | ||
104 | n2l(iv, xor0); | ||
105 | n2l(iv, xor1); | ||
106 | iv -= 8; | ||
107 | for (l -= 8; l >= 0; l -= 8) | ||
102 | { | 108 | { |
103 | n2l(iv,xor0); | 109 | n2l(in, tin0); |
104 | n2l(iv,xor1); | 110 | tin[0] = tin0; |
105 | iv-=8; | 111 | n2l(in, tin1); |
106 | for (l-=8; l>=0; l-=8) | 112 | tin[1] = tin1; |
107 | { | 113 | idea_encrypt(tin, ks); |
108 | n2l(in,tin0); tin[0]=tin0; | 114 | tout0 = tin[0] ^ xor0; |
109 | n2l(in,tin1); tin[1]=tin1; | 115 | tout1 = tin[1] ^ xor1; |
110 | idea_encrypt(tin,ks); | 116 | l2n(tout0, out); |
111 | tout0=tin[0]^xor0; | 117 | l2n(tout1, out); |
112 | tout1=tin[1]^xor1; | 118 | xor0 = tin0; |
113 | l2n(tout0,out); | 119 | xor1 = tin1; |
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 | } | 120 | } |
132 | tin0=tin1=tout0=tout1=xor0=xor1=0; | 121 | if (l != -8) { |
133 | tin[0]=tin[1]=0; | 122 | n2l(in, tin0); |
123 | tin[0] = tin0; | ||
124 | n2l(in, tin1); | ||
125 | tin[1] = tin1; | ||
126 | idea_encrypt(tin, ks); | ||
127 | tout0 = tin[0] ^ xor0; | ||
128 | tout1 = tin[1] ^ xor1; | ||
129 | l2nn(tout0, tout1, out, l + 8); | ||
130 | xor0 = tin0; | ||
131 | xor1 = tin1; | ||
132 | } | ||
133 | l2n(xor0, iv); | ||
134 | l2n(xor1, iv); | ||
134 | } | 135 | } |
136 | tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; | ||
137 | tin[0] = tin[1] = 0; | ||
138 | } | ||
135 | 139 | ||
136 | void idea_encrypt(unsigned long *d, IDEA_KEY_SCHEDULE *key) | 140 | void |
137 | { | 141 | idea_encrypt(unsigned long *d, IDEA_KEY_SCHEDULE *key) |
142 | { | ||
138 | IDEA_INT *p; | 143 | IDEA_INT *p; |
139 | unsigned long x1,x2,x3,x4,t0,t1,ul; | 144 | unsigned long x1, x2, x3, x4, t0, t1, ul; |
140 | 145 | ||
141 | x2=d[0]; | 146 | x2 = d[0]; |
142 | x1=(x2>>16); | 147 | x1 = (x2 >> 16); |
143 | x4=d[1]; | 148 | x4 = d[1]; |
144 | x3=(x4>>16); | 149 | x3 = (x4 >> 16); |
145 | 150 | ||
146 | p= &(key->data[0][0]); | 151 | p = &(key->data[0][0]); |
147 | 152 | ||
148 | E_IDEA(0); | 153 | E_IDEA(0); |
149 | E_IDEA(1); | 154 | E_IDEA(1); |
@@ -154,15 +159,16 @@ void idea_encrypt(unsigned long *d, IDEA_KEY_SCHEDULE *key) | |||
154 | E_IDEA(6); | 159 | E_IDEA(6); |
155 | E_IDEA(7); | 160 | E_IDEA(7); |
156 | 161 | ||
157 | x1&=0xffff; | 162 | x1 &= 0xffff; |
158 | idea_mul(x1,x1,*p,ul); p++; | 163 | idea_mul(x1, x1, *p, ul); |
164 | p++; | ||
159 | 165 | ||
160 | t0= x3+ *(p++); | 166 | t0 = x3 + *(p++); |
161 | t1= x2+ *(p++); | 167 | t1 = x2 + *(p++); |
162 | 168 | ||
163 | x4&=0xffff; | 169 | x4 &= 0xffff; |
164 | idea_mul(x4,x4,*p,ul); | 170 | idea_mul(x4, x4, *p, ul); |
165 | 171 | ||
166 | d[0]=(t0&0xffff)|((x1&0xffff)<<16); | 172 | d[0] = (t0 & 0xffff)|((x1 & 0xffff) << 16); |
167 | d[1]=(x4&0xffff)|((t1&0xffff)<<16); | 173 | d[1] = (x4 & 0xffff)|((t1 & 0xffff) << 16); |
168 | } | 174 | } |
diff --git a/src/lib/libcrypto/idea/i_cfb64.c b/src/lib/libcrypto/idea/i_cfb64.c index d6b641197a..f284684502 100644 --- a/src/lib/libcrypto/idea/i_cfb64.c +++ b/src/lib/libcrypto/idea/i_cfb64.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: i_cfb64.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ | 1 | /* $OpenBSD: i_cfb64.c,v 1.5 2023/07/07 12:51:58 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 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 | 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 | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 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. | 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 | 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. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 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: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 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 | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 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 | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -64,59 +64,60 @@ | |||
64 | * 64bit block we have used is contained in *num; | 64 | * 64bit block we have used is contained in *num; |
65 | */ | 65 | */ |
66 | 66 | ||
67 | void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, | 67 | void |
68 | long length, IDEA_KEY_SCHEDULE *schedule, | 68 | idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, |
69 | unsigned char *ivec, int *num, int encrypt) | 69 | long length, IDEA_KEY_SCHEDULE *schedule, |
70 | { | 70 | unsigned char *ivec, int *num, int encrypt) |
71 | unsigned long v0,v1,t; | 71 | { |
72 | int n= *num; | 72 | unsigned long v0, v1, t; |
73 | long l=length; | 73 | int n = *num; |
74 | long l = length; | ||
74 | unsigned long ti[2]; | 75 | unsigned long ti[2]; |
75 | unsigned char *iv,c,cc; | 76 | unsigned char *iv, c, cc; |
76 | 77 | ||
77 | iv=(unsigned char *)ivec; | 78 | iv = (unsigned char *)ivec; |
78 | if (encrypt) | 79 | if (encrypt) { |
79 | { | 80 | while (l--) { |
80 | while (l--) | 81 | if (n == 0) { |
81 | { | 82 | n2l(iv, v0); |
82 | if (n == 0) | 83 | ti[0] = v0; |
83 | { | 84 | n2l(iv, v1); |
84 | n2l(iv,v0); ti[0]=v0; | 85 | ti[1] = v1; |
85 | n2l(iv,v1); ti[1]=v1; | 86 | idea_encrypt((unsigned long *)ti, schedule); |
86 | idea_encrypt((unsigned long *)ti,schedule); | 87 | iv = (unsigned char *)ivec; |
87 | iv=(unsigned char *)ivec; | 88 | t = ti[0]; |
88 | t=ti[0]; l2n(t,iv); | 89 | l2n(t, iv); |
89 | t=ti[1]; l2n(t,iv); | 90 | t = ti[1]; |
90 | iv=(unsigned char *)ivec; | 91 | l2n(t, iv); |
91 | } | 92 | iv = (unsigned char *)ivec; |
92 | c= *(in++)^iv[n]; | ||
93 | *(out++)=c; | ||
94 | iv[n]=c; | ||
95 | n=(n+1)&0x07; | ||
96 | } | 93 | } |
94 | c = *(in++) ^ iv[n]; | ||
95 | *(out++) = c; | ||
96 | iv[n] = c; | ||
97 | n = (n + 1) & 0x07; | ||
97 | } | 98 | } |
98 | else | 99 | } else { |
99 | { | 100 | while (l--) { |
100 | while (l--) | 101 | if (n == 0) { |
101 | { | 102 | n2l(iv, v0); |
102 | if (n == 0) | 103 | ti[0] = v0; |
103 | { | 104 | n2l(iv, v1); |
104 | n2l(iv,v0); ti[0]=v0; | 105 | ti[1] = v1; |
105 | n2l(iv,v1); ti[1]=v1; | 106 | idea_encrypt((unsigned long *)ti, schedule); |
106 | idea_encrypt((unsigned long *)ti,schedule); | 107 | iv = (unsigned char *)ivec; |
107 | iv=(unsigned char *)ivec; | 108 | t = ti[0]; |
108 | t=ti[0]; l2n(t,iv); | 109 | l2n(t, iv); |
109 | t=ti[1]; l2n(t,iv); | 110 | t = ti[1]; |
110 | iv=(unsigned char *)ivec; | 111 | l2n(t, iv); |
111 | } | 112 | iv = (unsigned char *)ivec; |
112 | cc= *(in++); | ||
113 | c=iv[n]; | ||
114 | iv[n]=cc; | ||
115 | *(out++)=c^cc; | ||
116 | n=(n+1)&0x07; | ||
117 | } | 113 | } |
114 | cc = *(in++); | ||
115 | c = iv[n]; | ||
116 | iv[n] = cc; | ||
117 | *(out++) = c ^ cc; | ||
118 | n = (n + 1) & 0x07; | ||
118 | } | 119 | } |
119 | v0=v1=ti[0]=ti[1]=t=c=cc=0; | ||
120 | *num=n; | ||
121 | } | 120 | } |
122 | 121 | v0 = v1 = ti[0] = ti[1] = t = c = cc = 0; | |
122 | *num = n; | ||
123 | } | ||
diff --git a/src/lib/libcrypto/idea/i_ecb.c b/src/lib/libcrypto/idea/i_ecb.c index 6fada765cd..ce67edba66 100644 --- a/src/lib/libcrypto/idea/i_ecb.c +++ b/src/lib/libcrypto/idea/i_ecb.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: i_ecb.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ | 1 | /* $OpenBSD: i_ecb.c,v 1.5 2023/07/07 12:51:58 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 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 | 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 | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 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. | 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 | 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. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 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: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 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 | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 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 | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -60,24 +60,29 @@ | |||
60 | #include "idea_local.h" | 60 | #include "idea_local.h" |
61 | #include <openssl/opensslv.h> | 61 | #include <openssl/opensslv.h> |
62 | 62 | ||
63 | const char *idea_options(void) | 63 | const char * |
64 | { | 64 | idea_options(void) |
65 | { | ||
65 | if (sizeof(short) != sizeof(IDEA_INT)) | 66 | if (sizeof(short) != sizeof(IDEA_INT)) |
66 | return("idea(int)"); | 67 | return ("idea(int)"); |
67 | else | 68 | else |
68 | return("idea(short)"); | 69 | return ("idea(short)"); |
69 | } | 70 | } |
70 | |||
71 | void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, | ||
72 | IDEA_KEY_SCHEDULE *ks) | ||
73 | { | ||
74 | unsigned long l0,l1,d[2]; | ||
75 | 71 | ||
76 | n2l(in,l0); d[0]=l0; | 72 | void |
77 | n2l(in,l1); d[1]=l1; | 73 | idea_ecb_encrypt(const unsigned char *in, unsigned char *out, |
78 | idea_encrypt(d,ks); | 74 | IDEA_KEY_SCHEDULE *ks) |
79 | l0=d[0]; l2n(l0,out); | 75 | { |
80 | l1=d[1]; l2n(l1,out); | 76 | unsigned long l0, l1, d[2]; |
81 | l0=l1=d[0]=d[1]=0; | ||
82 | } | ||
83 | 77 | ||
78 | n2l(in, l0); | ||
79 | d[0] = l0; | ||
80 | n2l(in, l1); | ||
81 | d[1] = l1; | ||
82 | idea_encrypt(d, ks); | ||
83 | l0 = d[0]; | ||
84 | l2n(l0, out); | ||
85 | l1 = d[1]; | ||
86 | l2n(l1, out); | ||
87 | l0 = l1 = d[0] = d[1] = 0; | ||
88 | } | ||
diff --git a/src/lib/libcrypto/idea/i_ofb64.c b/src/lib/libcrypto/idea/i_ofb64.c index b63144b6c4..27d85e5a37 100644 --- a/src/lib/libcrypto/idea/i_ofb64.c +++ b/src/lib/libcrypto/idea/i_ofb64.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: i_ofb64.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ | 1 | /* $OpenBSD: i_ofb64.c,v 1.5 2023/07/07 12:51:58 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 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 | 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 | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 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. | 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 | 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. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 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: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 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 | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 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 | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -63,49 +63,48 @@ | |||
63 | * used. The extra state information to record how much of the | 63 | * used. The extra state information to record how much of the |
64 | * 64bit block we have used is contained in *num; | 64 | * 64bit block we have used is contained in *num; |
65 | */ | 65 | */ |
66 | void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, | 66 | void |
67 | long length, IDEA_KEY_SCHEDULE *schedule, | 67 | idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, |
68 | unsigned char *ivec, int *num) | 68 | long length, IDEA_KEY_SCHEDULE *schedule, |
69 | { | 69 | unsigned char *ivec, int *num) |
70 | unsigned long v0,v1,t; | 70 | { |
71 | int n= *num; | 71 | unsigned long v0, v1, t; |
72 | long l=length; | 72 | int n = *num; |
73 | long l = length; | ||
73 | unsigned char d[8]; | 74 | unsigned char d[8]; |
74 | char *dp; | 75 | char *dp; |
75 | unsigned long ti[2]; | 76 | unsigned long ti[2]; |
76 | unsigned char *iv; | 77 | unsigned char *iv; |
77 | int save=0; | 78 | int save = 0; |
78 | 79 | ||
79 | iv=(unsigned char *)ivec; | 80 | iv = (unsigned char *)ivec; |
80 | n2l(iv,v0); | 81 | n2l(iv, v0); |
81 | n2l(iv,v1); | 82 | n2l(iv, v1); |
82 | ti[0]=v0; | 83 | ti[0] = v0; |
83 | ti[1]=v1; | 84 | ti[1] = v1; |
84 | dp=(char *)d; | 85 | dp = (char *)d; |
85 | l2n(v0,dp); | 86 | l2n(v0, dp); |
86 | l2n(v1,dp); | 87 | l2n(v1, dp); |
87 | while (l--) | 88 | while (l--) { |
88 | { | 89 | if (n == 0) { |
89 | if (n == 0) | 90 | idea_encrypt((unsigned long *)ti, schedule); |
90 | { | 91 | dp = (char *)d; |
91 | idea_encrypt((unsigned long *)ti,schedule); | 92 | t = ti[0]; |
92 | dp=(char *)d; | 93 | l2n(t, dp); |
93 | t=ti[0]; l2n(t,dp); | 94 | t = ti[1]; |
94 | t=ti[1]; l2n(t,dp); | 95 | l2n(t, dp); |
95 | save++; | 96 | 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 | } | 97 | } |
108 | t=v0=v1=ti[0]=ti[1]=0; | 98 | *(out++) = *(in++) ^ d[n]; |
109 | *num=n; | 99 | n = (n + 1) & 0x07; |
110 | } | 100 | } |
111 | 101 | if (save) { | |
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 | } | ||
diff --git a/src/lib/libcrypto/idea/i_skey.c b/src/lib/libcrypto/idea/i_skey.c index 4338165127..481c50ba55 100644 --- a/src/lib/libcrypto/idea/i_skey.c +++ b/src/lib/libcrypto/idea/i_skey.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: i_skey.c,v 1.5 2022/11/26 16:08:53 tb Exp $ */ | 1 | /* $OpenBSD: i_skey.c,v 1.6 2023/07/07 12:51:58 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 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 | 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 | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 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. | 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 | 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. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 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: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 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 | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 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 | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -61,97 +61,107 @@ | |||
61 | #include "idea_local.h" | 61 | #include "idea_local.h" |
62 | 62 | ||
63 | static IDEA_INT inverse(unsigned int xin); | 63 | static IDEA_INT inverse(unsigned int xin); |
64 | void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks) | 64 | void |
65 | { | 65 | idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks) |
66 | { | ||
66 | int i; | 67 | int i; |
67 | IDEA_INT *kt,*kf,r0,r1,r2; | 68 | IDEA_INT *kt, *kf, r0, r1, r2; |
68 | 69 | ||
69 | kt= &(ks->data[0][0]); | 70 | 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[0]); |
71 | n2s(key,kt[4]); n2s(key,kt[5]); n2s(key,kt[6]); n2s(key,kt[7]); | 72 | n2s(key, kt[1]); |
73 | n2s(key, kt[2]); | ||
74 | n2s(key, kt[3]); | ||
75 | n2s(key, kt[4]); | ||
76 | n2s(key, kt[5]); | ||
77 | n2s(key, kt[6]); | ||
78 | n2s(key, kt[7]); | ||
72 | 79 | ||
73 | kf=kt; | 80 | kf = kt; |
74 | kt+=8; | 81 | kt += 8; |
75 | for (i=0; i<6; i++) | 82 | for (i = 0; i < 6; i++) |
76 | { | 83 | { |
77 | r2= kf[1]; | 84 | r2 = kf[1]; |
78 | r1= kf[2]; | 85 | r1 = kf[2]; |
79 | *(kt++)= ((r2<<9) | (r1>>7))&0xffff; | 86 | *(kt++) = ((r2 << 9) | (r1 >> 7)) & 0xffff; |
80 | r0= kf[3]; | 87 | r0 = kf[3]; |
81 | *(kt++)= ((r1<<9) | (r0>>7))&0xffff; | 88 | *(kt++) = ((r1 << 9) | (r0 >> 7)) & 0xffff; |
82 | r1= kf[4]; | 89 | r1 = kf[4]; |
83 | *(kt++)= ((r0<<9) | (r1>>7))&0xffff; | 90 | *(kt++) = ((r0 << 9) | (r1 >> 7)) & 0xffff; |
84 | r0= kf[5]; | 91 | r0 = kf[5]; |
85 | *(kt++)= ((r1<<9) | (r0>>7))&0xffff; | 92 | *(kt++) = ((r1 << 9) | (r0 >> 7)) & 0xffff; |
86 | r1= kf[6]; | 93 | r1 = kf[6]; |
87 | *(kt++)= ((r0<<9) | (r1>>7))&0xffff; | 94 | *(kt++) = ((r0 << 9) | (r1 >> 7)) & 0xffff; |
88 | r0= kf[7]; | 95 | r0 = kf[7]; |
89 | *(kt++)= ((r1<<9) | (r0>>7))&0xffff; | 96 | *(kt++) = ((r1 << 9) | (r0 >> 7)) & 0xffff; |
90 | r1= kf[0]; | 97 | r1 = kf[0]; |
91 | if (i >= 5) break; | 98 | if (i >= 5) |
92 | *(kt++)= ((r0<<9) | (r1>>7))&0xffff; | 99 | break; |
93 | *(kt++)= ((r1<<9) | (r2>>7))&0xffff; | 100 | *(kt++) = ((r0 << 9) | (r1 >> 7)) & 0xffff; |
94 | kf+=8; | 101 | *(kt++) = ((r1 << 9) | (r2 >> 7)) & 0xffff; |
95 | } | 102 | kf += 8; |
96 | } | 103 | } |
104 | } | ||
97 | 105 | ||
98 | void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk) | 106 | void |
99 | { | 107 | idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk) |
108 | { | ||
100 | int r; | 109 | int r; |
101 | IDEA_INT *fp,*tp,t; | 110 | IDEA_INT *fp, *tp, t; |
102 | 111 | ||
103 | tp= &(dk->data[0][0]); | 112 | tp = &(dk->data[0][0]); |
104 | fp= &(ek->data[8][0]); | 113 | fp = &(ek->data[8][0]); |
105 | for (r=0; r<9; r++) | 114 | for (r = 0; r < 9; r++) |
106 | { | 115 | { |
107 | *(tp++)=inverse(fp[0]); | 116 | *(tp++) = inverse(fp[0]); |
108 | *(tp++)=((int)(0x10000L-fp[2])&0xffff); | 117 | *(tp++) = ((int)(0x10000L - fp[2]) & 0xffff); |
109 | *(tp++)=((int)(0x10000L-fp[1])&0xffff); | 118 | *(tp++) = ((int)(0x10000L - fp[1]) & 0xffff); |
110 | *(tp++)=inverse(fp[3]); | 119 | *(tp++) = inverse(fp[3]); |
111 | if (r == 8) break; | 120 | if (r == 8) |
112 | fp-=6; | 121 | break; |
113 | *(tp++)=fp[4]; | 122 | fp -= 6; |
114 | *(tp++)=fp[5]; | 123 | *(tp++) = fp[4]; |
115 | } | 124 | *(tp++) = fp[5]; |
125 | } | ||
116 | 126 | ||
117 | tp= &(dk->data[0][0]); | 127 | tp = &(dk->data[0][0]); |
118 | t=tp[1]; | 128 | t = tp[1]; |
119 | tp[1]=tp[2]; | 129 | tp[1] = tp[2]; |
120 | tp[2]=t; | 130 | tp[2] = t; |
121 | 131 | ||
122 | t=tp[49]; | 132 | t = tp[49]; |
123 | tp[49]=tp[50]; | 133 | tp[49] = tp[50]; |
124 | tp[50]=t; | 134 | tp[50] = t; |
125 | } | 135 | } |
126 | 136 | ||
127 | /* taken directly from the 'paper' I'll have a look at it later */ | 137 | /* taken directly from the 'paper' I'll have a look at it later */ |
128 | static IDEA_INT inverse(unsigned int xin) | 138 | static IDEA_INT |
129 | { | 139 | inverse(unsigned int xin) |
130 | long n1,n2,q,r,b1,b2,t; | 140 | { |
141 | long n1, n2, q, r, b1, b2, t; | ||
131 | 142 | ||
132 | if (xin == 0) | 143 | if (xin == 0) |
133 | b2=0; | 144 | b2 = 0; |
134 | else | 145 | else { |
135 | { | 146 | n1 = 0x10001; |
136 | n1=0x10001; | 147 | n2 = xin; |
137 | n2=xin; | 148 | b2 = 1; |
138 | b2=1; | 149 | b1 = 0; |
139 | b1=0; | ||
140 | 150 | ||
141 | do { | 151 | do { |
142 | r=(n1%n2); | 152 | r = (n1 % n2); |
143 | q=(n1-r)/n2; | 153 | q = (n1 - r)/n2; |
144 | if (r == 0) | 154 | if (r == 0) { |
145 | { if (b2 < 0) b2=0x10001+b2; } | 155 | if (b2 < 0) |
146 | else | 156 | b2 = 0x10001 + b2; |
147 | { | 157 | } else { |
148 | n1=n2; | 158 | n1 = n2; |
149 | n2=r; | 159 | n2 = r; |
150 | t=b2; | 160 | t = b2; |
151 | b2=b1-q*b2; | 161 | b2 = b1 - q*b2; |
152 | b1=t; | 162 | b1 = t; |
153 | } | 163 | } |
154 | } while (r != 0); | 164 | } while (r != 0); |
155 | } | ||
156 | return((IDEA_INT)b2); | ||
157 | } | 165 | } |
166 | return ((IDEA_INT)b2); | ||
167 | } | ||
diff --git a/src/lib/libcrypto/idea/idea.h b/src/lib/libcrypto/idea/idea.h index f76bcaeba5..e5ddd3a6f6 100644 --- a/src/lib/libcrypto/idea/idea.h +++ b/src/lib/libcrypto/idea/idea.h | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: idea.h,v 1.10 2014/06/12 15:49:29 deraadt Exp $ */ | 1 | /* $OpenBSD: idea.h,v 1.11 2023/07/07 12:51:58 beck Exp $ */ |
2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 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 | 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 | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 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. | 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 | 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. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 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: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 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 | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 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 | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -75,23 +75,22 @@ | |||
75 | extern "C" { | 75 | extern "C" { |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | typedef struct idea_key_st | 78 | typedef struct idea_key_st { |
79 | { | ||
80 | IDEA_INT data[9][6]; | 79 | IDEA_INT data[9][6]; |
81 | } IDEA_KEY_SCHEDULE; | 80 | } IDEA_KEY_SCHEDULE; |
82 | 81 | ||
83 | const char *idea_options(void); | 82 | const char *idea_options(void); |
84 | void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, | 83 | void idea_ecb_encrypt(const unsigned char *in, unsigned char *out, |
85 | IDEA_KEY_SCHEDULE *ks); | 84 | IDEA_KEY_SCHEDULE *ks); |
86 | void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); | 85 | void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); |
87 | void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); | 86 | void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); |
88 | void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, | 87 | void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, |
89 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc); | 88 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int enc); |
90 | void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, | 89 | void idea_cfb64_encrypt(const unsigned char *in, unsigned char *out, |
91 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, | 90 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, |
92 | int *num,int enc); | 91 | int *num, int enc); |
93 | void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, | 92 | void idea_ofb64_encrypt(const unsigned char *in, unsigned char *out, |
94 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num); | 93 | long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num); |
95 | void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); | 94 | void idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); |
96 | #ifdef __cplusplus | 95 | #ifdef __cplusplus |
97 | } | 96 | } |
diff --git a/src/lib/libcrypto/idea/idea_local.h b/src/lib/libcrypto/idea/idea_local.h index 2663516c20..c7fd3271a7 100644 --- a/src/lib/libcrypto/idea/idea_local.h +++ b/src/lib/libcrypto/idea/idea_local.h | |||
@@ -1,25 +1,25 @@ | |||
1 | /* $OpenBSD: idea_local.h,v 1.1 2022/11/26 16:08:53 tb Exp $ */ | 1 | /* $OpenBSD: idea_local.h,v 1.2 2023/07/07 12:51:58 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 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 | 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 | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 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. | 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 | 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. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 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: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,24 +49,24 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 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 | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 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 | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | /* The new form of this macro (check if the a*b == 0) was suggested by | 59 | /* The new form of this macro (check if the a*b == 0) was suggested by |
60 | * Colin Plumb <colin@nyx10.cs.du.edu> */ | 60 | * Colin Plumb <colin@nyx10.cs.du.edu> */ |
61 | /* Removal of the inner if from from Wei Dai 24/4/96 */ | 61 | /* Removal of the inner if from from Wei Dai 24/4/96 */ |
62 | #define idea_mul(r,a,b,ul) \ | 62 | #define idea_mul(r,a,b,ul) \ |
63 | ul=(unsigned long)a*b; \ | 63 | ul=(unsigned long)a*b; \ |
64 | if (ul != 0) \ | 64 | if (ul != 0) \ |
65 | { \ | 65 | { \ |
66 | r=(ul&0xffff)-(ul>>16); \ | 66 | r=(ul&0xffff)-(ul>>16); \ |
67 | r-=((r)>>16); \ | 67 | r-=((r)>>16); \ |
68 | } \ | 68 | } \ |
69 | else \ | 69 | else \ |
70 | r=(-(int)a-b+1); /* assuming a or b is 0 and in range */ | 70 | r=(-(int)a-b+1); /* assuming a or b is 0 and in range */ |
71 | 71 | ||
72 | /* 7/12/95 - Many thanks to Rhys Weatherley <rweather@us.oracle.com> | 72 | /* 7/12/95 - Many thanks to Rhys Weatherley <rweather@us.oracle.com> |
@@ -80,46 +80,46 @@ else \ | |||
80 | */ | 80 | */ |
81 | 81 | ||
82 | /* NOTE - c is not incremented as per n2l */ | 82 | /* NOTE - c is not incremented as per n2l */ |
83 | #define n2ln(c,l1,l2,n) { \ | 83 | #define n2ln(c,l1,l2,n) { \ |
84 | c+=n; \ | 84 | c+=n; \ |
85 | l1=l2=0; \ | 85 | l1=l2=0; \ |
86 | switch (n) { \ | 86 | switch (n) { \ |
87 | case 8: l2 =((unsigned long)(*(--(c)))) ; \ | 87 | case 8: l2 =((unsigned long)(*(--(c)))) ; \ |
88 | case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ | 88 | case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ |
89 | case 6: l2|=((unsigned long)(*(--(c))))<<16; \ | 89 | case 6: l2|=((unsigned long)(*(--(c))))<<16; \ |
90 | case 5: l2|=((unsigned long)(*(--(c))))<<24; \ | 90 | case 5: l2|=((unsigned long)(*(--(c))))<<24; \ |
91 | case 4: l1 =((unsigned long)(*(--(c)))) ; \ | 91 | case 4: l1 =((unsigned long)(*(--(c)))) ; \ |
92 | case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ | 92 | case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ |
93 | case 2: l1|=((unsigned long)(*(--(c))))<<16; \ | 93 | case 2: l1|=((unsigned long)(*(--(c))))<<16; \ |
94 | case 1: l1|=((unsigned long)(*(--(c))))<<24; \ | 94 | case 1: l1|=((unsigned long)(*(--(c))))<<24; \ |
95 | } \ | 95 | } \ |
96 | } | 96 | } |
97 | 97 | ||
98 | /* NOTE - c is not incremented as per l2n */ | 98 | /* NOTE - c is not incremented as per l2n */ |
99 | #define l2nn(l1,l2,c,n) { \ | 99 | #define l2nn(l1,l2,c,n) { \ |
100 | c+=n; \ | 100 | c+=n; \ |
101 | switch (n) { \ | 101 | switch (n) { \ |
102 | case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ | 102 | case 8: *(--(c))=(unsigned char)(((l2) )&0xff);\ |
103 | case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ | 103 | case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff);\ |
104 | case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ | 104 | case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff);\ |
105 | case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ | 105 | case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff);\ |
106 | case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ | 106 | case 4: *(--(c))=(unsigned char)(((l1) )&0xff);\ |
107 | case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ | 107 | case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff);\ |
108 | case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ | 108 | case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff);\ |
109 | case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ | 109 | case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff);\ |
110 | } \ | 110 | } \ |
111 | } | 111 | } |
112 | 112 | ||
113 | #undef n2l | 113 | #undef n2l |
114 | #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ | 114 | #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ |
115 | l|=((unsigned long)(*((c)++)))<<16L, \ | 115 | l|=((unsigned long)(*((c)++)))<<16L, \ |
116 | l|=((unsigned long)(*((c)++)))<< 8L, \ | 116 | l|=((unsigned long)(*((c)++)))<< 8L, \ |
117 | l|=((unsigned long)(*((c)++)))) | 117 | l|=((unsigned long)(*((c)++)))) |
118 | 118 | ||
119 | #undef l2n | 119 | #undef l2n |
120 | #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ | 120 | #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ |
121 | *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ | 121 | *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ |
122 | *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ | 122 | *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ |
123 | *((c)++)=(unsigned char)(((l) )&0xff)) | 123 | *((c)++)=(unsigned char)(((l) )&0xff)) |
124 | 124 | ||
125 | #undef s2n | 125 | #undef s2n |
@@ -130,21 +130,20 @@ else \ | |||
130 | #define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \ | 130 | #define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \ |
131 | l|=((IDEA_INT)(*((c)++))) ) | 131 | l|=((IDEA_INT)(*((c)++))) ) |
132 | 132 | ||
133 | #define E_IDEA(num) \ | 133 | #define E_IDEA(num) \ |
134 | x1&=0xffff; \ | 134 | x1&=0xffff; \ |
135 | idea_mul(x1,x1,*p,ul); p++; \ | 135 | idea_mul(x1,x1,*p,ul); p++; \ |
136 | x2+= *(p++); \ | 136 | x2+= *(p++); \ |
137 | x3+= *(p++); \ | 137 | x3+= *(p++); \ |
138 | x4&=0xffff; \ | 138 | x4&=0xffff; \ |
139 | idea_mul(x4,x4,*p,ul); p++; \ | 139 | idea_mul(x4,x4,*p,ul); p++; \ |
140 | t0=(x1^x3)&0xffff; \ | 140 | t0=(x1^x3)&0xffff; \ |
141 | idea_mul(t0,t0,*p,ul); p++; \ | 141 | idea_mul(t0,t0,*p,ul); p++; \ |
142 | t1=(t0+(x2^x4))&0xffff; \ | 142 | t1=(t0+(x2^x4))&0xffff; \ |
143 | idea_mul(t1,t1,*p,ul); p++; \ | 143 | idea_mul(t1,t1,*p,ul); p++; \ |
144 | t0+=t1; \ | 144 | t0+=t1; \ |
145 | x1^=t1; \ | 145 | x1^=t1; \ |
146 | x4^=t0; \ | 146 | x4^=t0; \ |
147 | ul=x2^t0; /* do the swap to x3 */ \ | 147 | ul=x2^t0; /* do the swap to x3 */ \ |
148 | x2=x3^t1; \ | 148 | x2=x3^t1; \ |
149 | x3=ul; | 149 | x3=ul; |
150 | |||