mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
add AVX to clobber list
This commit is contained in:
parent
992603496e
commit
34df1b1646
14
Crypto.cpp
14
Crypto.cpp
|
@ -387,8 +387,10 @@ namespace crypto
|
||||||
const uint64_t IPAD = 0x3636363636363636;
|
const uint64_t IPAD = 0x3636363636363636;
|
||||||
const uint64_t OPAD = 0x5C5C5C5C5C5C5C5C;
|
const uint64_t OPAD = 0x5C5C5C5C5C5C5C5C;
|
||||||
|
|
||||||
|
#if defined(__AVX__)
|
||||||
static const uint64_t ipads[] = { IPAD, IPAD, IPAD, IPAD };
|
static const uint64_t ipads[] = { IPAD, IPAD, IPAD, IPAD };
|
||||||
static const uint64_t opads[] = { OPAD, OPAD, OPAD, OPAD };
|
static const uint64_t opads[] = { OPAD, OPAD, OPAD, OPAD };
|
||||||
|
#endif
|
||||||
|
|
||||||
void HMACMD5Digest (uint8_t * msg, size_t len, const MACKey& key, uint8_t * digest)
|
void HMACMD5Digest (uint8_t * msg, size_t len, const MACKey& key, uint8_t * digest)
|
||||||
// key is 32 bytes
|
// key is 32 bytes
|
||||||
|
@ -413,7 +415,7 @@ namespace crypto
|
||||||
"movups %%xmm0, 80%[hash] \n" // zero last 16 bytes
|
"movups %%xmm0, 80%[hash] \n" // zero last 16 bytes
|
||||||
: [buf]"=m"(*buf), [hash]"=m"(*hash)
|
: [buf]"=m"(*buf), [hash]"=m"(*hash)
|
||||||
: [key]"m"(*(const uint8_t *)key), [ipad]"m"(*ipads), [opad]"m"(*opads)
|
: [key]"m"(*(const uint8_t *)key), [ipad]"m"(*ipads), [opad]"m"(*opads)
|
||||||
: "memory"
|
: "memory", "%xmm0" // TODO: change to %ymm0 later
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
// ikeypad
|
// ikeypad
|
||||||
|
@ -421,13 +423,19 @@ namespace crypto
|
||||||
buf[1] = key.GetLL ()[1] ^ IPAD;
|
buf[1] = key.GetLL ()[1] ^ IPAD;
|
||||||
buf[2] = key.GetLL ()[2] ^ IPAD;
|
buf[2] = key.GetLL ()[2] ^ IPAD;
|
||||||
buf[3] = key.GetLL ()[3] ^ IPAD;
|
buf[3] = key.GetLL ()[3] ^ IPAD;
|
||||||
memcpy (buf + 4, ipads, 32);
|
buf[4] = IPAD;
|
||||||
|
buf[5] = IPAD;
|
||||||
|
buf[6] = IPAD;
|
||||||
|
buf[7] = IPAD;
|
||||||
// okeypad
|
// okeypad
|
||||||
hash[0] = key.GetLL ()[0] ^ OPAD;
|
hash[0] = key.GetLL ()[0] ^ OPAD;
|
||||||
hash[1] = key.GetLL ()[1] ^ OPAD;
|
hash[1] = key.GetLL ()[1] ^ OPAD;
|
||||||
hash[2] = key.GetLL ()[2] ^ OPAD;
|
hash[2] = key.GetLL ()[2] ^ OPAD;
|
||||||
hash[3] = key.GetLL ()[3] ^ OPAD;
|
hash[3] = key.GetLL ()[3] ^ OPAD;
|
||||||
memcpy (hash + 4, opads, 32);
|
hash[4] = OPAD;
|
||||||
|
hash[5] = OPAD;
|
||||||
|
hash[6] = OPAD;
|
||||||
|
hash[7] = OPAD;
|
||||||
// fill last 16 bytes with zeros (first hash size assumed 32 bytes in I2P)
|
// fill last 16 bytes with zeros (first hash size assumed 32 bytes in I2P)
|
||||||
memset (hash + 10, 0, 16);
|
memset (hash + 10, 0, 16);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue