mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
add and use constant time 32 byte equality function
This commit is contained in:
parent
993a55246e
commit
c0f02c85b5
9 changed files with 138 additions and 15 deletions
|
@ -73,3 +73,26 @@ TEST(Crypto, Ostream)
|
|||
EXPECT_TRUE(is_formatted<crypto::key_derivation>());
|
||||
EXPECT_TRUE(is_formatted<crypto::key_image>());
|
||||
}
|
||||
|
||||
TEST(Crypto, null_keys)
|
||||
{
|
||||
char zero[32];
|
||||
memset(zero, 0, 32);
|
||||
ASSERT_EQ(memcmp(crypto::null_skey.data, zero, 32), 0);
|
||||
ASSERT_EQ(memcmp(crypto::null_pkey.data, zero, 32), 0);
|
||||
}
|
||||
|
||||
TEST(Crypto, verify_32)
|
||||
{
|
||||
// all bytes are treated the same, so we can brute force just one byte
|
||||
unsigned char k0[32] = {0}, k1[32] = {0};
|
||||
for (unsigned int i0 = 0; i0 < 256; ++i0)
|
||||
{
|
||||
k0[0] = i0;
|
||||
for (unsigned int i1 = 0; i1 < 256; ++i1)
|
||||
{
|
||||
k1[0] = i1;
|
||||
ASSERT_EQ(!crypto_verify_32(k0, k1), i0 == i1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue