verifySalt function
Verifies that a salt meets security requirements.
A salt must meet the minimum recommended length (16 bytes / 128 bits by default).
The minimum length can be overridden with minimumByteLength
, but values
below 16 bytes are not recommended for production use.
Parameters:
salt
: The salt bytes to verify.minimumByteLength
: Minimum required byte length (default: 16 bytes / 128 bits).
Throws:
- InvalidParameterException if the salt is shorter than the minimum length.
Implementation
void verifySalt(Uint8List salt, {int minimumByteLength = minimumRecommendedSaltByteLength}) {
if (salt.length < minimumByteLength) {
throw InvalidParameterException(
'Salt length (${salt.length} bytes) is below the recommended minimum '
'($minimumByteLength bytes). This may be cryptographically insecure.'
);
}
}