From 03beb35dbc7bcb46e5e461c9fbb9236e6b576e6f Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Wed, 29 Apr 2020 23:04:41 +0200 Subject: [PATCH] Add pbkdf2 digest sh512 --- example/lib/main.dart | 2 +- lib/symmetric_crypto.dart | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 19d71ec..c0fcfc4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -52,7 +52,7 @@ class _MyAppState extends State { if (password.isEmpty) { output = 'Password is empty'; } else { - key = await KeyGenerator().pbkdf2(password, 'salt', digest: Digest.sha1); + key = await KeyGenerator().pbkdf2(password, 'salt', digest: Digest.sha512); output = 'Key successfully derived.'; } setState(() { diff --git a/lib/symmetric_crypto.dart b/lib/symmetric_crypto.dart index e781714..6e949ba 100644 --- a/lib/symmetric_crypto.dart +++ b/lib/symmetric_crypto.dart @@ -16,7 +16,7 @@ const String TAG_DEBUG = 'debug.native_crypto.symmetric_crypto'; enum KeySize { bits128, bits192, bits256 } /// Defines all available digest. -enum Digest { sha1, sha256 } +enum Digest { sha1, sha256, sha512 } /// Defines all available ciphers. enum Cipher { AES } @@ -68,6 +68,7 @@ class KeyGenerator { String algo; if (digest == Digest.sha1) algo = 'sha1'; if (digest == Digest.sha256) algo = 'sha256'; + if (digest == Digest.sha512) algo = 'sha512'; try { key = await NativeCrypto().pbkdf2( password, salt, keyLength: keyLength, iteration: iteration, algorithm: algo);