Botan: Botan::CMS_Decoder Class Reference

Botan 1.10.16

Public Types | Public Member Functions | List of all members
Botan::CMS_Decoder Class Reference

`#include <cms_dec.h>`

## Public Types
enum | Content_Type { DATA, UNKNOWN, COMPRESSED, ENVELOPED, SIGNED, AUTHENTICATED, DIGESTED }
enum | Status { GOOD, BAD, NO_KEY, FAILURE }

## Public Member Functions
void | add_key (Private_Key *)
| CMS_Decoder (DataSource &, const X509_Store &, Private_Key *=0)
std::vector< X509_Certificate > | get_certs () const
std::vector< X509_CRL > | get_crls () const
std::string | get_data () const
std::string | layer_algo () const
std::string | layer_info () const
Status | layer_status () const
Content_Type | layer_type () const
void | next_layer ()

## Detailed Description

CMS Decoding Operation

Definition at line 21 of file cms_dec.h.

## Member Enumeration Documentation

## ◆ Content_Type

enum Botan::CMS_Decoder::Content_Type

Enumerator
DATA |
UNKNOWN |
COMPRESSED |
ENVELOPED |
SIGNED |
AUTHENTICATED |
DIGESTED |

Definition at line 26 of file cms_dec.h.

26 { DATA, UNKNOWN, COMPRESSED, ENVELOPED, SIGNED,
27 AUTHENTICATED, DIGESTED };
Botan::CMS_Decoder::DIGESTED
Definition: cms_dec.h:27
Botan::CMS_Decoder::SIGNED
Definition: cms_dec.h:26
Botan::CMS_Decoder::ENVELOPED
Definition: cms_dec.h:26
Botan::CMS_Decoder::COMPRESSED
Definition: cms_dec.h:26
Botan::CMS_Decoder::AUTHENTICATED
Definition: cms_dec.h:27
Botan::CMS_Decoder::UNKNOWN
Definition: cms_dec.h:26
Botan::CMS_Decoder::DATA
Definition: cms_dec.h:26

## ◆ Status

enum Botan::CMS_Decoder::Status

Enumerator
GOOD |
BAD |
NO_KEY |
FAILURE |

Definition at line 24 of file cms_dec.h.

24 { GOOD, BAD, NO_KEY, FAILURE };
Botan::CMS_Decoder::BAD
Definition: cms_dec.h:24
Botan::CMS_Decoder::FAILURE
Definition: cms_dec.h:24
Botan::CMS_Decoder::GOOD
Definition: cms_dec.h:24
Botan::CMS_Decoder::NO_KEY
Definition: cms_dec.h:24

## Constructor & Destructor Documentation

## ◆ CMS_Decoder()

Botan::CMS_Decoder::CMS_Decoder | ( | DataSource & | in,
|  | const X509_Store & | x509store,
|  | Private_Key * | key = `0`
| ) |  |

Definition at line 19 of file cms_dec.cpp.

References add_key(), Botan::PEM_Code::decode_check_label(), GOOD, Botan::PEM_Code::matches(), and Botan::ASN1::maybe_BER().

20 :
21 store(x509store)
22 {
23 status = GOOD;
24
25 add_key(key);
26
27 if(ASN1::maybe_BER(in) && !PEM_Code::matches(in))
28 initial_read(in);
29 else
30 {
31 DataSource_Memory ber(PEM_Code::decode_check_label(in, "PKCS7"));
32 initial_read(ber);
33 }
34 }
Botan::ASN1::maybe_BER
bool maybe_BER(DataSource &source)
Definition: asn1_int.cpp:55
Botan::CMS_Decoder::GOOD
Definition: cms_dec.h:24
Botan::CMS_Decoder::add_key
void add_key(Private_Key *)
Definition: cms_dec.cpp:60
Botan::PEM_Code::matches
bool matches(DataSource &source, const std::string &extra, size_t search_range)
Definition: pem.cpp:116
Botan::PEM_Code::decode_check_label
SecureVector< byte > decode_check_label(DataSource &source, const std::string &label_want)
Definition: pem.cpp:42

## Member Function Documentation

## ◆ add_key()

void Botan::CMS_Decoder::add_key | ( | Private_Key * | key | ) |

Definition at line 60 of file cms_dec.cpp.

Referenced by CMS_Decoder().

61 {
62 if(!key)
63 return;
64
65 #if 0
66 for(u32bit j = 0; j != keys.size(); j++)
67 if(keys[j]->key_id() == key->key_id())
68 return;
69 #endif
70
71 keys.push_back(key);
72 }
Botan::u32bit
unsigned int u32bit
Definition: types.h:32

## ◆ get_certs()

std::vector<X509_Certificate> Botan::CMS_Decoder::get_certs | ( |  | ) | const

## ◆ get_crls()

std::vector<X509_CRL> Botan::CMS_Decoder::get_crls | ( |  | ) | const

## ◆ get_data()

std::string Botan::CMS_Decoder::get_data | ( |  | ) | const

Definition at line 85 of file cms_dec.cpp.

References DATA, layer_type(), and Botan::MemoryRegion< T >::size().

86 {
87 if(layer_type() != DATA)
88 throw Invalid_State("CMS: Cannot retrieve data from non-DATA layer");
89
90 return std::string(reinterpret_cast<const char*>(&data[0]),
91 data.size());
92 }
Botan::CMS_Decoder::layer_type
Content_Type layer_type() const
Definition: cms_dec.cpp:97
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::CMS_Decoder::DATA
Definition: cms_dec.h:26

## ◆ layer_algo()

std::string Botan::CMS_Decoder::layer_algo | ( |  | ) | const

## ◆ layer_info()

std::string Botan::CMS_Decoder::layer_info | ( |  | ) | const

Definition at line 111 of file cms_dec.cpp.

References Botan::BER_Decoder::decode(), Botan::SEQUENCE, and Botan::BER_Decoder::start_cons().

112 {
113 return info;
114 }

## ◆ layer_status()

CMS_Decoder::Status Botan::CMS_Decoder::layer_status | ( |  | ) | const

Definition at line 77 of file cms_dec.cpp.

78 {
79 return status;
80 }

## ◆ layer_type()

CMS_Decoder::Content_Type Botan::CMS_Decoder::layer_type | ( |  | ) | const

Definition at line 97 of file cms_dec.cpp.

References AUTHENTICATED, COMPRESSED, DATA, DIGESTED, ENVELOPED, Botan::OIDS::lookup(), SIGNED, and UNKNOWN.

Referenced by get_data().

98 {
99 if(type == OIDS::lookup("CMS.DataContent")) return DATA;
100 if(type == OIDS::lookup("CMS.EnvelopedData")) return ENVELOPED;
101 if(type == OIDS::lookup("CMS.CompressedData")) return COMPRESSED;
102 if(type == OIDS::lookup("CMS.SignedData")) return SIGNED;
103 if(type == OIDS::lookup("CMS.AuthenticatedData")) return AUTHENTICATED;
104 if(type == OIDS::lookup("CMS.DigestedData")) return DIGESTED;
105 return UNKNOWN;
106 }
Botan::CMS_Decoder::DIGESTED
Definition: cms_dec.h:27
Botan::CMS_Decoder::SIGNED
Definition: cms_dec.h:26
Botan::CMS_Decoder::ENVELOPED
Definition: cms_dec.h:26
Botan::CMS_Decoder::COMPRESSED
Definition: cms_dec.h:26
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:31
Botan::CMS_Decoder::AUTHENTICATED
Definition: cms_dec.h:27
Botan::CMS_Decoder::UNKNOWN
Definition: cms_dec.h:26
Botan::CMS_Decoder::DATA
Definition: cms_dec.h:26

## ◆ next_layer()

void Botan::CMS_Decoder::next_layer | ( |  | ) |
| inline

Definition at line 37 of file cms_dec.h.

37 { decode_layer(); }

The documentation for this class was generated from the following files:

- src/cms/cms_dec.h
- src/cms/cms_comp.cpp
- src/cms/cms_dalg.cpp
- src/cms/cms_dec.cpp