aboutsummaryrefslogtreecommitdiff
path: root/libbb/hash_md5_sha.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2022-01-07 01:32:13 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2022-01-07 01:32:13 +0100
commita96ccbefe417aaac6a2ce59c788e01fc0f83902f (patch)
tree4151347572dcbce6777ba66c40cf0bc0135ee491 /libbb/hash_md5_sha.c
parent711e20ecb85d13f98ba3e2bdcb344ee7534829c4 (diff)
downloadbusybox-w32-a96ccbefe417aaac6a2ce59c788e01fc0f83902f.tar.gz
busybox-w32-a96ccbefe417aaac6a2ce59c788e01fc0f83902f.tar.bz2
busybox-w32-a96ccbefe417aaac6a2ce59c788e01fc0f83902f.zip
libbb/sha1: optional i686 hardware accelerates hashing
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>
Diffstat (limited to 'libbb/hash_md5_sha.c')
-rw-r--r--libbb/hash_md5_sha.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
index 4c6904b48..0b3af723a 100644
--- a/libbb/hash_md5_sha.c
+++ b/libbb/hash_md5_sha.c
@@ -1143,6 +1143,25 @@ static void FAST_FUNC sha512_process_block128(sha512_ctx_t *ctx)
1143#endif /* NEED_SHA512 */ 1143#endif /* NEED_SHA512 */
1144 1144
1145#if ENABLE_SHA1_HWACCEL 1145#if ENABLE_SHA1_HWACCEL
1146# if defined(__GNUC__) && defined(__i386__)
1147static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
1148{
1149 asm (
1150 " cpuid\n"
1151 : "=a"(*eax), /* Output */
1152 "=b"(*ebx),
1153 "=c"(*ecx),
1154 "=d"(*edx)
1155 : "0"(*eax), /* Input */
1156 "1"(*ebx),
1157 "2"(*ecx),
1158 "3"(*edx)
1159 /* No clobbered registers */
1160 );
1161}
1162struct ASM_expects_76_shaNI { char t[1 - 2*(offsetof(sha1_ctx_t, hash) != 76)]; };
1163void FAST_FUNC sha1_process_block64_shaNI(sha1_ctx_t *ctx);
1164# endif
1146# if defined(__GNUC__) && defined(__x86_64__) 1165# if defined(__GNUC__) && defined(__x86_64__)
1147static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) 1166static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
1148{ 1167{
@@ -1174,7 +1193,7 @@ void FAST_FUNC sha1_begin(sha1_ctx_t *ctx)
1174 ctx->total64 = 0; 1193 ctx->total64 = 0;
1175 ctx->process_block = sha1_process_block64; 1194 ctx->process_block = sha1_process_block64;
1176#if ENABLE_SHA1_HWACCEL 1195#if ENABLE_SHA1_HWACCEL
1177# if defined(__GNUC__) && defined(__x86_64__) 1196# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
1178 { 1197 {
1179 static smallint shaNI; 1198 static smallint shaNI;
1180 if (!shaNI) { 1199 if (!shaNI) {