Botan 1.10.17

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
25 void encrypt(RandomNumberGenerator&,
26 const X509_Certificate&, const std::string = "");
27
28 void encrypt(RandomNumberGenerator& rng,
29 const std::string&, const std::string& = "");
30
31 void encrypt(RandomNumberGenerator& rng,
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,
40 RandomNumberGenerator& rng,
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&,
62 const X509_Certificate&, Public_Key*,
63 const std::string&);
64 void encrypt_kari(RandomNumberGenerator&,
65 const X509_Certificate&, Public_Key*,
66 const std::string&);
67
68 SecureVector<byte> do_encrypt(RandomNumberGenerator& rng,
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
Botan::OctetString
Definition: symkey.h:19
Botan::RandomNumberGenerator
Definition: rng.h:20
Botan::Private_Key
Definition: pk_keys.h:86
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::CMS_Encoder
Definition: cms_enc.h:21
Botan::DER_Encoder
Definition: der_enc.h:22
Botan::X509_Certificate
Definition: x509cert.h:23
Botan
Definition: algo_base.h:14
Botan::Public_Key
Definition: pk_keys.h:21
Botan::CMS_Encoder::CMS_Encoder
CMS_Encoder(const std::string &str)
Definition: cms_enc.h:56
Botan::SecureVector< byte >
Botan::CMS_Encoder::CMS_Encoder
CMS_Encoder(const byte buf[], size_t length)
Definition: cms_enc.h:57