Botan  1.10.9
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_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

Enumerator
DATA 
UNKNOWN 
COMPRESSED 
ENVELOPED 
SIGNED 
AUTHENTICATED 
DIGESTED 

Definition at line 26 of file cms_dec.h.

Enumerator
GOOD 
BAD 
NO_KEY 
FAILURE 

Definition at line 24 of file cms_dec.h.

Constructor & Destructor Documentation

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  }
bool maybe_BER(DataSource &source)
Definition: asn1_int.cpp:55
void add_key(Private_Key *)
Definition: cms_dec.cpp:60
bool matches(DataSource &source, const std::string &extra, size_t search_range)
Definition: pem.cpp:116
SecureVector< byte > decode_check_label(DataSource &source, const std::string &label_want)
Definition: pem.cpp:42

Member Function Documentation

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  }
unsigned int u32bit
Definition: types.h:32
std::vector<X509_Certificate> Botan::CMS_Decoder::get_certs ( ) const
std::vector<X509_CRL> Botan::CMS_Decoder::get_crls ( ) const
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  }
size_t size() const
Definition: secmem.h:29
Content_Type layer_type() const
Definition: cms_dec.cpp:97
std::string Botan::CMS_Decoder::layer_algo ( ) const
std::string Botan::CMS_Decoder::layer_info ( ) const

Definition at line 111 of file cms_dec.cpp.

112  {
113  return info;
114  }
CMS_Decoder::Status Botan::CMS_Decoder::layer_status ( ) const

Definition at line 77 of file cms_dec.cpp.

78  {
79  return status;
80  }
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  }
std::string lookup(const OID &oid)
Definition: oids.cpp:31
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: