Virgil Security Crypto library  2.6.3
VirgilContentInfo.h
1 
37 #ifndef VIRGIL_CRYPTO_CONTENT_INFO_H
38 #define VIRGIL_CRYPTO_CONTENT_INFO_H
39 
40 #include "VirgilCustomParams.h"
41 #include "foundation/asn1/VirgilAsn1Compatible.h"
42 
43 #include <memory>
44 #include <functional>
45 
46 namespace virgil { namespace crypto {
47 
52 public:
64  size_t asn1Write(
67  size_t childWrittenBytes = 0) const override;
68 
71 public:
79 
86  void addKeyRecipient(const VirgilByteArray& recipientId, const VirgilByteArray& publicKey);
87 
98  bool hasKeyRecipient(const VirgilByteArray& recipientId) const;
99 
105  void removeKeyRecipient(const VirgilByteArray& recipientId);
106 
110  void removeKeyRecipients();
111 
120  void addPasswordRecipient(const VirgilByteArray& pwd);
121 
131  bool hasPasswordRecipient(const VirgilByteArray& password) const;
132 
137  void removePasswordRecipient(const VirgilByteArray& pwd);
138 
143 
147  void removeAllRecipients();
149 
157 
164 
169  const VirgilCustomParams& customParams() const;
171 
175  static size_t defineSize(const VirgilByteArray& contentInfoData);
178 
179 private:
185 
189  VirgilByteArray decryptKeyRecipient(
190  const VirgilByteArray& recipientId,
191  std::function<VirgilByteArray(
192  const VirgilByteArray& algorithm, const VirgilByteArray& encryptedKey)> decrypt) const;
193 
197  VirgilByteArray decryptPasswordRecipient(
198  std::function<VirgilByteArray(
199  const VirgilByteArray& algorithm, const VirgilByteArray& encryptedKey)> decrypt) const;
200 
201  struct EncryptionResult {
202  VirgilByteArray encryptionAlgorithm;
203  VirgilByteArray encryptedContent;
204  };
205 
206  void encryptKeyRecipients(std::function<EncryptionResult(const VirgilByteArray& publicKey)> encrypt);
207 
208  void encryptPasswordRecipients(std::function<EncryptionResult(const VirgilByteArray& pwd)> encrypt);
209 
210  void setContentEncryptionAlgorithm(const VirgilByteArray& contentEncryptionAlgorithm);
211 
212  VirgilByteArray getContentEncryptionAlgorithm() const;
213 
214  bool isReadyForEncryption();
215 
216  bool isReadyForDecryption();
217 
218  friend class VirgilCipherBase;
220 
221 public:
223  VirgilContentInfo(VirgilContentInfo&& rhs) noexcept;
224 
225  VirgilContentInfo& operator=(VirgilContentInfo&& rhs) noexcept;
226 
227  ~VirgilContentInfo() noexcept;
229 
230 private:
231  class Impl;
232 
233  std::unique_ptr<Impl> impl_;
234 };
235 
236 }}
237 
238 #endif //VIRGIL_CRYPTO_CONTENT_INFO_H
void asn1Read(virgil::crypto::foundation::asn1::VirgilAsn1Reader &asn1Reader) override
Read object state from the reader.
Data object that represent ASN.1 structure: VirgilCustomParams.
Definition: VirgilCustomParams.h:51
This class provides methods for reading ASN.1 data structure.
Definition: VirgilAsn1Reader.h:53
void removeKeyRecipients()
Remove all recipients defined with identifier.
void removePasswordRecipients()
Remove all recipients defined with password.
This class provides interface that allow to save and restore object state in the ASN.1 structure.
Definition: VirgilAsn1Compatible.h:59
size_t asn1Write(virgil::crypto::foundation::asn1::VirgilAsn1Writer &asn1Writer, size_t childWrittenBytes=0) const override
Write object state to the writer.
Definition: VirgilContentInfo.h:51
This class provides methods for writing ASN.1 data structure.
Definition: VirgilAsn1Writer.h:54
VirgilContentInfo()
PIMPL initialization.
Root namespace for all Virgil Security libraries.
Definition: VirgilAsn1Compatible.h:46
std::vector< unsigned char > VirgilByteArray
This type represents a sequence of bytes.
Definition: VirgilByteArray.h:50
void removePasswordRecipient(const VirgilByteArray &pwd)
Remove recipient with given password.
VirgilCustomParams & customParams()
Provide access to the object that handles custom parameters.
bool hasPasswordRecipient(const VirgilByteArray &password) const
Check whether recipient with given password exists.
void removeKeyRecipient(const VirgilByteArray &recipientId)
Remove recipient with given identifier.
bool hasKeyRecipient(const VirgilByteArray &recipientId) const
Check whether recipient with given identifier exists.
void addPasswordRecipient(const VirgilByteArray &pwd)
Add recipient defined with password.
void addKeyRecipient(const VirgilByteArray &recipientId, const VirgilByteArray &publicKey)
Add recipient defined with id and public key.
void removeAllRecipients()
Remove all recipients.
This class provides configuration methods to all Virgil*Cipher classes.
Definition: VirgilCipherBase.h:61