Electroneum
Loading...
Searching...
No Matches
crypto.cpp File Reference
#include <cstdint>
#include <gtest/gtest.h>
#include <memory>
#include <sstream>
#include <string>
#include "cryptonote_basic/cryptonote_basic_impl.h"
Include dependency graph for crypto.cpp:

Go to the source code of this file.

Functions

 TEST (Crypto, Ostream)
 TEST (Crypto, null_keys)
 TEST (Crypto, verify_32)

Function Documentation

◆ TEST() [1/3]

TEST ( Crypto ,
null_keys  )

Definition at line 81 of file crypto.cpp.

82{
83 char zero[32];
84 memset(zero, 0, 32);
85 ASSERT_EQ(memcmp(crypto::null_skey.data, zero, 32), 0);
86 ASSERT_EQ(memcmp(crypto::null_pkey.data, zero, 32), 0);
87}
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1956
const crypto::public_key null_pkey
Definition crypto.cpp:72
const crypto::secret_key null_skey
Definition crypto.cpp:73
key zero()
Definition rctOps.h:70

◆ TEST() [2/3]

TEST ( Crypto ,
Ostream  )

Definition at line 70 of file crypto.cpp.

71{
72 EXPECT_TRUE(is_formatted<crypto::hash8>());
73 EXPECT_TRUE(is_formatted<crypto::hash>());
74 EXPECT_TRUE(is_formatted<crypto::public_key>());
75 EXPECT_TRUE(is_formatted<crypto::secret_key>());
76 EXPECT_TRUE(is_formatted<crypto::signature>());
77 EXPECT_TRUE(is_formatted<crypto::key_derivation>());
78 EXPECT_TRUE(is_formatted<crypto::key_image>());
79}
#define EXPECT_TRUE(condition)
Definition gtest.h:1859

◆ TEST() [3/3]

TEST ( Crypto ,
verify_32  )

Definition at line 89 of file crypto.cpp.

90{
91 // all bytes are treated the same, so we can brute force just one byte
92 unsigned char k0[32] = {0}, k1[32] = {0};
93 for (unsigned int i0 = 0; i0 < 256; ++i0)
94 {
95 k0[0] = i0;
96 for (unsigned int i1 = 0; i1 < 256; ++i1)
97 {
98 k1[0] = i1;
99 ASSERT_EQ(!crypto_verify_32(k0, k1), i0 == i1);
100 }
101 }
102}
int crypto_verify_32(const unsigned char *, const unsigned char *)
Here is the call graph for this function: