c2pa-c
C++ API for c2pa-c library
Loading...
Searching...
No Matches
c2pa::Signer Class Reference

Signer class for creating a Signer. More...

#include <c2pa.hpp>

Public Member Functions

 Signer (SignerFunc *callback, C2paSigningAlg alg, const std::string &sign_cert, const std::string &tsa_uri)
 Create a Signer from a callback function.
 
 Signer (C2paSigner *c_signer)
 Create a signer from a Signer pointer and take ownership of that pointer.
 
 Signer (const std::string &alg, const std::string &sign_cert, const std::string &private_key, const std::optional< std::string > &tsa_uri=std::nullopt)
 Create a Signer from signing credentials.
 
 Signer (const Signer &)=delete
 
Signeroperator= (const Signer &)=delete
 
 Signer (Signer &&other) noexcept
 Move constructor.
 
Signeroperator= (Signer &&other) noexcept
 
 ~Signer ()
 
uintptr_t reserve_size ()
 Get the size to reserve for a signature for this Signer.
 
C2paSigner * c2pa_signer () const noexcept
 Get the underlying C2paSigner pointer.
 

Friends

class Context::ContextBuilder
 

Detailed Description

Signer class for creating a Signer.

This class is used to create a signer from a signing algorithm, certificate, and TSA URI. Supports both callback-based and direct signing methods.

Constructor & Destructor Documentation

◆ Signer() [1/5]

c2pa::Signer::Signer ( SignerFunc callback,
C2paSigningAlg  alg,
const std::string &  sign_cert,
const std::string &  tsa_uri 
)

Create a Signer from a callback function.

Parameters
callbackThe callback function to use for signing.
algThe signing algorithm to use (e.g., C2paSigningAlg::PS256).
sign_certThe signing certificate in PEM format.
tsa_uriThe timestamp authority URI for time-stamping.
Exceptions
C2paExceptionif signer creation fails.

◆ Signer() [2/5]

c2pa::Signer::Signer ( C2paSigner *  c_signer)
inline

Create a signer from a Signer pointer and take ownership of that pointer.

Parameters
c_signerThe C2paSigner pointer (must be non-null).
773 : signer(c_signer) {
774 if (!c_signer) {
775 throw C2paException("Signer can not be null");
776 }
777 }

◆ Signer() [3/5]

c2pa::Signer::Signer ( const std::string &  alg,
const std::string &  sign_cert,
const std::string &  private_key,
const std::optional< std::string > &  tsa_uri = std::nullopt 
)

Create a Signer from signing credentials.

Parameters
algSigning algorithm name (e.g., "ps256", "es256").
sign_certSigning certificate in PEM format.
private_keyPrivate key in PEM format.
tsa_uriOptional timestamp authority URI.
Exceptions
C2paExceptionif signer creation fails.

◆ Signer() [4/5]

c2pa::Signer::Signer ( const Signer )
delete

◆ Signer() [5/5]

c2pa::Signer::Signer ( Signer &&  other)
inlinenoexcept

Move constructor.

Parameters
otherSigner to move from.
793 : signer(std::exchange(other.signer, nullptr)) {
794 }

◆ ~Signer()

c2pa::Signer::~Signer ( )

Member Function Documentation

◆ c2pa_signer()

C2paSigner * c2pa::Signer::c2pa_signer ( ) const
noexcept

Get the underlying C2paSigner pointer.

Returns
Pointer to the C2paSigner object.

◆ operator=() [1/2]

Signer & c2pa::Signer::operator= ( const Signer )
delete

◆ operator=() [2/2]

Signer & c2pa::Signer::operator= ( Signer &&  other)
inlinenoexcept
796 {
797 if (this != &other) {
798 c2pa_free(signer);
799 signer = std::exchange(other.signer, nullptr);
800 }
801 return *this;
802 }

◆ reserve_size()

uintptr_t c2pa::Signer::reserve_size ( )

Get the size to reserve for a signature for this Signer.

Returns
Reserved size for the signature in bytes.

Friends And Related Symbol Documentation

◆ Context::ContextBuilder

friend class Context::ContextBuilder
friend

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