3#include <StormByte/buffer/consumer.hxx>
4#include <StormByte/clonable.hxx>
5#include <StormByte/crypto/keypair/generic.hxx>
11namespace StormByte::Crypto::Signer {
27 class STORMBYTE_CRYPTO_PUBLIC
Generic:
public StormByte::Clonable<Generic> {
74 inline bool Sign(std::span<const std::byte> input, Buffer::WriteOnly& output)
const noexcept {
75 return DoSign(input, output);
84 inline bool Sign(
const Buffer::ReadOnly& input, Buffer::WriteOnly& output)
const noexcept {
85 return DoSign(
const_cast<Buffer::ReadOnly&
>(input), output, ReadMode::Copy);
94 inline bool Sign(Buffer::ReadOnly& input, Buffer::WriteOnly& output)
const noexcept {
95 return DoSign(input, output, ReadMode::Move);
104 inline Buffer::Consumer
Sign(Buffer::Consumer consumer, ReadMode mode = ReadMode::Move)
const noexcept {
105 return DoSign(consumer, mode);
114 inline bool Verify(std::span<const std::byte> input,
const std::string& signature)
const noexcept {
115 return DoVerify(input, signature);
124 inline bool Verify(
const Buffer::ReadOnly& input,
const std::string& signature)
const noexcept {
125 return DoVerify(
const_cast<Buffer::ReadOnly&
>(input), signature, ReadMode::Copy);
134 inline bool Verify(Buffer::ReadOnly& input,
const std::string& signature)
const noexcept {
135 return DoVerify(input, signature, ReadMode::Move);
145 inline bool Verify(Buffer::Consumer consumer,
const std::string& signature, ReadMode mode = ReadMode::Move)
const noexcept {
146 return DoVerify(consumer, signature, mode);
158 inline Generic(
enum Type type, KeyPair::Generic::PointerType keypair):
159 m_type(type), m_keypair(keypair) {}
167 m_type(type), m_keypair(keypair.Clone()) {}
175 m_type(type), m_keypair(keypair.Move()) {}
185 bool DoSign(Buffer::ReadOnly& input, Buffer::WriteOnly& output, ReadMode mode)
const noexcept;
194 virtual bool DoSign(std::span<const std::byte> input, Buffer::WriteOnly& output)
const noexcept = 0;
202 virtual Buffer::Consumer DoSign(Buffer::Consumer consumer, ReadMode mode)
const noexcept = 0;
211 bool DoVerify(Buffer::ReadOnly& input,
const std::string& signature, ReadMode mode)
const noexcept;
219 virtual bool DoVerify(std::span<const std::byte> input,
const std::string& signature)
const noexcept = 0;
228 virtual bool DoVerify(Buffer::Consumer consumer,
const std::string& signature, ReadMode mode)
const noexcept = 0;
237 STORMBYTE_CRYPTO_PUBLIC Generic::PointerType Create(
enum Type type, KeyPair::Generic::PointerType keypair)
noexcept;
245 STORMBYTE_CRYPTO_PUBLIC Generic::PointerType Create(
enum Type type,
const KeyPair::Generic& keypair)
noexcept;
252 STORMBYTE_CRYPTO_PUBLIC Generic::PointerType Create(
enum Type type,
KeyPair::Generic&& keypair)
noexcept;
A generic class.
Definition generic.hxx:34
A generic signer class.
Definition generic.hxx:27
Generic(enum Type type, KeyPair::Generic &&keypair)
Constructor.
Definition generic.hxx:174
bool Verify(std::span< const std::byte > input, const std::string &signature) const noexcept
Verify data from input span to output buffer.
Definition generic.hxx:114
enum Type m_type
The type of signer.
Definition generic.hxx:150
Generic(const Generic &other)=default
Copy constructor.
KeyPair::Generic::PointerType m_keypair
The password used for asymmetric encryption.
Definition generic.hxx:151
bool Verify(Buffer::ReadOnly &input, const std::string &signature) const noexcept
Verify data from input buffer to output buffer, moving the input data.
Definition generic.hxx:134
bool Verify(Buffer::Consumer consumer, const std::string &signature, ReadMode mode=ReadMode::Move) const noexcept
Verify data from a Consumer buffer.
Definition generic.hxx:145
bool Verify(const Buffer::ReadOnly &input, const std::string &signature) const noexcept
Verify data from input buffer to output buffer.
Definition generic.hxx:124
Generic(enum Type type, KeyPair::Generic::PointerType keypair)
Constructor.
Definition generic.hxx:158
virtual ~Generic() noexcept=default
Virtual destructor.
Buffer::Consumer Sign(Buffer::Consumer consumer, ReadMode mode=ReadMode::Move) const noexcept
Sign data from a Consumer buffer.
Definition generic.hxx:104
bool Sign(const Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
Sign data from input buffer to output buffer.
Definition generic.hxx:84
Generic(Generic &&other) noexcept=default
Move constructor.
bool Sign(std::span< const std::byte > input, Buffer::WriteOnly &output) const noexcept
Sign data from input span to output buffer.
Definition generic.hxx:74
Generic(enum Type type, const KeyPair::Generic &keypair)
Constructor.
Definition generic.hxx:166
bool Sign(Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
Sign data from input buffer to output buffer, moving the input data.
Definition generic.hxx:94
The namespace containing all the keypair-related classes.