mirror of
https://github.com/jakcron/nstool
synced 2024-11-15 02:06:40 +00:00
[crypto] Add header for ECDSA-240 defines.
This commit is contained in:
parent
adfbc55922
commit
8314a948f7
1 changed files with 62 additions and 0 deletions
62
lib/libcrypto/include/crypto/ecdsa.h
Normal file
62
lib/libcrypto/include/crypto/ecdsa.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <crypto/sha.h>
|
||||
|
||||
namespace crypto
|
||||
{
|
||||
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)
|
||||
{
|
||||
memcpy(this->r, r, kEcdsa240Size);
|
||||
memcpy(this->s, s, kEcdsa240Size);
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue