/*************************************************
* X.509 SIGNED Object Header File                *
* (C) 1999-2003 The Botan Project                *
*************************************************/

#ifndef BOTAN_X509_OBJECT_H__
#define BOTAN_X509_OBJECT_H__

#include <botan/asn1_obj.h>
#include <botan/pipe.h>
#include <vector>

namespace Botan {

/*************************************************
* Generic X.509 SIGNED Object                    *
*************************************************/
class X509_Object
   {
   public:
      SecureVector<byte> tbs_data() const;
      SecureVector<byte> signature() const;
      AlgorithmIdentifier signature_algorithm() const;

      void encode(Pipe&, X509_Encoding = PEM) const;
      std::string PEM_encode() const;

      virtual void force_decode() = 0;

      X509_Object(DataSource&, const std::string&, X509_Encoding);
      X509_Object(const std::string&, const std::string&, X509_Encoding);
      virtual ~X509_Object() {}
   protected:
      X509_Object() {}
      AlgorithmIdentifier sig_algo;
      SecureVector<byte> tbs_bits, sig;
      std::vector<std::string> PEM_labels_allowed;
      std::string PEM_label_pref;
   private:
      void init(DataSource&, const std::string&, X509_Encoding);
      void decode_info(DataSource&);
   };

}

#endif
