diff options
author | lloyd <[email protected]> | 2010-03-02 19:11:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-02 19:11:21 +0000 |
commit | 200e88602c2f5d3b09ee6f1caaac3d14da6c8860 (patch) | |
tree | 94d32d044a6ff39ee28c74c48a1b577063739eaa /src/cert/cvc/ecdsa_sig.h | |
parent | 732056d8876b669159b3ade4b9786528a3d2366f (diff) |
Remove ECDSA_Signature encoding/decoding cruft
Diffstat (limited to 'src/cert/cvc/ecdsa_sig.h')
-rw-r--r-- | src/cert/cvc/ecdsa_sig.h | 64 |
1 files changed, 14 insertions, 50 deletions
diff --git a/src/cert/cvc/ecdsa_sig.h b/src/cert/cvc/ecdsa_sig.h index 3e202d703..1397a92b1 100644 --- a/src/cert/cvc/ecdsa_sig.h +++ b/src/cert/cvc/ecdsa_sig.h @@ -1,5 +1,5 @@ /* -* ECDSA +* ECDSA Signature * (C) 2007 Falko Strenzke, FlexSecure GmbH * (C) 2008-2010 Jack Lloyd * @@ -21,9 +21,10 @@ class BOTAN_DLL ECDSA_Signature friend class ECDSA_Signature_Decoder; ECDSA_Signature() {} - ECDSA_Signature(const BigInt& r, const BigInt& s); - ECDSA_Signature(const ECDSA_Signature& other); - ECDSA_Signature& operator=(const ECDSA_Signature& other); + ECDSA_Signature(const BigInt& r, const BigInt& s) : + m_r(r), m_s(s) {} + + ECDSA_Signature(const MemoryRegion<byte>& ber); const BigInt& get_r() const { return m_r; } const BigInt& get_s() const { return m_s; } @@ -31,62 +32,25 @@ class BOTAN_DLL ECDSA_Signature /** * return the r||s */ - SecureVector<byte> get_concatenation() const; - private: - BigInt m_r; - BigInt m_s; - }; + MemoryVector<byte> get_concatenation() const; -/* Equality of ECDSA_Signature */ -bool operator==(const ECDSA_Signature& lhs, const ECDSA_Signature& rhs); -inline bool operator!=(const ECDSA_Signature& lhs, const ECDSA_Signature& rhs) - { - return !(lhs == rhs); - } + MemoryVector<byte> DER_encode() const; -class BOTAN_DLL ECDSA_Signature_Decoder - { - public: - void signature_bits(const MemoryRegion<byte>& bits) + bool operator==(const ECDSA_Signature& other) const { - BER_Decoder(bits) - .start_cons(SEQUENCE) - .decode(m_signature->m_r) - .decode(m_signature->m_s) - .verify_end() - .end_cons(); + return (get_r() == other.get_r() && get_s() == other.get_s()); } - ECDSA_Signature_Decoder(ECDSA_Signature* signature) : - m_signature(signature) - {} - private: - ECDSA_Signature* m_signature; + BigInt m_r; + BigInt m_s; }; -class BOTAN_DLL ECDSA_Signature_Encoder +inline bool operator!=(const ECDSA_Signature& lhs, const ECDSA_Signature& rhs) { - public: - MemoryVector<byte> signature_bits() const - { - return DER_Encoder() - .start_cons(SEQUENCE) - .encode(m_signature->get_r()) - .encode(m_signature->get_s()) - .end_cons() - .get_contents(); - } - - ECDSA_Signature_Encoder(const ECDSA_Signature* signature) : - m_signature(signature) - {} - - private: - const ECDSA_Signature* m_signature; - }; + return !(lhs == rhs); + } -ECDSA_Signature decode_seq(const MemoryRegion<byte>& seq); ECDSA_Signature decode_concatenation(const MemoryRegion<byte>& concatenation); } |