Virgil Security Crypto library  2.4.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
VirgilCipherBase.h
1 
37 #ifndef VIRGIL_CIPHER_BASE_H
38 #define VIRGIL_CIPHER_BASE_H
39 
40 #include <map>
41 #include <set>
42 #include <memory>
43 
44 #include "VirgilByteArray.h"
45 #include "VirgilCustomParams.h"
46 
50 namespace virgil { namespace crypto { namespace foundation {
52 class VirgilSymmetricCipher;
53 }}}
55 
56 namespace virgil { namespace crypto {
57 
62 public:
67 
68 public:
72 
79  void addKeyRecipient(const VirgilByteArray& recipientId, const VirgilByteArray& publicKey);
80 
86  void removeKeyRecipient(const VirgilByteArray& recipientId);
87 
98  bool keyRecipientExists(const VirgilByteArray& recipientId) const;
99 
108  void addPasswordRecipient(const VirgilByteArray& pwd);
109 
114  void removePasswordRecipient(const VirgilByteArray& pwd);
115 
125  bool passwordRecipientExists(const VirgilByteArray& password) const;
126 
130  void removeAllRecipients();
132 
138 
149 
156  void setContentInfo(const VirgilByteArray& contentInfo);
157 
162  static size_t defineContentInfoSize(const VirgilByteArray& data);
164 
171 
178 
183  const VirgilCustomParams& customParams() const;
185 
188 
203  const VirgilByteArray& publicKey,
204  const VirgilByteArray& privateKey, const VirgilByteArray& privateKeyPassword = VirgilByteArray());
206 
207 protected:
216  VirgilByteArray tryReadContentInfo(const VirgilByteArray& encryptedData);
217 
225 
232 
241  const VirgilByteArray& recipientId,
242  const VirgilByteArray& privateKey, const VirgilByteArray& privateKeyPassword);
243 
249 
256  void buildContentInfo();
257 
266  void clearCipherInfo();
267 
268 public:
270  VirgilCipherBase(VirgilCipherBase&& rhs) noexcept;
271 
272  VirgilCipherBase& operator=(VirgilCipherBase&& rhs) noexcept;
273 
274  virtual ~VirgilCipherBase() noexcept;
276 
277 private:
278  virtual VirgilByteArray doDecryptWithKey(
279  const VirgilByteArray& algorithm, const VirgilByteArray& encryptedKey,
280  const VirgilByteArray& privateKey, const VirgilByteArray& privateKeyPassword) const;
281 
282  virtual VirgilByteArray doDecryptWithPassword(
283  const VirgilByteArray& encryptedKey, const VirgilByteArray& encryptionAlgorithm,
284  const VirgilByteArray& password) const;
285 
286 private:
287  class Impl;
288 
289  std::unique_ptr<Impl> impl_;
290 };
291 
292 }}
293 
294 #endif /* VIRGIL_CIPHER_BASE_H */
Data object that represent ASN.1 structure: VirgilCustomParams.
Definition: VirgilCustomParams.h:51
void addPasswordRecipient(const VirgilByteArray &pwd)
Add recipient defined with password.
void clearCipherInfo()
Clear all information related to the cipher.
std::vector< unsigned char > VirgilByteArray
This type represents a sequence of bytes.
Definition: VirgilByteArray.h:50
VirgilByteArray getContentInfo() const
Return content info.
void addKeyRecipient(const VirgilByteArray &recipientId, const VirgilByteArray &publicKey)
Add recipient defined with id and public key.
virgil::crypto::foundation::VirgilSymmetricCipher & initDecryptionWithPassword(const VirgilByteArray &pwd)
Configures symmetric cipher for decryption based on the recipient's password.
VirgilByteArray tryReadContentInfo(const VirgilByteArray &encryptedData)
Make attempt to read content info from the encrypted data.
bool keyRecipientExists(const VirgilByteArray &recipientId) const
Check whether recipient with given identifier exists.
virgil::crypto::foundation::VirgilSymmetricCipher & initDecryptionWithKey(const VirgilByteArray &recipientId, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword)
Configures symmetric cipher for decryption based on the recipient's id and private key...
void removeAllRecipients()
Remove all recipients.
static VirgilByteArray computeShared(const VirgilByteArray &publicKey, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray())
Compute shared secret key on a given keys.
bool passwordRecipientExists(const VirgilByteArray &password) const
Check whether recipient with given password exists.
virgil::crypto::foundation::VirgilSymmetricCipher & getSymmetricCipher()
Return symmetric cipher configure by one of the methods: initEncryption(), initDecryptionWithPassword...
virgil::crypto::foundation::VirgilSymmetricCipher & initEncryption()
Configures symmetric cipher for encryption.
void setContentInfo(const VirgilByteArray &contentInfo)
Create content info object from ASN.1 structure.
Provides symmetric ciphers algorithms.
Definition: VirgilSymmetricCipher.h:52
void removePasswordRecipient(const VirgilByteArray &pwd)
Remove recipient with given password.
void buildContentInfo()
Build VirgilContentInfo object.
VirgilCustomParams & customParams()
Provide access to the object that handles custom parameters.
void removeKeyRecipient(const VirgilByteArray &recipientId)
Remove recipient with given identifier.
This class provides configuration methods to all Virgil*Cipher classes.
Definition: VirgilCipherBase.h:61
VirgilCipherBase()
Initialize submodules.
static size_t defineContentInfoSize(const VirgilByteArray &data)
Read content info size as part of the data.