Virgil Security Crypto library  2.0.7
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 <virgil/crypto/VirgilByteArray.h>
45 #include <virgil/crypto/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 
152 
159  void setContentInfo(const VirgilByteArray& contentInfo);
160 
165  static size_t defineContentInfoSize(const VirgilByteArray& data);
167 
174 
181 
186  const VirgilCustomParams& customParams() const;
188 
191 
206  const VirgilByteArray& publicKey,
207  const VirgilByteArray& privateKey, const VirgilByteArray& privateKeyPassword = VirgilByteArray());
209 
210 protected:
219  VirgilByteArray tryReadContentInfo(const VirgilByteArray& encryptedData);
220 
240  const VirgilByteArray& encryptedDataInfo,
241  const VirgilByteArray& recipientId, const VirgilByteArray& privateKey,
242  const VirgilByteArray& privateKeyPassword = VirgilByteArray());
243 
250 
259  const VirgilByteArray& recipientId,
260  const VirgilByteArray& privateKey, const VirgilByteArray& privateKeyPassword);
261 
267 
274  void buildContentInfo();
275 
284  void clearCipherInfo();
285 
286 public:
288  VirgilCipherBase(VirgilCipherBase&& rhs) noexcept;
289 
290  VirgilCipherBase& operator=(VirgilCipherBase&& rhs) noexcept;
291 
292  virtual ~VirgilCipherBase() noexcept;
294 private:
295  class Impl;
296 
297  std::unique_ptr<Impl> impl_;
298 };
299 
300 }}
301 
302 #endif /* VIRGIL_CIPHER_BASE_H */
Data object that represent ASN.1 structure: VirgilCustomParams.
Definition: VirgilCustomParams.h:51
virgil::crypto::foundation::VirgilSymmetricCipher & initDecryption(const VirgilByteArray &encryptedDataInfo, const VirgilByteArray &recipientId, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray())
Configures symmetric cipher for encryption.
void addPasswordRecipient(const VirgilByteArray &pwd)
Add recipient defined with password.
void clearCipherInfo()
Clear all information related to the cipher.
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:53
VirgilByteArray getContentInfo() const
Returns encrypted data 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.