|
@@ -114,6 +114,8 @@ begin
|
|
|
Fail('PBKDF2 HMAC-SHA1 with iteration count "5", 64 bits key generation test failed');
|
|
Fail('PBKDF2 HMAC-SHA1 with iteration count "5", 64 bits key generation test failed');
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
PasswordString :=
|
|
PasswordString :=
|
|
|
'All n-entities must communicate with other n-entities via n-1 entiteeheehees';
|
|
'All n-entities must communicate with other n-entities via n-1 entiteeheehees';
|
|
|
PasswordBytes := TConverters.ConvertStringToBytes(PasswordString,
|
|
PasswordBytes := TConverters.ConvertStringToBytes(PasswordString,
|
|
@@ -128,6 +130,8 @@ begin
|
|
|
Fail('PBKDF2 HMAC-SHA1 with iteration count "500", 192 bits key generation test failed');
|
|
Fail('PBKDF2 HMAC-SHA1 with iteration count "500", 192 bits key generation test failed');
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
generator.Init(PasswordBytes, SaltBytes, 60000);
|
|
generator.Init(PasswordBytes, SaltBytes, 60000);
|
|
|
|
|
|
|
|
if (not TArrayUtils.AreEqual((generator.GenerateDerivedMacParameters(192)
|
|
if (not TArrayUtils.AreEqual((generator.GenerateDerivedMacParameters(192)
|
|
@@ -137,6 +141,8 @@ begin
|
|
|
Fail('PBKDF2 HMAC-SHA1 with iteration count "60000", 192 bits key generation test failed');
|
|
Fail('PBKDF2 HMAC-SHA1 with iteration count "60000", 192 bits key generation test failed');
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
// https://github.com/ircmaxell/PHP-PasswordLib/blob/master/test/Data/Vectors/pbkdf2-draft-josefsson-sha1.test-vectors
|
|
// https://github.com/ircmaxell/PHP-PasswordLib/blob/master/test/Data/Vectors/pbkdf2-draft-josefsson-sha1.test-vectors
|
|
|
|
|
|
|
|
generator := TPkcs5S2ParametersGenerator.Create
|
|
generator := TPkcs5S2ParametersGenerator.Create
|
|
@@ -166,6 +172,8 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
// 2
|
|
// 2
|
|
|
|
|
|
|
|
iteration_count := 2;
|
|
iteration_count := 2;
|
|
@@ -183,6 +191,8 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// 3
|
|
// 3
|
|
|
|
|
|
|
@@ -201,6 +211,8 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
// 4
|
|
// 4
|
|
|
// commented out because iteration_count is very large
|
|
// commented out because iteration_count is very large
|
|
|
// iteration_count := 16777216;
|
|
// iteration_count := 16777216;
|
|
@@ -217,6 +229,8 @@ begin
|
|
|
// ('PBKDF2 HMAC-SHA1 with iteration count "%u", %u bits key generation test failed',
|
|
// ('PBKDF2 HMAC-SHA1 with iteration count "%u", %u bits key generation test failed',
|
|
|
// [iteration_count, dkLen]));
|
|
// [iteration_count, dkLen]));
|
|
|
// end;
|
|
// end;
|
|
|
|
|
+ //
|
|
|
|
|
+ // generator.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
// 5
|
|
// 5
|
|
@@ -243,6 +257,8 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// 6
|
|
// 6
|
|
|
|
|
|
|
@@ -269,6 +285,8 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
procedure TTestPkcs5.TestPkcs5_WITH_SHA256;
|
|
procedure TTestPkcs5.TestPkcs5_WITH_SHA256;
|
|
@@ -309,6 +327,8 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
// 2
|
|
// 2
|
|
|
|
|
|
|
|
iteration_count := 2;
|
|
iteration_count := 2;
|
|
@@ -327,6 +347,7 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
|
|
|
// 3
|
|
// 3
|
|
|
|
|
|
|
@@ -346,6 +367,8 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
// 4
|
|
// 4
|
|
|
// commented out because iteration_count is very large
|
|
// commented out because iteration_count is very large
|
|
|
// iteration_count := 16777216;
|
|
// iteration_count := 16777216;
|
|
@@ -363,7 +386,8 @@ begin
|
|
|
// ('PBKDF2 HMAC-SHA256 with iteration count "%u", %u bits key generation test failed',
|
|
// ('PBKDF2 HMAC-SHA256 with iteration count "%u", %u bits key generation test failed',
|
|
|
// [iteration_count, dkLen]));
|
|
// [iteration_count, dkLen]));
|
|
|
// end;
|
|
// end;
|
|
|
-
|
|
|
|
|
|
|
+ //
|
|
|
|
|
+ // generator.Clear();
|
|
|
|
|
|
|
|
// 5
|
|
// 5
|
|
|
|
|
|
|
@@ -391,6 +415,7 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
|
|
|
// 6
|
|
// 6
|
|
|
|
|
|
|
@@ -417,6 +442,8 @@ begin
|
|
|
[iteration_count, dkLen]));
|
|
[iteration_count, dkLen]));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
+ generator.Clear();
|
|
|
|
|
+
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
|
initialization
|