Botan 1.10.17
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_Certificateget_certs () const
std::vector< X509_CRLget_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

Enumerator
DATA 
UNKNOWN 
COMPRESSED 
ENVELOPED 
SIGNED 
AUTHENTICATED 
DIGESTED 

Definition at line 26 of file cms_dec.h.

◆ Status

Enumerator
GOOD 
BAD 
NO_KEY 
FAILURE 

Definition at line 24 of file cms_dec.h.

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.

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

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

Member Function Documentation

◆ add_key()

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

Definition at line 60 of file cms_dec.cpp.

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 }
unsigned int u32bit
Definition types.h:32

Referenced by CMS_Decoder().

◆ 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.

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 }
Content_Type layer_type() const
Definition cms_dec.cpp:97
Invalid_State(const std::string &err)
Definition exceptn.h:27

References DATA, Botan::Invalid_State::Invalid_State(), and layer_type().

Referenced by layer_algo().

◆ layer_algo()

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

References get_data().

◆ layer_info()

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

Definition at line 111 of file cms_dec.cpp.

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.

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 }
std::string lookup(const OID &oid)
Definition oids.cpp:31

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

Referenced by get_data().

◆ 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: