diff --git a/src/CryptHash.Net/lib/CryptHash.Net.Tests/CryptHash.Net.Tests.csproj b/src/CryptHash.Net/lib/CryptHash.Net.Tests/CryptHash.Net.Tests.csproj
index 80ce5cc..4f485ce 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net.Tests/CryptHash.Net.Tests.csproj
+++ b/src/CryptHash.Net/lib/CryptHash.Net.Tests/CryptHash.Net.Tests.csproj
@@ -5,11 +5,11 @@
false
- 3.3.1
+ 3.3.2
- 3.3.1
+ 3.3.2
- 3.3.1
+ 3.3.2
diff --git a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_128_CBC_HMAC_SHA_256_Tests.cs b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_128_CBC_HMAC_SHA_256_Tests.cs
index 33dfca4..bdd548c 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_128_CBC_HMAC_SHA_256_Tests.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_128_CBC_HMAC_SHA_256_Tests.cs
@@ -18,7 +18,7 @@ public void Test_EncryptString_with_append_encryption_data()
{
var appendEncryptionData = true;
- var aesEncryptionResult = _aes128cbcHmacSha256.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes128cbcHmacSha256.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
Assert.IsTrue(aesEncryptionResult.Success, aesEncryptionResult.Message);
}
@@ -28,7 +28,7 @@ public void Test_EncryptString_without_append_encryption_data()
{
var appendEncryptionData = false;
- var aesEncryptionResult = _aes128cbcHmacSha256.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes128cbcHmacSha256.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
Assert.IsTrue(aesEncryptionResult.Success, aesEncryptionResult.Message);
}
@@ -40,11 +40,11 @@ public void Test_DecryptString_with_encryption_data_appended()
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes128cbcHmacSha256.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes128cbcHmacSha256.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
- aesDecryptionResult = _aes128cbcHmacSha256.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, hasEncryptionDataAppendedInInputString: appendEncryptionData);
+ aesDecryptionResult = _aes128cbcHmacSha256.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, hasEncryptionDataAppendedInInput: appendEncryptionData);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
@@ -62,12 +62,12 @@ public void Test_DecryptString_without_encryption_data_appended()
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes128cbcHmacSha256.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes128cbcHmacSha256.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
aesDecryptionResult = _aes128cbcHmacSha256.DecryptString(aesEncryptionResult.EncryptedDataBytes, Encoding.UTF8.GetBytes(_password),
- hasEncryptionDataAppendedInInputString: appendEncryptionData, aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.IV);
+ hasEncryptionDataAppendedInInput: appendEncryptionData, aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.IV);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
diff --git a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_192_CBC_HMAC_SHA_384_Tests.cs b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_192_CBC_HMAC_SHA_384_Tests.cs
index b789475..08eac30 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_192_CBC_HMAC_SHA_384_Tests.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_192_CBC_HMAC_SHA_384_Tests.cs
@@ -18,7 +18,7 @@ public void Test_EncryptString_with_append_encryption_data()
{
var appendEncryptionData = true;
- var aesEncryptionResult = _aes192cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes192cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
Assert.IsTrue(aesEncryptionResult.Success, aesEncryptionResult.Message);
}
@@ -28,7 +28,7 @@ public void Test_EncryptString_without_append_encryption_data()
{
var appendEncryptionData = false;
- var aesEncryptionResult = _aes192cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes192cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
Assert.IsTrue(aesEncryptionResult.Success, aesEncryptionResult.Message);
}
@@ -40,11 +40,11 @@ public void Test_DecryptString_with_encryption_data_appended()
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes192cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes192cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
- aesDecryptionResult = _aes192cbcHmacSha384.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, hasEncryptionDataAppendedInInputString: appendEncryptionData);
+ aesDecryptionResult = _aes192cbcHmacSha384.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, hasEncryptionDataAppendedInInput: appendEncryptionData);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
@@ -62,12 +62,12 @@ public void Test_DecryptString_without_encryption_data_appended()
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes192cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes192cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
aesDecryptionResult = _aes192cbcHmacSha384.DecryptString(aesEncryptionResult.EncryptedDataBytes, Encoding.UTF8.GetBytes(_password),
- hasEncryptionDataAppendedInInputString: appendEncryptionData, aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.IV);
+ hasEncryptionDataAppendedInInput: appendEncryptionData, aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.IV);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
diff --git a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_384_Tests.cs b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_384_Tests.cs
index ca584c3..b30dddd 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_384_Tests.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_384_Tests.cs
@@ -18,7 +18,7 @@ public void Test_EncryptString_with_append_encryption_data()
{
var appendEncryptionData = true;
- var aesEncryptionResult = _aes256cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
Assert.IsTrue(aesEncryptionResult.Success, aesEncryptionResult.Message);
}
@@ -28,7 +28,7 @@ public void Test_EncryptString_without_append_encryption_data()
{
var appendEncryptionData = false;
- var aesEncryptionResult = _aes256cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
Assert.IsTrue(aesEncryptionResult.Success, aesEncryptionResult.Message);
}
@@ -40,11 +40,11 @@ public void Test_DecryptString_with_encryption_data_appended()
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes256cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
- aesDecryptionResult = _aes256cbcHmacSha384.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, hasEncryptionDataAppendedInInputString: appendEncryptionData);
+ aesDecryptionResult = _aes256cbcHmacSha384.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, hasEncryptionDataAppendedInInput: appendEncryptionData);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
@@ -62,12 +62,12 @@ public void Test_DecryptString_without_encryption_data_appended()
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes256cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256cbcHmacSha384.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
aesDecryptionResult = _aes256cbcHmacSha384.DecryptString(aesEncryptionResult.EncryptedDataBytes, Encoding.UTF8.GetBytes(_password),
- hasEncryptionDataAppendedInInputString: appendEncryptionData, aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.IV);
+ hasEncryptionDataAppendedInInput: appendEncryptionData, aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.IV);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
diff --git a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_512_Tests.cs b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_512_Tests.cs
index 1d8b370..112f9d7 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_512_Tests.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_512_Tests.cs
@@ -18,7 +18,7 @@ public void Test_EncryptString_with_append_encryption_data()
{
var appendEncryptionData = true;
- var aesEncryptionResult = _aes256cbcHmacSha512.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256cbcHmacSha512.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
Assert.IsTrue(aesEncryptionResult.Success, aesEncryptionResult.Message);
}
@@ -28,7 +28,7 @@ public void Test_EncryptString_without_append_encryption_data()
{
var appendEncryptionData = false;
- var aesEncryptionResult = _aes256cbcHmacSha512.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256cbcHmacSha512.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
Assert.IsTrue(aesEncryptionResult.Success, aesEncryptionResult.Message);
}
@@ -40,11 +40,11 @@ public void Test_DecryptString_with_encryption_data_appended()
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes256cbcHmacSha512.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256cbcHmacSha512.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
- aesDecryptionResult = _aes256cbcHmacSha512.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, hasEncryptionDataAppendedInInputString: appendEncryptionData);
+ aesDecryptionResult = _aes256cbcHmacSha512.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, hasEncryptionDataAppendedInInput: appendEncryptionData);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
@@ -62,12 +62,12 @@ public void Test_DecryptString_without_encryption_data_appended()
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes256cbcHmacSha512.EncryptString(_testString, _password, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256cbcHmacSha512.EncryptString(_testString, _password, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
aesDecryptionResult = _aes256cbcHmacSha512.DecryptString(aesEncryptionResult.EncryptedDataBytes, Encoding.UTF8.GetBytes(_password),
- hasEncryptionDataAppendedInInputString: appendEncryptionData, aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.IV);
+ hasEncryptionDataAppendedInInput: appendEncryptionData, aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.IV);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
diff --git a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AEAD/AEAD_AES_256_GCM_Tests.cs b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AEAD/AEAD_AES_256_GCM_Tests.cs
index abe7ca7..41e6159 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AEAD/AEAD_AES_256_GCM_Tests.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Encryption/AES/AEAD/AEAD_AES_256_GCM_Tests.cs
@@ -66,11 +66,11 @@ public void Test_DecryptString_without_encryption_data_appended_without_associat
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes256gcm.EncryptString(_testString, _password, associatedData, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256gcm.EncryptString(_testString, _password, associatedData, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
- aesDecryptionResult = _aes256gcm.DecryptString(aesEncryptionResult.EncryptedDataBytes, Encoding.UTF8.GetBytes(_password), null, hasEncryptionDataAppendedInInputString: appendEncryptionData,
+ aesDecryptionResult = _aes256gcm.DecryptString(aesEncryptionResult.EncryptedDataBytes, Encoding.UTF8.GetBytes(_password), null, hasEncryptionDataAppendedInInput: appendEncryptionData,
aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.Nonce);
if (!aesDecryptionResult.Success)
@@ -90,11 +90,11 @@ public void Test_DecryptString_without_encryption_data_appended_with_associated_
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes256gcm.EncryptString(_testString, _password, associatedData, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256gcm.EncryptString(_testString, _password, associatedData, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
- aesDecryptionResult = _aes256gcm.DecryptString(aesEncryptionResult.EncryptedDataBytes, Encoding.UTF8.GetBytes(_password), Encoding.UTF8.GetBytes(associatedData), hasEncryptionDataAppendedInInputString: appendEncryptionData,
+ aesDecryptionResult = _aes256gcm.DecryptString(aesEncryptionResult.EncryptedDataBytes, Encoding.UTF8.GetBytes(_password), Encoding.UTF8.GetBytes(associatedData), hasEncryptionDataAppendedInInput: appendEncryptionData,
aesEncryptionResult.Tag, aesEncryptionResult.Salt, aesEncryptionResult.Nonce);
if (!aesDecryptionResult.Success)
@@ -114,11 +114,11 @@ public void Test_DecryptString_with_encryption_data_appended_without_associated_
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes256gcm.EncryptString(_testString, _password, associatedData, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256gcm.EncryptString(_testString, _password, associatedData, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
- aesDecryptionResult = _aes256gcm.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, associatedData, hasEncryptionDataAppendedInInputString: appendEncryptionData);
+ aesDecryptionResult = _aes256gcm.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, associatedData, hasEncryptionDataAppendedInInput: appendEncryptionData);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
@@ -137,11 +137,11 @@ public void Test_DecryptString_with_encryption_data_appended_with_associated_dat
var aesDecryptionResult = new AesDecryptionResult();
string errorMessage = "";
- var aesEncryptionResult = _aes256gcm.EncryptString(_testString, _password, associatedData, appendEncryptionDataToOutputString: appendEncryptionData);
+ var aesEncryptionResult = _aes256gcm.EncryptString(_testString, _password, associatedData, appendEncryptionDataToOutput: appendEncryptionData);
if (aesEncryptionResult.Success)
{
- aesDecryptionResult = _aes256gcm.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, associatedData, hasEncryptionDataAppendedInInputString: appendEncryptionData);
+ aesDecryptionResult = _aes256gcm.DecryptString(aesEncryptionResult.EncryptedDataBase64String, _password, associatedData, hasEncryptionDataAppendedInInput: appendEncryptionData);
if (!aesDecryptionResult.Success)
errorMessage = aesDecryptionResult.Message;
diff --git a/src/CryptHash.Net/lib/CryptHash.Net.Tests/Hash/Argon2id_Tests.cs b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Hash/Argon2id_Tests.cs
new file mode 100644
index 0000000..0d6e729
--- /dev/null
+++ b/src/CryptHash.Net/lib/CryptHash.Net.Tests/Hash/Argon2id_Tests.cs
@@ -0,0 +1,82 @@
+using CryptHash.Net.Hash;
+using CryptHash.Net.Hash.HashResults;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace CryptHash.Net.Tests.Hash
+{
+ [TestClass]
+ public class Argon2id_Tests
+ {
+ Argon2id _argon2id = new Argon2id();
+ string _testString = "This is a test string!";
+
+ [TestMethod]
+ public void ComputeAndVerifyHash_String_without_associated_data()
+ {
+ Argon2idHashResult verifyResult = new Argon2idHashResult();
+ var errorMessage = "";
+
+ byte[] testStringBytes = Encoding.UTF8.GetBytes(_testString);
+ int iterations = 4;
+ int kbMemorySize = 1024;
+ int degreeOfParallelism = 0; // auto-generate based on number of the processor's cores
+ int amountBytesToReturn = 16;
+ byte[] salt = null; // auto-generate
+ byte[] associatedData = null;
+ byte[] knownSecret = null;
+
+ var hashResult = _argon2id.ComputeHash(testStringBytes, iterations, kbMemorySize, degreeOfParallelism, amountBytesToReturn, salt,
+ associatedData, knownSecret);
+
+ if (hashResult.Success)
+ {
+ verifyResult = _argon2id.VerifyHash(hashResult.HashBytes, testStringBytes, iterations, kbMemorySize, degreeOfParallelism,
+ amountBytesToReturn, hashResult.SaltBytes, associatedData, knownSecret);
+
+ if (!verifyResult.Success)
+ errorMessage = verifyResult.Message;
+ }
+ else
+ errorMessage = hashResult.Message;
+
+
+ Assert.IsTrue((hashResult.Success && verifyResult.Success), errorMessage);
+ }
+
+ [TestMethod]
+ public void ComputeAndVerifyHash_String_with_associated_data()
+ {
+ Argon2idHashResult verifyResult = new Argon2idHashResult();
+ var errorMessage = "";
+
+ byte[] testStringBytes = Encoding.UTF8.GetBytes(_testString);
+ int iterations = 4;
+ int kbMemorySize = 1024;
+ int degreeOfParallelism = 0; // auto-generate based on number of the processor's cores
+ int amountBytesToReturn = 16;
+ byte[] salt = null; // auto-generate
+ byte[] associatedData = Encoding.UTF8.GetBytes("0f8fad5b-d9cb-469f-a165-70867728950e");
+ byte[] knownSecret = null;
+
+ var hashResult = _argon2id.ComputeHash(testStringBytes, iterations, kbMemorySize, degreeOfParallelism, amountBytesToReturn, salt,
+ associatedData, knownSecret);
+
+ if (hashResult.Success)
+ {
+ verifyResult = _argon2id.VerifyHash(hashResult.HashBytes, testStringBytes, iterations, kbMemorySize, degreeOfParallelism,
+ amountBytesToReturn, hashResult.SaltBytes, associatedData, knownSecret);
+
+ if (!verifyResult.Success)
+ errorMessage = verifyResult.Message;
+ }
+ else
+ errorMessage = hashResult.Message;
+
+
+ Assert.IsTrue((hashResult.Success && verifyResult.Success), errorMessage);
+ }
+ }
+}
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/CryptHash.Net.csproj b/src/CryptHash.Net/lib/CryptHash.Net/CryptHash.Net.csproj
index 044ce2c..ae4855f 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/CryptHash.Net.csproj
+++ b/src/CryptHash.Net/lib/CryptHash.Net/CryptHash.Net.csproj
@@ -9,11 +9,11 @@
crypthash-icon-new.png
https://github.com/alecgn/crypthash-net
encryption decryption cryptography aes aes128 aes192 aes256 aes128cbc aes192cbc aes256cbc aes256gcm aescbc aesgcm aescbc128 aescbc192 aescbc256 aesgcm256 cbc gcm hash md5 sha1 sha256 sha384 sha512 hmacmd5 hmac-md5 hmacsha1 hmac-sha1 hmacsha256 hmac-sha256 hmacsha384 hmac-sha384 hmacsha512 hmac-sha512 pbkdf2 bcrypt argon2 argon2id c# c-sharp security password authentication authenticated
- 3.3.1
- 3.3.1
+ 3.3.2
+ 3.3.2
true
https://github.com/alecgn/crypthash-net
- 3.3.1
+ 3.3.2
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_128_CBC_HMAC_SHA_256.cs b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_128_CBC_HMAC_SHA_256.cs
index e77e50c..e044d4c 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_128_CBC_HMAC_SHA_256.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_128_CBC_HMAC_SHA_256.cs
@@ -62,9 +62,9 @@ public AE_AES_128_CBC_HMAC_SHA_256(byte[] key, byte[] IV)
///
/// The input plain string to encrypt.
/// The password string where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, string password, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, string password, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -87,7 +87,7 @@ public AesEncryptionResult EncryptString(string plainString, string password, bo
var plainStringBytes = Encoding.UTF8.GetBytes(plainString);
var passwordBytes = Encoding.UTF8.GetBytes(password);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -95,9 +95,9 @@ public AesEncryptionResult EncryptString(string plainString, string password, bo
///
/// The input plain string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -120,7 +120,7 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
var plainStringBytes = Encoding.UTF8.GetBytes(plainString);
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -128,9 +128,9 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
///
/// The input byte array of the string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -152,7 +152,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -160,9 +160,9 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
///
/// The input byte array of the string to encrypt.
/// The byte array of the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -197,7 +197,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
byte[] tag;
byte[] hmacSha256;
- if (appendEncryptionDataToOutputString)
+ if (appendEncryptionDataToOutput)
{
using (var ms = new MemoryStream())
{
@@ -253,12 +253,12 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
///
/// The base64 encoded input string to decrypt.
/// The password string where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, string password, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, string password, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -282,7 +282,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
var encryptedStringBytes = Convert.FromBase64String(base64EncryptedString);
var passwordBytes = Encoding.UTF8.GetBytes(password);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -290,12 +290,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
///
/// The base64 encoded input string to decrypt.
/// The SecureString with the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -319,7 +319,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
var encryptedStringBytes = Convert.FromBase64String(base64EncryptedString);
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -327,12 +327,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
///
/// The input byte array of the string to decrypt.
/// The SecureString with the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -355,7 +355,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -363,12 +363,12 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
///
/// The input byte array of the string to decrypt.
/// The byte array of the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -389,7 +389,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
};
}
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
if (encryptedStringBytes.Length < (_tagBytesLength + _saltBytesLength + _IVBytesLength))
{
@@ -403,7 +403,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
try
{
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
sentTag = new byte[_tagBytesLength];
Array.Copy(encryptedStringBytes, (encryptedStringBytes.Length - _tagBytesLength), sentTag, 0, sentTag.Length);
@@ -418,8 +418,8 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
byte[] derivedKey = CommonMethods.GetHashedBytesFromPBKDF2(passwordBytes, salt, (_keyBytesLength * 2), _iterationsForKeyDerivationFunction);
byte[] cryptKey = derivedKey.Take(_keyBytesLength).ToArray();
byte[] authKey = derivedKey.Skip(_keyBytesLength).Take(_keyBytesLength).ToArray();
- //var hmacSha256 = CommonMethods.ComputeHMACSHA256HashFromDataBytes(authKey, encryptedStringBytes, 0, (hasEncryptionDataAppendedInInputString ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length));
- var hmacSha256 = new HMAC_SHA_256().ComputeHMAC(encryptedStringBytes, authKey, 0, (hasEncryptionDataAppendedInInputString ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length)).HashBytes;
+ //var hmacSha256 = CommonMethods.ComputeHMACSHA256HashFromDataBytes(authKey, encryptedStringBytes, 0, (hasEncryptionDataAppendedInInput ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length));
+ var hmacSha256 = new HMAC_SHA_256().ComputeHMAC(encryptedStringBytes, authKey, 0, (hasEncryptionDataAppendedInInput ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length)).HashBytes;
var calcTag = hmacSha256.Take(_tagBytesLength).ToArray();
if (!CommonMethods.TagsMatch(calcTag, sentTag))
@@ -433,13 +433,13 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
byte[] encryptedSourceDataStringBytes = null;
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
encryptedSourceDataStringBytes = new byte[(encryptedStringBytes.Length - _tagBytesLength - _saltBytesLength - _IVBytesLength)];
Array.Copy(encryptedStringBytes, 0, encryptedSourceDataStringBytes, 0, encryptedSourceDataStringBytes.Length);
}
- var aesDecryptionResult = base.DecryptWithMemoryStream((hasEncryptionDataAppendedInInputString ? encryptedSourceDataStringBytes : encryptedStringBytes),
+ var aesDecryptionResult = base.DecryptWithMemoryStream((hasEncryptionDataAppendedInInput ? encryptedSourceDataStringBytes : encryptedStringBytes),
cryptKey, IV, _cipherMode, _paddingMode);
if (aesDecryptionResult.Success)
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_192_CBC_HMAC_SHA_384.cs b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_192_CBC_HMAC_SHA_384.cs
index 2e98073..ed33a69 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_192_CBC_HMAC_SHA_384.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_192_CBC_HMAC_SHA_384.cs
@@ -62,9 +62,9 @@ public AE_AES_192_CBC_HMAC_SHA_384(byte[] key, byte[] IV)
///
/// The input plain string to encrypt.
/// The password string where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, string password, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, string password, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -87,7 +87,7 @@ public AesEncryptionResult EncryptString(string plainString, string password, bo
var plainStringBytes = Encoding.UTF8.GetBytes(plainString);
var passwordBytes = Encoding.UTF8.GetBytes(password);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -95,9 +95,9 @@ public AesEncryptionResult EncryptString(string plainString, string password, bo
///
/// The input plain string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -120,7 +120,7 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
var plainStringBytes = Encoding.UTF8.GetBytes(plainString);
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -128,9 +128,9 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
///
/// The input byte array of the string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -152,7 +152,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -160,9 +160,9 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
///
/// The input byte array of the string to encrypt.
/// The byte array of the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -197,7 +197,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
byte[] tag;
byte[] hmacSha384bytes;
- if (appendEncryptionDataToOutputString)
+ if (appendEncryptionDataToOutput)
{
using (var ms = new MemoryStream())
{
@@ -253,12 +253,12 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
///
/// The base64 encoded input string to decrypt.
/// The password string where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, string password, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, string password, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -282,7 +282,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
var encryptedStringBytes = Convert.FromBase64String(base64EncryptedString);
var passwordBytes = Encoding.UTF8.GetBytes(password);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -290,12 +290,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
///
/// The base64 encoded input string to decrypt.
/// The SecureString with the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -319,7 +319,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
var encryptedStringBytes = Convert.FromBase64String(base64EncryptedString);
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -327,12 +327,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
///
/// The input byte array of the string to decrypt.
/// The SecureString with the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -355,7 +355,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -363,12 +363,12 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
///
/// The input byte array of the string to decrypt.
/// The byte array of the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -389,7 +389,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
};
}
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
if (encryptedStringBytes.Length < (_tagBytesLength + _saltBytesLength + _IVBytesLength))
{
@@ -403,7 +403,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
try
{
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
sentTag = new byte[_tagBytesLength];
Array.Copy(encryptedStringBytes, (encryptedStringBytes.Length - _tagBytesLength), sentTag, 0, sentTag.Length);
@@ -418,8 +418,8 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
byte[] derivedKey = CommonMethods.GetHashedBytesFromPBKDF2(passwordBytes, salt, (_keyBytesLength * 2), _iterationsForKeyDerivationFunction);
byte[] cryptKey = derivedKey.Take(_keyBytesLength).ToArray();
byte[] authKey = derivedKey.Skip(_keyBytesLength).Take(_keyBytesLength).ToArray();
- //var hmacSha384 = CommonMethods.ComputeHMACSHA384HashFromDataBytes(authKey, encryptedStringBytes, 0, (hasEncryptionDataAppendedInInputString ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length));
- var hmacSha384 = new HMAC_SHA_384().ComputeHMAC(encryptedStringBytes, authKey, 0, (hasEncryptionDataAppendedInInputString ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length)).HashBytes;
+ //var hmacSha384 = CommonMethods.ComputeHMACSHA384HashFromDataBytes(authKey, encryptedStringBytes, 0, (hasEncryptionDataAppendedInInput ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length));
+ var hmacSha384 = new HMAC_SHA_384().ComputeHMAC(encryptedStringBytes, authKey, 0, (hasEncryptionDataAppendedInInput ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length)).HashBytes;
var calcTag = hmacSha384.Take(_tagBytesLength).ToArray();
if (!CommonMethods.TagsMatch(calcTag, sentTag))
@@ -433,13 +433,13 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
byte[] encryptedSourceDataStringBytes = null;
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
encryptedSourceDataStringBytes = new byte[(encryptedStringBytes.Length - _tagBytesLength - _saltBytesLength - _IVBytesLength)];
Array.Copy(encryptedStringBytes, 0, encryptedSourceDataStringBytes, 0, encryptedSourceDataStringBytes.Length);
}
- var aesDecryptionResult = base.DecryptWithMemoryStream((hasEncryptionDataAppendedInInputString ? encryptedSourceDataStringBytes : encryptedStringBytes),
+ var aesDecryptionResult = base.DecryptWithMemoryStream((hasEncryptionDataAppendedInInput ? encryptedSourceDataStringBytes : encryptedStringBytes),
cryptKey, IV, _cipherMode, _paddingMode);
if (aesDecryptionResult.Success)
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_384.cs b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_384.cs
index 4b6a789..3c54773 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_384.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_384.cs
@@ -62,9 +62,9 @@ public AE_AES_256_CBC_HMAC_SHA_384(byte[] key, byte[] IV)
///
/// The input plain string to encrypt.
/// The password string where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, string password, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, string password, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -87,7 +87,7 @@ public AesEncryptionResult EncryptString(string plainString, string password, bo
var plainStringBytes = Encoding.UTF8.GetBytes(plainString);
var passwordBytes = Encoding.UTF8.GetBytes(password);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -95,9 +95,9 @@ public AesEncryptionResult EncryptString(string plainString, string password, bo
///
/// The input plain string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -120,7 +120,7 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
var plainStringBytes = Encoding.UTF8.GetBytes(plainString);
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -128,9 +128,9 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
///
/// The input byte array of the string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -152,7 +152,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -160,9 +160,9 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
///
/// The input byte array of the string to encrypt.
/// The byte array of the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -197,7 +197,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
byte[] tag;
byte[] hmacSha384bytes;
- if (appendEncryptionDataToOutputString)
+ if (appendEncryptionDataToOutput)
{
using (var ms = new MemoryStream())
{
@@ -253,12 +253,12 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
///
/// The base64 encoded input string to decrypt.
/// The password string where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, string password, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, string password, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -282,7 +282,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
var encryptedStringBytes = Convert.FromBase64String(base64EncryptedString);
var passwordBytes = Encoding.UTF8.GetBytes(password);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -290,12 +290,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
///
/// The base64 encoded input string to decrypt.
/// The SecureString with the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -319,7 +319,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
var encryptedStringBytes = Convert.FromBase64String(base64EncryptedString);
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -327,12 +327,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
///
/// The input byte array of the string to decrypt.
/// The SecureString with the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -355,7 +355,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -363,12 +363,12 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
///
/// The input byte array of the string to decrypt.
/// The byte array of the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -389,7 +389,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
};
}
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
if (encryptedStringBytes.Length < (_tagBytesLength + _saltBytesLength + _IVBytesLength))
{
@@ -403,7 +403,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
try
{
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
sentTag = new byte[_tagBytesLength];
Array.Copy(encryptedStringBytes, (encryptedStringBytes.Length - _tagBytesLength), sentTag, 0, sentTag.Length);
@@ -418,8 +418,8 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
byte[] derivedKey = CommonMethods.GetHashedBytesFromPBKDF2(passwordBytes, salt, (_keyBytesLength * 2), _iterationsForKeyDerivationFunction);
byte[] cryptKey = derivedKey.Take(_keyBytesLength).ToArray();
byte[] authKey = derivedKey.Skip(_keyBytesLength).Take(_keyBytesLength).ToArray();
- //var hmacSha384 = CommonMethods.ComputeHMACSHA384HashFromDataBytes(authKey, encryptedStringBytes, 0, (hasEncryptionDataAppendedInInputString ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length));
- var hmacSha384 = new HMAC_SHA_384().ComputeHMAC(encryptedStringBytes, authKey, 0, (hasEncryptionDataAppendedInInputString ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length)).HashBytes;
+ //var hmacSha384 = CommonMethods.ComputeHMACSHA384HashFromDataBytes(authKey, encryptedStringBytes, 0, (hasEncryptionDataAppendedInInput ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length));
+ var hmacSha384 = new HMAC_SHA_384().ComputeHMAC(encryptedStringBytes, authKey, 0, (hasEncryptionDataAppendedInInput ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length)).HashBytes;
var calcTag = hmacSha384.Take(_tagBytesLength).ToArray();
if (!CommonMethods.TagsMatch(calcTag, sentTag))
@@ -433,13 +433,13 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
byte[] encryptedSourceDataStringBytes = null;
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
encryptedSourceDataStringBytes = new byte[(encryptedStringBytes.Length - _tagBytesLength - _saltBytesLength - _IVBytesLength)];
Array.Copy(encryptedStringBytes, 0, encryptedSourceDataStringBytes, 0, encryptedSourceDataStringBytes.Length);
}
- var aesDecryptionResult = base.DecryptWithMemoryStream((hasEncryptionDataAppendedInInputString ? encryptedSourceDataStringBytes : encryptedStringBytes),
+ var aesDecryptionResult = base.DecryptWithMemoryStream((hasEncryptionDataAppendedInInput ? encryptedSourceDataStringBytes : encryptedStringBytes),
cryptKey, IV, _cipherMode, _paddingMode);
if (aesDecryptionResult.Success)
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_512.cs b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_512.cs
index 4e3fb08..ecec623 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_512.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AE/AE_AES_256_CBC_HMAC_SHA_512.cs
@@ -62,9 +62,9 @@ public AE_AES_256_CBC_HMAC_SHA_512(byte[] key, byte[] IV)
///
/// The input plain string to encrypt.
/// The password string where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, string password, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, string password, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -87,7 +87,7 @@ public AesEncryptionResult EncryptString(string plainString, string password, bo
var plainStringBytes = Encoding.UTF8.GetBytes(plainString);
var passwordBytes = Encoding.UTF8.GetBytes(password);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -95,9 +95,9 @@ public AesEncryptionResult EncryptString(string plainString, string password, bo
///
/// The input plain string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -120,7 +120,7 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
var plainStringBytes = Encoding.UTF8.GetBytes(plainString);
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -128,9 +128,9 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
///
/// The input byte array of the string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -152,7 +152,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, appendEncryptionDataToOutput);
}
///
@@ -160,9 +160,9 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
///
/// The input byte array of the string to encrypt.
/// The byte array of the password where the encryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -197,7 +197,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
byte[] tag;
byte[] hmacSha512bytes;
- if (appendEncryptionDataToOutputString)
+ if (appendEncryptionDataToOutput)
{
using (var ms = new MemoryStream())
{
@@ -253,12 +253,12 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
///
/// The base64 encoded input string to decrypt.
/// The password string where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, string password, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, string password, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -282,7 +282,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
var encryptedStringBytes = Convert.FromBase64String(base64EncryptedString);
var passwordBytes = Encoding.UTF8.GetBytes(password);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -290,12 +290,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
///
/// The base64 encoded input string to decrypt.
/// The SecureString with the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -319,7 +319,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
var encryptedStringBytes = Convert.FromBase64String(base64EncryptedString);
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -327,12 +327,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
///
/// The input byte array of the string to decrypt.
/// The SecureString with the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -355,7 +355,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
- return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInputString, sentTag, salt, IV);
+ return DecryptString(encryptedStringBytes, passwordBytes, hasEncryptionDataAppendedInInput, sentTag, salt, IV);
}
///
@@ -363,12 +363,12 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
///
/// The input byte array of the string to decrypt.
/// The byte array of the password where the decryption key will be derived from.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input byte array of the encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Initialization Vector used to initialize the first block. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesDecryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, bool hasEncryptionDataAppendedInInput = true,
byte[] sentTag = null, byte[] salt = null, byte[] IV = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -389,7 +389,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
};
}
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
if (encryptedStringBytes.Length < (_tagBytesLength + _saltBytesLength + _IVBytesLength))
{
@@ -403,7 +403,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
try
{
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
sentTag = new byte[_tagBytesLength];
Array.Copy(encryptedStringBytes, (encryptedStringBytes.Length - _tagBytesLength), sentTag, 0, sentTag.Length);
@@ -418,8 +418,8 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
byte[] derivedKey = CommonMethods.GetHashedBytesFromPBKDF2(passwordBytes, salt, (_keyBytesLength * 2), _iterationsForKeyDerivationFunction);
byte[] cryptKey = derivedKey.Take(_keyBytesLength).ToArray();
byte[] authKey = derivedKey.Skip(_keyBytesLength).Take(_keyBytesLength).ToArray();
- //var hmacSha512 = CommonMethods.ComputeHMACSHA512HashFromDataBytes(authKey, encryptedStringBytes, 0, (hasEncryptionDataAppendedInInputString ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length));
- var hmacSha512 = new HMAC_SHA_512().ComputeHMAC(encryptedStringBytes, authKey, 0, (hasEncryptionDataAppendedInInputString ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length)).HashBytes;
+ //var hmacSha512 = CommonMethods.ComputeHMACSHA512HashFromDataBytes(authKey, encryptedStringBytes, 0, (hasEncryptionDataAppendedInInput ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length));
+ var hmacSha512 = new HMAC_SHA_512().ComputeHMAC(encryptedStringBytes, authKey, 0, (hasEncryptionDataAppendedInInput ? (encryptedStringBytes.Length - _tagBytesLength) : encryptedStringBytes.Length)).HashBytes;
var calcTag = hmacSha512.Take(_tagBytesLength).ToArray();
if (!CommonMethods.TagsMatch(calcTag, sentTag))
@@ -433,13 +433,13 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
byte[] encryptedSourceDataStringBytes = null;
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
encryptedSourceDataStringBytes = new byte[(encryptedStringBytes.Length - _tagBytesLength - _saltBytesLength - _IVBytesLength)];
Array.Copy(encryptedStringBytes, 0, encryptedSourceDataStringBytes, 0, encryptedSourceDataStringBytes.Length);
}
- var aesDecryptionResult = base.DecryptWithMemoryStream((hasEncryptionDataAppendedInInputString ? encryptedSourceDataStringBytes : encryptedStringBytes),
+ var aesDecryptionResult = base.DecryptWithMemoryStream((hasEncryptionDataAppendedInInput ? encryptedSourceDataStringBytes : encryptedStringBytes),
cryptKey, IV, _cipherMode, _paddingMode);
if (aesDecryptionResult.Success)
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AEAD/AEAD_AES_256_GCM.cs b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AEAD/AEAD_AES_256_GCM.cs
index 1a160b7..8f7c2c4 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AEAD/AEAD_AES_256_GCM.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Encryption/AES/AEAD/AEAD_AES_256_GCM.cs
@@ -55,9 +55,9 @@ public class AEAD_AES_256_GCM
/// The input plain string to encrypt.
/// The password string where the encryption key will be derived from.
/// The encryption additional associated data string used in the authentication process together with the tag. It's not mandatory, leave empty or pass null to not use.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, string password, string associatedDataString = null, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, string password, string associatedDataString = null, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrEmpty(plainString))
{
@@ -81,7 +81,7 @@ public AesEncryptionResult EncryptString(string plainString, string password, st
var passwordBytes = Encoding.UTF8.GetBytes(password);
var associatedDataBytes = (associatedDataString == null ? null : Encoding.UTF8.GetBytes(associatedDataString));
- return EncryptString(plainStringBytes, passwordBytes, associatedDataBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, associatedDataBytes, appendEncryptionDataToOutput);
}
///
@@ -90,9 +90,9 @@ public AesEncryptionResult EncryptString(string plainString, string password, st
/// The input plain string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
/// The encryption additional associated data string used in the authentication process together with the tag. It's not mandatory, leave empty or pass null to not use.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, string associatedDataString = null, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(string plainString, SecureString secStrPassword, string associatedDataString = null, bool appendEncryptionDataToOutput = true)
{
if (string.IsNullOrWhiteSpace(plainString))
{
@@ -116,7 +116,7 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
var associatedDataBytes = (associatedDataString == null ? null : Encoding.UTF8.GetBytes(associatedDataString));
- return EncryptString(plainStringBytes, passwordBytes, associatedDataBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, associatedDataBytes, appendEncryptionDataToOutput);
}
///
@@ -125,9 +125,9 @@ public AesEncryptionResult EncryptString(string plainString, SecureString secStr
/// The input byte array of the string to encrypt.
/// The SecureString with the password where the encryption key will be derived from.
/// The encryption additional associated data string used in the authentication process together with the tag. It's not mandatory, leave empty or pass null to not use.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, string associatedDataString = null, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString secStrPassword, string associatedDataString = null, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length <= 0)
{
@@ -150,7 +150,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
var associatedDataBytes = (associatedDataString == null ? null : Encoding.UTF8.GetBytes(associatedDataString));
- return EncryptString(plainStringBytes, passwordBytes, associatedDataBytes, appendEncryptionDataToOutputString);
+ return EncryptString(plainStringBytes, passwordBytes, associatedDataBytes, appendEncryptionDataToOutput);
}
///
@@ -159,9 +159,9 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, SecureString s
/// The input byte array of the string to encrypt.
/// The byte array of the password where the encryption key will be derived from.
/// The byte array of the encryption additional associated data used in the authentication process together with the tag. It's not mandatory, leave empty or pass null to not use.
- /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
+ /// Flag to indicate if the encryption additional data required to decrypt will be appended to the output string. Enabling this option will not turn the encrypted data unsecure, but you'll have to provide that required info manually when you will do the decryption process.
/// AesEncryptionResult
- public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, byte[] associatedData = null, bool appendEncryptionDataToOutputString = true)
+ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwordBytes, byte[] associatedData = null, bool appendEncryptionDataToOutput = true)
{
if (plainStringBytes == null || plainStringBytes.Length == 0)
{
@@ -204,7 +204,7 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
aesGcm.Encrypt(nonce, plainStringBytes, encryptedData, tag, associatedData);
}
- if (appendEncryptionDataToOutputString)
+ if (appendEncryptionDataToOutput)
{
using (var ms = new MemoryStream())
{
@@ -254,9 +254,9 @@ public AesEncryptionResult EncryptString(byte[] plainStringBytes, byte[] passwor
/// The base64 encoded input string to decrypt.
/// The password string where the encryption key will be derived from.
/// The encryption additional associated data string used in the authentication process together with the tag. It's not mandatory, leave empty or pass null to not use.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
/// AesEncryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, string password, string associatedDataString = null, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, string password, string associatedDataString = null, bool hasEncryptionDataAppendedInInput = true,
byte[] tag = null, byte[] salt = null, byte[] nonce = null)
{
if (string.IsNullOrEmpty(base64EncryptedString))
@@ -281,7 +281,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
var passwordBytes = Encoding.UTF8.GetBytes(password);
var associatedDataBytes = (associatedDataString == null ? null : Encoding.UTF8.GetBytes(associatedDataString));
- return DecryptString(encryptedStringBytes, passwordBytes, associatedDataBytes, hasEncryptionDataAppendedInInputString, tag, salt, nonce);
+ return DecryptString(encryptedStringBytes, passwordBytes, associatedDataBytes, hasEncryptionDataAppendedInInput, tag, salt, nonce);
}
///
@@ -290,12 +290,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, string pa
/// The base64 encoded input string to decrypt.
/// The SecureString of the password where the encryption key will be derived from.
/// The encryption additional associated data string used in the authentication process together with the tag. It's not mandatory, leave empty or pass null to not use.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Nonce. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Nonce. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesEncryptionResult
- public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, string associatedDataString = null, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureString secStrPassword, string associatedDataString = null, bool hasEncryptionDataAppendedInInput = true,
byte[] tag = null, byte[] salt = null, byte[] nonce = null)
{
if (string.IsNullOrWhiteSpace(base64EncryptedString))
@@ -320,7 +320,7 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
var associatedDataBytes = (associatedDataString == null ? null : Encoding.UTF8.GetBytes(associatedDataString));
- return DecryptString(plainStringBytes, passwordBytes, associatedDataBytes, hasEncryptionDataAppendedInInputString, tag, salt, nonce);
+ return DecryptString(plainStringBytes, passwordBytes, associatedDataBytes, hasEncryptionDataAppendedInInput, tag, salt, nonce);
}
///
@@ -329,12 +329,12 @@ public AesDecryptionResult DecryptString(string base64EncryptedString, SecureStr
/// The byte array of the input string to decrypt.
/// The SecureString of the password where the encryption key will be derived from.
/// The encryption additional associated data string used in the authentication process together with the tag. It's not mandatory, leave empty or pass null to not use.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Nonce. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Nonce. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesEncryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, string associatedDataString = null, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureString secStrPassword, string associatedDataString = null, bool hasEncryptionDataAppendedInInput = true,
byte[] tag = null, byte[] salt = null, byte[] nonce = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length <= 0)
@@ -358,7 +358,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
var passwordBytes = CommonMethods.ConvertSecureStringToByteArray(secStrPassword);
var associatedDataBytes = (associatedDataString == null ? null : Encoding.UTF8.GetBytes(associatedDataString));
- return DecryptString(encryptedStringBytes, passwordBytes, associatedDataBytes, hasEncryptionDataAppendedInInputString, tag, salt, nonce);
+ return DecryptString(encryptedStringBytes, passwordBytes, associatedDataBytes, hasEncryptionDataAppendedInInput, tag, salt, nonce);
}
///
@@ -367,12 +367,12 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, SecureStri
/// The byte array of the input string to decrypt.
/// The byte array of the password where the encryption key will be derived from.
/// The byte array of the encryption additional associated data used in the authentication process together with the tag. It's not mandatory, leave empty or pass null to not use.
- /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
- /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
- /// The previously generated byte array of the Nonce. Leave empty or pass null if hasEncryptionDataAppendedInInputString = true.
+ /// Flag to indicate if the encryption additional data required to decrypt is present in the input base64 encoded encrypted string. If true, retrieves this info from it, otherwise use the manually provided data via parameters.
+ /// The previously generated byte array of the authentication tag. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the salt used with the password to derive the decryption key. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
+ /// The previously generated byte array of the Nonce. Leave empty or pass null if hasEncryptionDataAppendedInInput = true.
/// AesEncryptionResult
- public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, byte[] associatedData = null, bool hasEncryptionDataAppendedInInputString = true,
+ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] passwordBytes, byte[] associatedData = null, bool hasEncryptionDataAppendedInInput = true,
byte[] tag = null, byte[] salt = null, byte[] nonce = null)
{
if (encryptedStringBytes == null || encryptedStringBytes.Length == 0)
@@ -415,7 +415,7 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
{
byte[] encryptedStringBytesWithEncryptionData = null;
- if (hasEncryptionDataAppendedInInputString)
+ if (hasEncryptionDataAppendedInInput)
{
tag = new byte[_tagBytesLength];
Array.Copy(encryptedStringBytes, (encryptedStringBytes.Length - _tagBytesLength), tag, 0, tag.Length);
@@ -431,11 +431,11 @@ public AesDecryptionResult DecryptString(byte[] encryptedStringBytes, byte[] pas
}
byte[] derivedKey = CommonMethods.GetHashedBytesFromPBKDF2(passwordBytes, salt, _keyBytesLength, _iterationsForPBKDF2, HashAlgorithmName.SHA512);
- byte[] decryptedData = new byte[(hasEncryptionDataAppendedInInputString ? encryptedStringBytesWithEncryptionData.Length : encryptedStringBytes.Length)];
+ byte[] decryptedData = new byte[(hasEncryptionDataAppendedInInput ? encryptedStringBytesWithEncryptionData.Length : encryptedStringBytes.Length)];
using (var aesGcm = new AesGcm(derivedKey))
{
- aesGcm.Decrypt(nonce, (hasEncryptionDataAppendedInInputString ? encryptedStringBytesWithEncryptionData : encryptedStringBytes), tag, decryptedData, associatedData);
+ aesGcm.Decrypt(nonce, (hasEncryptionDataAppendedInInput ? encryptedStringBytesWithEncryptionData : encryptedStringBytes), tag, decryptedData, associatedData);
}
return new AesDecryptionResult()
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Hash/Argon2id.cs b/src/CryptHash.Net/lib/CryptHash.Net/Hash/Argon2id.cs
index aba081f..b70989f 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Hash/Argon2id.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Hash/Argon2id.cs
@@ -13,7 +13,7 @@ namespace CryptHash.Net.Hash
{
public class Argon2id
{
- public Argon2idHashResult ComputeHash(byte[] stringToBeHashedBytes, int iterations, int kBmemorySize, int degreeOfParallelism, int amountBytesToReturn,
+ public Argon2idHashResult ComputeHash(byte[] stringToComputeHashBytes, int iterations, int kBmemorySize, int degreeOfParallelism, int amountBytesToReturn,
byte[] salt = null, byte[] associatedData = null, byte[] knownSecret = null)
{
try
@@ -21,7 +21,7 @@ public Argon2idHashResult ComputeHash(byte[] stringToBeHashedBytes, int iteratio
salt = salt ?? CommonMethods.GenerateSalt(); // generate a 128 bits salt, if not provided
degreeOfParallelism = (degreeOfParallelism <= 0 ? Environment.ProcessorCount : degreeOfParallelism);
- using (var argon2id = new Konscious.Security.Cryptography.Argon2id(stringToBeHashedBytes) {
+ using (var argon2id = new Konscious.Security.Cryptography.Argon2id(stringToComputeHashBytes) {
Salt = salt,
DegreeOfParallelism = degreeOfParallelism,
Iterations = iterations,
@@ -56,12 +56,12 @@ public Argon2idHashResult ComputeHash(byte[] stringToBeHashedBytes, int iteratio
}
}
- public Argon2idHashResult VerifyHash(byte[] hash, byte[] stringToBeHashedBytes, int iterations, int kBmemorySize, int degreeOfParallelism, int amountBytesToReturn,
+ public Argon2idHashResult VerifyHash(byte[] hash, byte[] stringToComputeHashBytes, int iterations, int kBmemorySize, int degreeOfParallelism, int amountBytesToReturn,
byte[] salt = null, byte[] associatedData = null, byte[] knownSecret = null)
{
try
{
- var newHash = ComputeHash(stringToBeHashedBytes, iterations, kBmemorySize, degreeOfParallelism, amountBytesToReturn, salt, associatedData, knownSecret);
+ var newHash = ComputeHash(stringToComputeHashBytes, iterations, kBmemorySize, degreeOfParallelism, amountBytesToReturn, salt, associatedData, knownSecret);
return new Argon2idHashResult()
{
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Hash/Base/HMACBase.cs b/src/CryptHash.Net/lib/CryptHash.Net/Hash/Base/HMACBase.cs
index cd6a817..c413644 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Hash/Base/HMACBase.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Hash/Base/HMACBase.cs
@@ -31,15 +31,6 @@ internal HMACHashResult ComputeHMAC(Enums.HMACAlgorithm hmacAlgorithm, byte[] by
};
}
- //if (key != null && key.Length != (HMACOutputLengthDictionary.Instance[hmacAlgorithm] / 8))
- //{
- // //throw new ArgumentException($"Key size invalid for algorithm {hashAlgorithmHMACName}.", nameof(key));
- // return new HMACHashResult() {
- // Success = false,
- // Message = $"{MessageDictionary.Instance["Common.InvalidKeySizeError"]} ({key.Length})."
- // };
- //}
-
if (key == null || key.Length == 0)
key = CommonMethods.GenerateRandomBytes(HMACOutputLengthDictionary.Instance[hmacAlgorithm] / 8);
@@ -107,16 +98,6 @@ internal HMACHashResult ComputeFileHMAC(Enums.HMACAlgorithm hmacAlgorithm, strin
};
}
- //if (key != null && key.Length != (HMACOutputLengthDictionary.Instance[hmacAlgorithm] / 8))
- //{
- // //throw new ArgumentException($"Key size invalid for algorithm {hashAlgorithmName}.", nameof(key));
- // return new HMACHashResult()
- // {
- // Success = false,
- // Message = $"{MessageDictionary.Instance["Common.InvalidKeySizeError"]} ({key.Length})."
- // };
- //}
-
if (key == null || key.Length == 0)
key = CommonMethods.GenerateRandomBytes(HMACOutputLengthDictionary.Instance[hmacAlgorithm] / 8);
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_MD5.cs b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_MD5.cs
index 74b8cbe..2927fcf 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_MD5.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_MD5.cs
@@ -12,10 +12,10 @@ namespace CryptHash.Net.Hash
public class HMAC_MD5 : HMACBase
{
///
- /// Computes the HMACMD5 of an input byte array using a 128 bit key.
+ /// Computes the HMACMD5 of an input byte array using a key.
///
/// The input byte array to compute the HMAC.
- /// The 128 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -25,10 +25,10 @@ public HMACHashResult ComputeHMAC(byte[] bytesToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACMD5 of an input string using a 128 bit key.
+ /// Computes the HMACMD5 of an input string using a key.
///
/// The input string to compute the HMAC.
- /// The 128 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -38,10 +38,10 @@ public HMACHashResult ComputeHMAC(string stringToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACMD5 of an input file using a 128 bit key.
+ /// Computes the HMACMD5 of an input file using a key.
///
/// The input file path to compute the HMAC.
- /// The 128 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -52,11 +52,11 @@ public HMACHashResult ComputeFileHMAC(string filePathToComputeHMAC, byte[] key =
///
- /// Verifies the HMACMD5 of an input byte array using a 128 bit key.
+ /// Verifies the HMACMD5 of an input byte array using a key.
///
/// The pre-computed HMACMD5 byte array.
/// The input byte array to compute and verify the HMACMD5.
- /// The 128 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -66,11 +66,11 @@ public HMACHashResult VerifyHMAC(byte[] hmacBytes, byte[] bytesToVerifyHMAC, byt
}
///
- /// Verifies the HMACMD5 of an input string using a 128 bit key.
+ /// Verifies the HMACMD5 of an input string using a key.
///
/// The pre-computed HMACMD5 hexadecimal encoded string.
/// The input string to compute and verify the HMACMD5.
- /// The 128 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -80,11 +80,11 @@ public HMACHashResult VerifyHMAC(string hmacHexString, string stringToVerifyHMAC
}
///
- /// Verifies the HMACMD5 of an input file using a 128 bit key.
+ /// Verifies the HMACMD5 of an input file using a key.
///
/// The pre-computed HMACMD5 hexadecimal encoded string.
/// The input file path to compute and verify the HMACMD5.
- /// The 128 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -94,11 +94,11 @@ public HMACHashResult VerifyFileHMAC(string hmacHexString, string filePathToVeri
}
///
- /// Verifies the HMACMD5 of an input file using a 128 bit key.
+ /// Verifies the HMACMD5 of an input file using a key.
///
/// The pre-computed HMACMD5 byte array.
/// The input file path to compute and verify the HMACMD5.
- /// The 128 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_1.cs b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_1.cs
index 5432115..54621d2 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_1.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_1.cs
@@ -12,10 +12,10 @@ namespace CryptHash.Net.Hash
public class HMAC_SHA_1 : HMACBase
{
///
- /// Computes the HMACSHA1 of an input byte array using a 160 bit key.
+ /// Computes the HMACSHA1 of an input byte array using a key.
///
/// The input byte array to compute the HMACSHA1.
- /// The 160 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -25,10 +25,10 @@ public HMACHashResult ComputeHMAC(byte[] bytesToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACSHA1 of an input string using a 160 bit key.
+ /// Computes the HMACSHA1 of an input string using a key.
///
/// The input string to compute the HMACSHA1.
- /// The 160 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -38,10 +38,10 @@ public HMACHashResult ComputeHMAC(string stringToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACSHA1 of an input file using a 160 bit key.
+ /// Computes the HMACSHA1 of an input file using a key.
///
/// The input file path to compute the HMACSHA1.
- /// The 160 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -52,11 +52,11 @@ public HMACHashResult ComputeFileHMAC(string filePathToComputeHMAC, byte[] key =
///
- /// Verifies the HMACSHA1 of an input byte array using a 160 bit key.
+ /// Verifies the HMACSHA1 of an input byte array using a key.
///
/// The pre-computed HMACSHA1 byte array.
/// The input byte array to compute and verify the HMACSHA1.
- /// The 160 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -66,11 +66,11 @@ public HMACHashResult VerifyHMAC(byte[] hmacBytes, byte[] bytesToVerifyHMAC, byt
}
///
- /// Verifies the HMACSHA1 of an input string using a 160 bit key.
+ /// Verifies the HMACSHA1 of an input string using a key.
///
/// The pre-computed HMACSHA1 hexadecimal encoded string.
/// The input string to compute and verify the HMACSHA1.
- /// The 160 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -80,11 +80,11 @@ public HMACHashResult VerifyHMAC(string hmacHexString, string stringToVerifyHMAC
}
///
- /// Verifies the HMACSHA1 of an input file using a 160 bit key.
+ /// Verifies the HMACSHA1 of an input file using a key.
///
/// The pre-computed HMACSHA1 hexadecimal encoded string.
/// The input file path to compute and verify the HMACSHA1.
- /// The 160 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -94,11 +94,11 @@ public HMACHashResult VerifyFileHMAC(string hmacHexString, string sourceFilePath
}
///
- /// Verifies the HMACSHA1 of an input file using a 160 bit key.
+ /// Verifies the HMACSHA1 of an input file using a key.
///
/// The pre-computed HMACSHA1 byte array.
/// The input file path to compute and verify the HMACSHA1.
- /// The 160 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_256.cs b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_256.cs
index 80c38df..ee3488d 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_256.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_256.cs
@@ -12,10 +12,10 @@ namespace CryptHash.Net.Hash
public class HMAC_SHA_256 : HMACBase
{
///
- /// Computes the HMACSHA256 of an input byte array using a 256 bit key.
+ /// Computes the HMACSHA256 of an input byte array using a key.
///
/// The input byte array to compute the HMACSHA256.
- /// The 256 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -25,10 +25,10 @@ public HMACHashResult ComputeHMAC(byte[] bytesToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACSHA256 of an input string using a 256 bit key.
+ /// Computes the HMACSHA256 of an input string using a key.
///
/// The input string to compute the HMACSHA256.
- /// The 256 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -38,10 +38,10 @@ public HMACHashResult ComputeHMAC(string stringToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACSHA256 of an input file using a 256 bit key.
+ /// Computes the HMACSHA256 of an input file using a key.
///
/// The input file path to compute the HMACSHA256.
- /// The 256 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -51,11 +51,11 @@ public HMACHashResult ComputeFileHMAC(string filePathToComputeHMAC, byte[] key =
}
///
- /// Verifies the HMACSHA256 of an input byte array using a 256 bit key.
+ /// Verifies the HMACSHA256 of an input byte array using a key.
///
/// The pre-computed HMACSHA256 byte array.
/// The input byte array to compute and verify the HMACSHA256.
- /// The 256 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -65,11 +65,11 @@ public HMACHashResult VerifyHMAC(byte[] hmacBytes, byte[] bytesToVerifyHMAC, byt
}
///
- /// Verifies the HMACSHA256 of an input string using a 256 bit key.
+ /// Verifies the HMACSHA256 of an input string using a key.
///
/// The pre-computed HMACSHA256 hexadecimal encoded string.
/// The input string to compute and verify the HMACSHA256.
- /// The 256 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -79,11 +79,11 @@ public HMACHashResult VerifyHMAC(string hmacHexString, string stringToVerifyHMAC
}
///
- /// Verifies the HMACSHA256 of an input file using a 256 bit key.
+ /// Verifies the HMACSHA256 of an input file using a key.
///
/// The pre-computed HMACSHA256 hexadecimal encoded string.
/// The input file path to compute and verify the HMACSHA256.
- /// The 256 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -93,11 +93,11 @@ public HMACHashResult VerifyFileHMAC(string hmacHexString, string sourceFilePath
}
///
- /// Verifies the HMACSHA256 of an input file using a 256 bit key.
+ /// Verifies the HMACSHA256 of an input file using a key.
///
/// The pre-computed HMACSHA256 byte array.
/// The input file path to compute and verify the HMACSHA256.
- /// The 256 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_384.cs b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_384.cs
index e575589..6f4f722 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_384.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_384.cs
@@ -12,10 +12,10 @@ namespace CryptHash.Net.Hash
public class HMAC_SHA_384 : HMACBase
{
///
- /// Computes the HMACSHA384 of an input byte array using a 384 bit key.
+ /// Computes the HMACSHA384 of an input byte array using a key.
///
/// The input byte array to compute the HMACSHA384.
- /// The 384 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -25,10 +25,10 @@ public HMACHashResult ComputeHMAC(byte[] bytesToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACSHA384 of an input string using a 384 bit key.
+ /// Computes the HMACSHA384 of an input string using a key.
///
/// The input string to compute the HMACSHA384.
- /// The 384 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -38,10 +38,10 @@ public HMACHashResult ComputeHMAC(string stringToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACSHA384 of an input file using a 384 bit key.
+ /// Computes the HMACSHA384 of an input file using a key.
///
/// The input file path to compute the HMACSHA384.
- /// The 384 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -51,11 +51,11 @@ public HMACHashResult ComputeFileHMAC(string filePathToComputeHMAC, byte[] key =
}
///
- /// Verifies the HMACSHA384 of an input byte array using a 384 bit key.
+ /// Verifies the HMACSHA384 of an input byte array using a key.
///
/// The pre-computed HMACSHA384 byte array.
/// The input byte array to compute and verify the HMACSHA384.
- /// The 384 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -65,11 +65,11 @@ public HMACHashResult VerifyHMAC(byte[] hmacBytes, byte[] bytesToVerifyHMAC, byt
}
///
- /// Verifies the HMACSHA384 of an input string using a 384 bit key.
+ /// Verifies the HMACSHA384 of an input string using a key.
///
/// The pre-computed HMACSHA384 hexadecimal encoded string.
/// The input string to compute and verify the HMACSHA384.
- /// The 384 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -79,11 +79,11 @@ public HMACHashResult VerifyHMAC(string hmacHexString, string stringToVerifyHMAC
}
///
- /// Verifies the HMACSHA384 of an input file using a 384 bit key.
+ /// Verifies the HMACSHA384 of an input file using a key.
///
/// The pre-computed HMACSHA384 hexadecimal encoded string.
/// The input file path to compute and verify the HMACSHA384.
- /// The 384 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -93,11 +93,11 @@ public HMACHashResult VerifyFileHMAC(string hmacHexString, string filePathToVeri
}
///
- /// Verifies the HMACSHA384 of an input file using a 384 bit key.
+ /// Verifies the HMACSHA384 of an input file using a key.
///
/// The pre-computed HMACSHA384 byte array.
/// The input file path to compute and verify the HMACSHA384.
- /// The 384 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_512.cs b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_512.cs
index 450af48..2960e16 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_512.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Hash/HMAC_SHA_512.cs
@@ -12,10 +12,10 @@ namespace CryptHash.Net.Hash
public class HMAC_SHA_512 : HMACBase
{
///
- /// Computes the HMACSHA512 of an input byte array using a 512 bit key.
+ /// Computes the HMACSHA512 of an input byte array using a key.
///
/// The input byte array to compute the HMACSHA512.
- /// The 512 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -25,10 +25,10 @@ public HMACHashResult ComputeHMAC(byte[] bytesToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACSHA512 of an input string using a 512 bit key.
+ /// Computes the HMACSHA512 of an input string using a key.
///
/// The input string to compute the HMACSHA512.
- /// The 512 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -38,10 +38,10 @@ public HMACHashResult ComputeHMAC(string stringToComputeHMAC, byte[] key = null,
}
///
- /// Computes the HMACSHA512 of an input file using a 512 bit key.
+ /// Computes the HMACSHA512 of an input file using a key.
///
/// The input file path to compute the HMACSHA512.
- /// The 512 bit key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
+ /// The input key byte array. Leave empty or pass null to auto-generate a secure random key. The key will be present in the HMACHashResult return.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -51,11 +51,11 @@ public HMACHashResult ComputeFileHMAC(string filePathToComputeHMAC, byte[] key =
}
///
- /// Verifies the HMACSHA512 of an input byte array using a 512 bit key.
+ /// Verifies the HMACSHA512 of an input byte array using a key.
///
/// The pre-computed HMACSHA512 byte array.
/// The input byte array to compute and verify the HMACSHA512.
- /// The 512 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -65,11 +65,11 @@ public HMACHashResult VerifyHMAC(byte[] hmacBytes, byte[] bytesToVerifyHMAC, byt
}
///
- /// Verifies the HMACSHA512 of an input string using a 512 bit key.
+ /// Verifies the HMACSHA512 of an input string using a key.
///
/// The pre-computed HMACSHA512 hexadecimal encoded string.
/// The input string to compute and verify the HMACSHA512.
- /// The 512 bit key byte array.
+ /// The input key byte array.
/// The offset into the byte array from wich to begin reading data.
/// The number of bytes in the array to read after the offset.
/// HMACHashResult
@@ -79,11 +79,11 @@ public HMACHashResult VerifyHMAC(string hmacHexString, string stringToVerifyHMAC
}
///
- /// Verifies the HMACSHA512 of an input file using a 512 bit key.
+ /// Verifies the HMACSHA512 of an input file using a key.
///
/// The pre-computed HMACSHA512 hexadecimal encoded string.
/// The input file path to compute and verify the HMACSHA512.
- /// The 512 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
@@ -93,11 +93,11 @@ public HMACHashResult VerifyFileHMAC(string hmacHexString, string filePathToVeri
}
///
- /// Verifies the HMACSHA512 of an input file using a 512 bit key.
+ /// Verifies the HMACSHA512 of an input file using a key.
///
/// The pre-computed HMACSHA512 byte array.
/// The input file path to compute and verify the HMACSHA512.
- /// The 512 bit key byte array.
+ /// The input key byte array.
/// The offset into the FileStream from wich to begin reading data.
/// The number of bytes in the FileStream to read after the offset.
/// HMACHashResult
diff --git a/src/CryptHash.Net/lib/CryptHash.Net/Hash/PBKDF2_HMAC_SHA_1.cs b/src/CryptHash.Net/lib/CryptHash.Net/Hash/PBKDF2_HMAC_SHA_1.cs
index c86b396..d0c6088 100644
--- a/src/CryptHash.Net/lib/CryptHash.Net/Hash/PBKDF2_HMAC_SHA_1.cs
+++ b/src/CryptHash.Net/lib/CryptHash.Net/Hash/PBKDF2_HMAC_SHA_1.cs
@@ -8,15 +8,15 @@ namespace CryptHash.Net.Hash
//[Obsolete("This class is obsolete. Use PBKDF2.cs class instead.")]
public class PBKDF2_HMAC_SHA_1
{
- private static readonly int _hashBitSize = 160;
+ private static readonly int _hashBitSize = HMACOutputLengthDictionary.Instance[Enums.HMACAlgorithm.HMACSHA1];
private static readonly int _hashBytesLength = (_hashBitSize / 8);
private static readonly int _saltBitSize = 128;
private static readonly int _saltBytesLength = (_saltBitSize / 8);
- private static readonly int _iterations = 100000;
+ private const int _iterations = 100000;
- public PBKDF2HashResult ComputeHash(string stringToComputeHash, byte[] salt = null)
+ public PBKDF2HashResult ComputeHash(string stringToComputeHash, byte[] salt = null, int iterationsForKeyDerivation = _iterations)
{
if (string.IsNullOrWhiteSpace(stringToComputeHash))
{
@@ -35,7 +35,7 @@ public PBKDF2HashResult ComputeHash(string stringToComputeHash, byte[] salt = nu
{
using (var rfc2898DeriveBytes = new Rfc2898DeriveBytes(stringToComputeHash, salt))
{
- rfc2898DeriveBytes.IterationCount = _iterations;
+ rfc2898DeriveBytes.IterationCount = iterationsForKeyDerivation;
hash = rfc2898DeriveBytes.GetBytes(_hashBytesLength);
}
@@ -49,7 +49,7 @@ public PBKDF2HashResult ComputeHash(string stringToComputeHash, byte[] salt = nu
Message = MessageDictionary.Instance["Hash.ComputeSuccess"],
HashString = $"{Convert.ToBase64String(hashBytes)}",
HashBytes = hashBytes,
- Iterations = _iterations,
+ Iterations = iterationsForKeyDerivation,
Salt = salt,
PRF = Enums.HMACAlgorithm.HMACSHA1
};
@@ -63,7 +63,7 @@ public PBKDF2HashResult ComputeHash(string stringToComputeHash, byte[] salt = nu
}
}
- public PBKDF2HashResult VerifyHash(string stringToBeVerified, string hash)
+ public PBKDF2HashResult VerifyHash(string stringToBeVerified, string hash, int iterationsForKeyDerivation = _iterations)
{
if (string.IsNullOrWhiteSpace(stringToBeVerified))
{
@@ -100,7 +100,7 @@ public PBKDF2HashResult VerifyHash(string stringToBeVerified, string hash)
var hashBytes = new byte[_hashBytesLength];
Array.Copy(hashWithSaltBytes, _saltBytesLength, hashBytes, 0, _hashBytesLength);
- var result = ComputeHash(stringToBeVerified, saltBytes);
+ var result = ComputeHash(stringToBeVerified, saltBytes, iterationsForKeyDerivation);
if (string.Equals(result.HashString, hash))
{
@@ -110,7 +110,7 @@ public PBKDF2HashResult VerifyHash(string stringToBeVerified, string hash)
Message = MessageDictionary.Instance["Hash.Match"],
HashString = hash,
HashBytes = result.HashBytes,
- Iterations = _iterations,
+ Iterations = result.Iterations,
Salt = result.Salt,
PRF = result.PRF
};