mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-30 23:13:31 +01:00
Crypto: remove specific PBKDF2 optimization for block index encoding (except in 16-bit bootloader) in order to make code clearer and avoid bad usage in the future if this implementation is used to generate more bytes than today.
This commit is contained in:
parent
7c154a3f26
commit
194b641ebd
@ -171,8 +171,14 @@ static void derive_u_sha256 (char *salt, int salt_len, uint32 iterations, int b,
|
|||||||
memcpy (k, salt, salt_len); /* salt */
|
memcpy (k, salt, salt_len); /* salt */
|
||||||
|
|
||||||
/* big-endian block number */
|
/* big-endian block number */
|
||||||
|
#ifdef TC_WINDOWS_BOOT
|
||||||
|
/* specific case of 16-bit bootloader: b is a 16-bit integer that is always < 256 */
|
||||||
memset (&k[salt_len], 0, 3);
|
memset (&k[salt_len], 0, 3);
|
||||||
k[salt_len + 3] = (char) b;
|
k[salt_len + 3] = (char) b;
|
||||||
|
#else
|
||||||
|
b = bswap_32 (b);
|
||||||
|
memcpy (&k[salt_len], &b, 4);
|
||||||
|
#endif
|
||||||
|
|
||||||
hmac_sha256_internal (k, salt_len + 4, hmac);
|
hmac_sha256_internal (k, salt_len + 4, hmac);
|
||||||
memcpy (u, k, SHA256_DIGESTSIZE);
|
memcpy (u, k, SHA256_DIGESTSIZE);
|
||||||
@ -377,8 +383,8 @@ static void derive_u_sha512 (char *salt, int salt_len, uint32 iterations, int b,
|
|||||||
/* iteration 1 */
|
/* iteration 1 */
|
||||||
memcpy (k, salt, salt_len); /* salt */
|
memcpy (k, salt, salt_len); /* salt */
|
||||||
/* big-endian block number */
|
/* big-endian block number */
|
||||||
memset (&k[salt_len], 0, 3);
|
b = bswap_32 (b);
|
||||||
k[salt_len + 3] = (char) b;
|
memcpy (&k[salt_len], &b, 4);
|
||||||
|
|
||||||
hmac_sha512_internal (k, salt_len + 4, hmac);
|
hmac_sha512_internal (k, salt_len + 4, hmac);
|
||||||
memcpy (u, k, SHA512_DIGESTSIZE);
|
memcpy (u, k, SHA512_DIGESTSIZE);
|
||||||
@ -587,8 +593,14 @@ static void derive_u_ripemd160 (char *salt, int salt_len, uint32 iterations, int
|
|||||||
memcpy (k, salt, salt_len); /* salt */
|
memcpy (k, salt, salt_len); /* salt */
|
||||||
|
|
||||||
/* big-endian block number */
|
/* big-endian block number */
|
||||||
|
#ifdef TC_WINDOWS_BOOT
|
||||||
|
/* specific case of 16-bit bootloader: b is a 16-bit integer that is always < 256*/
|
||||||
memset (&k[salt_len], 0, 3);
|
memset (&k[salt_len], 0, 3);
|
||||||
k[salt_len + 3] = (char) b;
|
k[salt_len + 3] = (char) b;
|
||||||
|
#else
|
||||||
|
b = bswap_32 (b);
|
||||||
|
memcpy (&k[salt_len], &b, 4);
|
||||||
|
#endif
|
||||||
|
|
||||||
hmac_ripemd160_internal (k, salt_len + 4, hmac);
|
hmac_ripemd160_internal (k, salt_len + 4, hmac);
|
||||||
memcpy (u, k, RIPEMD160_DIGESTSIZE);
|
memcpy (u, k, RIPEMD160_DIGESTSIZE);
|
||||||
@ -800,8 +812,8 @@ static void derive_u_whirlpool (char *salt, int salt_len, uint32 iterations, int
|
|||||||
/* iteration 1 */
|
/* iteration 1 */
|
||||||
memcpy (k, salt, salt_len); /* salt */
|
memcpy (k, salt, salt_len); /* salt */
|
||||||
/* big-endian block number */
|
/* big-endian block number */
|
||||||
memset (&k[salt_len], 0, 3);
|
b = bswap_32 (b);
|
||||||
k[salt_len + 3] = (char) b;
|
memcpy (&k[salt_len], &b, 4);
|
||||||
|
|
||||||
hmac_whirlpool_internal (k, salt_len + 4, hmac);
|
hmac_whirlpool_internal (k, salt_len + 4, hmac);
|
||||||
memcpy (u, k, WHIRLPOOL_DIGESTSIZE);
|
memcpy (u, k, WHIRLPOOL_DIGESTSIZE);
|
||||||
@ -1015,8 +1027,8 @@ static void derive_u_streebog (char *salt, int salt_len, uint32 iterations, int
|
|||||||
/* iteration 1 */
|
/* iteration 1 */
|
||||||
memcpy (k, salt, salt_len); /* salt */
|
memcpy (k, salt, salt_len); /* salt */
|
||||||
/* big-endian block number */
|
/* big-endian block number */
|
||||||
memset (&k[salt_len], 0, 3);
|
b = bswap_32 (b);
|
||||||
k[salt_len + 3] = (char) b;
|
memcpy (&k[salt_len], &b, 4);
|
||||||
|
|
||||||
hmac_streebog_internal (k, salt_len + 4, hmac);
|
hmac_streebog_internal (k, salt_len + 4, hmac);
|
||||||
memcpy (u, k, STREEBOG_DIGESTSIZE);
|
memcpy (u, k, STREEBOG_DIGESTSIZE);
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
#define CRYPTOPP_BYTESWAP_AVAILABLE
|
#define CRYPTOPP_BYTESWAP_AVAILABLE
|
||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
#elif defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(_UEFI)
|
#elif defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(_UEFI)
|
||||||
|
#pragma intrinsic(_byteswap_ulong,_byteswap_uint64)
|
||||||
#define CRYPTOPP_BYTESWAP_AVAILABLE
|
#define CRYPTOPP_BYTESWAP_AVAILABLE
|
||||||
#define bswap_32(x) _byteswap_ulong(x)
|
#define bswap_32(x) _byteswap_ulong(x)
|
||||||
#define bswap_64(x) _byteswap_uint64(x)
|
#define bswap_64(x) _byteswap_uint64(x)
|
||||||
|
Loading…
Reference in New Issue
Block a user