Botan  1.11.17
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)
 
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)
 

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 
)

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 109 of file pubkey.cpp.

112  {
113  m_op.reset(get_pk_op<PK_Ops::Signature>("Signing", key, emsa));
114  m_sig_format = format;
115  }

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

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

Sign a message.

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 130 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().

132  {
133  this->update(in, length);
134  return this->signature(rng);
135  }
std::vector< byte > signature(RandomNumberGenerator &rng)
Definition: pubkey.cpp:122
void update(byte in)
Definition: pubkey.h:155
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 143 of file pubkey.h.

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

Definition at line 147 of file pubkey.h.

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

123  {
124  const std::vector<byte> plain_sig = unlock(m_op->sign(rng));
125  const size_t parts = m_op->message_parts();
126 
127  if(parts == 1 || m_sig_format == IEEE_1363)
128  return plain_sig;
129  else if(m_sig_format == DER_SEQUENCE)
130  return der_encode_signature(plain_sig, parts);
131  else
132  throw Encoding_Error("PK_Signer: Unknown signature format " +
133  std::to_string(m_sig_format));
134  }
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:46
std::vector< T > unlock(const secure_vector< T > &in)
Definition: secmem.h:97
void Botan::PK_Signer::update ( byte  in)
inline

Add a message part (single byte).

Parameters
inthe byte to add

Definition at line 155 of file pubkey.h.

References update().

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

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

118  {
119  m_op->update(in, length);
120  }
void Botan::PK_Signer::update ( const std::vector< byte > &  in)
inline

Add a message part.

Parameters
inthe message part to add

Definition at line 168 of file pubkey.h.

References update().

Referenced by update().

168 { update(&in[0], in.size()); }
void update(byte in)
Definition: pubkey.h:155

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