Virgil Security Crypto library  2.0.7
VirgilTinyCipher.h
1 
37 #ifndef VIRGIL_CRYPTO_TINY_CIPHER_H
38 #define VIRGIL_CRYPTO_TINY_CIPHER_H
39 
40 #include <memory>
41 #include <string>
42 
43 #include <virgil/crypto/VirgilByteArray.h>
44 
45 namespace virgil { namespace crypto {
46 
50 class VirgilTinyCipherImpl;
51 
120 public:
125  enum PackageSize {
129  };
130 public:
134 
144  explicit VirgilTinyCipher(size_t packageSize = PackageSize_Short_SMS);
145 
151  void reset();
153 
156 
167  void encrypt(const VirgilByteArray& data, const VirgilByteArray& recipientPublicKey);
168 
183  void encryptAndSign(
184  const VirgilByteArray& data, const VirgilByteArray& recipientPublicKey,
185  const VirgilByteArray& senderPrivateKey,
186  const VirgilByteArray& senderPrivateKeyPassword = VirgilByteArray());
187 
195  size_t getPackageCount() const;
196 
208  VirgilByteArray getPackage(size_t index) const;
210 
213 
225  void addPackage(const VirgilByteArray& package);
226 
234  bool isPackagesAccumulated() const;
235 
248  const VirgilByteArray& recipientPrivateKey,
249  const VirgilByteArray& recipientPrivateKeyPassword = VirgilByteArray());
250 
262  const VirgilByteArray& senderPublicKey,
263  const VirgilByteArray& recipientPrivateKey,
264  const VirgilByteArray& recipientPrivateKeyPassword = VirgilByteArray());
266 public:
268  VirgilTinyCipher(VirgilTinyCipher&& rhs) noexcept;
269 
270  VirgilTinyCipher& operator=(VirgilTinyCipher&& rhs) noexcept;
271 
272  virtual ~VirgilTinyCipher() noexcept;
274 
275 private:
276  class Impl;
277 
278  std::unique_ptr<Impl> impl_;
279 };
280 
281 }}
282 
283 #endif // VIRGIL_CRYPTO_TINY_CIPHER_H
Min.
Definition: VirgilTinyCipher.h:126
PackageSize
Constants that represents maximum number of bytes in one package.
Definition: VirgilTinyCipher.h:125
VirgilByteArray getPackage(size_t index) const
Return specific package.
void encrypt(const VirgilByteArray &data, const VirgilByteArray &recipientPublicKey)
Encrypt data with given public key.
VirgilByteArray verifyAndDecrypt(const VirgilByteArray &senderPublicKey, const VirgilByteArray &recipientPrivateKey, const VirgilByteArray &recipientPrivateKeyPassword=VirgilByteArray())
Verify accumulated packages and then decrypt it.
VirgilTinyCipher(size_t packageSize=PackageSize_Short_SMS)
Init cipher with given maximum package size.
Definition: VirgilHash.h:252
void addPackage(const VirgilByteArray &package)
Add package.
VirgilByteArray decrypt(const VirgilByteArray &recipientPrivateKey, const VirgilByteArray &recipientPrivateKeyPassword=VirgilByteArray())
Decrypt accumulated packages.
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
Long SMS.
Definition: VirgilTinyCipher.h:128
Short SMS.
Definition: VirgilTinyCipher.h:127
void reset()
Prepare cipher for the next encryption.
This class aim is to minimize encryption output.
Definition: VirgilTinyCipher.h:119
bool isPackagesAccumulated() const
Define whether all packages was accumulated or not.
void encryptAndSign(const VirgilByteArray &data, const VirgilByteArray &recipientPublicKey, const VirgilByteArray &senderPrivateKey, const VirgilByteArray &senderPrivateKeyPassword=VirgilByteArray())
Encrypt data with given public key and sign package.
size_t getPackageCount() const
Return total package count.