Browse Source

- add KMAC support

Ugochukwu Mmaduekwe 6 years ago
parent
commit
e9f17bb42a

+ 2 - 0
CryptoLib.Samples/Delphi.Samples/UsageSamples.dpr

@@ -379,6 +379,8 @@ uses
   ClpMultipliers in '..\..\CryptoLib\src\Math\EC\Multiplier\ClpMultipliers.pas',
   ClpIMultipliers in '..\..\CryptoLib\src\Interfaces\ClpIMultipliers.pas',
   ClpECCompUtilities in '..\..\CryptoLib\src\Math\EC\ClpECCompUtilities.pas',
+  ClpIKMac in '..\..\CryptoLib\src\Interfaces\ClpIKMac.pas',
+  ClpKMac in '..\..\CryptoLib\src\Crypto\Macs\ClpKMac.pas',
   UsageExamples in '..\src\UsageExamples.pas';
 
 begin

+ 3 - 0
CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.TestInsight.dpr

@@ -389,6 +389,8 @@ uses
   ClpMultipliers in '..\..\CryptoLib\src\Math\EC\Multiplier\ClpMultipliers.pas',
   ClpIMultipliers in '..\..\CryptoLib\src\Interfaces\ClpIMultipliers.pas',
   ClpECCompUtilities in '..\..\CryptoLib\src\Math\EC\ClpECCompUtilities.pas',
+  ClpIKMac in '..\..\CryptoLib\src\Interfaces\ClpIKMac.pas',
+  ClpKMac in '..\..\CryptoLib\src\Crypto\Macs\ClpKMac.pas',
   ClpFixedSecureRandom in '..\src\Utils\ClpFixedSecureRandom.pas',
   ClpIFixedSecureRandom in '..\src\Utils\ClpIFixedSecureRandom.pas',
   ClpIShortenedDigest in '..\src\Utils\ClpIShortenedDigest.pas',
@@ -460,6 +462,7 @@ uses
   ScryptTests in '..\src\Crypto\ScryptTests.pas',
   DHTests in '..\src\Crypto\DHTests.pas',
   Asn1IntegerTests in '..\src\Asn1\Asn1IntegerTests.pas',
+  KMacTests in '..\src\Crypto\KMacTests.pas',
   CryptoLibTestBase in '..\src\CryptoLibTestBase.pas';
 
 begin

+ 3 - 0
CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr

@@ -392,6 +392,8 @@ uses
   ClpMultipliers in '..\..\CryptoLib\src\Math\EC\Multiplier\ClpMultipliers.pas',
   ClpIMultipliers in '..\..\CryptoLib\src\Interfaces\ClpIMultipliers.pas',
   ClpECCompUtilities in '..\..\CryptoLib\src\Math\EC\ClpECCompUtilities.pas',
+  ClpIKMac in '..\..\CryptoLib\src\Interfaces\ClpIKMac.pas',
+  ClpKMac in '..\..\CryptoLib\src\Crypto\Macs\ClpKMac.pas',
   ClpFixedSecureRandom in '..\src\Utils\ClpFixedSecureRandom.pas',
   ClpIFixedSecureRandom in '..\src\Utils\ClpIFixedSecureRandom.pas',
   ClpIShortenedDigest in '..\src\Utils\ClpIShortenedDigest.pas',
@@ -463,6 +465,7 @@ uses
   ScryptTests in '..\src\Crypto\ScryptTests.pas',
   DHTests in '..\src\Crypto\DHTests.pas',
   Asn1IntegerTests in '..\src\Asn1\Asn1IntegerTests.pas',
+  KMacTests in '..\src\Crypto\KMacTests.pas',
   CryptoLibTestBase in '..\src\CryptoLibTestBase.pas';
 
 begin

+ 5 - 1
CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi

@@ -77,7 +77,7 @@
         <PackageName Value="FCL"/>
       </Item4>
     </RequiredPackages>
-    <Units Count="73">
+    <Units Count="74">
       <Unit0>
         <Filename Value="CryptoLib.lpr"/>
         <IsPartOfProject Value="True"/>
@@ -371,6 +371,10 @@
         <Filename Value="..\src\Asn1\Asn1IntegerTests.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit72>
+      <Unit73>
+        <Filename Value="..\src\Crypto\KMacTests.pas"/>
+        <IsPartOfProject Value="True"/>
+      </Unit73>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 1 - 0
CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr

