monotone

monotone Mtn Source Tree

Root/botan/der_enc.h

1/*************************************************
2* DER Encoder Header File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_DER_ENCODER_H__
7#define BOTAN_DER_ENCODER_H__
8
9#include <botan/asn1_oid.h>
10#include <botan/bigint.h>
11#include <vector>
12
13namespace Botan {
14
15/*************************************************
16* General DER Encoding Object *
17*************************************************/
18class DER_Encoder
19 {
20 public:
21 SecureVector<byte> get_contents();
22
23 void start_sequence(ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
24 void end_sequence(ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
25 void start_set(ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
26 void end_set(ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
27
28 void start_sequence();
29 void end_sequence();
30 void start_set();
31 void end_set();
32
33 void start_explicit(ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
34 void end_explicit(ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
35
36 void add_raw_octets(const byte[], u32bit);
37 void add_raw_octets(const MemoryRegion<byte>&);
38
39 void add_object(ASN1_Tag, ASN1_Tag, const byte[], u32bit);
40 void add_object(ASN1_Tag, ASN1_Tag, const MemoryRegion<byte>&);
41 void add_object(ASN1_Tag, ASN1_Tag, const std::string&);
42 void add_object(ASN1_Tag, ASN1_Tag, byte);
43
44 DER_Encoder();
45 private:
46 void start_cons(ASN1_Tag, ASN1_Tag, bool);
47 void end_cons(ASN1_Tag, ASN1_Tag);
48 class DER_Sequence
49 {
50 public:
51 ASN1_Tag tag_of() const;
52 SecureVector<byte> get_contents();
53 void add_bytes(const byte[], u32bit);
54 DER_Sequence(ASN1_Tag, ASN1_Tag, bool = false);
55 private:
56 ASN1_Tag type_tag, class_tag;
57 bool is_a_set;
58 SecureVector<byte> contents;
59 std::vector< SecureVector<byte> > set_contents;
60 };
61 SecureVector<byte> contents;
62 std::vector<DER_Sequence> subsequences;
63 u32bit sequence_level;
64 };
65
66/*************************************************
67* DER Encoding Functions *
68*************************************************/
69namespace DER {
70
71void encode_null(DER_Encoder&);
72void encode(DER_Encoder&, const OID&);
73
74void encode(DER_Encoder&, bool);
75void encode(DER_Encoder&, int);
76void encode(DER_Encoder&, u32bit);
77void encode(DER_Encoder&, const BigInt&);
78void encode(DER_Encoder&, const MemoryRegion<byte>&, ASN1_Tag);
79void encode(DER_Encoder&, const byte[], u32bit, ASN1_Tag);
80
81void encode(DER_Encoder&, bool, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
82void encode(DER_Encoder&, u32bit, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
83void encode(DER_Encoder&, const BigInt&, ASN1_Tag,
84 ASN1_Tag = CONTEXT_SPECIFIC);
85void encode(DER_Encoder&, const MemoryRegion<byte>&,
86 ASN1_Tag, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
87void encode(DER_Encoder&, const byte[], u32bit,
88 ASN1_Tag, ASN1_Tag, ASN1_Tag = CONTEXT_SPECIFIC);
89
90SecureVector<byte> put_in_sequence(const MemoryRegion<byte>&);
91
92}
93
94}
95
96#endif

Archive Download this file

Branches

Tags

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