diff options
Diffstat (limited to '')
-rw-r--r-- | libbb/yescrypt/alg-sha256.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libbb/yescrypt/alg-sha256.c b/libbb/yescrypt/alg-sha256.c index 20e8d1ee4..dc748c968 100644 --- a/libbb/yescrypt/alg-sha256.c +++ b/libbb/yescrypt/alg-sha256.c | |||
@@ -47,9 +47,12 @@ PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, | |||
47 | 47 | ||
48 | /* Iterate through the blocks. */ | 48 | /* Iterate through the blocks. */ |
49 | for (i = 0; dkLen != 0; ) { | 49 | for (i = 0; dkLen != 0; ) { |
50 | uint64_t U[32 / 8]; | 50 | long U[32 / sizeof(long)]; |
51 | uint64_t T[32 / 8]; | 51 | long T[32 / sizeof(long)]; |
52 | uint64_t j; | 52 | // Do not make these ^^ uint64_t[]. Keep them long[]. |
53 | // Even though the XORing loop below is optimized out, | ||
54 | // gcc is not smart enough to realize that 64-bit alignment of the stack | ||
55 | // is no longer useful, and generates ~50 more bytes of code on i386... | ||
53 | uint32_t ivec; | 56 | uint32_t ivec; |
54 | size_t clen; | 57 | size_t clen; |
55 | int k; | 58 | int k; |
@@ -64,13 +67,15 @@ PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, | |||
64 | //does libbb need a non-vararg version with just one (buf,len)? | 67 | //does libbb need a non-vararg version with just one (buf,len)? |
65 | 68 | ||
66 | if (c > 1) { | 69 | if (c > 1) { |
70 | //in yescrypt, c is always 1, so this if() branch is optimized out | ||
71 | uint64_t j; | ||
67 | /* T_i = U_1 ... */ | 72 | /* T_i = U_1 ... */ |
68 | memcpy(U, T, 32); | 73 | memcpy(U, T, 32); |
69 | for (j = 2; j <= c; j++) { | 74 | for (j = 2; j <= c; j++) { |
70 | /* Compute U_j. */ | 75 | /* Compute U_j. */ |
71 | hmac_peek_hash(&Phctx, (void*)U, U, 32, NULL); | 76 | hmac_peek_hash(&Phctx, (void*)U, U, 32, NULL); |
72 | /* ... xor U_j ... */ | 77 | /* ... xor U_j ... */ |
73 | for (k = 0; k < 32 / 8; k++) | 78 | for (k = 0; k < 32 / sizeof(long); k++) |
74 | T[k] ^= U[k]; | 79 | T[k] ^= U[k]; |
75 | //TODO: xorbuf32_aligned_long(T, U); | 80 | //TODO: xorbuf32_aligned_long(T, U); |
76 | } | 81 | } |