From a5d3b76b01f193ff0bc951cef6f90314568cfcad Mon Sep 17 00:00:00 2001 From: Pointcheval Hugo Date: Sat, 19 Dec 2020 21:42:36 +0100 Subject: [PATCH] Fix sha enums --- .../kotlin/fr/pointcheval/native_crypto/HashAlgorithm.kt | 9 ++++++--- .../kotlin/fr/pointcheval/native_crypto/KeyDerivation.kt | 2 +- lib/src/digest.dart | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/android/src/main/kotlin/fr/pointcheval/native_crypto/HashAlgorithm.kt b/android/src/main/kotlin/fr/pointcheval/native_crypto/HashAlgorithm.kt index caa201b..434f752 100644 --- a/android/src/main/kotlin/fr/pointcheval/native_crypto/HashAlgorithm.kt +++ b/android/src/main/kotlin/fr/pointcheval/native_crypto/HashAlgorithm.kt @@ -4,8 +4,9 @@ import java.security.MessageDigest enum class HashAlgorithm(val length : Int) { SHA1(160), - SHA128(128), + SHA224(224), SHA256(256), + SHA384(384), SHA512(512); } @@ -14,8 +15,9 @@ class Hash() { fun digest(data: ByteArray?, algorithm: HashAlgorithm): ByteArray { val func : String = when (algorithm) { HashAlgorithm.SHA1 -> "SHA-1" - HashAlgorithm.SHA128 -> "SHA-128" + HashAlgorithm.SHA224 -> "SHA-224" HashAlgorithm.SHA256 -> "SHA-256" + HashAlgorithm.SHA384 -> "SHA-384" HashAlgorithm.SHA512 -> "SHA-512" } val md = MessageDigest.getInstance(func) @@ -25,8 +27,9 @@ class Hash() { fun digest(data: ByteArray?, algorithm: String): ByteArray { val func : HashAlgorithm = when (algorithm) { "sha1" -> HashAlgorithm.SHA1 - "sha128" -> HashAlgorithm.SHA128 + "sha224" -> HashAlgorithm.SHA224 "sha256" -> HashAlgorithm.SHA256 + "sha384" -> HashAlgorithm.SHA384 "sha512" -> HashAlgorithm.SHA512 else -> HashAlgorithm.SHA256 } diff --git a/android/src/main/kotlin/fr/pointcheval/native_crypto/KeyDerivation.kt b/android/src/main/kotlin/fr/pointcheval/native_crypto/KeyDerivation.kt index de071c4..8931164 100644 --- a/android/src/main/kotlin/fr/pointcheval/native_crypto/KeyDerivation.kt +++ b/android/src/main/kotlin/fr/pointcheval/native_crypto/KeyDerivation.kt @@ -12,7 +12,7 @@ class KeyDerivation { "sha1" to "PBKDF2withHmacSHA1", "sha224" to "PBKDF2withHmacSHA224", "sha256" to "PBKDF2WithHmacSHA256", - "sha284" to "PBKDF2withHmacSHA384", + "sha384" to "PBKDF2withHmacSHA384", "sha512" to "PBKDF2withHmacSHA512" ) diff --git a/lib/src/digest.dart b/lib/src/digest.dart index 80d8805..344d5c5 100644 --- a/lib/src/digest.dart +++ b/lib/src/digest.dart @@ -7,7 +7,7 @@ import 'exceptions.dart'; import 'platform.dart'; import 'utils.dart'; -enum HashAlgorithm { SHA1, SHA128, SHA256, SHA512 } +enum HashAlgorithm { SHA1, SHA224, SHA256, SHA384, SHA512 } /// Represents message digest, or hash function. class MessageDigest {