monotone

monotone Mtn Source Tree

Root/botan/asn1_obj.h

1/*************************************************
2* Common ASN.1 Objects Header File *
3* (C) 1999-2006 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_ASN1_OBJ_H__
7#define BOTAN_ASN1_OBJ_H__
8
9#include <botan/asn1_int.h>
10#include <botan/asn1_oid.h>
11#include <botan/alg_id.h>
12#include <vector>
13#include <map>
14
15namespace Botan {
16
17/*************************************************
18* Attribute *
19*************************************************/
20class Attribute : public ASN1_Object
21 {
22 public:
23 void encode_into(class DER_Encoder&) const;
24 void decode_from(class BER_Decoder&);
25
26 OID oid;
27 SecureVector<byte> parameters;
28
29 Attribute() {}
30 Attribute(const OID&, const MemoryRegion<byte>&);
31 Attribute(const std::string&, const MemoryRegion<byte>&);
32 };
33
34/*************************************************
35* X.509 Time *
36*************************************************/
37class X509_Time : public ASN1_Object
38 {
39 public:
40 void encode_into(class DER_Encoder&) const;
41 void decode_from(class BER_Decoder&);
42
43 std::string as_string() const;
44 std::string readable_string() const;
45 bool time_is_set() const;
46
47 s32bit cmp(const X509_Time&) const;
48
49 void set_to(const std::string&);
50 void set_to(const std::string&, ASN1_Tag);
51
52 X509_Time(u64bit);
53 X509_Time(const std::string& = "");
54 X509_Time(const std::string&, ASN1_Tag);
55 private:
56 bool passes_sanity_check() const;
57 u32bit year, month, day, hour, minute, second;
58 ASN1_Tag tag;
59 };
60
61/*************************************************
62* Simple String *
63*************************************************/
64class ASN1_String : public ASN1_Object
65 {
66 public:
67 void encode_into(class DER_Encoder&) const;
68 void decode_from(class BER_Decoder&);
69
70 std::string value() const;
71 std::string iso_8859() const;
72
73 ASN1_Tag tagging() const;
74
75 ASN1_String(const std::string& = "");
76 ASN1_String(const std::string&, ASN1_Tag);
77 private:
78 std::string iso_8859_str;
79 ASN1_Tag tag;
80 };
81
82/*************************************************
83* Distinguished Name *
84*************************************************/
85class X509_DN : public ASN1_Object
86 {
87 public:
88 void encode_into(class DER_Encoder&) const;
89 void decode_from(class BER_Decoder&);
90
91 std::multimap<OID, std::string> get_attributes() const;
92 std::vector<std::string> get_attribute(const std::string&) const;
93
94 std::multimap<std::string, std::string> contents() const;
95
96 void add_attribute(const std::string&, const std::string&);
97 void add_attribute(const OID&, const std::string&);
98
99 static std::string deref_info_field(const std::string&);
100
101 void do_decode(const MemoryRegion<byte>&);
102 SecureVector<byte> get_bits() const;
103
104 X509_DN();
105 X509_DN(const std::multimap<OID, std::string>&);
106 X509_DN(const std::multimap<std::string, std::string>&);
107 private:
108 std::multimap<OID, ASN1_String> dn_info;
109 SecureVector<byte> dn_bits;
110 };
111
112/*************************************************
113* Alternative Name *
114*************************************************/
115class AlternativeName : public ASN1_Object
116 {
117 public:
118 void encode_into(class DER_Encoder&) const;
119 void decode_from(class BER_Decoder&);
120
121 std::multimap<std::string, std::string> contents() const;
122
123 void add_attribute(const std::string&, const std::string&);
124 std::multimap<std::string, std::string> get_attributes() const;
125
126 void add_othername(const OID&, const std::string&, ASN1_Tag);
127 std::multimap<OID, ASN1_String> get_othernames() const;
128
129 bool has_items() const;
130
131 AlternativeName(const std::string& = "", const std::string& = "",
132 const std::string& = "");
133 private:
134 std::multimap<std::string, std::string> alt_info;
135 std::multimap<OID, ASN1_String> othernames;
136 };
137
138/*************************************************
139* Comparison Operations *
140*************************************************/
141bool operator==(const AlgorithmIdentifier&, const AlgorithmIdentifier&);
142bool operator!=(const AlgorithmIdentifier&, const AlgorithmIdentifier&);
143
144bool operator==(const X509_Time&, const X509_Time&);
145bool operator!=(const X509_Time&, const X509_Time&);
146bool operator<=(const X509_Time&, const X509_Time&);
147bool operator>=(const X509_Time&, const X509_Time&);
148
149bool operator==(const X509_DN&, const X509_DN&);
150bool operator!=(const X509_DN&, const X509_DN&);
151bool operator<(const X509_DN&, const X509_DN&);
152
153/*************************************************
154* Helper Functions *
155*************************************************/
156s32bit validity_check(const X509_Time&, const X509_Time&, u64bit);
157
158bool is_string_type(ASN1_Tag);
159
160}
161
162#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status