4#ifndef _Stroika_Foundation_Cryptography_OpenSSL_DerivedKey_h_
5#define _Stroika_Foundation_Cryptography_OpenSSL_DerivedKey_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
13#include "Stroika/Foundation/Common/Common.h"
17#include "Stroika/Foundation/Memory/Common.h"
29namespace Stroika::Foundation::Cryptography::Providers::OpenSSL {
31 using Characters::String;
34#if qStroika_HasComponent_OpenSSL
52 DerivedKey (
const BLOB& key,
const BLOB& iv);
53 DerivedKey (
const pair<BLOB, BLOB>& keyAndIV);
58 nonvirtual
auto operator<=> (
const DerivedKey& rhs)
const =
default;
72 static BLOB NormalizePassword (
const BLOB& passwd);
73 static BLOB NormalizePassword (
const String& passwd);
82 struct WinCryptDeriveKey : DerivedKey {
83 WinCryptDeriveKey (
size_t keyLen, DigestAlgorithm digestAlgorithm,
const BLOB& passwd);
89 WinCryptDeriveKey (Provider provider, CipherAlgorithm cipherAlgorithm, DigestAlgorithm digestAlgorithm,
const BLOB& passwd);
98 struct EVP_BytesToKey : DerivedKey {
105 template <
typename PASSWORD_TYPE>
106 EVP_BytesToKey (CipherAlgorithm cipherAlgorithm, DigestAlgorithm digestAlgorithm,
const PASSWORD_TYPE& passwd,
107 unsigned int nRounds = 1,
const optional<BLOB>& salt = nullopt);
110 EVP_BytesToKey::EVP_BytesToKey (CipherAlgorithm cipherAlgorithm, DigestAlgorithm digestAlgorithm,
const BLOB& passwd,
111 unsigned int nRounds,
const optional<BLOB>& salt);
124 struct PKCS5_PBKDF2_HMAC : DerivedKey {
128 template <
typename PASSWORD_TYPE>
129 PKCS5_PBKDF2_HMAC (
size_t keyLen,
size_t ivLen, DigestAlgorithm digestAlgorithm,
const PASSWORD_TYPE& passwd,
130 unsigned int nRounds = 1000,
const optional<BLOB>& salt = nullopt);
131 template <
typename PASSWORD_TYPE,
typename CIPHER_ALGORITHM_TYPE>
132 PKCS5_PBKDF2_HMAC (CIPHER_ALGORITHM_TYPE cipherAlgorithm, DigestAlgorithm digestAlgorithm,
const PASSWORD_TYPE& passwd,
133 unsigned int nRounds = 1000,
const optional<BLOB>& salt = nullopt);
136 PKCS5_PBKDF2_HMAC::PKCS5_PBKDF2_HMAC (
size_t keyLen,
size_t ivLen, DigestAlgorithm digestAlgorithm,
const BLOB& passwd,
137 unsigned int nRounds,
const optional<BLOB>& salt);
147 struct PKCS5_PBKDF2_HMAC_SHA1 : PKCS5_PBKDF2_HMAC {
148 template <
typename PASSWORD_TYPE>
149 PKCS5_PBKDF2_HMAC_SHA1 (
size_t keyLen,
size_t ivLen,
const PASSWORD_TYPE& passwd,
unsigned int nRounds = 1000,
150 const optional<BLOB>& salt = nullopt);
151 template <
typename PASSWORD_TYPE,
typename CIPHER_ALGORITHM_TYPE>
152 PKCS5_PBKDF2_HMAC_SHA1 (CIPHER_ALGORITHM_TYPE cipherAlgorithm,
const PASSWORD_TYPE& passwd,
unsigned int nRounds = 1000,
153 const optional<BLOB>& salt = nullopt);
163#include "DerivedKey.inl"
STRING_TYPE ToString(FLOAT_TYPE f, const ToStringOptions &options={})