Virgil Security Crypto library
2.4.6
|
Provides Password-Based Cryptography. Now PKCS#5 and PKCS#12 are partially supported. More...
#include <VirgilPBE.h>
Public Types | |
enum | Algorithm { Algorithm::PKCS5, Algorithm::PKCS12 } |
Enumerates possible Password Based Encryption algorithms. More... | |
Public Member Functions | |
Constructor / Destructor | |
VirgilPBE () | |
Create object with undefined algorithm. More... | |
VirgilPBE (Algorithm alg, const VirgilByteArray &salt, size_t iterationCount=kIterationCountMin) | |
reate object with specific algorithm type. More... | |
Encryption / Decryption | |
virgil::crypto::VirgilByteArray | encrypt (const virgil::crypto::VirgilByteArray &data, const virgil::crypto::VirgilByteArray &pwd) const |
Encrypt data with given password. More... | |
virgil::crypto::VirgilByteArray | decrypt (const virgil::crypto::VirgilByteArray &data, const virgil::crypto::VirgilByteArray &pwd) const |
Decrypt data with given password. More... | |
VirgilAsn1Compatible implementation | |
Marshalling format:
PBE ::= AlgorithmIdentifier {{ PBEAlgorithms }}
PBEAlgorithms AlgorithmIdentifier ::= {
{ OID id-PBES2 PARMS PBES2-params } |
{ OID pkcs-12PbeId PARMS pkcs-12PbeParams }
}
| |
size_t | asn1Write (asn1::VirgilAsn1Writer &asn1Writer, size_t childWrittenBytes=0) const override |
Write object state to the writer. More... | |
void | asn1Read (asn1::VirgilAsn1Reader &asn1Reader) override |
Read object state from the reader. More... | |
Public Member Functions inherited from virgil::crypto::foundation::asn1::VirgilAsn1Compatible | |
virgil::crypto::VirgilByteArray | toAsn1 () const |
Save object state to the ASN.1 structure. | |
void | fromAsn1 (const virgil::crypto::VirgilByteArray &asn1) |
Restore object state from the ASN.1 structure. | |
virtual | ~VirgilAsn1Compatible () noexcept |
Polymorphic destructor. | |
Static Public Attributes | |
Constants | |
static constexpr size_t | kIterationCountMin = 1024 |
Recommended iteration count that is used for key derivation. | |
Additional Inherited Members | |
Protected Member Functions inherited from virgil::crypto::foundation::asn1::VirgilAsn1Compatible | |
virtual void | checkRequiredField (const VirgilByteArray ¶m) const |
If given parameter is empty exception will be thrown. More... | |
Provides Password-Based Cryptography. Now PKCS#5 and PKCS#12 are partially supported.
|
strong |
virgil::crypto::foundation::VirgilPBE::VirgilPBE | ( | ) |
Create object with undefined algorithm.
virgil::crypto::foundation::VirgilPBE::VirgilPBE | ( | Algorithm | alg, |
const VirgilByteArray & | salt, | ||
size_t | iterationCount = kIterationCountMin |
||
) |
reate object with specific algorithm type.
alg | Specific PBE algorithm. |
salt | Salt, it is recommended to use random value for security reasons. |
iterationCount | Iteration count for the key derivation, it is recommended to use random value for security reasons. |
|
overridevirtual |
Read object state from the reader.
asn1Reader | reader payloaded with ASN.1 to be read. |
Implements virgil::crypto::foundation::asn1::VirgilAsn1Compatible.
|
overridevirtual |
Write object state to the writer.
asn1Writer | writer that should be payloaded by subclasses. |
childWrittenBytes | count of bytes that was written by subclasses. |
Implements virgil::crypto::foundation::asn1::VirgilAsn1Compatible.
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilPBE::decrypt | ( | const virgil::crypto::VirgilByteArray & | data, |
const virgil::crypto::VirgilByteArray & | pwd | ||
) | const |
Decrypt data with given password.
data | - data to decrypt. |
pwd | - password to use for decryption (max length is 31 byte). |
virgil::crypto::VirgilByteArray virgil::crypto::foundation::VirgilPBE::encrypt | ( | const virgil::crypto::VirgilByteArray & | data, |
const virgil::crypto::VirgilByteArray & | pwd | ||
) | const |
Encrypt data with given password.
data | - data to encrypt. |
pwd | - password to use for encryption (max length is 31 byte). |