2018-06-22 13:16:36 +00:00
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstring>
|
|
|
|
|
2018-08-07 08:35:03 +00:00
|
|
|
namespace fnd
|
2018-06-22 13:16:36 +00:00
|
|
|
{
|
|
|
|
namespace ecdsa
|
|
|
|
{
|
|
|
|
const size_t kEcdsa240Size = 0x1E;
|
|
|
|
|
|
|
|
enum EcdsaType
|
|
|
|
{
|
|
|
|
ECDSA_240,
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack (push, 1)
|
|
|
|
struct sEcdsa240Point
|
|
|
|
{
|
|
|
|
uint8_t r[kEcdsa240Size];
|
|
|
|
uint8_t s[kEcdsa240Size];
|
|
|
|
|
|
|
|
void operator=(const sEcdsa240Point& other)
|
|
|
|
{
|
2018-08-14 07:24:10 +00:00
|
|
|
memcpy(this->r, other.r, kEcdsa240Size);
|
|
|
|
memcpy(this->s, other.s, kEcdsa240Size);
|
2018-06-22 13:16:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const sEcdsa240Point& other) const
|
|
|
|
{
|
|
|
|
return memcmp(this->r, other.r, kEcdsa240Size) == 0 \
|
|
|
|
&& memcmp(this->s, other.s, kEcdsa240Size) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const sEcdsa240Point& other) const
|
|
|
|
{
|
|
|
|
return !operator==(other);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sEcdsa240PrivateKey
|
|
|
|
{
|
|
|
|
uint8_t k[kEcdsa240Size];
|
|
|
|
|
|
|
|
void operator=(const sEcdsa240PrivateKey& other)
|
|
|
|
{
|
|
|
|
memcpy(this->k, k, kEcdsa240Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const sEcdsa240PrivateKey& other) const
|
|
|
|
{
|
|
|
|
return memcmp(this->k, other.k, kEcdsa240Size) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const sEcdsa240PrivateKey& other) const
|
|
|
|
{
|
|
|
|
return !operator==(other);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#pragma pack (pop)
|
|
|
|
}
|
|
|
|
}
|