Skip to content

Commit

Permalink
First work on fixing issue #46 about BPKDF2
Browse files Browse the repository at this point in the history
Started to implement regression test. Removed compatibility with compiler versions < 28.0 (XE7)
  • Loading branch information
MHumm committed Dec 23, 2022
1 parent 5fa9d48 commit 8393d4b
Show file tree
Hide file tree
Showing 71 changed files with 164,877 additions and 65,414 deletions.
781 changes: 163 additions & 618 deletions Demos/Cipher_Console/Cipher_Console.dproj

Large diffs are not rendered by default.

405 changes: 206 additions & 199 deletions Demos/Cipher_Console_KDF/Cipher_Console_KDF.dproj

Large diffs are not rendered by default.

Binary file modified Demos/Cipher_Console_KDF/Cipher_Console_KDF.res
Binary file not shown.
1,579 changes: 466 additions & 1,113 deletions Demos/Cipher_FMX/Cipher_FMX.dproj

Large diffs are not rendered by default.

660 changes: 165 additions & 495 deletions Demos/Format_Console/Format_Console.dproj

Large diffs are not rendered by default.

595 changes: 234 additions & 361 deletions Demos/HashBenchmark_FMX/HashBenchmark.dproj

Large diffs are not rendered by default.

660 changes: 165 additions & 495 deletions Demos/Hash_Console/Hash_Console.dproj

Large diffs are not rendered by default.

1,706 changes: 473 additions & 1,233 deletions Demos/Hash_FMX/Hash_FMX.dproj

Large diffs are not rendered by default.

404 changes: 206 additions & 198 deletions Demos/Password_Console/Password_Console.dproj

Large diffs are not rendered by default.

Binary file modified Demos/Password_Console/Password_Console.res
Binary file not shown.
419 changes: 209 additions & 210 deletions Demos/Progress_VCL/ProgressDemoVCL.dproj

Large diffs are not rendered by default.

420 changes: 205 additions & 215 deletions Demos/Random_Console/Random_Console.dproj

Large diffs are not rendered by default.

Binary file modified Demos/Random_Console/Random_Console.identcache
Binary file not shown.
404 changes: 206 additions & 198 deletions Demos/Random_VCL_Comparison/RandomComparison_VCL.dproj

Large diffs are not rendered by default.

414 changes: 206 additions & 208 deletions Install/SetIDEPaths.dproj

Large diffs are not rendered by default.

680 changes: 160 additions & 520 deletions Source/DEC60.dproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/DEC60.todo
@@ -1 +1 @@

408 changes: 204 additions & 204 deletions Source/DEC60Complete.groupproj

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Source/DECCipherModesGCM.pas
Expand Up @@ -654,8 +654,6 @@ function TGCM.GetAuthenticationTagBitLength: UInt32;
end;

function TGCM.GetStandardAuthenticationTagBitLengths: TStandardBitLengths;
var
i : integer;
begin
SetLength(Result, 5);
Result := [96, 104, 112, 120, 128];
Expand Down
10 changes: 6 additions & 4 deletions Source/DECHashAuthentication.pas
Expand Up @@ -457,6 +457,9 @@ TDECHashAuthentication = class(TDECHash)
/// <param name="KeyLength">
/// Length of the resulting key in byte
/// </param>
/// <returns>
/// The calculated PBKDF2 value
/// </returns>
class function PBKDF2(const Password, Salt: TBytes; Iterations: Integer;
KeyLength: Integer): TBytes; overload;

