Virgil Security Crypto library
2.0.7
|
This class provides configuration methods to all Virgil*Cipher classes. More...
#include <VirgilCipherBase.h>
Public Member Functions | |
VirgilCipherBase () | |
Initialize submodules. | |
Recipent 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 | tryReadContentInfo (const VirgilByteArray &encryptedData) |
Make attempt to read content info from the encrypted data. More... | |
virgil::crypto::foundation::VirgilSymmetricCipher & | initEncryption () |
Configures symmetric cipher for encryption. More... | |
virgil::crypto::foundation::VirgilSymmetricCipher & | initDecryption (const VirgilByteArray &encryptedDataInfo, const VirgilByteArray &recipientId, const VirgilByteArray &privateKey, const VirgilByteArray &privateKeyPassword=VirgilByteArray()) |
Configures symmetric cipher for encryption. More... | |
virgil::crypto::foundation::VirgilSymmetricCipher & | initDecryptionWithPassword (const VirgilByteArray &pwd) |
Configures symmetric cipher for decryption based on the recipient's password. More... | |
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. More... | |
virgil::crypto::foundation::VirgilSymmetricCipher & | getSymmetricCipher () |
Return symmetric cipher configure by one of the methods: initEncryption(), initDecryptionWithPassword(), initDecryptionWithKey. | |
void | buildContentInfo () |
Build VirgilContentInfo object. More... | |
void | clearCipherInfo () |
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 |
Returns encrypted data 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.
VirgilByteArray virgil::crypto::VirgilCipherBase::getContentInfo | ( | ) | const |
Returns encrypted data info.
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 |
Configures symmetric cipher for encryption.
Configures symmetric cipher for decryption.
encryptedDataInfo | - serialized encrypted data info. |
recipientId | - id that corresponds to the user's private key. |
privateKey | - user's private key. |
privateKeyPassword | - user's private key password. |
|
protected |
Configures symmetric cipher for decryption based on the recipient's id and private key.
recipientId | - recipient's id. |
privateKey | - recipient's private key. |
privateKeyPassword | - recipient's private key password. |
|
protected |
Configures symmetric cipher for decryption based on the recipient's password.
pwd | - recipient's password. |
|
protected |
Configures symmetric cipher 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. |
|
protected |
Make attempt to read content info from the encrypted data.
Payload content info if was detected in the encrypted data.
encryptedData | - data that was encrypted. return Encrypted data without content info. |