Virgil Security Crypto library
2.6.3
|
This class provides configuration methods to all Virgil*Cipher classes. More...
#include <VirgilCipherBase.h>
Public Member Functions | |
VirgilCipherBase () | |
Initialize submodules. | |
Recipient management | |
void | addKeyRecipient (const VirgilByteArray &recipientId, const VirgilByteArray &publicKey) |
Add recipient defined with id and public key. More... | |
void | removeKeyRecipient (const VirgilByteArray &recipientId) |
Remove recipient with given identifier. More... | |
bool | keyRecipientExists (const VirgilByteArray &recipientId) const |
Check whether recipient with given identifier exists. More... | |
void | addPasswordRecipient (const VirgilByteArray &pwd) |
Add recipient defined with password. More... | |
void | removePasswordRecipient (const VirgilByteArray &pwd) |
Remove recipient with given password. More... | |
bool | passwordRecipientExists (const VirgilByteArray &password) const |
Check whether recipient with given password exists. More... | |
void | removeAllRecipients () |
Remove all recipients. | |
Custom parameters Access / Management | |
Custom parameters is a structure that contains additional user defined information about encrypted data.
| |
VirgilCustomParams & | customParams () |
Provide access to the object that handles custom parameters. More... | |
const VirgilCustomParams & | customParams () const |
Provide readonly access to the object that handles custom parameters. More... | |
Static Public Member Functions | |
Helpers to create shared key with Diffie–Hellman algorithms | |
static VirgilByteArray | computeShared (const VirgilByteArray &publicKey, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray()) |
Compute shared secret key on a given keys. More... | |
Protected Member Functions | |
VirgilByteArray | filterAndSetupContentInfo (const VirgilByteArray &encryptedData, bool isLastChunk) |
Extract content info from the encrypted data and setup it. More... | |
void | initEncryption () |
Configures symmetric cipher for encryption. More... | |
void | initDecryptionWithPassword (const VirgilByteArray &pwd) |
Stores recipient's password that is used for cipher's key decryption when content becomes available. More... | |
void | initDecryptionWithKey (const VirgilByteArray &recipientId, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword) |
Stores recipient's information that is used for cipher's key decryption when content becomes available. More... | |
bool | isInited () const |
bool | isReadyForEncryption () const |
bool | isReadyForDecryption () const |
virgil::crypto::foundation::VirgilSymmetricCipher & | getSymmetricCipher () |
Return symmetric cipher configure by one of the methods: initEncryption(), initDecryptionWithPassword(), initDecryptionWithKey. | |
void | buildContentInfo () |
Build VirgilContentInfo object. More... | |
void | clear () |
Clear all information related to the cipher. More... | |
Content Info Access / Management | |
Content info is a structure that contains all necessary information for future decription in secure form. | |
VirgilByteArray | getContentInfo () const |
Return content info. More... | |
void | setContentInfo (const VirgilByteArray &contentInfo) |
Create content info object from ASN.1 structure. More... | |
static size_t | defineContentInfoSize (const VirgilByteArray &data) |
Read content info size as part of the data. More... | |
This class provides configuration methods to all Virgil*Cipher classes.
void virgil::crypto::VirgilCipherBase::addKeyRecipient | ( | const VirgilByteArray & | recipientId, |
const VirgilByteArray & | publicKey | ||
) |
Add recipient defined with id and public key.
recipientId | Recipient's unique identifier, MUST not be empty. |
publicKey | Recipient's public key, MUST not be empty. |
VirgilCryptoException | with VirgilCryptoErrorCode::InvalidArgument, if invalid arguments are given. |
void virgil::crypto::VirgilCipherBase::addPasswordRecipient | ( | const VirgilByteArray & | pwd | ) |
Add recipient defined with password.
Use it for password based encryption.
pwd | Recipient's password, MUST not be empty. |
VirgilCryptoException | with VirgilCryptoErrorCode::InvalidArgument, if empty argument are given. |
|
protected |
Build VirgilContentInfo object.
This method SHOULD be called after encryption process is finished.
|
protected |
Clear all information related to the cipher.
Clear symmetric cipher and correspond internal states.
|
static |
Compute shared secret key on a given keys.
publicKey | - alice public key. |
privateKey | - bob private key. |
privateKeyPassword | - bob private key password. |
VirgilCryptoException | - if keys are invalid or keys are not compatible. |
VirgilCustomParams& virgil::crypto::VirgilCipherBase::customParams | ( | ) |
Provide access to the object that handles custom parameters.
const VirgilCustomParams& virgil::crypto::VirgilCipherBase::customParams | ( | ) | const |
Provide readonly access to the object that handles custom parameters.
|
static |
Read content info size as part of the data.
|
protected |
Extract content info from the encrypted data and setup it.
This function should be used always to filter input encrypted data.
encryptedData | - data that was encrypted. |
isLastChunk | - tell filter that given data is the last one. return Encrypted data that is follows content info, if content info was fully extracted, otherwise - empty data. |
VirgilByteArray virgil::crypto::VirgilCipherBase::getContentInfo | ( | ) | const |
Return content info.
Return Virgil Security Cryptogram, that contains public algorithm parameters that was used for encryption.
VirgilCryptoException | with VirgilCryptoErrorCode::InvalidOperation, if this function is used before any encryption operation. |
|
protected |
Stores recipient's information that is used for cipher's key decryption when content becomes available.
recipientId | - recipient's id. |
privateKey | - recipient's private key. |
privateKeyPassword | - recipient's private key password. |
|
protected |
Stores recipient's password that is used for cipher's key decryption when content becomes available.
pwd | - recipient's password. |
|
protected |
Configures symmetric cipher for encryption.
|
protected |
Return true if one one of the init function was called.
|
protected |
Return true if underlying symmetric cipher is properly configured for decryption.
|
protected |
Return true if underlying symmetric cipher is properly configured for encryption.
bool virgil::crypto::VirgilCipherBase::keyRecipientExists | ( | const VirgilByteArray & | recipientId | ) | const |
Check whether recipient with given identifier exists.
Search order:
recipientId | Recipient's unique identifier. |
bool virgil::crypto::VirgilCipherBase::passwordRecipientExists | ( | const VirgilByteArray & | password | ) | const |
Check whether recipient with given password exists.
Search order:
password | Recipient's unique identifier. |
void virgil::crypto::VirgilCipherBase::removeKeyRecipient | ( | const VirgilByteArray & | recipientId | ) |
Remove recipient with given identifier.
recipientId | Recipient's unique identifier. |
void virgil::crypto::VirgilCipherBase::removePasswordRecipient | ( | const VirgilByteArray & | pwd | ) |
Remove recipient with given password.
void virgil::crypto::VirgilCipherBase::setContentInfo | ( | const VirgilByteArray & | contentInfo | ) |
Create content info object from ASN.1 structure.
contentInfo | Virgil Security Cryptogram. |
VirgilCryptoException | with VirgilCryptoErrorCode::InvalidFormat, if content info can not be parsed. |