Botan  1.11.26
Public Member Functions | List of all members
Botan::PK_Signer Class Reference

#include <pubkey.h>

Public Member Functions

 PK_Signer (const Private_Key &key, const std::string &emsa, Signature_Format format=IEEE_1363, const std::string &provider="")
 
void set_output_format (Signature_Format format)
 
std::vector< bytesign_message (const byte in[], size_t length, RandomNumberGenerator &rng)
 
std::vector< bytesign_message (const std::vector< byte > &in, RandomNumberGenerator &rng)
 
std::vector< bytesign_message (const secure_vector< byte > &in, RandomNumberGenerator &rng)
 
std::vector< bytesignature (RandomNumberGenerator &rng)
 
void update (byte in)
 
void update (const byte in[], size_t length)
 
void update (const std::vector< byte > &in)
 
void update (const std::string &in)
 

Detailed Description

Public Key Signer. Use the sign_message() functions for small messages. Use multiple calls update() to process large messages and generate the signature by finally calling signature().

Definition at line 120 of file pubkey.h.

Constructor & Destructor Documentation

Botan::PK_Signer::PK_Signer ( const Private_Key key,
const std::string &  emsa,
Signature_Format  format = IEEE_1363,
const std::string &  provider = "" 
)

Construct a PK Signer.

Parameters
keythe key to use inside this signer
emsathe EMSA to use An example would be "EMSA1(SHA-224)".
formatthe signature format to use

Definition at line 159 of file pubkey.cpp.

163  {
164  m_op.reset(get_pk_op<PK_Ops::Signature>("Signing", key, emsa, provider));
165  m_sig_format = format;
166  }

Member Function Documentation

void Botan::PK_Signer::set_output_format ( Signature_Format  format)
inline

Set the output format of the signature.

Parameters
formatthe signature format to use

Definition at line 204 of file pubkey.h.

204 { m_sig_format = format; }
std::vector<byte> Botan::PK_Signer::sign_message ( const byte  in[],
size_t  length,
RandomNumberGenerator rng 
)
inline

Sign a message all in one go

Parameters
inthe message to sign as a byte array
lengththe length of the above byte array
rngthe rng to use
Returns
signature

Definition at line 143 of file pubkey.h.

Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), Botan::EAC1_1_ADO::make_signed(), Botan::X509_Object::make_signed(), Botan::EAC1_1_gen_CVC< Derived >::make_signed(), and Botan::KeyPair::signature_consistency_check().

145  {
146  this->update(in, length);
147  return this->signature(rng);
148  }
std::vector< byte > signature(RandomNumberGenerator &rng)
Definition: pubkey.cpp:173
void update(byte in)
Definition: pubkey.h:168
std::vector<byte> Botan::PK_Signer::sign_message ( const std::vector< byte > &  in,
RandomNumberGenerator rng 
)
inline

Sign a message.

Parameters
inthe message to sign
rngthe rng to use
Returns
signature

Definition at line 156 of file pubkey.h.

158  { return sign_message(in.data(), in.size(), rng); }
std::vector< byte > sign_message(const byte in[], size_t length, RandomNumberGenerator &rng)
Definition: pubkey.h:143
std::vector<byte> Botan::PK_Signer::sign_message ( const secure_vector< byte > &  in,
RandomNumberGenerator rng 
)
inline

Definition at line 160 of file pubkey.h.

162  { return sign_message(in.data(), in.size(), rng); }
std::vector< byte > sign_message(const byte in[], size_t length, RandomNumberGenerator &rng)
Definition: pubkey.h:143
std::vector< byte > Botan::PK_Signer::signature ( RandomNumberGenerator rng)

Get the signature of the so far processed message (provided by the calls to update()).

Parameters
rngthe rng to use
Returns
signature of the total message

Definition at line 173 of file pubkey.cpp.

References Botan::DER_SEQUENCE, Botan::IEEE_1363, Botan::ASN1::to_string(), and Botan::unlock().

Referenced by Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().

174  {
175  const std::vector<byte> plain_sig = unlock(m_op->sign(rng));
176  const size_t parts = m_op->message_parts();
177 
178  if(parts == 1 || m_sig_format == IEEE_1363)
179  return plain_sig;
180  else if(m_sig_format == DER_SEQUENCE)
181  return der_encode_signature(plain_sig, parts);
182  else
183  throw Encoding_Error("PK_Signer: Unknown signature format " +
184  std::to_string(m_sig_format));
185  }
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:47
std::vector< T > unlock(const secure_vector< T > &in)
Definition: secmem.h:100
void Botan::PK_Signer::update ( byte  in)
inline

Add a message part (single byte).

Parameters
inthe byte to add

Definition at line 168 of file pubkey.h.

References update().

Referenced by botan_pk_op_sign_update(), Botan::TLS::Server_Key_Exchange::Server_Key_Exchange(), and update().

168 { update(&in, 1); }
void update(byte in)
Definition: pubkey.h:168
void Botan::PK_Signer::update ( const byte  in[],
size_t  length 
)

Add a message part.

Parameters
inthe message part to add as a byte array
lengththe length of the above byte array

Definition at line 168 of file pubkey.cpp.

169  {
170  m_op->update(in, length);
171  }
void Botan::PK_Signer::update ( const std::vector< byte > &  in)
inline

Add a message part.

Parameters
inthe message part to add

Definition at line 181 of file pubkey.h.

References update().

Referenced by update().

181 { update(in.data(), in.size()); }
void update(byte in)
Definition: pubkey.h:168
void Botan::PK_Signer::update ( const std::string &  in)
inline

Add a message part.

Parameters
inthe message part to add

Definition at line 187 of file pubkey.h.

188  {
189  update(reinterpret_cast<const byte*>(in.data()), in.size());
190  }
void update(byte in)
Definition: pubkey.h:168

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