37 #ifndef VIRGIL_CRYPTO_SYMMETRIC_SIPHER_H
38 #define VIRGIL_CRYPTO_SYMMETRIC_SIPHER_H
42 #include <virgil/crypto/VirgilByteArray.h>
43 #include <virgil/crypto/foundation/asn1/VirgilAsn1Compatible.h>
45 namespace virgil {
namespace crypto {
namespace foundation {
50 class VirgilSymmetricCipherImpl;
64 VirgilSymmetricCipherPadding_PKCS7,
65 VirgilSymmetricCipherPadding_OneAndZeros,
66 VirgilSymmetricCipherPadding_ZerosAndLen,
67 VirgilSymmetricCipherPadding_Zeros
68 } VirgilSymmetricCipherPadding;
100 std::string
name()
const;
179 void setPadding(VirgilSymmetricCipherPadding padding);
184 void setIV(
const virgil::crypto::VirgilByteArray& iv);
192 void setAuthData(
const virgil::crypto::VirgilByteArray& authData);
218 virgil::crypto::VirgilByteArray
crypt(
219 const virgil::crypto::VirgilByteArray& input,
220 const virgil::crypto::VirgilByteArray& iv);
235 virgil::crypto::VirgilByteArray
update(
const virgil::crypto::VirgilByteArray& input);
245 virgil::crypto::VirgilByteArray
finish();
264 size_t childWrittenBytes = 0)
const;
278 void checkState()
const;
281 VirgilSymmetricCipherImpl* impl_;
void setPadding(VirgilSymmetricCipherPadding padding)
Defines padding mode.
bool isDecryptionMode() const
Returns true if cipher is in the decryption mode.
void setIV(const virgil::crypto::VirgilByteArray &iv)
Configures the initialization vector.
This class provides methods for reading ASN.1 data structure.
Definition: VirgilAsn1Reader.h:53
bool isSupportPadding() const
Returns true if cipher support padding.
bool isAuthMode() const
Returns true if cipher is configured to support authenticated encryption and decryption.
This class provides interface that allow to save and restore object state in the ASN.1 structure.
Definition: VirgilAsn1Compatible.h:59
size_t keyLength() const
Returns the key length of the cipher.
virtual void asn1Read(virgil::crypto::foundation::asn1::VirgilAsn1Reader &asn1Reader)
Read object state from the reader.
This class provides methods for writing ASN.1 data structure.
Definition: VirgilAsn1Writer.h:54
Definition: VirgilAsn1Compatible.h:46
size_t ivSize() const
Returns the size of the cipher's IV in octets.
bool isEncryptionMode() const
Returns true if cipher is in the encryption mode.
virgil::crypto::VirgilByteArray finish()
Cipher finalization method.
static VirgilSymmetricCipher aes256()
Creates object that handles AES-256 encryption / decription algorithms.
virtual size_t asn1Write(virgil::crypto::foundation::asn1::VirgilAsn1Writer &asn1Writer, size_t childWrittenBytes=0) const
Write object state to the writer.
VirgilSymmetricCipher()
Create object with undefined algorithm.
void setDecryptionKey(const virgil::crypto::VirgilByteArray &key)
Configures decryption key.
size_t authTagLength() const
Returns the authentication tag length of the cipher.
void setAuthData(const virgil::crypto::VirgilByteArray &authData)
Add additional data (for AEAD ciphers).
void reset()
Finish preparation before encryption / decryption.
void setEncryptionKey(const virgil::crypto::VirgilByteArray &key)
Configures encryption key.
virgil::crypto::VirgilByteArray update(const virgil::crypto::VirgilByteArray &input)
Generic cipher update function.
Provides symmetric ciphers algorithms.
Definition: VirgilSymmetricCipher.h:57
std::string name() const
Returns the name of the given cipher, as a string.
size_t blockSize() const
Returns the block size of the current cipher.
virtual ~VirgilSymmetricCipher()
Polymorphic destructor.
void clear()
Clear all configuration settings.
size_t keySize() const
Returns the key length of the cipher.
virgil::crypto::VirgilByteArray crypt(const virgil::crypto::VirgilByteArray &input, const virgil::crypto::VirgilByteArray &iv)
Generic all-in-one encryption / decryption.