Browse Source

correct alignment for polyKey

pull/1274/head
orignal 6 years ago
parent
commit
fa620e41a4
  1. 6
      libi2pd/Crypto.cpp

6
libi2pd/Crypto.cpp

@ -1088,9 +1088,9 @@ namespace crypto
bool ret = true; bool ret = true;
#if LEGACY_OPENSSL #if LEGACY_OPENSSL
// generate one time poly key // generate one time poly key
uint8_t polyKey[64]; uint64_t polyKey[8];
memset(polyKey, 0, sizeof(polyKey)); memset(polyKey, 0, sizeof(polyKey));
chacha20 (polyKey, 64, nonce, key, 0); chacha20 ((uint8_t *)polyKey, 64, nonce, key, 0);
// create Poly1305 message // create Poly1305 message
if (!ad) adLen = 0; if (!ad) adLen = 0;
@ -1142,7 +1142,7 @@ namespace crypto
{ {
uint64_t tag[4]; uint64_t tag[4];
// calculate Poly1305 tag // calculate Poly1305 tag
Poly1305HMAC (tag, (uint64_t *)polyKey, polyMsg.data (), offset); Poly1305HMAC (tag, polyKey, polyMsg.data (), offset);
if (memcmp (tag, msg + msgLen, 16)) ret = false; // compare with provided if (memcmp (tag, msg + msgLen, 16)) ret = false; // compare with provided
} }
#else #else

Loading…
Cancel
Save