Botan  1.10.9
Public Member Functions | Friends | List of all members
Botan::ECDSA_Signature Class Reference

#include <ecdsa_sig.h>

Public Member Functions

MemoryVector< byteDER_encode () const
 
 ECDSA_Signature ()
 
 ECDSA_Signature (const BigInt &r, const BigInt &s)
 
 ECDSA_Signature (const MemoryRegion< byte > &ber)
 
MemoryVector< byteget_concatenation () const
 
const BigIntget_r () const
 
const BigIntget_s () const
 
bool operator== (const ECDSA_Signature &other) const
 

Friends

class ECDSA_Signature_Decoder
 

Detailed Description

Class representing an ECDSA signature

Definition at line 21 of file ecdsa_sig.h.

Constructor & Destructor Documentation

Botan::ECDSA_Signature::ECDSA_Signature ( )
inline

Definition at line 26 of file ecdsa_sig.h.

26 {}
Botan::ECDSA_Signature::ECDSA_Signature ( const BigInt r,
const BigInt s 
)
inline

Definition at line 27 of file ecdsa_sig.h.

27  :
28  m_r(r), m_s(s) {}
BigInt r
Definition: numthry.cpp:26
size_t s
Definition: numthry.cpp:27
Botan::ECDSA_Signature::ECDSA_Signature ( const MemoryRegion< byte > &  ber)

Definition at line 13 of file ecdsa_sig.cpp.

References Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::SEQUENCE, Botan::BER_Decoder::start_cons(), and Botan::BER_Decoder::verify_end().

14  {
15  BER_Decoder(ber)
16  .start_cons(SEQUENCE)
17  .decode(m_r)
18  .decode(m_s)
19  .end_cons()
20  .verify_end();
21  }

Member Function Documentation

MemoryVector< byte > Botan::ECDSA_Signature::DER_encode ( ) const

Definition at line 23 of file ecdsa_sig.cpp.

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents(), get_r(), get_s(), Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().

Referenced by Botan::EAC1_1_obj< EAC1_1_Req >::check_signature().

24  {
25  return DER_Encoder()
26  .start_cons(SEQUENCE)
27  .encode(get_r())
28  .encode(get_s())
29  .end_cons()
30  .get_contents();
31  }
const BigInt & get_s() const
Definition: ecdsa_sig.h:33
const BigInt & get_r() const
Definition: ecdsa_sig.h:32
MemoryVector< byte > Botan::ECDSA_Signature::get_concatenation ( ) const

return the r||s

Definition at line 33 of file ecdsa_sig.cpp.

References Botan::BigInt::bytes(), and Botan::BigInt::encode_1363().

Referenced by Botan::EAC1_1_obj< EAC1_1_Req >::get_concat_sig().

34  {
35  // use the larger
36  const size_t enc_len = m_r > m_s ? m_r.bytes() : m_s.bytes();
37 
38  SecureVector<byte> sv_r = BigInt::encode_1363(m_r, enc_len);
39  SecureVector<byte> sv_s = BigInt::encode_1363(m_s, enc_len);
40 
41  SecureVector<byte> result(sv_r);
42  result += sv_s;
43  return result;
44  }
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:78
size_t bytes() const
Definition: bigint.cpp:245
const BigInt& Botan::ECDSA_Signature::get_r ( ) const
inline

Definition at line 32 of file ecdsa_sig.h.

Referenced by DER_encode(), and operator==().

32 { return m_r; }
const BigInt& Botan::ECDSA_Signature::get_s ( ) const
inline

Definition at line 33 of file ecdsa_sig.h.

Referenced by DER_encode(), and operator==().

33 { return m_s; }
bool Botan::ECDSA_Signature::operator== ( const ECDSA_Signature other) const
inline

Definition at line 42 of file ecdsa_sig.h.

References get_r(), and get_s().

43  {
44  return (get_r() == other.get_r() && get_s() == other.get_s());
45  }
const BigInt & get_s() const
Definition: ecdsa_sig.h:33
const BigInt & get_r() const
Definition: ecdsa_sig.h:32

Friends And Related Function Documentation

friend class ECDSA_Signature_Decoder
friend

Definition at line 24 of file ecdsa_sig.h.


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