Botan 1.10.17
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

◆ ECDSA_Signature() [1/3]

Botan::ECDSA_Signature::ECDSA_Signature ( )
inline

Definition at line 26 of file ecdsa_sig.h.

26{}

Referenced by Botan::decode_concatenation(), and operator==().

◆ ECDSA_Signature() [2/3]

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) {}

◆ ECDSA_Signature() [3/3]

Botan::ECDSA_Signature::ECDSA_Signature ( const MemoryRegion< byte > & ber)

Definition at line 13 of file ecdsa_sig.cpp.

14 {
15 BER_Decoder(ber)
16 .start_cons(SEQUENCE)
17 .decode(m_r)
18 .decode(m_s)
19 .end_cons()
20 .verify_end();
21 }
BER_Decoder(DataSource &)
Definition ber_dec.cpp:264
@ SEQUENCE
Definition asn1_int.h:35

References Botan::BER_Decoder::BER_Decoder(), and Botan::SEQUENCE.

Member Function Documentation

◆ DER_encode()

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

Definition at line 23 of file ecdsa_sig.cpp.

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_r() const
Definition ecdsa_sig.h:32
const BigInt & get_s() const
Definition ecdsa_sig.h:33

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< Derived >::check_signature().

◆ get_concatenation()

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

return the r||s

Definition at line 33 of file ecdsa_sig.cpp.

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

References Botan::BigInt::encode_1363().

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

◆ get_r()

const BigInt & Botan::ECDSA_Signature::get_r ( ) const
inline

Definition at line 32 of file ecdsa_sig.h.

32{ return m_r; }

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

◆ get_s()

const BigInt & Botan::ECDSA_Signature::get_s ( ) const
inline

Definition at line 33 of file ecdsa_sig.h.

33{ return m_s; }

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

◆ operator==()

bool Botan::ECDSA_Signature::operator== ( const ECDSA_Signature & other) const
inline

Definition at line 42 of file ecdsa_sig.h.

43 {
44 return (get_r() == other.get_r() && get_s() == other.get_s());
45 }

References ECDSA_Signature(), get_r(), and get_s().

◆ ECDSA_Signature_Decoder

friend class ECDSA_Signature_Decoder
friend

Definition at line 24 of file ecdsa_sig.h.

References ECDSA_Signature_Decoder.

Referenced by ECDSA_Signature_Decoder.


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