aboutsummaryrefslogtreecommitdiffstats
path: root/include/asn1_int.h
blob: 83bedf52b9d6206824abff8601e247ad2a1f0915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*************************************************
* ASN.1 Internals Header File                    *
* (C) 1999-2008 The Botan Project                *
*************************************************/

#ifndef BOTAN_ASN1_H__
#define BOTAN_ASN1_H__

#include <botan/secmem.h>
#include <botan/enums.h>
#include <botan/exceptn.h>

namespace Botan {

/*************************************************
* Basic ASN.1 Object Interface                   *
*************************************************/
class ASN1_Object
   {
   public:
      virtual void encode_into(class DER_Encoder&) const = 0;
      virtual void decode_from(class BER_Decoder&) = 0;
      virtual ~ASN1_Object() {}
   };

/*************************************************
* BER Encoded Object                             *
*************************************************/
class BER_Object
   {
   public:
      void assert_is_a(ASN1_Tag, ASN1_Tag);

      ASN1_Tag type_tag, class_tag;
      SecureVector<byte> value;
   };

/*************************************************
* ASN.1 Utility Functions                        *
*************************************************/
class DataSource;

namespace ASN1 {

SecureVector<byte> put_in_sequence(const MemoryRegion<byte>&);
std::string to_string(const BER_Object&);
bool maybe_BER(DataSource&);

}

/*************************************************
* General BER Decoding Error Exception           *
*************************************************/
struct BER_Decoding_Error : public Decoding_Error
   {
   BER_Decoding_Error(const std::string&);
   };

/*************************************************
* Exception For Incorrect BER Taggings           *
*************************************************/
struct BER_Bad_Tag : public BER_Decoding_Error
   {
   BER_Bad_Tag(const std::string&, ASN1_Tag);
   BER_Bad_Tag(const std::string&, ASN1_Tag, ASN1_Tag);
   };

}

#endif