aboutsummaryrefslogtreecommitdiff
path: root/libbb/hash_md5_sha.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* libbb: fix sha1 on !x86 if CONFIG_SHA1_HWACCEL=yRudi Heitbaum2024-10-061-0/+2
| | | | | | | | | | | fixes non i386 and x86 builds libbb/hash_md5_sha.c: In function 'sha1_end': libbb/hash_md5_sha.c:1316:35: error: 'sha1_process_block64_shaNI' undeclared 1316 | || ctx->process_block == sha1_process_block64_shaNI Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tls: fix CONFIG_FEATURE_TLS_SHA1=y + CONFIG_SHA1_HWACCEL=yDenys Vlasenko2024-07-121-6/+23
| | | | | | | | | | | | | | | | The check for result hash size was buggy for CONFIG_SHA1_HWACCEL=y. While at it, document CPUID use a bit better. function old new delta get_shaNI - 28 +28 sha1_end 66 79 +13 sha256_begin 83 60 -23 sha1_begin 111 88 -23 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/2 up/down: 41/-46) Total: -5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha: do not read shaNI variable twice, and factor out its settingDenys Vlasenko2023-03-291-12/+16
| | | | | | | | | | | | My gcc inlines both calls, so instead of "-20 bytes" I get only this: function old new delta sha256_begin 84 83 -1 sha1_begin 114 111 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-4) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha: fix sha-NI instruction detectionDenys Vlasenko2023-03-291-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha256: optional x86 hardware accelerated hashingDenys Vlasenko2022-02-031-20/+34
| | | | | | | | | | | | | | | | | | | | 64 bit: function old new delta sha256_process_block64_shaNI - 730 +730 .rodata 108314 108586 +272 sha256_begin 31 83 +52 ------------------------------------------------------------------------------ (add/remove: 5/1 grow/shrink: 2/0 up/down: 1055/-1) Total: 1054 bytes 32 bit: function old new delta sha256_process_block64_shaNI - 747 +747 .rodata 104318 104590 +272 sha256_begin 29 84 +55 ------------------------------------------------------------------------------ (add/remove: 5/1 grow/shrink: 2/0 up/down: 1075/-1) Total: 1074 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: simplify cpuid codeDenys Vlasenko2022-01-081-32/+10
| | | | | | | function old new delta sha1_begin 107 106 -1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: optional i686 hardware accelerates hashingDenys Vlasenko2022-01-071-1/+20
| | | | | | | | | | | | function old new delta sha1_process_block64_shaNI - 524 +524 sha1_begin 57 114 +57 .rodata 104353 104369 +16 static.shaNI - 1 +1 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 2/0 up/down: 598/0) Total: 598 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: optional x86-64 hardware accelerates hashingDenys Vlasenko2022-01-071-1/+37
| | | | | | | | | | | | function old new delta sha1_process_block64_shaNI - 510 +510 sha1_begin 52 107 +55 .rodata 108285 108301 +16 static.shaNI - 1 +1 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 2/0 up/down: 582/0) Total: 582 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: x86_64 version: move to a separate .S file, no code changesDenys Vlasenko2022-01-031-389/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: code shrink in medium-speed versionDenys Vlasenko2022-01-021-2/+2
| | | | | | | function old new delta sha1_process_block64 654 641 -13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: x86_64 version: bswap in 64-bit chunksDenys Vlasenko2022-01-011-20/+22
| | | | | | | function old new delta sha1_process_block64 3562 3570 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: shrink x86_64 version - use r8..15 for W[8..15]Denys Vlasenko2022-01-011-60/+239
| | | | | | | function old new delta sha1_process_block64 3683 3562 -121 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: assembly versions for x86Denys Vlasenko2022-01-011-0/+417
| | | | | | | | | | 32 bits: function old new delta sha1_process_block64 3950 3657 -293 64 bits: sha1_process_block64 4167 3683 -484 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: shrink and speed up fully unrolled versionDenys Vlasenko2021-12-311-0/+22
| | | | | | | function old new delta sha1_process_block64 4149 3950 -199 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: add config-selectable partially unrolled versionDenys Vlasenko2021-12-301-4/+96
| | | | | | | | | | function old new delta sha1_process_block64 364 732 +368 static.rconsts 16 - -16 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 368/-16) Total: 352 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/sha1: add config-selectable fully unrolled version, closes 14391Denys Vlasenko2021-12-301-7/+77
| | | | | | | | | | function old new delta sha1_process_block64 364 4167 +3803 static.rconsts 16 - -16 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 3803/-16) Total: 3787 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: cose shrink in sha1Denys Vlasenko2021-12-281-5/+2
| | | | | | | function old new delta sha1_process_block64 356 342 -14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nillyDenys Vlasenko2020-11-301-11/+11
| | | | | | | | 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>
* libbb: fold common64_hash() into its only userDenys Vlasenko2020-09-301-47/+28
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: add comment on sha384Denys Vlasenko2018-11-261-0/+5
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* whitespace and comment format fixes, no code changesDenys Vlasenko2017-10-051-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* tls: add 2nd cipher_id, TLS_RSA_WITH_AES_128_CBC_SHA, so far it doesn't workDenys Vlasenko2017-01-241-5/+10
| | | | | | | | | | Good news that TLS_RSA_WITH_AES_256_CBC_SHA256 still works with new code ;) This change adds inevitable extension to have different sized hashes and AES key sizes. In libbb, md5_end() and shaX_end() are extended to return result size instead of void - this helps *a lot* in tls (the cost is ~5 bytes per _end() function). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha512: use larger constant table only if sha512 is in fact selectedDenys Vlasenko2017-01-151-46/+66
| | | | | | | function old new delta sha_K 640 256 -384 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: fix to conform to final SHA3 padding standard, add -a BITS optionDenys Vlasenko2016-08-291-20/+35
| | | | | | | | | | | | function old new delta hash_file 331 396 +65 md5_sha1_sum_main 485 538 +53 packed_usage 30423 30464 +41 sha3_begin 17 31 +14 sha3_hash 101 110 +9 sha3_end 41 49 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* md5sum: code shrinkDenys Vlasenko2015-10-071-10/+6
| | | | | | | | | | | | For CONFIG_MD5_SMALL=1: function old new delta md5_process_block64 925 881 -44 For CONFIG_MD5_SMALL=0: function old new delta md5_process_block64 1603 1586 -17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: tweak comments and indentationDenys Vlasenko2014-07-301-13/+14
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: code shrink (and speedup for SHA3_SMALL=0)Denys Vlasenko2014-07-301-16/+66
| | | | | | | function old new delta sha3_process_block72 1454 1359 -95 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: add 32-bit optimized bit-sliced implementationDenys Vlasenko2014-07-251-14/+242
| | | | | | | | It is an interesting trick, but so far I only managed to make it work correctly, not to make it faster and/or smaller. The code is ifdefed out for now. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* md5/sha512: a better fix for strict aliasing warningsDenys Vlasenko2013-06-271-3/+3
| | | | | | | The locations *are* well-aligned for direct stores on any architecture. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* md5/sha512: fix strict aliasing warningsMike Frysinger2013-06-191-3/+3
| | | | | | | | | | | | | | | | | | | | If the target can tolerate these issues, then gcc is smart enough to generate the same code (x86_64 produces the same code). If the target can't, then it needs the memcpy anyways. libbb/hash_md5_sha.c: In function 'common64_end': libbb/hash_md5_sha.c:87:4: warning: dereferencing type-punned pointer will break strict-aliasing rules *(uint64_t *) (&ctx->wbuffer[64 - 8]) = t; libbb/hash_md5_sha.c: In function 'sha512_end': libbb/hash_md5_sha.c:886:4: warning: dereferencing type-punned pointer will break strict-aliasing rules *(uint64_t *) (&ctx->wbuffer[128 - 8]) = t; libbb/hash_md5_sha.c:889:4: warning: dereferencing type-punned pointer will break strict-aliasing rules *(uint64_t *) (&ctx->wbuffer[128 - 16]) = t; Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* sha3: code shrinkDenys Vlasenko2013-01-201-32/+59
| | | | | | | function old new delta sha3_hash 155 101 -54 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: s/sha3_process_block76/sha3_process_block72/Denys Vlasenko2013-01-161-4/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: rename KeccakF->sha3_process_block76.Denys Vlasenko2013-01-161-79/+81
| | | | | | | | This brings the naming more in line with other hashes. Pulled most statics and constants into it. Also noticed that two byte arrays are 1 element too big. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: cache ctx->bytes_queuedDenys Vlasenko2013-01-151-11/+11
| | | | | | | function old new delta sha3_hash 171 155 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: remove two "small code" codepaths: I can't reproduce code size win on ↵Denys Vlasenko2013-01-151-43/+18
| | | | | | them anymore Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: tweak choice of a fast code path for 64-bitDenys Vlasenko2013-01-151-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: cosmetic tweaks to various names, comments. No logic changes.Denys Vlasenko2013-01-151-61/+63
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: code shrinkDenys Vlasenko2013-01-151-26/+36
| | | | | | | | function old new delta KeccakF 1053 1078 +25 KeccakF_RoundConstants 192 48 -144 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: code shrinkDenys Vlasenko2013-01-151-13/+18
| | | | | | | function old new delta KeccakF 1064 1053 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: another speedup for SHA3_SMALL=0 caseDenys Vlasenko2013-01-151-10/+25
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3: make size/speed optimization decision configurableDenys Vlasenko2013-01-151-19/+58
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha3sum: new appletLauri Kasanen2013-01-141-0/+194
| | | | | | | | | | | | | | | | | | | | | | function old new delta KeccakF - 496 +496 KeccakF_RoundConstants - 192 +192 sha3_hash - 171 +171 sha3_end - 40 +40 hash_file 274 299 +25 KeccakF_RotationConstants - 25 +25 KeccakF_PiLane - 25 +25 packed_usage 29213 29232 +19 sha3_begin - 18 +18 KeccakF_Mod5 - 10 +10 applet_names 2445 2453 +8 applet_main 1420 1424 +4 applet_nameofs 710 712 +2 ------------------------------------------------------------------------------ (add/remove: 8/0 grow/shrink: 9/7 up/down: 1049/-54) Total: ~995 bytes Signed-off-by: Lauri Kasanen <curaga@operamail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* regularize options which control size/speed tradeDenys Vlasenko2011-09-101-16/+16
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* whitespace cleanupDenys Vlasenko2010-10-291-4/+4
| | | | Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* sha1: small tweak for clearer code, no logic changesDenys Vlasenko2010-10-241-1/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sha1: use Rob's code, it's smaller and fasterDenys Vlasenko2010-10-241-54/+51
| | | | | | | | | | function old new delta static.rconsts - 16 +16 sha1_process_block64 460 298 -162 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 16/-162) Total: -146 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* md5: remove outdated commentDenys Vlasenko2010-10-191-3/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/hash_md5_sha: use common ctx and code for md5 and sha1/256Denys Vlasenko2010-10-191-482/+416
| | | | | | | | | | | | | | function old new delta sha256_process_block64 421 433 +12 md5_crypt 578 587 +9 md5_begin 43 50 +7 md5_hash 99 97 -2 sha1_end 85 82 -3 md5_end 36 31 -5 common64_end 93 86 -7 sha1_hash 97 - -97 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* hash_md5_sha: use common finalization routine for MD5 and sha1/256. -15 bytesDenys Vlasenko2010-10-181-78/+85
| | | | Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* libbb/hash_sha.c -> libbb/hash_md5_sha.cDenys Vlasenko2010-10-181-0/+962
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>