2023-04-05 15:58:25 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2023, stelar7 <dudedbz@gmail.com>
|
2025-02-16 17:38:58 +01:00
|
|
|
* Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com>
|
2023-04-05 15:58:25 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-02-16 17:38:58 +01:00
|
|
|
#include <LibCrypto/Hash/HashManager.h>
|
2023-04-05 15:58:25 +02:00
|
|
|
|
|
|
|
|
namespace Crypto::Hash {
|
|
|
|
|
|
|
|
|
|
class PBKDF2 {
|
|
|
|
|
public:
|
2025-02-16 17:38:58 +01:00
|
|
|
PBKDF2(HashKind hash_kind);
|
2023-04-05 15:58:25 +02:00
|
|
|
|
2025-02-16 17:38:58 +01:00
|
|
|
~PBKDF2()
|
|
|
|
|
{
|
|
|
|
|
EVP_KDF_free(m_kdf);
|
|
|
|
|
}
|
2023-04-05 15:58:25 +02:00
|
|
|
|
2025-02-16 17:38:58 +01:00
|
|
|
ErrorOr<ByteBuffer> derive_key(ReadonlyBytes password, ReadonlyBytes salt, u32 iterations, u32 key_length_bytes);
|
2023-04-05 15:58:25 +02:00
|
|
|
|
2025-02-16 17:38:58 +01:00
|
|
|
private:
|
|
|
|
|
EVP_KDF* m_kdf;
|
|
|
|
|
HashKind m_hash_kind;
|
2023-04-05 15:58:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|