StormByte C++ Library: Crypto module 1.0.0
StormByte-Crypto is a StormByte library module for handling cryptographic operations
Loading...
Searching...
No Matches
Public Member Functions | List of all members
StormByte::Crypto::Signer Class Referencefinal

A class for managing digital signing and signature verification. More...

#include <signer.hxx>

Public Member Functions

 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 (const Signer &signer)=default
 Copy constructor for the Signer class.
 
 Signer (Signer &&signer) noexcept=default
 Move constructor for the Signer class.
 
 ~Signer () noexcept=default
 Destructor for the Signer class.
 
Signeroperator= (const Signer &signer)=default
 Copy assignment operator for the Signer class.
 
Signeroperator= (Signer &&signer) noexcept=default
 Move assignment operator for the Signer class.
 
Expected< std::string, ExceptionSign (const std::string &input) const noexcept
 Signs a string input using the specified signing algorithm.
 
Expected< std::string, ExceptionSign (const Buffer::Simple &buffer) const noexcept
 Signs a buffer using the specified signing algorithm.
 
Buffer::Consumer Sign (const Buffer::Consumer consumer) const noexcept
 Signs data asynchronously using a Consumer/Producer model.
 
bool Verify (const std::string &message, const std::string &signature) const noexcept
 Verifies a digital signature for a string message.
 
bool Verify (const Buffer::Simple &buffer, const std::string &signature) const noexcept
 Verifies a digital signature for a buffer.
 
bool Verify (const Buffer::Consumer consumer, const std::string &signature) const noexcept
 Verifies a digital signature for data provided by a Consumer buffer.
 

Detailed Description

A class for managing digital signing and signature verification.

This class provides methods for creating digital signatures and verifying them using various signing algorithms.

Constructor & Destructor Documentation

◆ Signer() [1/4]

StormByte::Crypto::Signer::Signer ( const Algorithm::Sign &  algorithm,
const KeyPair keypair 
)
explicitnoexcept

Constructs a Signer instance with a specified algorithm and key pair.

This constructor initializes the Signer instance with the specified signing algorithm and a key pair. The key pair is used for signing and verifying operations.

Parameters
algorithmThe signing algorithm to use.
keypairThe key pair to use for signing and verifying.

◆ Signer() [2/4]

StormByte::Crypto::Signer::Signer ( const Algorithm::Sign &  algorithm,
KeyPair &&  keypair 
)
explicitnoexcept

Constructs a Signer instance with a specified algorithm and key pair (move version).

This constructor initializes the Signer instance with the specified signing algorithm and a key pair. The key pair is moved into the instance to avoid unnecessary copying.

Parameters
algorithmThe signing algorithm to use.
keypairThe key pair to use for signing and verifying (rvalue reference).

◆ Signer() [3/4]

StormByte::Crypto::Signer::Signer ( const Signer signer)
default

Copy constructor for the Signer class.

Creates a copy of the given Signer instance.

Parameters
signerThe Signer instance to copy.

◆ Signer() [4/4]

StormByte::Crypto::Signer::Signer ( Signer &&  signer)
defaultnoexcept

Move constructor for the Signer class.

Moves the given Signer instance into the current instance.

Parameters
signerThe Signer instance to move.

◆ ~Signer()

StormByte::Crypto::Signer::~Signer ( )
defaultnoexcept

Destructor for the Signer class.

Cleans up the Signer instance.

Member Function Documentation

◆ operator=() [1/2]

Signer & StormByte::Crypto::Signer::operator= ( const Signer signer)
default

Copy assignment operator for the Signer class.

Assigns the values from the given Signer instance to the current instance.

Parameters
signerThe Signer instance to copy.
Returns
A reference to the updated Signer instance.

◆ operator=() [2/2]

Signer & StormByte::Crypto::Signer::operator= ( Signer &&  signer)
defaultnoexcept

Move assignment operator for the Signer class.

Moves the values from the given Signer instance to the current instance.

Parameters
signerThe Signer instance to move.
Returns
A reference to the updated Signer instance.

◆ Sign() [1/3]

Buffer::Consumer StormByte::Crypto::Signer::Sign ( const Buffer::Consumer  consumer) const
noexcept

Signs data asynchronously using a Consumer/Producer model.

This method creates a digital signature for the data provided by the Consumer buffer.

Parameters
consumerThe Consumer buffer containing the input data.
Returns
A Consumer buffer containing the digital signature.

◆ Sign() [2/3]

Expected< std::string, Exception > StormByte::Crypto::Signer::Sign ( const Buffer::Simple &  buffer) const
noexcept

Signs a buffer using the specified signing algorithm.

This method creates a digital signature for the given buffer.

Parameters
bufferThe buffer to sign.
Returns
An Expected containing the digital signature or an error.

◆ Sign() [3/3]

Expected< std::string, Exception > StormByte::Crypto::Signer::Sign ( const std::string &  input) const
noexcept

Signs a string input using the specified signing algorithm.

This method creates a digital signature for the given string input.

Parameters
inputThe string to sign.
Returns
An Expected containing the digital signature or an error.

◆ Verify() [1/3]

bool StormByte::Crypto::Signer::Verify ( const Buffer::Consumer  consumer,
const std::string &  signature 
) const
noexcept

Verifies a digital signature for data provided by a Consumer buffer.

This method verifies the digital signature of the data provided by the Consumer buffer.

Parameters
consumerThe Consumer buffer containing the original data.
signatureThe digital signature to verify.
Returns
true if the signature is valid, false otherwise.

◆ Verify() [2/3]

bool StormByte::Crypto::Signer::Verify ( const Buffer::Simple &  buffer,
const std::string &  signature 
) const
noexcept

Verifies a digital signature for a buffer.

This method verifies the digital signature of the given buffer.

Parameters
bufferThe original buffer.
signatureThe digital signature to verify.
Returns
true if the signature is valid, false otherwise.

◆ Verify() [3/3]

bool StormByte::Crypto::Signer::Verify ( const std::string &  message,
const std::string &  signature 
) const
noexcept

Verifies a digital signature for a string message.

This method verifies the digital signature of the given string message.

Parameters
messageThe original message.
signatureThe digital signature to verify.
Returns
true if the signature is valid, false otherwise.

The documentation for this class was generated from the following file: