Virgil Security Crypto library  2.0.7
VirgilChunkCipher.h
1 
37 #ifndef VIRGIL_CHUNK_CIPHER_H
38 #define VIRGIL_CHUNK_CIPHER_H
39 
40 #include <cstdlib>
41 
42 #include <virgil/crypto/VirgilCipherBase.h>
43 #include <virgil/crypto/VirgilByteArray.h>
44 #include <virgil/crypto/VirgilDataSource.h>
45 #include <virgil/crypto/VirgilDataSink.h>
46 
47 namespace virgil { namespace crypto {
48 
55 public:
59 
64  static constexpr size_t kPreferredChunkSize = 1024 * 1024;
66 public:
76  void encrypt(
77  VirgilDataSource& source, VirgilDataSink& sink, bool embedContentInfo = true,
78  size_t preferredChunkSize = kPreferredChunkSize);
79 
86  void decryptWithKey(
87  VirgilDataSource& source, VirgilDataSink& sink, const VirgilByteArray& recipientId,
88  const VirgilByteArray& privateKey, const VirgilByteArray& privateKeyPassword = VirgilByteArray());
89 
96  void decryptWithPassword(VirgilDataSource& source, VirgilDataSink& sink, const VirgilByteArray& pwd);
97 
98 private:
102  void storeChunkSize(size_t chunkSize);
103 
107  size_t retrieveChunkSize() const;
112  VirgilByteArray tryReadContentInfo(VirgilDataSource& source);
113 };
114 
115 }}
116 
117 #endif /* VIRGIL_CHUNK_CIPHER_H */
void decryptWithPassword(VirgilDataSource &source, VirgilDataSink &sink, const VirgilByteArray &pwd)
Decrypt data read from given source for recipient defined by password, and write it to the sink...
This class provides high-level interface to encrypt / decrypt data splitted to chunks.
Definition: VirgilChunkCipher.h:54
This is base class for output streams.
Definition: VirgilDataSink.h:49
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
void decryptWithKey(VirgilDataSource &source, VirgilDataSink &sink, const VirgilByteArray &recipientId, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray())
Decrypt data read from given source for recipient defined by id and private key, and write it to the ...
static constexpr size_t kPreferredChunkSize
Recommended chunk size.
Definition: VirgilChunkCipher.h:64
void encrypt(VirgilDataSource &source, VirgilDataSink &sink, bool embedContentInfo=true, size_t preferredChunkSize=kPreferredChunkSize)
Encrypt data read from given source and write it the sink.
This is base class for input streams.
Definition: VirgilDataSource.h:49
This class provides configuration methods to all Virgil*Cipher classes.
Definition: VirgilCipherBase.h:61