From 1143c94ae5896e9c465418c3ef5be8169a779be4 Mon Sep 17 00:00:00 2001 From: jsing Date: Sat, 8 Jul 2023 07:34:34 +0000 Subject: [PATCH] More style(9). --- lib/libcrypto/des/cbc_cksm.c | 5 +-- lib/libcrypto/des/cfb64ede.c | 14 +++---- lib/libcrypto/des/des_enc.c | 20 ++++------ lib/libcrypto/des/ede_cbcm_enc.c | 8 ++-- lib/libcrypto/des/enc_writ.c | 8 ++-- lib/libcrypto/des/fcrypt.c | 11 ++---- lib/libcrypto/des/fcrypt_b.c | 8 ++-- lib/libcrypto/des/ncbc_enc.c | 10 ++--- lib/libcrypto/des/pcbc_enc.c | 8 ++-- lib/libcrypto/des/qud_cksm.c | 5 +-- lib/libcrypto/des/set_key.c | 65 ++++++++++++++++---------------- lib/libcrypto/des/spr.h | 5 ++- lib/libcrypto/des/str2key.c | 14 +++---- lib/libcrypto/des/xcbc_enc.c | 8 ++-- 14 files changed, 82 insertions(+), 107 deletions(-) diff --git a/lib/libcrypto/des/cbc_cksm.c b/lib/libcrypto/des/cbc_cksm.c index 640c1249665..afa3f03d92d 100644 --- a/lib/libcrypto/des/cbc_cksm.c +++ b/lib/libcrypto/des/cbc_cksm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cbc_cksm.c,v 1.9 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: cbc_cksm.c,v 1.10 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,8 +71,7 @@ DES_cbc_cksum(const unsigned char *in, DES_cblock *output, c2l(iv, tout0); c2l(iv, tout1); - for (; l > 0; l -= 8) - { + for (; l > 0; l -= 8) { if (l >= 8) { c2l(in, tin0); c2l(in, tin1); diff --git a/lib/libcrypto/des/cfb64ede.c b/lib/libcrypto/des/cfb64ede.c index 700a36620fd..e91dbbfc4a4 100644 --- a/lib/libcrypto/des/cfb64ede.c +++ b/lib/libcrypto/des/cfb64ede.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfb64ede.c,v 1.11 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: cfb64ede.c,v 1.12 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -178,13 +178,13 @@ DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, memmove(ovec, ovec + num/8, 8 + (num % 8 ? 1 : 0)); /* now the remaining bits */ - if (num % 8 != 0) - for (i = 0; i < 8; ++i) - { + if (num % 8 != 0) { + for (i = 0; i < 8; ++i) { ovec[i] <<= num % 8; ovec[i] |= ovec[i + 1] >> (8 - num % 8); } + } iv = &ovec[0]; c2l(iv, v0); c2l(iv, v1); @@ -216,13 +216,13 @@ DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, memmove(ovec, ovec + num/8, 8 + (num % 8 ? 1 : 0)); /* now the remaining bits */ - if (num % 8 != 0) - for (i = 0; i < 8; ++i) - { + if (num % 8 != 0) { + for (i = 0; i < 8; ++i) { ovec[i] <<= num % 8; ovec[i] |= ovec[i + 1] >> (8 - num % 8); } + } iv = &ovec[0]; c2l(iv, v0); c2l(iv, v1); diff --git a/lib/libcrypto/des/des_enc.c b/lib/libcrypto/des/des_enc.c index a8d8bd7ecbd..7319639c82a 100644 --- a/lib/libcrypto/des/des_enc.c +++ b/lib/libcrypto/des/des_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: des_enc.c,v 1.14 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: des_enc.c,v 1.15 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -110,8 +110,7 @@ DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) D_ENCRYPT(l, r, 28); /* 15 */ D_ENCRYPT(r, l, 30); /* 16 */ #else - for (i = 0; i < 32; i += 4) - { + for (i = 0; i < 32; i += 4) { D_ENCRYPT(l, r, i + 0); /* 1 */ D_ENCRYPT(r, l, i + 2); /* 2 */ } @@ -135,8 +134,7 @@ DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) D_ENCRYPT(l, r, 2); /* 2 */ D_ENCRYPT(r, l, 0); /* 1 */ #else - for (i = 30; i > 0; i -= 4) - { + for (i = 30; i > 0; i -= 4) { D_ENCRYPT(l, r, i - 0); /* 16 */ D_ENCRYPT(r, l, i - 2); /* 15 */ } @@ -200,8 +198,7 @@ DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) D_ENCRYPT(l, r, 28); /* 15 */ D_ENCRYPT(r, l, 30); /* 16 */ #else - for (i = 0; i < 32; i += 4) - { + for (i = 0; i < 32; i += 4) { D_ENCRYPT(l, r, i + 0); /* 1 */ D_ENCRYPT(r, l, i + 2); /* 2 */ } @@ -225,8 +222,7 @@ DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) D_ENCRYPT(l, r, 2); /* 2 */ D_ENCRYPT(r, l, 0); /* 1 */ #else - for (i = 30; i > 0; i -= 4) - { + for (i = 30; i > 0; i -= 4) { D_ENCRYPT(l, r, i - 0); /* 16 */ D_ENCRYPT(r, l, i - 2); /* 15 */ } @@ -308,8 +304,7 @@ DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, if (enc) { c2l(iv, tout0); c2l(iv, tout1); - for (l -= 8; l >= 0; l -= 8) - { + for (l -= 8; l >= 0; l -= 8) { c2l(in, tin0); c2l(in, tin1); tin0 ^= tout0; @@ -346,8 +341,7 @@ DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, c2l(iv, xor0); c2l(iv, xor1); - for (l -= 8; l >= 0; l -= 8) - { + for (l -= 8; l >= 0; l -= 8) { c2l(in, tin0); c2l(in, tin1); diff --git a/lib/libcrypto/des/ede_cbcm_enc.c b/lib/libcrypto/des/ede_cbcm_enc.c index d276009c603..eb6fd4f5452 100644 --- a/lib/libcrypto/des/ede_cbcm_enc.c +++ b/lib/libcrypto/des/ede_cbcm_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ede_cbcm_enc.c,v 1.8 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: ede_cbcm_enc.c,v 1.9 2023/07/08 07:34:34 jsing Exp $ */ /* Written by Ben Laurie for the OpenSSL * project 13 Feb 1999. */ @@ -93,8 +93,7 @@ DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, c2l(iv1, m1); c2l(iv2, tout0); c2l(iv2, tout1); - for (l -= 8; l >= -7; l -= 8) - { + for (l -= 8; l >= -7; l -= 8) { tin[0] = m0; tin[1] = m1; DES_encrypt1(tin, ks3, 1); @@ -139,8 +138,7 @@ DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, c2l(iv1, m1); c2l(iv2, xor0); c2l(iv2, xor1); - for (l -= 8; l >= -7; l -= 8) - { + for (l -= 8; l >= -7; l -= 8) { tin[0] = m0; tin[1] = m1; DES_encrypt1(tin, ks3, 1); diff --git a/lib/libcrypto/des/enc_writ.c b/lib/libcrypto/des/enc_writ.c index 8a19fb84f91..3def8a8d73b 100644 --- a/lib/libcrypto/des/enc_writ.c +++ b/lib/libcrypto/des/enc_writ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enc_writ.c,v 1.16 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: enc_writ.c,v 1.17 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -110,8 +110,7 @@ DES_enc_write(int fd, const void *_buf, int len, /* lets recurse if we want to send the data in small chunks */ if (len > MAXWRITE) { j = 0; - for (i = 0; i < len; i += k) - { + for (i = 0; i < len; i += k) { k = DES_enc_write(fd, &(buf[i]), ((len - i) > MAXWRITE) ? MAXWRITE : (len - i), sched, iv); @@ -148,8 +147,7 @@ DES_enc_write(int fd, const void *_buf, int len, /* output */ outnum = rnum + HDRSIZE; - for (j = 0; j < outnum; j += i) - { + for (j = 0; j < outnum; j += i) { /* eay 26/08/92 I was not doing writing from where we * got up to. */ i = write(fd, (void *)&(outbuf[j]), outnum - j); diff --git a/lib/libcrypto/des/fcrypt.c b/lib/libcrypto/des/fcrypt.c index 1e42ecbfe89..b183ceef147 100644 --- a/lib/libcrypto/des/fcrypt.c +++ b/lib/libcrypto/des/fcrypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fcrypt.c,v 1.14 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: fcrypt.c,v 1.15 2023/07/08 07:34:34 jsing Exp $ */ #include @@ -87,8 +87,7 @@ DES_fcrypt(const char *buf, const char *salt, char *ret) r=strlen(buf); r=(r+7)/8; */ - for (i = 0; i < 8; i++) - { + for (i = 0; i < 8; i++) { c = *(buf++); if (!c) break; @@ -107,11 +106,9 @@ r=(r+7)/8; y = 0; u = 0x80; bb[8] = 0; - for (i = 2; i < 13; i++) - { + for (i = 2; i < 13; i++) { c = 0; - for (j = 0; j < 6; j++) - { + for (j = 0; j < 6; j++) { c <<= 1; if (bb[y] & u) c |= 1; diff --git a/lib/libcrypto/des/fcrypt_b.c b/lib/libcrypto/des/fcrypt_b.c index 193ea349577..58c9bc34c57 100644 --- a/lib/libcrypto/des/fcrypt_b.c +++ b/lib/libcrypto/des/fcrypt_b.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fcrypt_b.c,v 1.11 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: fcrypt_b.c,v 1.12 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -98,13 +98,11 @@ fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0, E0 = Eswap0; E1 = Eswap1; - for (j = 0; j < 25; j++) - { + for (j = 0; j < 25; j++) { #ifndef DES_UNROLL int i; - for (i = 0; i < 32; i += 4) - { + for (i = 0; i < 32; i += 4) { D_ENCRYPT(l, r, i + 0); /* 1 */ D_ENCRYPT(r, l, i + 2); /* 2 */ } diff --git a/lib/libcrypto/des/ncbc_enc.c b/lib/libcrypto/des/ncbc_enc.c index d7e47813b3c..c4da94c4892 100644 --- a/lib/libcrypto/des/ncbc_enc.c +++ b/lib/libcrypto/des/ncbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncbc_enc.c,v 1.9 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: ncbc_enc.c,v 1.10 2023/07/08 07:34:34 jsing Exp $ */ /* * #included by: * cbc_enc.c (DES_cbc_encrypt) @@ -84,8 +84,7 @@ DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, if (enc) { c2l(iv, tout0); c2l(iv, tout1); - for (l -= 8; l >= 0; l -= 8) - { + for (l -= 8; l >= 0; l -= 8) { c2l(in, tin0); c2l(in, tin1); tin0 ^= tout0; @@ -118,8 +117,7 @@ DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, } else { c2l(iv, xor0); c2l(iv, xor1); - for (l -= 8; l >= 0; l -= 8) - { + for (l -= 8; l >= 0; l -= 8) { c2l(in, tin0); tin[0] = tin0; c2l(in, tin1); @@ -146,7 +144,7 @@ DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, xor1 = tin1; #endif } -#ifndef CBC_ENC_C__DONT_UPDATE_IV +#ifndef CBC_ENC_C__DONT_UPDATE_IV iv = &(*ivec)[0]; l2c(xor0, iv); l2c(xor1, iv); diff --git a/lib/libcrypto/des/pcbc_enc.c b/lib/libcrypto/des/pcbc_enc.c index 8574a440834..3a420f01365 100644 --- a/lib/libcrypto/des/pcbc_enc.c +++ b/lib/libcrypto/des/pcbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcbc_enc.c,v 1.8 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: pcbc_enc.c,v 1.9 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -75,8 +75,7 @@ DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, if (enc) { c2l(iv, xor0); c2l(iv, xor1); - for (; length > 0; length -= 8) - { + for (; length > 0; length -= 8) { if (length >= 8) { c2l(in, sin0); c2l(in, sin1); @@ -95,8 +94,7 @@ DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, } else { c2l(iv, xor0); c2l(iv, xor1); - for (; length > 0; length -= 8) - { + for (; length > 0; length -= 8) { c2l(in, sin0); c2l(in, sin1); tin[0] = sin0; diff --git a/lib/libcrypto/des/qud_cksm.c b/lib/libcrypto/des/qud_cksm.c index c9d2c01fa17..ab286682644 100644 --- a/lib/libcrypto/des/qud_cksm.c +++ b/lib/libcrypto/des/qud_cksm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qud_cksm.c,v 1.9 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: qud_cksm.c,v 1.10 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -92,8 +92,7 @@ DES_quad_cksum(const unsigned char *input, DES_cblock output[], z1 = Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3( (*seed)[7]); - for (i = 0; ((i < 4) && (i < out_count)); i++) - { + for (i = 0; ((i < 4) && (i < out_count)); i++) { cp = input; l = length; while (l > 0) { diff --git a/lib/libcrypto/des/set_key.c b/lib/libcrypto/des/set_key.c index 07b8d03da1d..91116c4d163 100644 --- a/lib/libcrypto/des/set_key.c +++ b/lib/libcrypto/des/set_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: set_key.c,v 1.22 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: set_key.c,v 1.23 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -84,7 +84,8 @@ static const unsigned char odd_parity[256] = { 193, 193, 194, 194, 196, 196, 199, 199, 200, 200, 203, 203, 205, 205, 206, 206, 208, 208, 211, 211, 213, 213, 214, 214, 217, 217, 218, 218, 220, 220, 223, 223, 224, 224, 227, 227, 229, 229, 230, 230, 233, 233, 234, 234, 236, 236, 239, 239, - 241, 241, 242, 242, 244, 244, 247, 247, 248, 248, 251, 251, 253, 253, 254, 254}; + 241, 241, 242, 242, 244, 244, 247, 247, 248, 248, 251, 251, 253, 253, 254, 254, +}; void DES_set_odd_parity(DES_cblock *key) @@ -100,8 +101,7 @@ DES_check_key_parity(const_DES_cblock *key) { unsigned int i; - for (i = 0; i < DES_KEY_SZ; i++) - { + for (i = 0; i < DES_KEY_SZ; i++) { if ((*key)[i] != odd_parity[(*key)[i]]) return (0); } @@ -120,23 +120,24 @@ DES_check_key_parity(const_DES_cblock *key) #define NUM_WEAK_KEY 16 static const DES_cblock weak_keys[NUM_WEAK_KEY] = { /* weak keys */ - {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, - {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, - {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E}, - {0xE0,0xE0,0xE0,0xE0,0xF1,0xF1,0xF1,0xF1}, + {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, + {0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE}, + {0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E}, + {0xE0, 0xE0, 0xE0, 0xE0, 0xF1, 0xF1, 0xF1, 0xF1}, /* semi-weak keys */ - {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE}, - {0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01}, - {0x1F,0xE0,0x1F,0xE0,0x0E,0xF1,0x0E,0xF1}, - {0xE0,0x1F,0xE0,0x1F,0xF1,0x0E,0xF1,0x0E}, - {0x01,0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1}, - {0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1,0x01}, - {0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E,0xFE}, - {0xFE,0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E}, - {0x01,0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E}, - {0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E,0x01}, - {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, - {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; + {0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE}, + {0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01}, + {0x1F, 0xE0, 0x1F, 0xE0, 0x0E, 0xF1, 0x0E, 0xF1}, + {0xE0, 0x1F, 0xE0, 0x1F, 0xF1, 0x0E, 0xF1, 0x0E}, + {0x01, 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1}, + {0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1, 0x01}, + {0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E, 0xFE}, + {0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E}, + {0x01, 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E}, + {0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E, 0x01}, + {0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE}, + {0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1}, +}; int DES_is_weak_key(const_DES_cblock *key) @@ -161,7 +162,7 @@ DES_is_weak_key(const_DES_cblock *key) static const DES_LONG des_skb[8][64] = { { - /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ + /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000L, 0x00000010L, 0x20000000L, 0x20000010L, 0x00010000L, 0x00010010L, 0x20010000L, 0x20010010L, 0x00000800L, 0x00000810L, 0x20000800L, 0x20000810L, @@ -179,7 +180,7 @@ static const DES_LONG des_skb[8][64] = { 0x00080820L, 0x00080830L, 0x20080820L, 0x20080830L, 0x00090820L, 0x00090830L, 0x20090820L, 0x20090830L, }, { - /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ + /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ 0x00000000L, 0x02000000L, 0x00002000L, 0x02002000L, 0x00200000L, 0x02200000L, 0x00202000L, 0x02202000L, 0x00000004L, 0x02000004L, 0x00002004L, 0x02002004L, @@ -197,7 +198,7 @@ static const DES_LONG des_skb[8][64] = { 0x10000404L, 0x12000404L, 0x10002404L, 0x12002404L, 0x10200404L, 0x12200404L, 0x10202404L, 0x12202404L, }, { - /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ + /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ 0x00000000L, 0x00000001L, 0x00040000L, 0x00040001L, 0x01000000L, 0x01000001L, 0x01040000L, 0x01040001L, 0x00000002L, 0x00000003L, 0x00040002L, 0x00040003L, @@ -215,7 +216,7 @@ static const DES_LONG des_skb[8][64] = { 0x08000202L, 0x08000203L, 0x08040202L, 0x08040203L, 0x09000202L, 0x09000203L, 0x09040202L, 0x09040203L, }, { - /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ + /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ 0x00000000L, 0x00100000L, 0x00000100L, 0x00100100L, 0x00000008L, 0x00100008L, 0x00000108L, 0x00100108L, 0x00001000L, 0x00101000L, 0x00001100L, 0x00101100L, @@ -233,7 +234,7 @@ static const DES_LONG des_skb[8][64] = { 0x04021000L, 0x04121000L, 0x04021100L, 0x04121100L, 0x04021008L, 0x04121008L, 0x04021108L, 0x04121108L, }, { - /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ + /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000L, 0x10000000L, 0x00010000L, 0x10010000L, 0x00000004L, 0x10000004L, 0x00010004L, 0x10010004L, 0x20000000L, 0x30000000L, 0x20010000L, 0x30010000L, @@ -251,7 +252,7 @@ static const DES_LONG des_skb[8][64] = { 0x20101000L, 0x30101000L, 0x20111000L, 0x30111000L, 0x20101004L, 0x30101004L, 0x20111004L, 0x30111004L, }, { - /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ + /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ 0x00000000L, 0x08000000L, 0x00000008L, 0x08000008L, 0x00000400L, 0x08000400L, 0x00000408L, 0x08000408L, 0x00020000L, 0x08020000L, 0x00020008L, 0x08020008L, @@ -269,7 +270,7 @@ static const DES_LONG des_skb[8][64] = { 0x02020001L, 0x0A020001L, 0x02020009L, 0x0A020009L, 0x02020401L, 0x0A020401L, 0x02020409L, 0x0A020409L, }, { - /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ + /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ 0x00000000L, 0x00000100L, 0x00080000L, 0x00080100L, 0x01000000L, 0x01000100L, 0x01080000L, 0x01080100L, 0x00000010L, 0x00000110L, 0x00080010L, 0x00080110L, @@ -287,7 +288,7 @@ static const DES_LONG des_skb[8][64] = { 0x00200210L, 0x00200310L, 0x00280210L, 0x00280310L, 0x01200210L, 0x01200310L, 0x01280210L, 0x01280310L, }, { - /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ + /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ 0x00000000L, 0x04000000L, 0x00040000L, 0x04040000L, 0x00000002L, 0x04000002L, 0x00040002L, 0x04040002L, 0x00002000L, 0x04002000L, 0x00042000L, 0x04042000L, @@ -304,7 +305,8 @@ static const DES_LONG des_skb[8][64] = { 0x00000822L, 0x04000822L, 0x00040822L, 0x04040822L, 0x00002820L, 0x04002820L, 0x00042820L, 0x04042820L, 0x00002822L, 0x04002822L, 0x00042822L, 0x04042822L, - }}; + }, +}; int 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) void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) { - static const int shifts2[16] = {0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; + static const int shifts2[16] = {0, 0,1, 1,1, 1,1, 1,0, 1,1, 1,1, 1,1, 0}; DES_LONG c, d, t, s, t2; const unsigned char *in; DES_LONG *k; @@ -360,8 +362,7 @@ DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) ((d & 0x00ff0000L) >> 16L)|((c & 0xf0000000L) >> 4L)); c &= 0x0fffffffL; - for (i = 0; i < ITERATIONS; i++) - { + for (i = 0; i < ITERATIONS; i++) { if (shifts2[i]) { c = ((c >> 2L)|(c << 26L)); d = ((d >> 2L)|(d << 26L)); diff --git a/lib/libcrypto/des/spr.h b/lib/libcrypto/des/spr.h index 5e9b6d1e720..e0f413e4618 100644 --- a/lib/libcrypto/des/spr.h +++ b/lib/libcrypto/des/spr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: spr.h,v 1.7 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: spr.h,v 1.8 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -203,6 +203,7 @@ const DES_LONG DES_SPtrans[8][64] = { 0x00820000L, 0x00020080L, 0x20020080L, 0x20800000L, 0x00000080L, 0x20820000L, 0x00820080L, 0x00000000L, 0x20000000L, 0x20800080L, 0x00020000L, 0x00820080L, - }}; + }, +}; __END_HIDDEN_DECLS diff --git a/lib/libcrypto/des/str2key.c b/lib/libcrypto/des/str2key.c index c9bd9aad1b2..dd17a441b74 100644 --- a/lib/libcrypto/des/str2key.c +++ b/lib/libcrypto/des/str2key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: str2key.c,v 1.12 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: str2key.c,v 1.13 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -72,8 +72,7 @@ DES_string_to_key(const char *str, DES_cblock *key) for (i = 0; i < length; i++) (*key)[i % 8] ^= (str[i] << 1); #else /* MIT COMPATIBLE */ - for (i = 0; i < length; i++) - { + for (i = 0; i < length; i++) { j = str[i]; if ((i % 16) < 8) (*key)[i % 8] ^= (j << 1); @@ -111,13 +110,11 @@ DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) length = strlen(str); #ifdef OLD_STR_TO_KEY if (length <= 8) { - for (i = 0; i < length; i++) - { + for (i = 0; i < length; i++) { (*key2)[i] = (*key1)[i] = (str[i] << 1); } } else { - for (i = 0; i < length; i++) - { + for (i = 0; i < length; i++) { if ((i/8) & 1) (*key2)[i % 8] ^= (str[i] << 1); else @@ -125,8 +122,7 @@ DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) } } #else /* MIT COMPATIBLE */ - for (i = 0; i < length; i++) - { + for (i = 0; i < length; i++) { j = str[i]; if ((i % 32) < 16) { if ((i % 16) < 8) diff --git a/lib/libcrypto/des/xcbc_enc.c b/lib/libcrypto/des/xcbc_enc.c index 754d989fbfc..87f348a9ab4 100644 --- a/lib/libcrypto/des/xcbc_enc.c +++ b/lib/libcrypto/des/xcbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xcbc_enc.c,v 1.11 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: xcbc_enc.c,v 1.12 2023/07/08 07:34:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -86,8 +86,7 @@ DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, if (enc) { c2l(iv, tout0); c2l(iv, tout1); - for (l -= 8; l >= 0; l -= 8) - { + for (l -= 8; l >= 0; l -= 8) { c2l(in, tin0); c2l(in, tin1); tin0 ^= tout0 ^ inW0; @@ -118,8 +117,7 @@ DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, } else { c2l(iv, xor0); c2l(iv, xor1); - for (l -= 8; l > 0; l -= 8) - { + for (l -= 8; l > 0; l -= 8) { c2l(in, tin0); tin[0] = tin0 ^ outW0; c2l(in, tin1); -- 2.20.1