2023-07-25 11:53:09 +02:00
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "crypto_core.h"
|
2024-01-12 21:30:48 +01:00
|
|
|
#include "crypto_core_test_util.hh"
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
TEST(Util, TwoRandomIdsAreNotEqual)
|
|
|
|
{
|
2024-01-12 21:30:48 +01:00
|
|
|
Test_Random rng;
|
2023-07-25 11:53:09 +02:00
|
|
|
uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE];
|
|
|
|
uint8_t sk1[CRYPTO_SECRET_KEY_SIZE];
|
|
|
|
uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE];
|
|
|
|
uint8_t sk2[CRYPTO_SECRET_KEY_SIZE];
|
|
|
|
|
|
|
|
crypto_new_keypair(rng, pk1, sk1);
|
|
|
|
crypto_new_keypair(rng, pk2, sk2);
|
|
|
|
|
|
|
|
EXPECT_FALSE(pk_equal(pk1, pk2));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Util, IdCopyMakesKeysEqual)
|
|
|
|
{
|
2024-01-12 21:30:48 +01:00
|
|
|
Test_Random rng;
|
2023-07-25 11:53:09 +02:00
|
|
|
uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE];
|
|
|
|
uint8_t sk1[CRYPTO_SECRET_KEY_SIZE];
|
|
|
|
uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE] = {0};
|
|
|
|
|
|
|
|
crypto_new_keypair(rng, pk1, sk1);
|
|
|
|
pk_copy(pk2, pk1);
|
|
|
|
|
|
|
|
EXPECT_TRUE(pk_equal(pk1, pk2));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|