PBKDF2 class
This is an implementation of Password Based Key Derivation Algorithm, PBKDF2 derived from RFC-8081, which internally uses a MAC based Pseudo Random Function (PRF) for key derivation.
PBKDF2 is part of Public-Key Cryptography Standards (PKCS) series published by the RSA Laboratories, specifically PKCS #5 v2.0. It supersedes PBKDF1, which could only produce derived keys up to 160 bits long.
The strength of the generated password using PBKDF2 depends on the number of iterations. The idea is to prevent a brute force attack on the original password by making the key derivation time long. This implementation can be used for both to convert a passphrase and verify it with a derived key.
- Inheritance
-
- Object
- KeyDerivatorBase
- PBKDF2
Constructors
-
PBKDF2.new(MACHash<
HashDigestSink> mac, int iterations, {List<int> ? salt, int? keyLength}) -
Create a PBKDF2 instance with a MAC instance.
factory
-
PBKDF2.fromSecurity(PBKDF2Security security, {List<
int> ? salt, MACHash<HashDigestSink> ? mac, int? iterations, int? keyLength}) -
Create a PBKDF2 instance from PBKDF2Security.
factory
Properties
-
algo
→ MACHash<
HashDigestSink> -
The underlying algorithm used as Pseudo Random Function (PRF)
final
- derivedKeyLength → int
-
The length of derived key in bytes
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- iterations → int
-
The number of iterations
final
- name → String
-
The name of this algorithm
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
salt
→ List<
int> -
The byte array containing salt
final
Methods
-
convert(
List< int> password) → HashDigest -
Generate a derived key from a
password
override -
hex(
List< int> password) → String -
Returns the derived key in hexadecimal.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
string(
String password, [Encoding? encoding]) → HashDigest -
Process the
password
string and returns derived key as HashDigest.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
verify(
List< int> derivedKey, List<int> password) → bool -
Verify if the
derivedKey
was derived from the originalpassword
using the current parameters.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited