Virgil Security Crypto library  1.8.2
VirgilCipherBase.h
1 
37 #ifndef VIRGIL_CIPHER_BASE_H
38 #define VIRGIL_CIPHER_BASE_H
39 
40 #include <map>
41 #include <set>
42 
43 #include <virgil/crypto/VirgilByteArray.h>
44 #include <virgil/crypto/VirgilCustomParams.h>
45 
49 namespace virgil { namespace crypto {
51 class VirgilCipherBaseImpl;
52 }}
53 
54 namespace virgil { namespace crypto { namespace foundation {
55 class VirgilSymmetricCipher;
56 }}}
58 
59 namespace virgil { namespace crypto {
60 
65 public:
70 
74  virtual ~VirgilCipherBase() throw();
75 
76 public:
80 
84  void addKeyRecipient(const VirgilByteArray& recipientId, const VirgilByteArray& publicKey);
85 
90  void removeKeyRecipient(const VirgilByteArray& recipientId);
91 
102  bool keyRecipientExists(const VirgilByteArray& recipientId) const;
103 
107  void addPasswordRecipient(const VirgilByteArray& pwd);
108 
113  void removePasswordRecipient(const VirgilByteArray& pwd);
114 
118  void removeAllRecipients();
120 
126 
134  VirgilByteArray getContentInfo() const;
135 
140  void setContentInfo(const VirgilByteArray& contentInfo);
141 
146  static size_t defineContentInfoSize(const VirgilByteArray& data);
152 
160  VirgilCustomParams& customParams();
162 
167  const VirgilCustomParams& customParams() const;
169 
172 
186  static VirgilByteArray computeShared(
187  const VirgilByteArray& publicKey,
188  const VirgilByteArray& privateKey, const VirgilByteArray& privateKeyPassword = VirgilByteArray());
190 
191 protected:
200  VirgilByteArray tryReadContentInfo(const VirgilByteArray& encryptedData);
201 
221  const VirgilByteArray& encryptedDataInfo,
222  const VirgilByteArray& recipientId, const VirgilByteArray& privateKey,
223  const VirgilByteArray& privateKeyPassword = VirgilByteArray());
224 
231 
240  const VirgilByteArray& recipientId,
241  const VirgilByteArray& privateKey, const VirgilByteArray& privateKeyPassword);
242 
248 
255  void buildContentInfo();
256 
265  void clearCipherInfo();
266 
267 private:
268  VirgilCipherBase(const VirgilCipherBase& other);
269 
270  VirgilCipherBase& operator=(const VirgilCipherBase& rhs);
271 
272 private:
273  VirgilCipherBaseImpl* impl_;
274 };
275 
276 }}
277 
278 #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.
Definition: VirgilAsn1Compatible.h:46
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.
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:57
void removePasswordRecipient(const VirgilByteArray &pwd)
Remove recipient with given password.
void buildContentInfo()
Build VirgilContentInfo object.
void removeKeyRecipient(const VirgilByteArray &recipientId)
Remove recipient with given id.
virtual ~VirgilCipherBase()
Dispose used resources.
This class provides configuration methods to all Virgil*Cipher classes.
Definition: VirgilCipherBase.h:64
VirgilCipherBase()
Initialize randomization module used by encryption.
static size_t defineContentInfoSize(const VirgilByteArray &data)
Read content info size as part of the data.