@@ -73,6 +73,7 @@ uses
   DigestUtilitiesTests,
   DHTests,
   Asn1IntegerTests,
+  KMacTests,
   CryptoLibTestBase,
   ClpFixedSecureRandom,
   ClpIFixedSecureRandom,

+ 5 - 1
CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.Tests.lpi

@@ -37,7 +37,7 @@
         <PackageName Value="FCL"/>
       </Item2>
     </RequiredPackages>
-    <Units Count="73">
+    <Units Count="74">
       <Unit0>
         <Filename Value="CryptoLibConsole.lpr"/>
         <IsPartOfProject Value="True"/>
@@ -330,6 +330,10 @@
         <Filename Value="..\src\Asn1\Asn1IntegerTests.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit72>
+      <Unit73>
+        <Filename Value="..\src\Crypto\KMacTests.pas"/>
+        <IsPartOfProject Value="True"/>
+      </Unit73>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 1 - 0
CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr

@@ -71,6 +71,7 @@ uses
   DigestUtilitiesTests,
   DHTests,
   Asn1IntegerTests,
+  KMacTests,
   CryptoLibTestBase,
   ClpFixedSecureRandom,
   ClpIFixedSecureRandom,

+ 193 - 0
CryptoLib.Tests/src/Crypto/KMacTests.pas

@@ -0,0 +1,193 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit KMacTests;
+
+interface
+
+{$IFDEF FPC}
+{$MODE DELPHI}
+{$ENDIF FPC}
+
+uses
+  SysUtils,
+{$IFDEF FPC}
+  fpcunit,
+  testregistry,
+{$ELSE}
+  TestFramework,
+{$ENDIF FPC}
+  ClpKeyParameter,
+  ClpIKeyParameter,
+  ClpKMac,
+  ClpIMac,
+  ClpConverters,
+  CryptoLibTestBase;
+
+type
+
+  /// <summary>
+  /// KMAC tester
+  /// </summary>
+  TTestKMac = class(TCryptoLibAlgorithmTestCase)
+  private
+  var
+    FData, FRawKeyInHex, FCustomizationMessage, FZeroToThreeInHex: String;
+
+    procedure DoComputeKMAC128(const AKey, ACustomization, AData,
+      AExpectedResult: String; AOutputSizeInBits: UInt64);
+
+    procedure DoComputeKMAC256(const AKey, ACustomization, AData,
+      AExpectedResult: String; AOutputSizeInBits: UInt64);
+
+  protected
+    procedure SetUp; override;
+    procedure TearDown; override;
+  published
+
+    procedure TestKMac;
+
+  end;
+
+implementation
+
+{ TTestKMac }
+
+procedure TTestKMac.SetUp;
+var
+  LIdx: Int32;
+  LTemp: TBytes;
+begin
+  inherited;
+  System.SetLength(LTemp, 200);
+  for LIdx := 0 to 199 do
+  begin
+    LTemp[LIdx] := LIdx;
+  end;
+
+  FData := TConverters.ConvertBytesToHexString(LTemp, False);
+  FRawKeyInHex :=
+    '404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F';
+  FCustomizationMessage := 'My Tagged Application';
+  FZeroToThreeInHex := '00010203';
+end;
+
+procedure TTestKMac.TearDown;
+begin
+  inherited;
+
+end;
+
+procedure TTestKMac.DoComputeKMAC128(const AKey, ACustomization, AData,
+  AExpectedResult: String; AOutputSizeInBits: UInt64);
+var
+  LMac: IMac;
+  LIdx: Int32;
+  LActualResult, LKey, LCustomization, LData: TBytes;
+begin
+  LKey := TConverters.ConvertHexStringToBytes(AKey);
+  LCustomization := TConverters.ConvertStringToBytes(ACustomization,
+    TEncoding.UTF8);
+  LData := TConverters.ConvertHexStringToBytes(AData);
+
+  LMac := TKMAC128.Create(LCustomization, AOutputSizeInBits);
+
+  LMac.Init(TKeyParameter.Create(LKey) as IKeyParameter);
+
+  for LIdx := System.Low(LData) to System.High(LData) do
+  begin
+    // do incremental hashing
+    LMac.BlockUpdate(TBytes.Create(LData[LIdx]), 0, 1);
+  end;
+
+  System.SetLength(LActualResult, LMac.GetMacSize());
+  LMac.DoFinal(LActualResult, 0);
+
+  CheckEquals(AExpectedResult, TConverters.ConvertBytesToHexString
+    (LActualResult, False), Format('Expected %s But got %s',
+    [AExpectedResult, TConverters.ConvertBytesToHexString(LActualResult,
+    False)]));
+
+end;
+
+procedure TTestKMac.DoComputeKMAC256(const AKey, ACustomization, AData,
+  AExpectedResult: String; AOutputSizeInBits: UInt64);
+var
+  LMac: IMac;
+  LIdx: Int32;
+  LActualResult, LKey, LCustomization, LData: TBytes;
+begin
+  LKey := TConverters.ConvertHexStringToBytes(AKey);
+  LCustomization := TConverters.ConvertStringToBytes(ACustomization,
+    TEncoding.UTF8);
+  LData := TConverters.ConvertHexStringToBytes(AData);
+
+  LMac := TKMAC256.Create(LCustomization, AOutputSizeInBits);
+
+  LMac.Init(TKeyParameter.Create(LKey) as IKeyParameter);
+
+  for LIdx := System.Low(LData) to System.High(LData) do
+  begin
+    // do incremental hashing
+    LMac.BlockUpdate(TBytes.Create(LData[LIdx]), 0, 1);
+  end;
+
+  System.SetLength(LActualResult, LMac.GetMacSize());
+  LMac.DoFinal(LActualResult, 0);
+
+  CheckEquals(AExpectedResult, TConverters.ConvertBytesToHexString
+    (LActualResult, False), Format('Expected %s But got %s',
+    [AExpectedResult, TConverters.ConvertBytesToHexString(LActualResult,
+    False)]));
+
+end;
+
+procedure TTestKMac.TestKMac;
+begin
+  DoComputeKMAC128(FRawKeyInHex, '', FZeroToThreeInHex,
+    'E5780B0D3EA6F7D3A429C5706AA43A00FADBD7D49628839E3187243F456EE14E', 32 * 8);
+
+  DoComputeKMAC128(FRawKeyInHex, FCustomizationMessage, FZeroToThreeInHex,
+    '3B1FBA963CD8B0B59E8C1A6D71888B7143651AF8BA0A7070C0979E2811324AA5', 32 * 8);
+
+  DoComputeKMAC128(FRawKeyInHex, FCustomizationMessage, FData,
+    '1F5B4E6CCA02209E0DCB5CA635B89A15E271ECC760071DFD805FAA38F9729230', 32 * 8);
+
+  DoComputeKMAC256(FRawKeyInHex, FCustomizationMessage, FZeroToThreeInHex,
+    '20C570C31346F703C9AC36C61C03CB64C3970D0CFC787E9B79599D273A68D2F7F69D4CC3DE9D104A351689F27CF6F5951F0103F33F4F24871024D9C27773A8DD',
+    64 * 8);
+
+  DoComputeKMAC256(FRawKeyInHex, '', FData,
+    '75358CF39E41494E949707927CEE0AF20A3FF553904C86B08F21CC414BCFD691589D27CF5E15369CBBFF8B9A4C2EB17800855D0235FF635DA82533EC6B759B69',
+    64 * 8);
+
+  DoComputeKMAC256(FRawKeyInHex, FCustomizationMessage, FData,
+    'B58618F71F92E1D56C1B8C55DDD7CD188B97B4CA4D99831EB2699A837DA2E4D970FBACFDE50033AEA585F1A2708510C32D07880801BD182898FE476876FC8965',
+    64 * 8);
+end;
+
+initialization
+
+// Register any test cases with the test runner
+
+{$IFDEF FPC}
+  RegisterTest(TTestKMac);
+{$ELSE}
+  RegisterTest(TTestKMac.Suite);
+{$ENDIF FPC}
+
+end.

+ 200 - 0
CryptoLib/src/Crypto/Macs/ClpKMac.pas

@@ -0,0 +1,200 @@
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpKMac;
+
+{$I ..\..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  HlpIHashInfo,
+  HlpHashFactory,
+  ClpIMac,
+  ClpIKMac,
+  ClpIKeyParameter,
+  ClpICipherParameters,
+  ClpCryptoLibTypes;
+
+resourcestring
+  SOutputBufferTooShort = 'Output Buffer Too Short';
+
+type
+
+  /// <summary>
+  /// <para>
+  /// KMAC implementation based on FIPS 202
+  /// </para>
+  /// <para>
+  /// Note: This is Just a Wrapper for <b>KMAC</b> Implementation in
+  /// HashLib4Pascal
+  /// </para>
+  /// </summary>
+  TKMac = class(TInterfacedObject, IKMac, IMac)
+
+  strict protected
+  var
+    FKMAC: HlpIHashInfo.IKMac;
+    FOutputLengthInBits: UInt64;
+
+    function GetAlgorithmName: string; inline;
+
+  public
+
+    destructor Destroy(); override;
+
+    procedure Clear();
+
+    function GetMacSize: Int32; inline;
+
+    procedure Update(input: Byte);
+    procedure BlockUpdate(const input: TCryptoLibByteArray; inOff, len: Int32);
+    procedure Init(const parameters: ICipherParameters);
+    function DoFinal(const output: TCryptoLibByteArray; outOff: Int32)
+      : Int32; overload;
+    function DoFinal: TCryptoLibByteArray; overload;
+
+    /// <summary>
+    /// Reset the mac generator.
+    /// </summary>
+    procedure Reset();
+
+    property AlgorithmName: String read GetAlgorithmName;
+
+  end;
+
+type
+  TKMac128 = class(TKMac, IKMac, IMac)
+
+  public
+    constructor Create(const ACustomization: TCryptoLibByteArray;
+      AOutputLengthInBits: UInt64);
+
+  end;
+
+type
+  TKMac256 = class(TKMac, IKMac, IMac)
+
+  public
+    constructor Create(const ACustomization: TCryptoLibByteArray;
+      AOutputLengthInBits: UInt64);
+
+  end;
+
+implementation
+
+{ TKMac }
+
+function TKMac.GetMacSize: Int32;
+begin
+  result := FOutputLengthInBits shr 3;
+end;
+
+procedure TKMac.BlockUpdate(const input: TCryptoLibByteArray;
+  inOff, len: Int32);
+begin
+  FKMAC.TransformBytes(input, inOff, len);
+end;
+
+procedure TKMac.Clear();
+begin
+  FKMAC.Clear();
+end;
+
+destructor TKMac.Destroy;
+begin
+  Clear();
+  inherited Destroy;
+end;
+
+function TKMac.DoFinal(const output: TCryptoLibByteArray; outOff: Int32): Int32;
+var
+  buf: TCryptoLibByteArray;
+begin
+
+  if (System.Length(output) - outOff) < GetMacSize then
+  begin
+    raise EDataLengthCryptoLibException.CreateRes(@SOutputBufferTooShort);
+  end
+  else
+  begin
+    buf := DoFinal();
+    System.Move(buf[0], output[outOff], System.Length(buf) *
+      System.SizeOf(Byte));
+  end;
+  result := System.Length(buf);
+end;
+
+function TKMac.DoFinal: TCryptoLibByteArray;
+begin
+  result := FKMAC.TransformFinal.GetBytes();
+end;
+
+function TKMac.GetAlgorithmName: string;
+var
+  LName: String;
+  LowPoint, HighPoint: Int32;
+begin
+  LName := Self.ClassName;
+{$IFDEF DELPHIXE3_UP}
+  LowPoint := System.Low(LName);
+  HighPoint := System.High(LName);
+{$ELSE}
+  LowPoint := 1;
+  HighPoint := System.Length(LName);
+{$ENDIF DELPHIXE3_UP}
+  result := Copy(LName, LowPoint + 1, HighPoint - 1);
+end;
+
+procedure TKMac.Init(const parameters: ICipherParameters);
+begin
+  FKMAC.Key := (parameters as IKeyParameter).GetKey();
+  FKMAC.Initialize;
+end;
+
+procedure TKMac.Reset;
+begin
+  FKMAC.Initialize;
+end;
+
+procedure TKMac.Update(input: Byte);
+begin
+  FKMAC.TransformUntyped(input, System.SizeOf(Byte));
+end;
+
+{ TKMac128 }
+
+constructor TKMac128.Create(const ACustomization: TCryptoLibByteArray;
+  AOutputLengthInBits: UInt64);
+begin
+  Inherited Create();
+  FOutputLengthInBits := AOutputLengthInBits;
+  FKMAC := THashFactory.TKMac.CreateKMAC128(Nil, ACustomization,
+    FOutputLengthInBits);
+end;
+
+{ TKMac256 }
+
+constructor TKMac256.Create(const ACustomization: TCryptoLibByteArray;
+  AOutputLengthInBits: UInt64);
+begin
+  Inherited Create();
+  FOutputLengthInBits := AOutputLengthInBits;
+  FKMAC := THashFactory.TKMac.CreateKMAC256(Nil, ACustomization,
+    FOutputLengthInBits);
+end;
+
+end.

+ 2 - 4
CryptoLib/src/Crypto/Parameters/ClpECKeyParameters.pas

@@ -25,15 +25,13 @@ uses
 
   SysUtils,
   ClpECGost3410NamedCurves,
-  ClpCryptoLibTypes,
-  ClpECDomainParameters,
   ClpIECKeyParameters,
-  ClpIX9ECParameters,
   ClpIECDomainParameters,
   ClpIECKeyGenerationParameters,
   ClpAsymmetricKeyParameter,
   ClpECKeyGenerationParameters,
-  ClpISecureRandom;
+  ClpISecureRandom,
+  ClpCryptoLibTypes;
 
 resourcestring
   SAlgorithmNil = 'Algorithm Cannot be Empty';

+ 3 - 0
CryptoLib/src/Interfaces/ClpIHMac.pas

@@ -22,6 +22,7 @@ unit ClpIHMac;
 interface
 
 uses
+  ClpIDigest,
   ClpIMac;
 
 type
@@ -29,6 +30,8 @@ type
   IHMac = interface(IMac)
     ['{B1182608-04D5-4985-91C8-571C51E07CB5}']
 
+    function GetUnderlyingDigest: IDigest;
+
   end;
 
 implementation

+ 36 - 0
CryptoLib/src/Interfaces/ClpIKMac.pas

@@ -0,0 +1,36 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpIKMac;
+
+{$I ..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpIMac;
+
+type
+
+  IKMac = interface(IMac)
+    ['{8C0D16C4-80DD-4E8A-8D1D-958AD7C442DD}']
+
+  end;
+
+implementation
+
+end.

+ 0 - 3
CryptoLib/src/Interfaces/ClpIMac.pas

@@ -22,7 +22,6 @@ unit ClpIMac;
 interface
 
 uses
-  ClpIDigest,
   ClpICipherParameters,
   ClpCryptoLibTypes;
 
@@ -42,8 +41,6 @@ type
     /// </summary>
     function GetAlgorithmName: string;
 
-    function GetUnderlyingDigest: IDigest;
-
     /// <summary>
     /// the block size for this MAC (in bytes).
     /// </summary>

+ 1 - 2
CryptoLib/src/Interfaces/ClpIScalarSplitParameters.pas

@@ -22,8 +22,7 @@ unit ClpIScalarSplitParameters;
 interface
 
 uses
-  ClpBigInteger,
-  ClpIGlvEndomorphism;
+  ClpBigInteger;
 
 type
   IScalarSplitParameters = interface(IInterface)

+ 73 - 73
CryptoLib/src/Math/EC/ClpECCompUtilities.pas

@@ -63,23 +63,23 @@ type
 
     end;
 
-  type
-    TMapPointCallback = class(TInterfacedObject, IPreCompCallback,
-      IMapPointCallback)
-
-    strict private
-    var
-      Fm_wnafPreCompP: IWNafPreCompInfo;
-      Fm_includeNegated: Boolean;
-      Fm_pointMap: IECPointMap;
-
-    public
-      constructor Create(const wnafPreCompP: IWNafPreCompInfo;
-        includeNegated: Boolean; const pointMap: IECPointMap);
-
-      function Precompute(const existing: IPreCompInfo): IPreCompInfo;
-
-    end;
+    // type
+    // TMapPointCallback = class(TInterfacedObject, IPreCompCallback,
+    // IMapPointCallback)
+    //
+    // strict private
+    // var
+    // Fm_wnafPreCompP: IWNafPreCompInfo;
+    // Fm_includeNegated: Boolean;
+    // Fm_pointMap: IECPointMap;
+    //
+    // public
+    // constructor Create(const wnafPreCompP: IWNafPreCompInfo;
+    // includeNegated: Boolean; const pointMap: IECPointMap);
+    //
+    // function Precompute(const existing: IPreCompInfo): IPreCompInfo;
+    //
+    // end;
 
   type
     IWNafCallback = interface(IPreCompCallback)
@@ -886,62 +886,62 @@ begin
     fromWNaf, includeNegated) as IPointMapCallback) as IWNafPreCompInfo;
 end;
 
