StormByte C++ Library: Crypto module 1.0.0
StormByte-Crypto is a StormByte library module for handling cryptographic operations
Loading...
Searching...
No Matches
signer.hxx
1#pragma once
2
3#include <StormByte/buffer/consumer.hxx>
4#include <StormByte/crypto/algorithm.hxx>
5#include <StormByte/crypto/exception.hxx>
6#include <StormByte/crypto/keypair.hxx>
7#include <StormByte/expected.hxx>
8
9#include <string>
10
15namespace StormByte::Crypto {
22 class STORMBYTE_CRYPTO_PUBLIC Signer final {
23 public:
33 explicit Signer(const Algorithm::Sign& algorithm, const KeyPair& keypair) noexcept;
34
44 explicit Signer(const Algorithm::Sign& algorithm, KeyPair&& keypair) noexcept;
45
53 Signer(const Signer& signer) = default;
54
62 Signer(Signer&& signer) noexcept = default;
63
69 ~Signer() noexcept = default;
70
79 Signer& operator=(const Signer& signer) = default;
80
89 Signer& operator=(Signer&& signer) noexcept = default;
90
99 [[nodiscard]]
100 Expected<std::string, Exception> Sign(const std::string& input) const noexcept;
101
110 [[nodiscard]]
111 Expected<std::string, Exception> Sign(const Buffer::Simple& buffer) const noexcept;
112
121 [[nodiscard]]
122 Buffer::Consumer Sign(const Buffer::Consumer consumer) const noexcept;
123
133 bool Verify(const std::string& message, const std::string& signature) const noexcept;
134
144 bool Verify(const Buffer::Simple& buffer, const std::string& signature) const noexcept;
145
155 bool Verify(const Buffer::Consumer consumer, const std::string& signature) const noexcept;
156
157 private:
158 Algorithm::Sign m_algorithm;
159 class KeyPair m_keys;
160 };
161};
A class representing an exception in the crypto module.
Definition exception.hxx:15
A class representing a public/private key pair.
Definition keypair.hxx:23
A class for managing digital signing and signature verification.
Definition signer.hxx:22
Signer(const Algorithm::Sign &algorithm, const KeyPair &keypair) noexcept
Constructs a Signer instance with a specified algorithm and key pair.
Signer(const Algorithm::Sign &algorithm, KeyPair &&keypair) noexcept
Constructs a Signer instance with a specified algorithm and key pair (move version).
~Signer() noexcept=default
Destructor for the Signer class.
Signer(const Signer &signer)=default
Copy constructor for the Signer class.
Signer(Signer &&signer) noexcept=default
Move constructor for the Signer class.
The namespace containing cryptographic algorithms.