Botan  1.10.9
cms_enc.h
Go to the documentation of this file.
1 /*
2 * CMS Encoding
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_CMS_ENCODER_H__
9 #define BOTAN_CMS_ENCODER_H__
10 
11 #include <botan/x509cert.h>
12 #include <botan/x509stor.h>
13 #include <botan/pkcs8.h>
14 #include <botan/symkey.h>
15 
16 namespace Botan {
17 
18 /**
19 * CMS Encoding Operation
20 */
21 class BOTAN_DLL CMS_Encoder
22  {
23  public:
24 
26  const X509_Certificate&, const std::string = "");
27 
29  const std::string&, const std::string& = "");
30 
32  const SymmetricKey&, const std::string& = "");
33 
34  void authenticate(const X509_Certificate&, const std::string& = "");
35  void authenticate(const std::string&, const std::string& = "");
36  void authenticate(const SymmetricKey&, const std::string& = "");
37 
38  void sign(const X509_Certificate& cert,
39  const Private_Key& key,
41  const std::vector<X509_Certificate>& cert_chain,
42  const std::string& hash,
43  const std::string& padding);
44 
45  void digest(const std::string& = "");
46 
47  void compress(const std::string&);
48  static bool can_compress_with(const std::string&);
49 
50  SecureVector<byte> get_contents();
51  std::string PEM_contents();
52 
53  void set_data(const std::string&);
54  void set_data(const byte[], size_t);
55 
56  CMS_Encoder(const std::string& str) { set_data(str); }
57  CMS_Encoder(const byte buf[], size_t length) { set_data(buf, length); }
58  private:
59  void add_layer(const std::string&, DER_Encoder&);
60 
61  void encrypt_ktri(RandomNumberGenerator&,
63  const std::string&);
64  void encrypt_kari(RandomNumberGenerator&,
66  const std::string&);
67 
69  const SymmetricKey&, const std::string&);
70 
71  static SecureVector<byte> make_econtent(const SecureVector<byte>&,
72  const std::string&);
73 
74  static SymmetricKey setup_key(RandomNumberGenerator& rng,
75  const std::string&);
76 
77  static SecureVector<byte> wrap_key(RandomNumberGenerator& rng,
78  const std::string&,
79  const SymmetricKey&,
80  const SymmetricKey&);
81 
82  static SecureVector<byte> encode_params(const std::string&,
83  const SymmetricKey&,
84  const InitializationVector&);
85 
86  SecureVector<byte> data;
87  std::string type;
88  };
89 
90 }
91 
92 #endif
unsigned char byte
Definition: types.h:22
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
EVP_CIPHER_CTX encrypt
Definition: ossl_bc.cpp:43
CMS_Encoder(const std::string &str)
Definition: cms_enc.h:56
CMS_Encoder(const byte buf[], size_t length)
Definition: cms_enc.h:57