Virgil Security Crypto library
2.6.3
|
Provides password based key derivation function. More...
#include <VirgilPBKDF.h>
Public Types | |
enum | Algorithm { Algorithm::PBKDF2 } |
Defines specific password based key derivation function algorithm. More... | |
Public Member Functions | |
Constructor / Destructor | |
VirgilPBKDF () | |
Create object with undefined algorithms. More... | |
VirgilPBKDF (const virgil::crypto::VirgilByteArray &salt, unsigned int iterationCount=kIterationCount_Default) | |
Create object with default algorithm. More... | |
Configuration / Info | |
Provide methods that allow precise algorithm configuration and get information about it. | |
VirgilByteArray | getSalt () const |
Return salt. | |
unsigned int | getIterationCount () const |
Return iteration count. | |
void | setAlgorithm (VirgilPBKDF::Algorithm alg) |
Set specific algorithm of the password based key derivation function. | |
VirgilPBKDF::Algorithm | getAlgorithm () const |
Return current algorithm of the password based key derivation function. | |
void | setHashAlgorithm (VirgilHash::Algorithm hash) |
Set underlying digest algorithm. | |
VirgilHash::Algorithm | getHashAlgorithm () const |
Returns underlying digest algorithm. | |
void | enableRecommendationsCheck () |
Involve security check for used parameters. More... | |
void | disableRecommendationsCheck () |
Ignore security check for used parameters. More... | |
Process password based key derivation | |
virgil::crypto::VirgilByteArray | derive (const virgil::crypto::VirgilByteArray &pwd, size_t outSize=0) |
Derive key from the given key material. More... | |
VirgilAsn1Compatible implementation | |
Marshalling format: KeyDerivationFunction ::= AlgorithmIdentifier {{ PBKDFAlgorithms }} PBKDFAlgorithms AlgorithmIdentifier ::= { { OID id-PBKDF2 PARMS BKDF2-params }, ... -- additional algorithms --- } PBKDF2-params ::= SEQUENCE { salt CHOICE { specified OCTET STRING, otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}} }, iterationCount INTEGER (1..MAX), keyLength INTEGER (1..MAX) OPTIONAL, prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1 } | |
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 | |
static constexpr unsigned int | kIterationCount_Default = 2048 |
Default iteration count. | |
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 key derivation function.
Defines specific password based key derivation function algorithm.
Enumerator | |
---|---|
PBKDF2 |
Defines PBKDF2 algorithm (https://www.ietf.org/rfc/rfc2898.txt) |
virgil::crypto::foundation::VirgilPBKDF::VirgilPBKDF | ( | ) |
Create object with undefined algorithms.
virgil::crypto::foundation::VirgilPBKDF::VirgilPBKDF | ( | const virgil::crypto::VirgilByteArray & | salt, |
unsigned int | iterationCount = kIterationCount_Default |
||
) |
Create object with default algorithm.
salt | - salt to use when generating key, the best practice is to pass random value. |
iterationCount | - iteration count, the best practice is to pass random value. |
|
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::VirgilPBKDF::derive | ( | const virgil::crypto::VirgilByteArray & | pwd, |
size_t | outSize = 0 |
||
) |
Derive key from the given key material.
pwd | - password to use when generating key. |
outSize | - size of the output sequence, if 0 - then size of the underlying hash will be used. |
void virgil::crypto::foundation::VirgilPBKDF::disableRecommendationsCheck | ( | ) |
Ignore security check for used parameters.
void virgil::crypto::foundation::VirgilPBKDF::enableRecommendationsCheck | ( | ) |
Involve security check for used parameters.