Expand All @@ -480,6 +483,9 @@ TDECHashAuthentication = class(TDECHash)
/// <param name="KeyLength">
/// Length of the resulting key in byte
/// </param>
/// <returns>
/// The calculated PBKDF2 value
/// </returns>
class function PBKDF2(const Password, Salt: RawByteString;
Iterations: Integer;
KeyLength: Integer): TBytes; overload;
Expand Down Expand Up @@ -1307,11 +1313,7 @@ class function TDECHashAuthentication.PBKDF2(const Password, Salt: TBytes; Itera
end;
end;

{$IF CompilerVersion >= 28.0}
Result := Result + T; // DK += F , DK = DK || Ti
{$ELSE}
TArrHelper.AppendArrays<Byte>(Result, T);
{$IFEND}
end;
finally
Hash.Free;
Expand Down
59 changes: 59 additions & 0 deletions Unit Tests/CodeCoverage/DECCodeCoverage.dccp
@@ -0,0 +1,59 @@
<DCCProject xmlns="">
<VersionInfo>
<ApplicationVersion>V2.0.0 build 4</ApplicationVersion>
<FileFormatVersion>1</FileFormatVersion>
</VersionInfo>
<SourceCodeFiles>
<SourceBasePath>D:\Projekte\DECGitMaster\Source\</SourceBasePath>
<SourceFile Selected="True">DEC60Lazarus.pas</SourceFile>
<SourceFile Selected="True">DECBaseClass.pas</SourceFile>
<SourceFile Selected="True">DECCipherBase.pas</SourceFile>
<SourceFile Selected="True">DECCipherFormats.pas</SourceFile>
<SourceFile Selected="True">DECCipherInterface.pas</SourceFile>
<SourceFile Selected="True">DECCipherModes.pas</SourceFile>
<SourceFile Selected="True">DECCipherModesGCM.pas</SourceFile>
<SourceFile Selected="True">DECCiphers.pas</SourceFile>
<SourceFile Selected="True">DECCRC.pas</SourceFile>
<SourceFile Selected="True">DECData.pas</SourceFile>
<SourceFile Selected="True">DECDataCipher.pas</SourceFile>
<SourceFile Selected="True">DECDataHash.pas</SourceFile>
<SourceFile Selected="True">DECFormat.pas</SourceFile>
<SourceFile Selected="True">DECFormatBase.pas</SourceFile>
<SourceFile Selected="True">DECHash.pas</SourceFile>
<SourceFile Selected="True">DECHashAuthentication.pas</SourceFile>
<SourceFile Selected="True">DECHashBase.pas</SourceFile>
<SourceFile Selected="True">DECHashBitBase.pas</SourceFile>
<SourceFile Selected="True">DECHashInterface.pas</SourceFile>
<SourceFile Selected="True">DECRandom.pas</SourceFile>
<SourceFile Selected="True">DECTypes.pas</SourceFile>
<SourceFile Selected="True">DECUtil.pas</SourceFile>
<SourceFile Selected="True">DECUtilRawByteStringHelper.pas</SourceFile>
<CodePage>0</CodePage>
</SourceCodeFiles>
<OutputSettings>
<ReportOutputFormats>ofHTML</ReportOutputFormats>
<ScriptOutputPath>D:\Projekte\DECGitMaster\Unit Tests\CodeCoverage</ScriptOutputPath>
<ReportOutputPath>D:\Projekte\DECGitMaster\Unit Tests\CodeCoverage\Output</ReportOutputPath>
<DisplayEMMAExternally>False</DisplayEMMAExternally>
<DisplayXMLExternally>False</DisplayXMLExternally>
<DisplayHTMLExternally>False</DisplayHTMLExternally>
<XMLLineNumbers>False</XMLLineNumbers>
<XMLCombineLines>False</XMLCombineLines>
<XMLJacocoFormat>False</XMLJacocoFormat>
</OutputSettings>
<UnitTestFiles>
<ExecutableToAnalyze>D:\Projekte\DECGitMaster\Compiled\BIN_IDE22.0_Win32_Debug\DECDUnitTestSuite.exe</ExecutableToAnalyze>
<CommandLineParams></CommandLineParams>
<UseExeDirAsWorkingDir>False</UseExeDirAsWorkingDir>
<MapFile>D:\Projekte\DECGitMaster\Compiled\BIN_IDE22.0_Win32_Debug\DECDUnitTestSuite.map</MapFile>
<CodeCoverageExe>D:\Projekte\DelphiCodeCoverageWizardNew\Binaries\CodeCoverage.exe</CodeCoverageExe>
</UnitTestFiles>
<MiscSettings>
<UseRelativePaths>True</UseRelativePaths>
<AdditionalParams></AdditionalParams>
<AdditionalParamsIndex>0</AdditionalParamsIndex>
<LogToTextFile>True</LogToTextFile>
<LogToOutputDebugString>False</LogToOutputDebugString>
<PassThroughExitCode>False</PassThroughExitCode>
</MiscSettings>
</DCCProject>
1 change: 1 addition & 0 deletions Unit Tests/CodeCoverage/DECCodeCoverage_dcov_execute.bat
@@ -0,0 +1 @@
"..\..\..\DelphiCodeCoverageWizardNew\Binaries\CodeCoverage.exe" -e "..\..\Compiled\BIN_IDE22.0_Win32_Debug\DECDUnitTestSuite.exe" -m "..\..\Compiled\BIN_IDE22.0_Win32_Debug\DECDUnitTestSuite.map" -sd "..\..\Source\" -ife -uf "DECCodeCoverage_dcov_units.lst" -spf "DECCodeCoverage_dcov_paths.lst" -od "Output" -v -lt "Output\DECCodeCoverage_DelphiCodeCoverageDebug.log" -html
Empty file.
23 changes: 23 additions & 0 deletions Unit Tests/CodeCoverage/DECCodeCoverage_dcov_units.lst
@@ -0,0 +1,23 @@
DEC60Lazarus
DECBaseClass
DECCipherBase
DECCipherFormats
DECCipherInterface
DECCipherModes
DECCipherModesGCM
DECCiphers
DECCRC
DECData
DECDataCipher
DECDataHash
DECFormat
DECFormatBase
DECHash
DECHashAuthentication
DECHashBase
DECHashBitBase
DECHashInterface
DECRandom
DECTypes
DECUtil
DECUtilRawByteStringHelper
80 changes: 80 additions & 0 deletions Unit Tests/CodeCoverage/Output/CodeCoverage_summary.html
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Delphi CodeCoverage Coverage Report</title>
<style type="text/css">
body {max-width: max-content;margin: auto;}
table {border-spacing:0;}
table, td, th {border: 0;}
td, th {background: white; margin: 0; padding: .5em 1em}
table small { color: #777; }
p, h1, h2, h3, th {font-family: verdana,arial,sans-serif; font-size: 10pt;}
td {font-family: consolas,courier,monospace; font-size: 10pt;}
thead, th {background: #808C98; color: white; }
table th small { color: #ddd; }
th[idx] {cursor: pointer; user-select: none;}
table.o tr td:nth-child(1) {font-weight: bold;}
table.o tr td:nth-child(2) {text-align: right;}
table.o tr td {border-width: 1px;}
table.s {width: calc(min(80em, 95vw));}
table.s tr td {padding: .1em .5em; white-space: pre-wrap;}
table.s tr td:first-child {text-align: right; font-weight: bold; vertical-align: top}
table.s tr.notcovered td {background: #ddf;}
table.s tr.nocodegen td {background: #ffe;}
table.s tr.covered td {background: #cfc;}
table.s tr.covered td:first-child {color: green;}
table.s {border-width: 1px 0 1px 1px;}
table.sum td { background-position: 50%; background-repeat: no-repeat; background-size: 90% 70%; }
table.sum tr:nth-child(odd) td { background-color: #f4f4f4}
table.sum tr:hover td, tr:hover td a { filter: invert(10%) }
table.sum tr th {text-align:left; border: .5px solid #5d4e4c; height: 1em}
table.sum tr td {text-align:right;}
table.sum tr td:first-child {text-align:left;}
table.sum thead th { position: sticky; top:0; }
table.sum thead tr + tr th { position: sticky; top: calc(2.5em - 2px); }
table.sum tfoot th { position: sticky; bottom:0; }
table.sum tfoot th+th {text-align: right;}
table.sum a, table.sum a:visited {color: #5d4e4c; text-decoration: none;}
#nav {position: fixed;overflow: visible;left: min(calc(50% + 41em), calc(100% - 6em));padding: .1em .5em .1em .2em;background: white;box-shadow: 1px 1px 3px #888;}
#nav div {opacity: .3; user-select: none; pointer-events: none;}
#nav div.active {opacity: 1; cursor: pointer; pointer-events: initial;}
#nav div.active:hover {color: #00A;}
</style>
</head>
<body>
<h1>Summary Coverage Report</h1>
<p>Generated at 30.11.2022 22:06:19 by <a href="https://github.com/DelphiCodeCoverage/DelphiCodeCoverage" target="_blank" title="DelphiCodeCoverage on GitHub">DelphiCodeCoverage</a> - an open source tool for Delphi Code Coverage.</p>
<p>Aggregate statistics for all modules</p><table class="sum"><thead><tr><th rowspan=2 idx=0>Unit Name<th colspan=3 idx=3>Number of lines<th rowspan=2 idx=4>Percent(s) covered<tr><th idx=1>Covered<th idx=2>Not Covered<th idx=3>Which generated code
<tbody>
<tr><td><a href="DECBaseClass(DECBaseClass.pas).html">DECBaseClass</a><td>62<td>0<td>62<td style="background-image: linear-gradient(90deg, #9fe098 100%, transparent 100%)">100<small>.0</small>&nbsp;%
<tr><td><a href="DECCipherBase(DECCipherBase.pas).html">DECCipherBase</a><td>133<td>44<td>177<td style="background-image: linear-gradient(90deg, #9fe098 75%, transparent 75%)">75<small>.1</small>&nbsp;%
<tr><td><a href="DECCipherFormats(DECCipherFormats.pas).html">DECCipherFormats</a><td>151<td>20<td>171<td style="background-image: linear-gradient(90deg, #9fe098 88%, transparent 88%)">88<small>.3</small>&nbsp;%
<tr><td><a href="DECCipherModes(DECCipherModes.pas).html">DECCipherModes</a><td>382<td>75<td>457<td style="background-image: linear-gradient(90deg, #9fe098 83%, transparent 83%)">83<small>.6</small>&nbsp;%
<tr><td><a href="DECCipherModesGCM(DECCipherModesGCM.pas).html">DECCipherModesGCM</a><td>123<td>3<td>126<td style="background-image: linear-gradient(90deg, #9fe098 97%, transparent 97%)">97<small>.6</small>&nbsp;%
<tr><td><a href="DECCiphers(DECCiphers.pas).html">DECCiphers</a><td>3147<td>110<td>3257<td style="background-image: linear-gradient(90deg, #9fe098 96%, transparent 96%)">96<small>.6</small>&nbsp;%
<tr><td><a href="DECCRC(DECCRC.pas).html">DECCRC</a><td>150<td>5<td>155<td style="background-image: linear-gradient(90deg, #9fe098 96%, transparent 96%)">96<small>.8</small>&nbsp;%
<tr><td><a href="DECFormat(DECFormat.pas).html">DECFormat</a><td>727<td>13<td>740<td style="background-image: linear-gradient(90deg, #9fe098 98%, transparent 98%)">98<small>.2</small>&nbsp;%
<tr><td><a href="DECFormatBase(DECFormatBase.pas).html">DECFormatBase</a><td>97<td>17<td>114<td style="background-image: linear-gradient(90deg, #9fe098 85%, transparent 85%)">85<small>.1</small>&nbsp;%
<tr><td><a href="DECHash(DECHash.pas).html">DECHash</a><td>2619<td>20<td>2639<td style="background-image: linear-gradient(90deg, #9fe098 99%, transparent 99%)">99<small>.2</small>&nbsp;%
<tr><td><a href="DECHashAuthentication(DECHashAuthentication.pas).html">DECHashAuthentication</a><td>304<td>29<td>333<td style="background-image: linear-gradient(90deg, #9fe098 91%, transparent 91%)">91<small>.3</small>&nbsp;%
<tr><td><a href="DECHashBase(DECHashBase.pas).html">DECHashBase</a><td>152<td>19<td>171<td style="background-image: linear-gradient(90deg, #9fe098 88%, transparent 88%)">88<small>.9</small>&nbsp;%
<tr><td><a href="DECHashBitBase(DECHashBitBase.pas).html">DECHashBitBase</a><td>8<td>0<td>8<td style="background-image: linear-gradient(90deg, #9fe098 100%, transparent 100%)">100<small>.0</small>&nbsp;%
<tr><td><a href="DECRandom(DECRandom.pas).html">DECRandom</a><td>91<td>3<td>94<td style="background-image: linear-gradient(90deg, #9fe098 96%, transparent 96%)">96<small>.8</small>&nbsp;%
<tr><td><a href="DECTypes(DECTypes.pas).html">DECTypes</a><td>3<td>0<td>3<td style="background-image: linear-gradient(90deg, #9fe098 100%, transparent 100%)">100<small>.0</small>&nbsp;%
<tr><td><a href="DECUtil(DECUtil.pas).html">DECUtil</a><td>116<td>0<td>116<td style="background-image: linear-gradient(90deg, #9fe098 100%, transparent 100%)">100<small>.0</small>&nbsp;%
<tr><td><a href="DECUtilRawByteStringHelper(DECUtilRawByteStringHelper.pas).html">DECUtilRawByteStringHelper</a><td>34<td>4<td>38<td style="background-image: linear-gradient(90deg, #9fe098 89%, transparent 89%)">89<small>.5</small>&nbsp;%
<tfoot><tr><th>Aggregated for all units<th>8299<th>362<th>8661<th>95<small>.8</small>&nbsp;%
</table>
<script>
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>!isNaN(parseFloat(v1 || "-")) && !isNaN(parseFloat(v2 || "-")) ? parseFloat(v1)-parseFloat(v2) : v1.toString().localeCompare(v2))(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
document.querySelectorAll("thead th[idx]").forEach(th => th.addEventListener("click", (() => {
const table = th.closest("table").querySelector("tbody");
Array.from(table.querySelectorAll("tr"))
.sort(comparer(+th.getAttribute("idx"), this.asc = !this.asc))
.forEach(tr => table.appendChild(tr) );
})));
</script>
</body>
</html>

0 comments on commit 8393d4b

Please sign in to comment.