From 6c477ec24079ae36dfc618e3e344179e7d7f7952 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Fri, 9 Jul 2021 10:19:47 +0200 Subject: [PATCH] never return null for kdfType --- lib/src/crypto/key_encrypter_kdf.dart | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/src/crypto/key_encrypter_kdf.dart b/lib/src/crypto/key_encrypter_kdf.dart index 144f8b8..60f993a 100644 --- a/lib/src/crypto/key_encrypter_kdf.dart +++ b/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;