aboutsummaryrefslogtreecommitdiff
path: root/libbb/hash_md5_sha.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-11-30 13:03:03 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-11-30 13:03:03 +0100
commit965b795b87c59ed45cc7f16a62301dbae65b1627 (patch)
tree958e486f4f23177746ddee11913d3b59ff4e7f8e /libbb/hash_md5_sha.c
parent2fba2f5bb99145eaa1635fe5a162426158d56a2c (diff)
downloadbusybox-w32-965b795b87c59ed45cc7f16a62301dbae65b1627.tar.gz
busybox-w32-965b795b87c59ed45cc7f16a62301dbae65b1627.tar.bz2
busybox-w32-965b795b87c59ed45cc7f16a62301dbae65b1627.zip
decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly
text data bss dec hex filename 1021988 559 5052 1027599 fae0f busybox_old 1021236 559 5052 1026847 fab1f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/hash_md5_sha.c')
-rw-r--r--libbb/hash_md5_sha.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
index d8f210173..e0db8ce67 100644
--- a/libbb/hash_md5_sha.c
+++ b/libbb/hash_md5_sha.c
@@ -111,7 +111,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
111 They are defined in RFC 1321 as 111 They are defined in RFC 1321 as
112 T[i] = (int)(2^32 * fabs(sin(i))), i=1..64 112 T[i] = (int)(2^32 * fabs(sin(i))), i=1..64
113 */ 113 */
114 static const uint32_t C_array[] = { 114 static const uint32_t C_array[] ALIGN4 = {
115 /* round 1 */ 115 /* round 1 */
116 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 116 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
117 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, 117 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
@@ -492,7 +492,7 @@ unsigned FAST_FUNC md5_end(md5_ctx_t *ctx, void *resbuf)
492 492
493static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) 493static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx)
494{ 494{
495 static const uint32_t rconsts[] = { 495 static const uint32_t rconsts[] ALIGN4 = {
496 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 496 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
497 }; 497 };
498 int i, j; 498 int i, j;
@@ -567,7 +567,7 @@ typedef uint64_t sha_K_int;
567typedef uint32_t sha_K_int; 567typedef uint32_t sha_K_int;
568# define K(v) (uint32_t)(v >> 32) 568# define K(v) (uint32_t)(v >> 32)
569#endif 569#endif
570static const sha_K_int sha_K[] = { 570static const sha_K_int sha_K[] ALIGN8 = {
571 K(0x428a2f98d728ae22ULL), K(0x7137449123ef65cdULL), 571 K(0x428a2f98d728ae22ULL), K(0x7137449123ef65cdULL),
572 K(0xb5c0fbcfec4d3b2fULL), K(0xe9b5dba58189dbbcULL), 572 K(0xb5c0fbcfec4d3b2fULL), K(0xe9b5dba58189dbbcULL),
573 K(0x3956c25bf348b538ULL), K(0x59f111f1b605d019ULL), 573 K(0x3956c25bf348b538ULL), K(0x59f111f1b605d019ULL),
@@ -760,7 +760,7 @@ void FAST_FUNC sha1_begin(sha1_ctx_t *ctx)
760 ctx->process_block = sha1_process_block64; 760 ctx->process_block = sha1_process_block64;
761} 761}
762 762
763static const uint32_t init256[] = { 763static const uint32_t init256[] ALIGN4 = {
764 0, 764 0,
765 0, 765 0,
766 0x6a09e667, 766 0x6a09e667,
@@ -773,7 +773,7 @@ static const uint32_t init256[] = {
773 0x5be0cd19, 773 0x5be0cd19,
774}; 774};
775#if NEED_SHA512 775#if NEED_SHA512
776static const uint32_t init512_lo[] = { 776static const uint32_t init512_lo[] ALIGN4 = {
777 0, 777 0,
778 0, 778 0,
779 0xf3bcc908, 779 0xf3bcc908,
@@ -1009,7 +1009,7 @@ static void sha3_process_block72(uint64_t *state)
1009 1009
1010#if OPTIMIZE_SHA3_FOR_32 1010#if OPTIMIZE_SHA3_FOR_32
1011 /* 1011 /*
1012 static const uint32_t IOTA_CONST_0[NROUNDS] = { 1012 static const uint32_t IOTA_CONST_0[NROUNDS] ALIGN4 = {
1013 0x00000001UL, 1013 0x00000001UL,
1014 0x00000000UL, 1014 0x00000000UL,
1015 0x00000000UL, 1015 0x00000000UL,
@@ -1038,7 +1038,7 @@ static void sha3_process_block72(uint64_t *state)
1038 ** bits are in lsb: 0101 0000 1111 0100 1111 0001 1038 ** bits are in lsb: 0101 0000 1111 0100 1111 0001
1039 */ 1039 */
1040 uint32_t IOTA_CONST_0bits = (uint32_t)(0x0050f4f1); 1040 uint32_t IOTA_CONST_0bits = (uint32_t)(0x0050f4f1);
1041 static const uint32_t IOTA_CONST_1[NROUNDS] = { 1041 static const uint32_t IOTA_CONST_1[NROUNDS] ALIGN4 = {
1042 0x00000000UL, 1042 0x00000000UL,
1043 0x00000089UL, 1043 0x00000089UL,
1044 0x8000008bUL, 1044 0x8000008bUL,
@@ -1174,7 +1174,7 @@ static void sha3_process_block72(uint64_t *state)
1174 combine_halves(state); 1174 combine_halves(state);
1175#else 1175#else
1176 /* Native 64-bit algorithm */ 1176 /* Native 64-bit algorithm */
1177 static const uint16_t IOTA_CONST[NROUNDS] = { 1177 static const uint16_t IOTA_CONST[NROUNDS] ALIGN2 = {
1178 /* Elements should be 64-bit, but top half is always zero 1178 /* Elements should be 64-bit, but top half is always zero
1179 * or 0x80000000. We encode 63rd bits in a separate word below. 1179 * or 0x80000000. We encode 63rd bits in a separate word below.
1180 * Same is true for 31th bits, which lets us use 16-bit table 1180 * Same is true for 31th bits, which lets us use 16-bit table
@@ -1210,15 +1210,15 @@ static void sha3_process_block72(uint64_t *state)
1210 /* bit for CONST[0] is in msb: 0001 0110 0011 1000 0001 1011 */ 1210 /* bit for CONST[0] is in msb: 0001 0110 0011 1000 0001 1011 */
1211 const uint32_t IOTA_CONST_bit31 = (uint32_t)(0x16381b00); 1211 const uint32_t IOTA_CONST_bit31 = (uint32_t)(0x16381b00);
1212 1212
1213 static const uint8_t ROT_CONST[24] = { 1213 static const uint8_t ROT_CONST[24] ALIGN1 = {
1214 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 1214 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
1215 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44, 1215 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44,
1216 }; 1216 };
1217 static const uint8_t PI_LANE[24] = { 1217 static const uint8_t PI_LANE[24] ALIGN1 = {
1218 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 1218 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
1219 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1, 1219 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1,
1220 }; 1220 };
1221 /*static const uint8_t MOD5[10] = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/ 1221 /*static const uint8_t MOD5[10] ALIGN1 = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/
1222 1222
1223 unsigned x; 1223 unsigned x;
1224 unsigned round; 1224 unsigned round;