Botan 1.10.17

ecdsa_sig.h
Go to the documentation of this file.
1 /*
2 * ECDSA Signature
3 * (C) 2007 Falko Strenzke, FlexSecure GmbH
4 * (C) 2008-2010 Jack Lloyd
5 *
6 * Distributed under the terms of the Botan license
7 */
8
9 #ifndef BOTAN_ECDSA_SIGNATURE_H__
10 #define BOTAN_ECDSA_SIGNATURE_H__
11
12 #include <botan/bigint.h>
13 #include <botan/der_enc.h>
14 #include <botan/ber_dec.h>
15
16 namespace Botan {
17
18 /**
19 * Class representing an ECDSA signature
20 */
21 class BOTAN_DLL ECDSA_Signature
22 {
23 public:
24 friend class ECDSA_Signature_Decoder;
25
26 ECDSA_Signature() {}
27 ECDSA_Signature(const BigInt& r, const BigInt& s) :
28 m_r(r), m_s(s) {}
29
30 ECDSA_Signature(const MemoryRegion<byte>& ber);
31
32 const BigInt& get_r() const { return m_r; }
33 const BigInt& get_s() const { return m_s; }
34
35 /**
36 * return the r||s
37 */
38 MemoryVector<byte> get_concatenation() const;
39
40 MemoryVector<byte> DER_encode() const;
41
42 bool operator==(const ECDSA_Signature& other) const
43 {
44 return (get_r() == other.get_r() && get_s() == other.get_s());
45 }
46
47 private:
48 BigInt m_r;
49 BigInt m_s;
50 };
51
52 inline bool operator!=(const ECDSA_Signature& lhs, const ECDSA_Signature& rhs)
53 {
54 return !(lhs == rhs);
55 }
56
57 ECDSA_Signature decode_concatenation(const MemoryRegion<byte>& concatenation);
58
59 }
60
61 #endif
Botan::operator!=
bool operator!=(const OctetString &s1, const OctetString &s2)
Definition: symkey.cpp:106
Botan::BigInt
Definition: bigint.h:22
Botan::ECDSA_Signature::operator==
bool operator==(const ECDSA_Signature &other) const
Definition: ecdsa_sig.h:42
Botan::ECDSA_Signature::ECDSA_Signature
ECDSA_Signature(const BigInt &r, const BigInt &s)
Definition: ecdsa_sig.h:27
Botan::ECDSA_Signature::get_s
const BigInt & get_s() const
Definition: ecdsa_sig.h:33
Botan::ECDSA_Signature::ECDSA_Signature
ECDSA_Signature()
Definition: ecdsa_sig.h:26
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::MemoryVector< byte >
Botan::decode_concatenation
ECDSA_Signature decode_concatenation(const MemoryRegion< byte > &concat)
Definition: ecdsa_sig.cpp:46
Botan::ECDSA_Signature::get_r
const BigInt & get_r() const
Definition: ecdsa_sig.h:32
Botan::ECDSA_Signature
Definition: ecdsa_sig.h:21