Browse Source

never return null for kdfType

pull/5/head
Herbert Poul 3 years ago
parent
commit
6c477ec240
  1. 11
      lib/src/crypto/key_encrypter_kdf.dart

11
lib/src/crypto/key_encrypter_kdf.dart

@ -76,18 +76,15 @@ class KeyEncrypterKdf {
return KdbxUuid(uuid);
}
static KdfType? kdfTypeFor(VarDictionary kdfParameters) {
static KdfType kdfTypeFor(VarDictionary kdfParameters) {
final uuid = KdfField.uuid.read(kdfParameters);
if (uuid == null) {
throw KdbxCorruptedFileException('No Kdf UUID');
}
final kdfUuid = base64.encode(uuid);
try {
return kdfUuids[kdfUuid];
} catch (e) {
throw KdbxCorruptedFileException(
'Invalid KDF UUID ${uuid.encodeBase64()}');
}
return kdfUuids[kdfUuid] ??
(() => throw KdbxCorruptedFileException(
'Invalid KDF UUID ${uuid.encodeBase64()}'))();
}
final Argon2 argon2;

Loading…
Cancel
Save