5namespace Stroika::Foundation::Cryptography::Providers::OpenSSL {
7#if qStroika_HasComponent_OpenSSL
13 inline DerivedKey::DerivedKey (
const BLOB& key,
const BLOB& iv)
18 inline DerivedKey::DerivedKey (
const pair<BLOB, BLOB>& keyAndIV)
19 : fKey{keyAndIV.first}
20 , fIV{keyAndIV.second}
23 inline BLOB DerivedKey::NormalizePassword (
const BLOB& passwd)
27 inline BLOB DerivedKey::NormalizePassword (
const String& passwd)
29 string ascii = passwd.AsASCII ();
30 return BLOB{
reinterpret_cast<const byte*
> (ascii.c_str ()),
reinterpret_cast<const byte*
> (ascii.c_str () + ascii.length ())};
38 template <
typename PASSWORD_TYPE>
39 inline EVP_BytesToKey::EVP_BytesToKey (CipherAlgorithm cipherAlgorithm, DigestAlgorithm digestAlgorithm,
const PASSWORD_TYPE& passwd,
40 unsigned int nRounds,
const optional<BLOB>& salt)
41 : EVP_BytesToKey{cipherAlgorithm, digestAlgorithm, NormalizePassword (passwd), nRounds, salt}
50 template <
typename PASSWORD_TYPE>
51 inline PKCS5_PBKDF2_HMAC::PKCS5_PBKDF2_HMAC (
size_t keyLen,
size_t ivLen, DigestAlgorithm digestAlgorithm,
const PASSWORD_TYPE& passwd,
52 unsigned int nRounds,
const optional<BLOB>& salt)
53 : PKCS5_PBKDF2_HMAC{keyLen, ivLen, digestAlgorithm, NormalizePassword (passwd), nRounds, salt}
56 template <
typename PASSWORD_TYPE,
typename CIPHER_ALGORITHM_TYPE>
57 inline PKCS5_PBKDF2_HMAC::PKCS5_PBKDF2_HMAC (CIPHER_ALGORITHM_TYPE cipherAlgorithm, DigestAlgorithm digestAlgorithm,
58 const PASSWORD_TYPE& passwd,
unsigned int nRounds,
const optional<BLOB>& salt)
59 : PKCS5_PBKDF2_HMAC{KeyLength (cipherAlgorithm), IVLength (cipherAlgorithm), digestAlgorithm, passwd, nRounds, salt}
68 template <
typename PASSWORD_TYPE>
69 inline PKCS5_PBKDF2_HMAC_SHA1::PKCS5_PBKDF2_HMAC_SHA1 (
size_t keyLen,
size_t ivLen,
const PASSWORD_TYPE& passwd,
unsigned int nRounds,
70 const optional<BLOB>& salt)
71 : PKCS5_PBKDF2_HMAC{keyLen, ivLen, DigestAlgorithms::kSHA1, passwd, nRounds, salt}
74 template <
typename PASSWORD_TYPE,
typename CIPHER_ALGORITHM_TYPE>
75 inline PKCS5_PBKDF2_HMAC_SHA1::PKCS5_PBKDF2_HMAC_SHA1 (CIPHER_ALGORITHM_TYPE cipherAlgorithm,
const PASSWORD_TYPE& passwd,
76 unsigned int nRounds,
const optional<BLOB>& salt)
77 : PKCS5_PBKDF2_HMAC{cipherAlgorithm, DigestAlgorithms::kSHA1, passwd, nRounds, salt}