diff options
author | jsing <> | 2023-07-08 07:34:34 +0000 |
---|---|---|
committer | jsing <> | 2023-07-08 07:34:34 +0000 |
commit | f21447ceff21c91ccffb7bda7502d04bdc536012 (patch) | |
tree | 14fa0c0b3cfd9f5af3d0193d221ba10deb8fbcce /src | |
parent | 903dc2a64c29e2f25074485b7e91d9844296b1f3 (diff) | |
download | openbsd-f21447ceff21c91ccffb7bda7502d04bdc536012.tar.gz openbsd-f21447ceff21c91ccffb7bda7502d04bdc536012.tar.bz2 openbsd-f21447ceff21c91ccffb7bda7502d04bdc536012.zip |
More style(9).
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/des/cbc_cksm.c | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/des/cfb64ede.c | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des_enc.c | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/des/ede_cbcm_enc.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/des/enc_writ.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/des/fcrypt.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/des/fcrypt_b.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/des/ncbc_enc.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/des/pcbc_enc.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/des/qud_cksm.c | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/des/set_key.c | 65 | ||||
-rw-r--r-- | src/lib/libcrypto/des/spr.h | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/des/str2key.c | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/des/xcbc_enc.c | 8 |
14 files changed, 82 insertions, 107 deletions
diff --git a/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c index 640c124966..afa3f03d92 100644 --- a/src/lib/libcrypto/des/cbc_cksm.c +++ b/src/lib/libcrypto/des/cbc_cksm.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cbc_cksm.c,v 1.9 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: cbc_cksm.c,v 1.10 2023/07/08 07:34:34 jsing 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 | * |
@@ -71,8 +71,7 @@ DES_cbc_cksum(const unsigned char *in, DES_cblock *output, | |||
71 | 71 | ||
72 | c2l(iv, tout0); | 72 | c2l(iv, tout0); |
73 | c2l(iv, tout1); | 73 | c2l(iv, tout1); |
74 | for (; l > 0; l -= 8) | 74 | for (; l > 0; l -= 8) { |
75 | { | ||
76 | if (l >= 8) { | 75 | if (l >= 8) { |
77 | c2l(in, tin0); | 76 | c2l(in, tin0); |
78 | c2l(in, tin1); | 77 | c2l(in, tin1); |
diff --git a/src/lib/libcrypto/des/cfb64ede.c b/src/lib/libcrypto/des/cfb64ede.c index 700a36620f..e91dbbfc4a 100644 --- a/src/lib/libcrypto/des/cfb64ede.c +++ b/src/lib/libcrypto/des/cfb64ede.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cfb64ede.c,v 1.11 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: cfb64ede.c,v 1.12 2023/07/08 07:34:34 jsing 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 | * |
@@ -178,13 +178,13 @@ DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, | |||
178 | memmove(ovec, ovec + num/8, | 178 | memmove(ovec, ovec + num/8, |
179 | 8 + (num % 8 ? 1 : 0)); | 179 | 8 + (num % 8 ? 1 : 0)); |
180 | /* now the remaining bits */ | 180 | /* now the remaining bits */ |
181 | if (num % 8 != 0) | 181 | if (num % 8 != 0) { |
182 | for (i = 0; i < 8; ++i) | 182 | for (i = 0; i < 8; ++i) { |
183 | { | ||
184 | ovec[i] <<= num % 8; | 183 | ovec[i] <<= num % 8; |
185 | ovec[i] |= ovec[i + 1] >> | 184 | ovec[i] |= ovec[i + 1] >> |
186 | (8 - num % 8); | 185 | (8 - num % 8); |
187 | } | 186 | } |
187 | } | ||
188 | iv = &ovec[0]; | 188 | iv = &ovec[0]; |
189 | c2l(iv, v0); | 189 | c2l(iv, v0); |
190 | c2l(iv, v1); | 190 | c2l(iv, v1); |
@@ -216,13 +216,13 @@ DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, | |||
216 | memmove(ovec, ovec + num/8, | 216 | memmove(ovec, ovec + num/8, |
217 | 8 + (num % 8 ? 1 : 0)); | 217 | 8 + (num % 8 ? 1 : 0)); |
218 | /* now the remaining bits */ | 218 | /* now the remaining bits */ |
219 | if (num % 8 != 0) | 219 | if (num % 8 != 0) { |
220 | for (i = 0; i < 8; ++i) | 220 | for (i = 0; i < 8; ++i) { |
221 | { | ||
222 | ovec[i] <<= num % 8; | 221 | ovec[i] <<= num % 8; |
223 | ovec[i] |= ovec[i + 1] >> | 222 | ovec[i] |= ovec[i + 1] >> |
224 | (8 - num % 8); | 223 | (8 - num % 8); |
225 | } | 224 | } |
225 | } | ||
226 | iv = &ovec[0]; | 226 | iv = &ovec[0]; |
227 | c2l(iv, v0); | 227 | c2l(iv, v0); |
228 | c2l(iv, v1); | 228 | c2l(iv, v1); |
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c index a8d8bd7ecb..7319639c82 100644 --- a/src/lib/libcrypto/des/des_enc.c +++ b/src/lib/libcrypto/des/des_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: des_enc.c,v 1.14 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: des_enc.c,v 1.15 2023/07/08 07:34:34 jsing 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 | * |
@@ -110,8 +110,7 @@ DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) | |||
110 | D_ENCRYPT(l, r, 28); /* 15 */ | 110 | D_ENCRYPT(l, r, 28); /* 15 */ |
111 | D_ENCRYPT(r, l, 30); /* 16 */ | 111 | D_ENCRYPT(r, l, 30); /* 16 */ |
112 | #else | 112 | #else |
113 | for (i = 0; i < 32; i += 4) | 113 | for (i = 0; i < 32; i += 4) { |
114 | { | ||
115 | D_ENCRYPT(l, r, i + 0); /* 1 */ | 114 | D_ENCRYPT(l, r, i + 0); /* 1 */ |
116 | D_ENCRYPT(r, l, i + 2); /* 2 */ | 115 | D_ENCRYPT(r, l, i + 2); /* 2 */ |
117 | } | 116 | } |
@@ -135,8 +134,7 @@ DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) | |||
135 | D_ENCRYPT(l, r, 2); /* 2 */ | 134 | D_ENCRYPT(l, r, 2); /* 2 */ |
136 | D_ENCRYPT(r, l, 0); /* 1 */ | 135 | D_ENCRYPT(r, l, 0); /* 1 */ |
137 | #else | 136 | #else |
138 | for (i = 30; i > 0; i -= 4) | 137 | for (i = 30; i > 0; i -= 4) { |
139 | { | ||
140 | D_ENCRYPT(l, r, i - 0); /* 16 */ | 138 | D_ENCRYPT(l, r, i - 0); /* 16 */ |
141 | D_ENCRYPT(r, l, i - 2); /* 15 */ | 139 | D_ENCRYPT(r, l, i - 2); /* 15 */ |
142 | } | 140 | } |
@@ -200,8 +198,7 @@ DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) | |||
200 | D_ENCRYPT(l, r, 28); /* 15 */ | 198 | D_ENCRYPT(l, r, 28); /* 15 */ |
201 | D_ENCRYPT(r, l, 30); /* 16 */ | 199 | D_ENCRYPT(r, l, 30); /* 16 */ |
202 | #else | 200 | #else |
203 | for (i = 0; i < 32; i += 4) | 201 | for (i = 0; i < 32; i += 4) { |
204 | { | ||
205 | D_ENCRYPT(l, r, i + 0); /* 1 */ | 202 | D_ENCRYPT(l, r, i + 0); /* 1 */ |
206 | D_ENCRYPT(r, l, i + 2); /* 2 */ | 203 | D_ENCRYPT(r, l, i + 2); /* 2 */ |
207 | } | 204 | } |
@@ -225,8 +222,7 @@ DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) | |||
225 | D_ENCRYPT(l, r, 2); /* 2 */ | 222 | D_ENCRYPT(l, r, 2); /* 2 */ |
226 | D_ENCRYPT(r, l, 0); /* 1 */ | 223 | D_ENCRYPT(r, l, 0); /* 1 */ |
227 | #else | 224 | #else |
228 | for (i = 30; i > 0; i -= 4) | 225 | for (i = 30; i > 0; i -= 4) { |
229 | { | ||
230 | D_ENCRYPT(l, r, i - 0); /* 16 */ | 226 | D_ENCRYPT(l, r, i - 0); /* 16 */ |
231 | D_ENCRYPT(r, l, i - 2); /* 15 */ | 227 | D_ENCRYPT(r, l, i - 2); /* 15 */ |
232 | } | 228 | } |
@@ -308,8 +304,7 @@ DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, | |||
308 | if (enc) { | 304 | if (enc) { |
309 | c2l(iv, tout0); | 305 | c2l(iv, tout0); |
310 | c2l(iv, tout1); | 306 | c2l(iv, tout1); |
311 | for (l -= 8; l >= 0; l -= 8) | 307 | for (l -= 8; l >= 0; l -= 8) { |
312 | { | ||
313 | c2l(in, tin0); | 308 | c2l(in, tin0); |
314 | c2l(in, tin1); | 309 | c2l(in, tin1); |
315 | tin0 ^= tout0; | 310 | tin0 ^= tout0; |
@@ -346,8 +341,7 @@ DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, | |||
346 | 341 | ||
347 | c2l(iv, xor0); | 342 | c2l(iv, xor0); |
348 | c2l(iv, xor1); | 343 | c2l(iv, xor1); |
349 | for (l -= 8; l >= 0; l -= 8) | 344 | for (l -= 8; l >= 0; l -= 8) { |
350 | { | ||
351 | c2l(in, tin0); | 345 | c2l(in, tin0); |
352 | c2l(in, tin1); | 346 | c2l(in, tin1); |
353 | 347 | ||
diff --git a/src/lib/libcrypto/des/ede_cbcm_enc.c b/src/lib/libcrypto/des/ede_cbcm_enc.c index d276009c60..eb6fd4f545 100644 --- a/src/lib/libcrypto/des/ede_cbcm_enc.c +++ b/src/lib/libcrypto/des/ede_cbcm_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ede_cbcm_enc.c,v 1.8 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: ede_cbcm_enc.c,v 1.9 2023/07/08 07:34:34 jsing Exp $ */ |
2 | /* Written by Ben Laurie <ben@algroup.co.uk> for the OpenSSL | 2 | /* Written by Ben Laurie <ben@algroup.co.uk> for the OpenSSL |
3 | * project 13 Feb 1999. | 3 | * project 13 Feb 1999. |
4 | */ | 4 | */ |
@@ -93,8 +93,7 @@ DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, | |||
93 | c2l(iv1, m1); | 93 | c2l(iv1, m1); |
94 | c2l(iv2, tout0); | 94 | c2l(iv2, tout0); |
95 | c2l(iv2, tout1); | 95 | c2l(iv2, tout1); |
96 | for (l -= 8; l >= -7; l -= 8) | 96 | for (l -= 8; l >= -7; l -= 8) { |
97 | { | ||
98 | tin[0] = m0; | 97 | tin[0] = m0; |
99 | tin[1] = m1; | 98 | tin[1] = m1; |
100 | DES_encrypt1(tin, ks3, 1); | 99 | DES_encrypt1(tin, ks3, 1); |
@@ -139,8 +138,7 @@ DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, | |||
139 | c2l(iv1, m1); | 138 | c2l(iv1, m1); |
140 | c2l(iv2, xor0); | 139 | c2l(iv2, xor0); |
141 | c2l(iv2, xor1); | 140 | c2l(iv2, xor1); |
142 | for (l -= 8; l >= -7; l -= 8) | 141 | for (l -= 8; l >= -7; l -= 8) { |
143 | { | ||
144 | tin[0] = m0; | 142 | tin[0] = m0; |
145 | tin[1] = m1; | 143 | tin[1] = m1; |
146 | DES_encrypt1(tin, ks3, 1); | 144 | DES_encrypt1(tin, ks3, 1); |
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c index 8a19fb84f9..3def8a8d73 100644 --- a/src/lib/libcrypto/des/enc_writ.c +++ b/src/lib/libcrypto/des/enc_writ.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: enc_writ.c,v 1.16 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: enc_writ.c,v 1.17 2023/07/08 07:34:34 jsing 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 | * |
@@ -110,8 +110,7 @@ DES_enc_write(int fd, const void *_buf, int len, | |||
110 | /* lets recurse if we want to send the data in small chunks */ | 110 | /* lets recurse if we want to send the data in small chunks */ |
111 | if (len > MAXWRITE) { | 111 | if (len > MAXWRITE) { |
112 | j = 0; | 112 | j = 0; |
113 | for (i = 0; i < len; i += k) | 113 | for (i = 0; i < len; i += k) { |
114 | { | ||
115 | k = DES_enc_write(fd, &(buf[i]), | 114 | k = DES_enc_write(fd, &(buf[i]), |
116 | ((len - i) > MAXWRITE) ? MAXWRITE : (len - i), | 115 | ((len - i) > MAXWRITE) ? MAXWRITE : (len - i), |
117 | sched, iv); | 116 | sched, iv); |
@@ -148,8 +147,7 @@ DES_enc_write(int fd, const void *_buf, int len, | |||
148 | /* output */ | 147 | /* output */ |
149 | outnum = rnum + HDRSIZE; | 148 | outnum = rnum + HDRSIZE; |
150 | 149 | ||
151 | for (j = 0; j < outnum; j += i) | 150 | for (j = 0; j < outnum; j += i) { |
152 | { | ||
153 | /* eay 26/08/92 I was not doing writing from where we | 151 | /* eay 26/08/92 I was not doing writing from where we |
154 | * got up to. */ | 152 | * got up to. */ |
155 | i = write(fd, (void *)&(outbuf[j]), outnum - j); | 153 | i = write(fd, (void *)&(outbuf[j]), outnum - j); |
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c index 1e42ecbfe8..b183ceef14 100644 --- a/src/lib/libcrypto/des/fcrypt.c +++ b/src/lib/libcrypto/des/fcrypt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: fcrypt.c,v 1.14 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: fcrypt.c,v 1.15 2023/07/08 07:34:34 jsing Exp $ */ |
2 | 2 | ||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | 4 | ||
@@ -87,8 +87,7 @@ DES_fcrypt(const char *buf, const char *salt, char *ret) | |||
87 | r=strlen(buf); | 87 | r=strlen(buf); |
88 | r=(r+7)/8; | 88 | r=(r+7)/8; |
89 | */ | 89 | */ |
90 | for (i = 0; i < 8; i++) | 90 | for (i = 0; i < 8; i++) { |
91 | { | ||
92 | c = *(buf++); | 91 | c = *(buf++); |
93 | if (!c) | 92 | if (!c) |
94 | break; | 93 | break; |
@@ -107,11 +106,9 @@ r=(r+7)/8; | |||
107 | y = 0; | 106 | y = 0; |
108 | u = 0x80; | 107 | u = 0x80; |
109 | bb[8] = 0; | 108 | bb[8] = 0; |
110 | for (i = 2; i < 13; i++) | 109 | for (i = 2; i < 13; i++) { |
111 | { | ||
112 | c = 0; | 110 | c = 0; |
113 | for (j = 0; j < 6; j++) | 111 | for (j = 0; j < 6; j++) { |
114 | { | ||
115 | c <<= 1; | 112 | c <<= 1; |
116 | if (bb[y] & u) | 113 | if (bb[y] & u) |
117 | c |= 1; | 114 | c |= 1; |
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c index 193ea34957..58c9bc34c5 100644 --- a/src/lib/libcrypto/des/fcrypt_b.c +++ b/src/lib/libcrypto/des/fcrypt_b.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: fcrypt_b.c,v 1.11 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: fcrypt_b.c,v 1.12 2023/07/08 07:34:34 jsing 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 | * |
@@ -98,13 +98,11 @@ fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0, | |||
98 | E0 = Eswap0; | 98 | E0 = Eswap0; |
99 | E1 = Eswap1; | 99 | E1 = Eswap1; |
100 | 100 | ||
101 | for (j = 0; j < 25; j++) | 101 | for (j = 0; j < 25; j++) { |
102 | { | ||
103 | #ifndef DES_UNROLL | 102 | #ifndef DES_UNROLL |
104 | int i; | 103 | int i; |
105 | 104 | ||
106 | for (i = 0; i < 32; i += 4) | 105 | for (i = 0; i < 32; i += 4) { |
107 | { | ||
108 | D_ENCRYPT(l, r, i + 0); /* 1 */ | 106 | D_ENCRYPT(l, r, i + 0); /* 1 */ |
109 | D_ENCRYPT(r, l, i + 2); /* 2 */ | 107 | D_ENCRYPT(r, l, i + 2); /* 2 */ |
110 | } | 108 | } |
diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c index d7e47813b3..c4da94c489 100644 --- a/src/lib/libcrypto/des/ncbc_enc.c +++ b/src/lib/libcrypto/des/ncbc_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ncbc_enc.c,v 1.9 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: ncbc_enc.c,v 1.10 2023/07/08 07:34:34 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * #included by: | 3 | * #included by: |
4 | * cbc_enc.c (DES_cbc_encrypt) | 4 | * cbc_enc.c (DES_cbc_encrypt) |
@@ -84,8 +84,7 @@ DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, | |||
84 | if (enc) { | 84 | if (enc) { |
85 | c2l(iv, tout0); | 85 | c2l(iv, tout0); |
86 | c2l(iv, tout1); | 86 | c2l(iv, tout1); |
87 | for (l -= 8; l >= 0; l -= 8) | 87 | for (l -= 8; l >= 0; l -= 8) { |
88 | { | ||
89 | c2l(in, tin0); | 88 | c2l(in, tin0); |
90 | c2l(in, tin1); | 89 | c2l(in, tin1); |
91 | tin0 ^= tout0; | 90 | tin0 ^= tout0; |
@@ -118,8 +117,7 @@ DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, | |||
118 | } else { | 117 | } else { |
119 | c2l(iv, xor0); | 118 | c2l(iv, xor0); |
120 | c2l(iv, xor1); | 119 | c2l(iv, xor1); |
121 | for (l -= 8; l >= 0; l -= 8) | 120 | for (l -= 8; l >= 0; l -= 8) { |
122 | { | ||
123 | c2l(in, tin0); | 121 | c2l(in, tin0); |
124 | tin[0] = tin0; | 122 | tin[0] = tin0; |
125 | c2l(in, tin1); | 123 | c2l(in, tin1); |
@@ -146,7 +144,7 @@ DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, | |||
146 | xor1 = tin1; | 144 | xor1 = tin1; |
147 | #endif | 145 | #endif |
148 | } | 146 | } |
149 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | 147 | #ifndef CBC_ENC_C__DONT_UPDATE_IV |
150 | iv = &(*ivec)[0]; | 148 | iv = &(*ivec)[0]; |
151 | l2c(xor0, iv); | 149 | l2c(xor0, iv); |
152 | l2c(xor1, iv); | 150 | l2c(xor1, iv); |
diff --git a/src/lib/libcrypto/des/pcbc_enc.c b/src/lib/libcrypto/des/pcbc_enc.c index 8574a44083..3a420f0136 100644 --- a/src/lib/libcrypto/des/pcbc_enc.c +++ b/src/lib/libcrypto/des/pcbc_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcbc_enc.c,v 1.8 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: pcbc_enc.c,v 1.9 2023/07/08 07:34:34 jsing 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 | * |
@@ -75,8 +75,7 @@ DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, | |||
75 | if (enc) { | 75 | if (enc) { |
76 | c2l(iv, xor0); | 76 | c2l(iv, xor0); |
77 | c2l(iv, xor1); | 77 | c2l(iv, xor1); |
78 | for (; length > 0; length -= 8) | 78 | for (; length > 0; length -= 8) { |
79 | { | ||
80 | if (length >= 8) { | 79 | if (length >= 8) { |
81 | c2l(in, sin0); | 80 | c2l(in, sin0); |
82 | c2l(in, sin1); | 81 | c2l(in, sin1); |
@@ -95,8 +94,7 @@ DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, | |||
95 | } else { | 94 | } else { |
96 | c2l(iv, xor0); | 95 | c2l(iv, xor0); |
97 | c2l(iv, xor1); | 96 | c2l(iv, xor1); |
98 | for (; length > 0; length -= 8) | 97 | for (; length > 0; length -= 8) { |
99 | { | ||
100 | c2l(in, sin0); | 98 | c2l(in, sin0); |
101 | c2l(in, sin1); | 99 | c2l(in, sin1); |
102 | tin[0] = sin0; | 100 | tin[0] = sin0; |
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c index c9d2c01fa1..ab28668264 100644 --- a/src/lib/libcrypto/des/qud_cksm.c +++ b/src/lib/libcrypto/des/qud_cksm.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: qud_cksm.c,v 1.9 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: qud_cksm.c,v 1.10 2023/07/08 07:34:34 jsing 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 | * |
@@ -92,8 +92,7 @@ DES_quad_cksum(const unsigned char *input, DES_cblock output[], | |||
92 | z1 = Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3( | 92 | z1 = Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3( |
93 | (*seed)[7]); | 93 | (*seed)[7]); |
94 | 94 | ||
95 | for (i = 0; ((i < 4) && (i < out_count)); i++) | 95 | for (i = 0; ((i < 4) && (i < out_count)); i++) { |
96 | { | ||
97 | cp = input; | 96 | cp = input; |
98 | l = length; | 97 | l = length; |
99 | while (l > 0) { | 98 | while (l > 0) { |
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c index 07b8d03da1..91116c4d16 100644 --- a/src/lib/libcrypto/des/set_key.c +++ b/src/lib/libcrypto/des/set_key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: set_key.c,v 1.22 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: set_key.c,v 1.23 2023/07/08 07:34:34 jsing 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 | * |
@@ -84,7 +84,8 @@ static const unsigned char odd_parity[256] = { | |||
84 | 193, 193, 194, 194, 196, 196, 199, 199, 200, 200, 203, 203, 205, 205, 206, 206, | 84 | 193, 193, 194, 194, 196, 196, 199, 199, 200, 200, 203, 203, 205, 205, 206, 206, |
85 | 208, 208, 211, 211, 213, 213, 214, 214, 217, 217, 218, 218, 220, 220, 223, 223, | 85 | 208, 208, 211, 211, 213, 213, 214, 214, 217, 217, 218, 218, 220, 220, 223, 223, |
86 | 224, 224, 227, 227, 229, 229, 230, 230, 233, 233, 234, 234, 236, 236, 239, 239, | 86 | 224, 224, 227, 227, 229, 229, 230, 230, 233, 233, 234, 234, 236, 236, 239, 239, |
87 | 241, 241, 242, 242, 244, 244, 247, 247, 248, 248, 251, 251, 253, 253, 254, 254}; | 87 | 241, 241, 242, 242, 244, 244, 247, 247, 248, 248, 251, 251, 253, 253, 254, 254, |
88 | }; | ||
88 | 89 | ||
89 | void | 90 | void |
90 | DES_set_odd_parity(DES_cblock *key) | 91 | DES_set_odd_parity(DES_cblock *key) |
@@ -100,8 +101,7 @@ DES_check_key_parity(const_DES_cblock *key) | |||
100 | { | 101 | { |
101 | unsigned int i; | 102 | unsigned int i; |
102 | 103 | ||
103 | for (i = 0; i < DES_KEY_SZ; i++) | 104 | for (i = 0; i < DES_KEY_SZ; i++) { |
104 | { | ||
105 | if ((*key)[i] != odd_parity[(*key)[i]]) | 105 | if ((*key)[i] != odd_parity[(*key)[i]]) |
106 | return (0); | 106 | return (0); |
107 | } | 107 | } |
@@ -120,23 +120,24 @@ DES_check_key_parity(const_DES_cblock *key) | |||
120 | #define NUM_WEAK_KEY 16 | 120 | #define NUM_WEAK_KEY 16 |
121 | static const DES_cblock weak_keys[NUM_WEAK_KEY] = { | 121 | static const DES_cblock weak_keys[NUM_WEAK_KEY] = { |
122 | /* weak keys */ | 122 | /* weak keys */ |
123 | {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, | 123 | {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, |
124 | {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, | 124 | {0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE}, |
125 | {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E}, | 125 | {0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E}, |
126 | {0xE0,0xE0,0xE0,0xE0,0xF1,0xF1,0xF1,0xF1}, | 126 | {0xE0, 0xE0, 0xE0, 0xE0, 0xF1, 0xF1, 0xF1, 0xF1}, |
127 | /* semi-weak keys */ | 127 | /* semi-weak keys */ |
128 | {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE}, | 128 | {0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE}, |
129 | {0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01}, | 129 | {0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01}, |
130 | {0x1F,0xE0,0x1F,0xE0,0x0E,0xF1,0x0E,0xF1}, | 130 | {0x1F, 0xE0, 0x1F, 0xE0, 0x0E, 0xF1, 0x0E, 0xF1}, |
131 | {0xE0,0x1F,0xE0,0x1F,0xF1,0x0E,0xF1,0x0E}, | 131 | {0xE0, 0x1F, 0xE0, 0x1F, 0xF1, 0x0E, 0xF1, 0x0E}, |
132 | {0x01,0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1}, | 132 | {0x01, 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1}, |
133 | {0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1,0x01}, | 133 | {0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1, 0x01}, |
134 | {0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E,0xFE}, | 134 | {0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E, 0xFE}, |
135 | {0xFE,0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E}, | 135 | {0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E}, |
136 | {0x01,0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E}, | 136 | {0x01, 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E}, |
137 | {0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E,0x01}, | 137 | {0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E, 0x01}, |
138 | {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, | 138 | {0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE}, |
139 | {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; | 139 | {0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1}, |
140 | }; | ||
140 | 141 | ||
141 | int | 142 | int |
142 | DES_is_weak_key(const_DES_cblock *key) | 143 | DES_is_weak_key(const_DES_cblock *key) |
@@ -161,7 +162,7 @@ DES_is_weak_key(const_DES_cblock *key) | |||
161 | 162 | ||
162 | static const DES_LONG des_skb[8][64] = { | 163 | static const DES_LONG des_skb[8][64] = { |
163 | { | 164 | { |
164 | /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ | 165 | /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ |
165 | 0x00000000L, 0x00000010L, 0x20000000L, 0x20000010L, | 166 | 0x00000000L, 0x00000010L, 0x20000000L, 0x20000010L, |
166 | 0x00010000L, 0x00010010L, 0x20010000L, 0x20010010L, | 167 | 0x00010000L, 0x00010010L, 0x20010000L, 0x20010010L, |
167 | 0x00000800L, 0x00000810L, 0x20000800L, 0x20000810L, | 168 | 0x00000800L, 0x00000810L, 0x20000800L, 0x20000810L, |
@@ -179,7 +180,7 @@ static const DES_LONG des_skb[8][64] = { | |||
179 | 0x00080820L, 0x00080830L, 0x20080820L, 0x20080830L, | 180 | 0x00080820L, 0x00080830L, 0x20080820L, 0x20080830L, |
180 | 0x00090820L, 0x00090830L, 0x20090820L, 0x20090830L, | 181 | 0x00090820L, 0x00090830L, 0x20090820L, 0x20090830L, |
181 | }, { | 182 | }, { |
182 | /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ | 183 | /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ |
183 | 0x00000000L, 0x02000000L, 0x00002000L, 0x02002000L, | 184 | 0x00000000L, 0x02000000L, 0x00002000L, 0x02002000L, |
184 | 0x00200000L, 0x02200000L, 0x00202000L, 0x02202000L, | 185 | 0x00200000L, 0x02200000L, 0x00202000L, 0x02202000L, |
185 | 0x00000004L, 0x02000004L, 0x00002004L, 0x02002004L, | 186 | 0x00000004L, 0x02000004L, 0x00002004L, 0x02002004L, |
@@ -197,7 +198,7 @@ static const DES_LONG des_skb[8][64] = { | |||
197 | 0x10000404L, 0x12000404L, 0x10002404L, 0x12002404L, | 198 | 0x10000404L, 0x12000404L, 0x10002404L, 0x12002404L, |
198 | 0x10200404L, 0x12200404L, 0x10202404L, 0x12202404L, | 199 | 0x10200404L, 0x12200404L, 0x10202404L, 0x12202404L, |
199 | }, { | 200 | }, { |
200 | /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ | 201 | /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ |
201 | 0x00000000L, 0x00000001L, 0x00040000L, 0x00040001L, | 202 | 0x00000000L, 0x00000001L, 0x00040000L, 0x00040001L, |
202 | 0x01000000L, 0x01000001L, 0x01040000L, 0x01040001L, | 203 | 0x01000000L, 0x01000001L, 0x01040000L, 0x01040001L, |
203 | 0x00000002L, 0x00000003L, 0x00040002L, 0x00040003L, | 204 | 0x00000002L, 0x00000003L, 0x00040002L, 0x00040003L, |
@@ -215,7 +216,7 @@ static const DES_LONG des_skb[8][64] = { | |||
215 | 0x08000202L, 0x08000203L, 0x08040202L, 0x08040203L, | 216 | 0x08000202L, 0x08000203L, 0x08040202L, 0x08040203L, |
216 | 0x09000202L, 0x09000203L, 0x09040202L, 0x09040203L, | 217 | 0x09000202L, 0x09000203L, 0x09040202L, 0x09040203L, |
217 | }, { | 218 | }, { |
218 | /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ | 219 | /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ |
219 | 0x00000000L, 0x00100000L, 0x00000100L, 0x00100100L, | 220 | 0x00000000L, 0x00100000L, 0x00000100L, 0x00100100L, |
220 | 0x00000008L, 0x00100008L, 0x00000108L, 0x00100108L, | 221 | 0x00000008L, 0x00100008L, 0x00000108L, 0x00100108L, |
221 | 0x00001000L, 0x00101000L, 0x00001100L, 0x00101100L, | 222 | 0x00001000L, 0x00101000L, 0x00001100L, 0x00101100L, |
@@ -233,7 +234,7 @@ static const DES_LONG des_skb[8][64] = { | |||
233 | 0x04021000L, 0x04121000L, 0x04021100L, 0x04121100L, | 234 | 0x04021000L, 0x04121000L, 0x04021100L, 0x04121100L, |
234 | 0x04021008L, 0x04121008L, 0x04021108L, 0x04121108L, | 235 | 0x04021008L, 0x04121008L, 0x04021108L, 0x04121108L, |
235 | }, { | 236 | }, { |
236 | /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ | 237 | /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ |
237 | 0x00000000L, 0x10000000L, 0x00010000L, 0x10010000L, | 238 | 0x00000000L, 0x10000000L, 0x00010000L, 0x10010000L, |
238 | 0x00000004L, 0x10000004L, 0x00010004L, 0x10010004L, | 239 | 0x00000004L, 0x10000004L, 0x00010004L, 0x10010004L, |
239 | 0x20000000L, 0x30000000L, 0x20010000L, 0x30010000L, | 240 | 0x20000000L, 0x30000000L, 0x20010000L, 0x30010000L, |
@@ -251,7 +252,7 @@ static const DES_LONG des_skb[8][64] = { | |||
251 | 0x20101000L, 0x30101000L, 0x20111000L, 0x30111000L, | 252 | 0x20101000L, 0x30101000L, 0x20111000L, 0x30111000L, |
252 | 0x20101004L, 0x30101004L, 0x20111004L, 0x30111004L, | 253 | 0x20101004L, 0x30101004L, 0x20111004L, 0x30111004L, |
253 | }, { | 254 | }, { |
254 | /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ | 255 | /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ |
255 | 0x00000000L, 0x08000000L, 0x00000008L, 0x08000008L, | 256 | 0x00000000L, 0x08000000L, 0x00000008L, 0x08000008L, |
256 | 0x00000400L, 0x08000400L, 0x00000408L, 0x08000408L, | 257 | 0x00000400L, 0x08000400L, 0x00000408L, 0x08000408L, |
257 | 0x00020000L, 0x08020000L, 0x00020008L, 0x08020008L, | 258 | 0x00020000L, 0x08020000L, 0x00020008L, 0x08020008L, |
@@ -269,7 +270,7 @@ static const DES_LONG des_skb[8][64] = { | |||
269 | 0x02020001L, 0x0A020001L, 0x02020009L, 0x0A020009L, | 270 | 0x02020001L, 0x0A020001L, 0x02020009L, 0x0A020009L, |
270 | 0x02020401L, 0x0A020401L, 0x02020409L, 0x0A020409L, | 271 | 0x02020401L, 0x0A020401L, 0x02020409L, 0x0A020409L, |
271 | }, { | 272 | }, { |
272 | /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ | 273 | /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ |
273 | 0x00000000L, 0x00000100L, 0x00080000L, 0x00080100L, | 274 | 0x00000000L, 0x00000100L, 0x00080000L, 0x00080100L, |
274 | 0x01000000L, 0x01000100L, 0x01080000L, 0x01080100L, | 275 | 0x01000000L, 0x01000100L, 0x01080000L, 0x01080100L, |
275 | 0x00000010L, 0x00000110L, 0x00080010L, 0x00080110L, | 276 | 0x00000010L, 0x00000110L, 0x00080010L, 0x00080110L, |
@@ -287,7 +288,7 @@ static const DES_LONG des_skb[8][64] = { | |||
287 | 0x00200210L, 0x00200310L, 0x00280210L, 0x00280310L, | 288 | 0x00200210L, 0x00200310L, 0x00280210L, 0x00280310L, |
288 | 0x01200210L, 0x01200310L, 0x01280210L, 0x01280310L, | 289 | 0x01200210L, 0x01200310L, 0x01280210L, 0x01280310L, |
289 | }, { | 290 | }, { |
290 | /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ | 291 | /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ |
291 | 0x00000000L, 0x04000000L, 0x00040000L, 0x04040000L, | 292 | 0x00000000L, 0x04000000L, 0x00040000L, 0x04040000L, |
292 | 0x00000002L, 0x04000002L, 0x00040002L, 0x04040002L, | 293 | 0x00000002L, 0x04000002L, 0x00040002L, 0x04040002L, |
293 | 0x00002000L, 0x04002000L, 0x00042000L, 0x04042000L, | 294 | 0x00002000L, 0x04002000L, 0x00042000L, 0x04042000L, |
@@ -304,7 +305,8 @@ static const DES_LONG des_skb[8][64] = { | |||
304 | 0x00000822L, 0x04000822L, 0x00040822L, 0x04040822L, | 305 | 0x00000822L, 0x04000822L, 0x00040822L, 0x04040822L, |
305 | 0x00002820L, 0x04002820L, 0x00042820L, 0x04042820L, | 306 | 0x00002820L, 0x04002820L, 0x00042820L, 0x04042820L, |
306 | 0x00002822L, 0x04002822L, 0x00042822L, 0x04042822L, | 307 | 0x00002822L, 0x04002822L, 0x00042822L, 0x04042822L, |
307 | }}; | 308 | }, |
309 | }; | ||
308 | 310 | ||
309 | int | 311 | int |
310 | DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) | 312 | DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) |
@@ -335,7 +337,7 @@ DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule) | |||
335 | void | 337 | void |
336 | DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) | 338 | DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) |
337 | { | 339 | { |
338 | static const int shifts2[16] = {0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; | 340 | static const int shifts2[16] = {0, 0,1, 1,1, 1,1, 1,0, 1,1, 1,1, 1,1, 0}; |
339 | DES_LONG c, d, t, s, t2; | 341 | DES_LONG c, d, t, s, t2; |
340 | const unsigned char *in; | 342 | const unsigned char *in; |
341 | DES_LONG *k; | 343 | DES_LONG *k; |
@@ -360,8 +362,7 @@ DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) | |||
360 | ((d & 0x00ff0000L) >> 16L)|((c & 0xf0000000L) >> 4L)); | 362 | ((d & 0x00ff0000L) >> 16L)|((c & 0xf0000000L) >> 4L)); |
361 | c &= 0x0fffffffL; | 363 | c &= 0x0fffffffL; |
362 | 364 | ||
363 | for (i = 0; i < ITERATIONS; i++) | 365 | for (i = 0; i < ITERATIONS; i++) { |
364 | { | ||
365 | if (shifts2[i]) { | 366 | if (shifts2[i]) { |
366 | c = ((c >> 2L)|(c << 26L)); | 367 | c = ((c >> 2L)|(c << 26L)); |
367 | d = ((d >> 2L)|(d << 26L)); | 368 | d = ((d >> 2L)|(d << 26L)); |
diff --git a/src/lib/libcrypto/des/spr.h b/src/lib/libcrypto/des/spr.h index 5e9b6d1e72..e0f413e461 100644 --- a/src/lib/libcrypto/des/spr.h +++ b/src/lib/libcrypto/des/spr.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: spr.h,v 1.7 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: spr.h,v 1.8 2023/07/08 07:34:34 jsing 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 | * |
@@ -203,6 +203,7 @@ const DES_LONG DES_SPtrans[8][64] = { | |||
203 | 0x00820000L, 0x00020080L, 0x20020080L, 0x20800000L, | 203 | 0x00820000L, 0x00020080L, 0x20020080L, 0x20800000L, |
204 | 0x00000080L, 0x20820000L, 0x00820080L, 0x00000000L, | 204 | 0x00000080L, 0x20820000L, 0x00820080L, 0x00000000L, |
205 | 0x20000000L, 0x20800080L, 0x00020000L, 0x00820080L, | 205 | 0x20000000L, 0x20800080L, 0x00020000L, 0x00820080L, |
206 | }}; | 206 | }, |
207 | }; | ||
207 | 208 | ||
208 | __END_HIDDEN_DECLS | 209 | __END_HIDDEN_DECLS |
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c index c9bd9aad1b..dd17a441b7 100644 --- a/src/lib/libcrypto/des/str2key.c +++ b/src/lib/libcrypto/des/str2key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: str2key.c,v 1.12 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: str2key.c,v 1.13 2023/07/08 07:34:34 jsing 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 | * |
@@ -72,8 +72,7 @@ DES_string_to_key(const char *str, DES_cblock *key) | |||
72 | for (i = 0; i < length; i++) | 72 | for (i = 0; i < length; i++) |
73 | (*key)[i % 8] ^= (str[i] << 1); | 73 | (*key)[i % 8] ^= (str[i] << 1); |
74 | #else /* MIT COMPATIBLE */ | 74 | #else /* MIT COMPATIBLE */ |
75 | for (i = 0; i < length; i++) | 75 | for (i = 0; i < length; i++) { |
76 | { | ||
77 | j = str[i]; | 76 | j = str[i]; |
78 | if ((i % 16) < 8) | 77 | if ((i % 16) < 8) |
79 | (*key)[i % 8] ^= (j << 1); | 78 | (*key)[i % 8] ^= (j << 1); |
@@ -111,13 +110,11 @@ DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) | |||
111 | length = strlen(str); | 110 | length = strlen(str); |
112 | #ifdef OLD_STR_TO_KEY | 111 | #ifdef OLD_STR_TO_KEY |
113 | if (length <= 8) { | 112 | if (length <= 8) { |
114 | for (i = 0; i < length; i++) | 113 | for (i = 0; i < length; i++) { |
115 | { | ||
116 | (*key2)[i] = (*key1)[i] = (str[i] << 1); | 114 | (*key2)[i] = (*key1)[i] = (str[i] << 1); |
117 | } | 115 | } |
118 | } else { | 116 | } else { |
119 | for (i = 0; i < length; i++) | 117 | for (i = 0; i < length; i++) { |
120 | { | ||
121 | if ((i/8) & 1) | 118 | if ((i/8) & 1) |
122 | (*key2)[i % 8] ^= (str[i] << 1); | 119 | (*key2)[i % 8] ^= (str[i] << 1); |
123 | else | 120 | else |
@@ -125,8 +122,7 @@ DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) | |||
125 | } | 122 | } |
126 | } | 123 | } |
127 | #else /* MIT COMPATIBLE */ | 124 | #else /* MIT COMPATIBLE */ |
128 | for (i = 0; i < length; i++) | 125 | for (i = 0; i < length; i++) { |
129 | { | ||
130 | j = str[i]; | 126 | j = str[i]; |
131 | if ((i % 32) < 16) { | 127 | if ((i % 32) < 16) { |
132 | if ((i % 16) < 8) | 128 | if ((i % 16) < 8) |
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c index 754d989fbf..87f348a9ab 100644 --- a/src/lib/libcrypto/des/xcbc_enc.c +++ b/src/lib/libcrypto/des/xcbc_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: xcbc_enc.c,v 1.11 2023/07/08 07:11:07 beck Exp $ */ | 1 | /* $OpenBSD: xcbc_enc.c,v 1.12 2023/07/08 07:34:34 jsing 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 | * |
@@ -86,8 +86,7 @@ DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, | |||
86 | if (enc) { | 86 | if (enc) { |
87 | c2l(iv, tout0); | 87 | c2l(iv, tout0); |
88 | c2l(iv, tout1); | 88 | c2l(iv, tout1); |
89 | for (l -= 8; l >= 0; l -= 8) | 89 | for (l -= 8; l >= 0; l -= 8) { |
90 | { | ||
91 | c2l(in, tin0); | 90 | c2l(in, tin0); |
92 | c2l(in, tin1); | 91 | c2l(in, tin1); |
93 | tin0 ^= tout0 ^ inW0; | 92 | tin0 ^= tout0 ^ inW0; |
@@ -118,8 +117,7 @@ DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, | |||
118 | } else { | 117 | } else { |
119 | c2l(iv, xor0); | 118 | c2l(iv, xor0); |
120 | c2l(iv, xor1); | 119 | c2l(iv, xor1); |
121 | for (l -= 8; l > 0; l -= 8) | 120 | for (l -= 8; l > 0; l -= 8) { |
122 | { | ||
123 | c2l(in, tin0); | 121 | c2l(in, tin0); |
124 | tin[0] = tin0 ^ outW0; | 122 | tin[0] = tin0 ^ outW0; |
125 | c2l(in, tin1); | 123 | c2l(in, tin1); |