[monero-project/monero] add and use constant time 32 byte equality function (#3999)

stoffu commented on this pull request.

> @@ -127,7 +127,8 @@ namespace hw {
}

bool operator==(const crypto::key_derivation &d0, const crypto::key_derivation &d1) {
– return !memcmp(&d0, &d1, sizeof(d0));
+ static_assert(sizeof(crypto::key_derivation) == 32, “key_derivation must be 32 bytes”);
+ return !crypto_verify_32(&d0, &d1);

From buildbot:
“`
/home/vagrant/slave/monero-static-ubuntu-amd64/build/src/device/device_ledger.cpp:131:40: error: cannot convert ‘const crypto::key_derivation*’ to ‘const unsigned char*’ for argument ‘1’ to ‘int crypto_verify_32(const unsigned char*, const unsigned char*)’
return !crypto_verify_32(&d0, &d1);
“`

This post was last modified on June 14, 2018, 3:41 am