Botan  1.11.15
src/lib/cert/cvc/ecdsa_sig.h
Go to the documentation of this file.
00001 /*
00002 * ECDSA Signature
00003 * (C) 2007 Falko Strenzke, FlexSecure GmbH
00004 * (C) 2008-2010 Jack Lloyd
00005 *
00006 * Botan is released under the Simplified BSD License (see license.txt)
00007 */
00008 
00009 #ifndef BOTAN_ECDSA_SIGNATURE_H__
00010 #define BOTAN_ECDSA_SIGNATURE_H__
00011 
00012 #include <botan/bigint.h>
00013 #include <botan/der_enc.h>
00014 #include <botan/ber_dec.h>
00015 
00016 namespace Botan {
00017 
00018 /**
00019 * Class representing an ECDSA signature
00020 */
00021 class BOTAN_DLL ECDSA_Signature
00022    {
00023    public:
00024       friend class ECDSA_Signature_Decoder;
00025 
00026       ECDSA_Signature() {}
00027       ECDSA_Signature(const BigInt& r, const BigInt& s) :
00028          m_r(r), m_s(s) {}
00029 
00030       ECDSA_Signature(const std::vector<byte>& ber);
00031 
00032       const BigInt& get_r() const { return m_r; }
00033       const BigInt& get_s() const { return m_s; }
00034 
00035       /**
00036       * return the r||s
00037       */
00038       std::vector<byte> get_concatenation() const;
00039 
00040       std::vector<byte> DER_encode() const;
00041 
00042       bool operator==(const ECDSA_Signature& other) const
00043          {
00044          return (get_r() == other.get_r() && get_s() == other.get_s());
00045          }
00046 
00047    private:
00048       BigInt m_r;
00049       BigInt m_s;
00050    };
00051 
00052 inline bool operator!=(const ECDSA_Signature& lhs, const ECDSA_Signature& rhs)
00053    {
00054    return !(lhs == rhs);
00055    }
00056 
00057 ECDSA_Signature decode_concatenation(const std::vector<byte>& concatenation);
00058 
00059 }
00060 
00061 #endif