-{ TWNafUtilities.TMapPointCallback }
-
-constructor TWNafUtilities.TMapPointCallback.Create(const wnafPreCompP
-  : IWNafPreCompInfo; includeNegated: Boolean; const pointMap: IECPointMap);
-begin
-  Inherited Create();
-  Fm_wnafPreCompP := wnafPreCompP;
-  Fm_includeNegated := includeNegated;
-  Fm_pointMap := pointMap;
-end;
-
-function TWNafUtilities.TMapPointCallback.Precompute(const existing
-  : IPreCompInfo): IPreCompInfo;
-var
-  tempResult: IWNafPreCompInfo;
-  twiceP, twiceQ: IECPoint;
-  preCompP, preCompQ, preCompNegQ: TCryptoLibGenericArray<IECPoint>;
-  i: Int32;
-begin
-  tempResult := TWNafPreCompInfo.Create();
-
-  tempResult.ConfWidth := Fm_wnafPreCompP.ConfWidth;
-
-  twiceP := Fm_wnafPreCompP.Twice;
-  if (twiceP <> Nil) then
-  begin
-    twiceQ := Fm_pointMap.Map(twiceP);
-    tempResult.Twice := twiceQ;
-  end;
-
-  preCompP := Fm_wnafPreCompP.PreComp;
-
-  System.SetLength(preCompQ, System.length(preCompP));
-  for i := 0 to System.Pred(System.length(preCompP)) do
-  begin
-    preCompQ[i] := Fm_pointMap.Map(preCompP[i]);
-  end;
-
-  tempResult.PreComp := preCompQ;
-  tempResult.width := Fm_wnafPreCompP.width;
-
-  if (Fm_includeNegated) then
-  begin
-
-    System.SetLength(preCompNegQ, System.length(preCompQ));
-
-    for i := 0 to System.Pred(System.length(preCompNegQ)) do
-    begin
-      preCompNegQ[i] := preCompQ[i].Negate();
-    end;
-
-    tempResult.PreCompNeg := preCompNegQ;
-  end;
-
-  result := tempResult;
-end;
+// { TWNafUtilities.TMapPointCallback }
+//
+// constructor TWNafUtilities.TMapPointCallback.Create(const wnafPreCompP
+// : IWNafPreCompInfo; includeNegated: Boolean; const pointMap: IECPointMap);
+// begin
+// Inherited Create();
+// Fm_wnafPreCompP := wnafPreCompP;
+// Fm_includeNegated := includeNegated;
+// Fm_pointMap := pointMap;
+// end;
+//
+// function TWNafUtilities.TMapPointCallback.Precompute(const existing
+// : IPreCompInfo): IPreCompInfo;
+// var
+// tempResult: IWNafPreCompInfo;
+// twiceP, twiceQ: IECPoint;
+// preCompP, preCompQ, preCompNegQ: TCryptoLibGenericArray<IECPoint>;
+// i: Int32;
+// begin
+// tempResult := TWNafPreCompInfo.Create();
+//
+// tempResult.ConfWidth := Fm_wnafPreCompP.ConfWidth;
+//
+// twiceP := Fm_wnafPreCompP.Twice;
+// if (twiceP <> Nil) then
+// begin
+// twiceQ := Fm_pointMap.Map(twiceP);
+// tempResult.Twice := twiceQ;
+// end;
+//
+// preCompP := Fm_wnafPreCompP.PreComp;
+//
+// System.SetLength(preCompQ, System.length(preCompP));
+// for i := 0 to System.Pred(System.length(preCompP)) do
+// begin
+// preCompQ[i] := Fm_pointMap.Map(preCompP[i]);
+// end;
+//
+// tempResult.PreComp := preCompQ;
+// tempResult.width := Fm_wnafPreCompP.width;
+//
+// if (Fm_includeNegated) then
+// begin
+//
+// System.SetLength(preCompNegQ, System.length(preCompQ));
+//
+// for i := 0 to System.Pred(System.length(preCompNegQ)) do
+// begin
+// preCompNegQ[i] := preCompQ[i].Negate();
+// end;
+//
+// tempResult.PreCompNeg := preCompNegQ;
+// end;
+//
+// result := tempResult;
+// end;
 
 { TWNafUtilities.TWNafCallback }
 

+ 2 - 0
README.md

@@ -113,6 +113,8 @@ Available Algorithms
 
 * `HMAC (all supported hashes)`
 
+* `KMAC (KMAC128, KMAC256)`
+
 ### Hashes
 ----------------------------------------