Botan  1.11.30
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 156 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 236 of file pubkey.cpp.

240  {
241  m_op.reset(get_pk_op<PK_Ops::Signature>("Signing", key, emsa, provider));
242  m_sig_format = format;
243  }

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 240 of file pubkey.h.

240 { 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 179 of file pubkey.h.

Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), Botan::X509_Object::make_signed(), and Botan::KeyPair::signature_consistency_check().

181  {
182  this->update(in, length);
183  return this->signature(rng);
184  }
std::vector< byte > signature(RandomNumberGenerator &rng)
Definition: pubkey.cpp:250
void update(byte in)
Definition: pubkey.h:204
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 192 of file pubkey.h.

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

Definition at line 196 of file pubkey.h.

198  { return sign_message(in.data(), in.size(), rng); }
std::vector< byte > sign_message(const byte in[], size_t length, RandomNumberGenerator &rng)
Definition: pubkey.h:179
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 250 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().

251  {
252  const std::vector<byte> plain_sig = unlock(m_op->sign(rng));
253  const size_t parts = m_op->message_parts();
254 
255  if(parts == 1 || m_sig_format == IEEE_1363)
256  return plain_sig;
257  else if(m_sig_format == DER_SEQUENCE)
258  return der_encode_signature(plain_sig, parts);
259  else
260  throw Encoding_Error("PK_Signer: Unknown signature format " +
261  std::to_string(m_sig_format));
262  }
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 204 of file pubkey.h.

References update().

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

204 { update(&in, 1); }
void update(byte in)
Definition: pubkey.h:204
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 245 of file pubkey.cpp.

246  {
247  m_op->update(in, length);
248  }
void Botan::PK_Signer::update ( const std::vector< byte > &  in)
inline

Add a message part.

Parameters
inthe message part to add

Definition at line 217 of file pubkey.h.

References update().

Referenced by update().

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

Add a message part.

Parameters
inthe message part to add

Definition at line 223 of file pubkey.h.

224  {
225  update(reinterpret_cast<const byte*>(in.data()), in.size());
226  }
void update(byte in)
Definition: pubkey.h:204

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