Sfoglia il codice sorgente

rename ClpBigIntegers to ClpBigIntegerUtilities

Ugochukwu Mmaduekwe 14 ore fa
parent
commit
fb7d14384a
28 ha cambiato i file con 93 aggiunte e 93 eliminazioni
  1. 1 1
      CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr
  2. 2 2
      CryptoLib.Tests/src/Math/ECNRTests.pas
  3. 2 2
      CryptoLib.Tests/src/Math/ECPointTests.pas
  4. 2 2
      CryptoLib.Tests/src/Math/PrimesTests.pas
  5. 6 6
      CryptoLib.Tests/src/Others/ECTests.pas
  6. 2 2
      CryptoLib/src/Asn1/ClpAsn1Objects.pas
  7. 2 2
      CryptoLib/src/Asn1/Sec/ClpSecECAsn1Objects.pas
  8. 2 2
      CryptoLib/src/Crypto/Engines/ClpIesEngine.pas
  9. 2 2
      CryptoLib/src/Crypto/Engines/ClpPascalCoinIesEngine.pas
  10. 3 3
      CryptoLib/src/Crypto/Engines/ClpRsaBlindedEngine.pas
  11. 2 2
      CryptoLib/src/Crypto/Engines/ClpRsaBlindingEngine.pas
  12. 3 3
      CryptoLib/src/Crypto/Engines/ClpRsaCoreEngine.pas
  13. 2 2
      CryptoLib/src/Crypto/Generators/ClpDHKeyGeneratorHelper.pas
  14. 2 2
      CryptoLib/src/Crypto/Generators/ClpDHParametersHelper.pas
  15. 3 3
      CryptoLib/src/Crypto/Generators/ClpDsaGenerators.pas
  16. 3 3
      CryptoLib/src/Crypto/Generators/ClpRsaGenerators.pas
  17. 2 2
      CryptoLib/src/Crypto/Parameters/ClpRsaParameters.pas
  18. 2 2
      CryptoLib/src/Crypto/Signers/ClpECNRSigner.pas
  19. 5 5
      CryptoLib/src/Crypto/Signers/ClpX931Signer.pas
  20. 5 5
      CryptoLib/src/Crypto/Signers/SignerCalculators/ClpHMacDsaKCalculator.pas
  21. 4 4
      CryptoLib/src/Crypto/Signers/SignerEncodings/ClpPlainDsaEncoding.pas
  22. 18 18
      CryptoLib/src/Math/ClpBigIntegerUtilities.pas
  23. 3 3
      CryptoLib/src/Math/ClpPrimes.pas
  24. 6 6
      CryptoLib/src/Math/EC/ClpECCurve.pas
  25. 4 4
      CryptoLib/src/Math/EC/ClpECFieldElement.pas
  26. 2 2
      CryptoLib/src/Math/EC/ClpLongArray.pas
  27. 2 2
      CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk
  28. 1 1
      CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas

+ 1 - 1
CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr

@@ -45,7 +45,7 @@ uses
   ClpAsymmetricKeyParameter in '..\..\CryptoLib\src\Crypto\Parameters\ClpAsymmetricKeyParameter.pas',
   ClpAsymmetricKeyParameter in '..\..\CryptoLib\src\Crypto\Parameters\ClpAsymmetricKeyParameter.pas',
   ClpBaseKdfBytesGenerator in '..\..\CryptoLib\src\Crypto\Generators\ClpBaseKdfBytesGenerator.pas',
   ClpBaseKdfBytesGenerator in '..\..\CryptoLib\src\Crypto\Generators\ClpBaseKdfBytesGenerator.pas',
   ClpBigInteger in '..\..\CryptoLib\src\Math\ClpBigInteger.pas',
   ClpBigInteger in '..\..\CryptoLib\src\Math\ClpBigInteger.pas',
-  ClpBigIntegers in '..\..\CryptoLib\src\Math\ClpBigIntegers.pas',
+  ClpBigIntegerUtilities in '..\..\CryptoLib\src\Math\ClpBigIntegerUtilities.pas',
   ClpPrimes in '..\..\CryptoLib\src\Math\ClpPrimes.pas',
   ClpPrimes in '..\..\CryptoLib\src\Math\ClpPrimes.pas',
   ClpBitConverter in '..\..\CryptoLib\src\Misc\ClpBitConverter.pas',
   ClpBitConverter in '..\..\CryptoLib\src\Misc\ClpBitConverter.pas',
   ClpCbcBlockCipher in '..\..\CryptoLib\src\Crypto\Ciphers\ClpCbcBlockCipher.pas',
   ClpCbcBlockCipher in '..\..\CryptoLib\src\Crypto\Ciphers\ClpCbcBlockCipher.pas',

+ 2 - 2
CryptoLib.Tests/src/Math/ECNRTests.pas

@@ -54,7 +54,7 @@ uses
   ClpFixedSecureRandom,
   ClpFixedSecureRandom,
   ClpSignerUtilities,
   ClpSignerUtilities,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpConverters,
   ClpConverters,
   ClpCryptoLibTypes,
   ClpCryptoLibTypes,
   ClpDigestUtilities,
   ClpDigestUtilities,
@@ -530,7 +530,7 @@ begin
   order := (myPair.Public as IECPublicKeyParameters).parameters.n;
   order := (myPair.Public as IECPublicKeyParameters).parameters.n;
 
 
   signer.Init(true, myPair.Private);
   signer.Init(true, myPair.Private);
-  msg := TBigIntegers.AsUnsignedByteArray(order.Subtract(TBigInteger.One));
+  msg := TBigIntegerUtilities.AsUnsignedByteArray(order.Subtract(TBigInteger.One));
   sig := signer.GenerateSignature(msg);
   sig := signer.GenerateSignature(msg);
 
 
   signer.Init(false, myPair.getPublic());
   signer.Init(false, myPair.getPublic());

+ 2 - 2
CryptoLib.Tests/src/Math/ECPointTests.pas

@@ -40,7 +40,7 @@ uses
   ClpSecureRandom,
   ClpSecureRandom,
   ClpISecureRandom,
   ClpISecureRandom,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpECAlgorithms,
   ClpECAlgorithms,
   ClpWNafUtilities,
   ClpWNafUtilities,
   ClpIFiniteField,
   ClpIFiniteField,
@@ -408,7 +408,7 @@ begin
     count := 0;
     count := 0;
     while (count < 10) do
     while (count < 10) do
     begin
     begin
-      nonSquare := TBigIntegers.CreateRandomInRange(TBigInteger.Two,
+      nonSquare := TBigIntegerUtilities.CreateRandomInRange(TBigInteger.Two,
         pMinusOne, FRandom);
         pMinusOne, FRandom);
       if (not nonSquare.ModPow(legendreExponent, p).Equals(TBigInteger.One))
       if (not nonSquare.ModPow(legendreExponent, p).Equals(TBigInteger.One))
       then
       then

+ 2 - 2
CryptoLib.Tests/src/Math/PrimesTests.pas

@@ -33,7 +33,7 @@ uses
 {$ENDIF FPC}
 {$ENDIF FPC}
   ClpPrimes,
   ClpPrimes,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpSecureRandom,
   ClpSecureRandom,
   ClpISecureRandom,
   ClpISecureRandom,
   ClpDigestUtilities,
   ClpDigestUtilities,
@@ -102,7 +102,7 @@ begin
 
 
   for LI := 0 to ANumBases - 1 do
   for LI := 0 to ANumBases - 1 do
   begin
   begin
-    LB := TBigIntegers.CreateRandomInRange(TBigInteger.Two, LXSubTwo, FRandom);
+    LB := TBigIntegerUtilities.CreateRandomInRange(TBigInteger.Two, LXSubTwo, FRandom);
     if not TPrimes.IsMRProbablePrimeToBase(AX, LB) then
     if not TPrimes.IsMRProbablePrimeToBase(AX, LB) then
       Exit(False);
       Exit(False);
   end;
   end;

+ 6 - 6
CryptoLib.Tests/src/Others/ECTests.pas

@@ -52,7 +52,7 @@ uses
   ClpIECCommon,
   ClpIECCommon,
   ClpIECFieldElement,
   ClpIECFieldElement,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpCryptoLibTypes,
   ClpCryptoLibTypes,
   CryptoLibTestBase;
   CryptoLibTestBase;
 
 
@@ -193,7 +193,7 @@ begin
   s := TBigInteger.Create
   s := TBigInteger.Create
     ('308992691965804947361541664549085895292153777025772063598');
     ('308992691965804947361541664549085895292153777025772063598');
 
 
-  kData := TBigIntegers.AsUnsignedByteArray
+  kData := TBigIntegerUtilities.AsUnsignedByteArray
     (TBigInteger.Create
     (TBigInteger.Create
     ('1542725565216523985789236956265265265235675811949404040041'));
     ('1542725565216523985789236956265265265235675811949404040041'));
 
 
@@ -277,7 +277,7 @@ begin
   s := TBigInteger.Create
   s := TBigInteger.Create
     ('5735822328888155254683894997897571951568553642892029982342');
     ('5735822328888155254683894997897571951568553642892029982342');
 
 
-  kData := TBigIntegers.AsUnsignedByteArray
+  kData := TBigIntegerUtilities.AsUnsignedByteArray
     (TBigInteger.Create
     (TBigInteger.Create
     ('6140507067065001063065065565667405560006161556565665656654'));
     ('6140507067065001063065065565667405560006161556565665656654'));
 
 
@@ -361,7 +361,7 @@ begin
   s := TBigInteger.Create
   s := TBigInteger.Create
     ('197030374000731686738334997654997227052849804072198819102649413465737174');
     ('197030374000731686738334997654997227052849804072198819102649413465737174');
 
 
-  kData := TBigIntegers.AsUnsignedByteArray
+  kData := TBigIntegerUtilities.AsUnsignedByteArray
     (TBigInteger.Create
     (TBigInteger.Create
     ('171278725565216523967285789236956265265265235675811949404040041670216363')
     ('171278725565216523967285789236956265265265235675811949404040041670216363')
     );
     );
@@ -446,7 +446,7 @@ begin
   s := TBigInteger.Create
   s := TBigInteger.Create
     ('144940322424411242416373536877786566515839911620497068645600824084578597');
     ('144940322424411242416373536877786566515839911620497068645600824084578597');
 
 
-  kData := TBigIntegers.AsUnsignedByteArray
+  kData := TBigIntegerUtilities.AsUnsignedByteArray
     (TBigInteger.Create
     (TBigInteger.Create
     ('171278725565216523967285789236956265265265235675811949404040041670216363')
     ('171278725565216523967285789236956265265265235675811949404040041670216363')
     );
     );
@@ -532,7 +532,7 @@ begin
   s := TBigInteger.Create
   s := TBigInteger.Create
     ('323813553209797357708078776831250505931891051755007842781978505179448783');
     ('323813553209797357708078776831250505931891051755007842781978505179448783');
 
 
-  kData := TBigIntegers.AsUnsignedByteArray
+  kData := TBigIntegerUtilities.AsUnsignedByteArray
     (TBigInteger.Create
     (TBigInteger.Create
     ('700000017569056646655505781757157107570501575775705779575555657156756655')
     ('700000017569056646655505781757157107570501575775705779575555657156756655')
     );
     );

+ 2 - 2
CryptoLib/src/Asn1/ClpAsn1Objects.pas

@@ -29,7 +29,7 @@ uses
   ClpBitOperations,
   ClpBitOperations,
   ClpCryptoLibTypes,
   ClpCryptoLibTypes,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpAsn1Tags,
   ClpAsn1Tags,
   ClpIAsn1Objects,
   ClpIAsn1Objects,
   ClpIAsn1Encodings,
   ClpIAsn1Encodings,
@@ -12182,7 +12182,7 @@ class function TDerInteger.GetEncodingLength(const AX: TBigInteger): Int32;
 var
 var
   LByteLength: Int32;
   LByteLength: Int32;
 begin
 begin
-  LByteLength := TBigIntegers.GetByteLength(AX);
+  LByteLength := TBigIntegerUtilities.GetByteLength(AX);
   Result := TAsn1OutputStream.GetLengthOfEncodingDL(TAsn1Tags.Integer, LByteLength);
   Result := TAsn1OutputStream.GetLengthOfEncodingDL(TAsn1Tags.Integer, LByteLength);
 end;
 end;
 
 

+ 2 - 2
CryptoLib/src/Asn1/Sec/ClpSecECAsn1Objects.pas

@@ -24,7 +24,7 @@ interface
 uses
 uses
   SysUtils,
   SysUtils,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpAsn1Objects,
   ClpAsn1Objects,
   ClpIAsn1Objects,
   ClpIAsn1Objects,
   ClpAsn1Core,
   ClpAsn1Core,
@@ -193,7 +193,7 @@ begin
   if AOrderBitLength < AKey.BitLength then
   if AOrderBitLength < AKey.BitLength then
     raise EArgumentCryptoLibException.Create(SOrderBitLengthTooSmall);
     raise EArgumentCryptoLibException.Create(SOrderBitLengthTooSmall);
 
 
-  LPrivateKeyContents := TBigIntegers.AsUnsignedByteArray((AOrderBitLength + 7) div 8, AKey);
+  LPrivateKeyContents := TBigIntegerUtilities.AsUnsignedByteArray((AOrderBitLength + 7) div 8, AKey);
 
 
   FVersion := TDerInteger.One;
   FVersion := TDerInteger.One;
   FPrivateKey := TDerOctetString.Create(LPrivateKeyContents);
   FPrivateKey := TDerOctetString.Create(LPrivateKeyContents);

+ 2 - 2
CryptoLib/src/Crypto/Engines/ClpIesEngine.pas

@@ -44,7 +44,7 @@ uses
   ClpPack,
   ClpPack,
   ClpArrayUtilities,
   ClpArrayUtilities,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpCryptoLibTypes;
   ClpCryptoLibTypes;
 
 
 resourcestring
 resourcestring
@@ -610,7 +610,7 @@ begin
   // Compute the common value and convert to byte array.
   // Compute the common value and convert to byte array.
   FAgree.Init(FPrivParam);
   FAgree.Init(FPrivParam);
   LZ := FAgree.CalculateAgreement(FPubParam);
   LZ := FAgree.CalculateAgreement(FPubParam);
-  BigZ := TBigIntegers.AsUnsignedByteArray(FAgree.GetFieldSize, LZ);
+  BigZ := TBigIntegerUtilities.AsUnsignedByteArray(FAgree.GetFieldSize, LZ);
 
 
   // Create input to KDF.
   // Create input to KDF.
   if (System.Length(FV) <> 0) then
   if (System.Length(FV) <> 0) then

+ 2 - 2
CryptoLib/src/Crypto/Engines/ClpPascalCoinIesEngine.pas

@@ -37,7 +37,7 @@ uses
   ClpIESEngine,
   ClpIESEngine,
   ClpArrayUtilities,
   ClpArrayUtilities,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpCryptoLibTypes;
   ClpCryptoLibTypes;
 
 
 resourcestring
 resourcestring
@@ -293,7 +293,7 @@ begin
   // Compute the common value and convert to byte array.
   // Compute the common value and convert to byte array.
   FAgree.Init(FPrivParam);
   FAgree.Init(FPrivParam);
   LZ := FAgree.CalculateAgreement(FPubParam);
   LZ := FAgree.CalculateAgreement(FPubParam);
-  LBigZ := TBigIntegers.AsUnsignedByteArray(FAgree.GetFieldSize, LZ);
+  LBigZ := TBigIntegerUtilities.AsUnsignedByteArray(FAgree.GetFieldSize, LZ);
 
 
   try
   try
     // Initialise the KDF.
     // Initialise the KDF.

+ 3 - 3
CryptoLib/src/Crypto/Engines/ClpRsaBlindedEngine.pas

@@ -24,7 +24,7 @@ interface
 uses
 uses
   SysUtils,
   SysUtils,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpICipherParameters,
   ClpICipherParameters,
   ClpIRsaParameters,
   ClpIRsaParameters,
   ClpIRsa,
   ClpIRsa,
@@ -155,12 +155,12 @@ begin
     m := crtKey.Modulus;
     m := crtKey.Modulus;
 
 
     // Generate random r in range [1, m-1]
     // Generate random r in range [1, m-1]
-    r := TBigIntegers.CreateRandomInRange(TBigInteger.One, m.Subtract(TBigInteger.One), FRandom);
+    r := TBigIntegerUtilities.CreateRandomInRange(TBigInteger.One, m.Subtract(TBigInteger.One), FRandom);
 
 
     // blind = r^e mod m
     // blind = r^e mod m
     blind := r.ModPow(e, m);
     blind := r.ModPow(e, m);
     // unblind = r^(-1) mod m
     // unblind = r^(-1) mod m
-    unblind := TBigIntegers.ModOddInverse(m, r);
+    unblind := TBigIntegerUtilities.ModOddInverse(m, r);
 
 
     // Blind the input: blindedInput = blind * input mod m
     // Blind the input: blindedInput = blind * input mod m
     blindedInput := blind.Multiply(input).&Mod(m);
     blindedInput := blind.Multiply(input).&Mod(m);

+ 2 - 2
CryptoLib/src/Crypto/Engines/ClpRsaBlindingEngine.pas

@@ -24,7 +24,7 @@ interface
 uses
 uses
   SysUtils,
   SysUtils,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpICipherParameters,
   ClpICipherParameters,
   ClpIParametersWithRandom,
   ClpIParametersWithRandom,
   ClpIRsaParameters,
   ClpIRsaParameters,
@@ -149,7 +149,7 @@ var
   m, blindFactorInverse, res: TBigInteger;
   m, blindFactorInverse, res: TBigInteger;
 begin
 begin
   m := FKey.Modulus;
   m := FKey.Modulus;
-  blindFactorInverse := TBigIntegers.ModOddInverse(m, FBlindingFactor);
+  blindFactorInverse := TBigIntegerUtilities.ModOddInverse(m, FBlindingFactor);
   res := blindedMsg.Multiply(blindFactorInverse);
   res := blindedMsg.Multiply(blindFactorInverse);
   Result := res.&Mod(m);
   Result := res.&Mod(m);
 end;
 end;

+ 3 - 3
CryptoLib/src/Crypto/Engines/ClpRsaCoreEngine.pas

@@ -24,7 +24,7 @@ interface
 uses
 uses
   SysUtils,
   SysUtils,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpICipherParameters,
   ClpICipherParameters,
   ClpParameterUtilities,
   ClpParameterUtilities,
   ClpIRsaParameters,
   ClpIRsaParameters,
@@ -163,11 +163,11 @@ begin
 
 
   if FForEncryption then
   if FForEncryption then
   begin
   begin
-    Result := TBigIntegers.AsUnsignedByteArray(GetOutputBlockSize, res);
+    Result := TBigIntegerUtilities.AsUnsignedByteArray(GetOutputBlockSize, res);
   end
   end
   else
   else
   begin
   begin
-    Result := TBigIntegers.AsUnsignedByteArray(res);
+    Result := TBigIntegerUtilities.AsUnsignedByteArray(res);
   end;
   end;
 end;
 end;
 
 

+ 2 - 2
CryptoLib/src/Crypto/Generators/ClpDHKeyGeneratorHelper.pas

@@ -25,7 +25,7 @@ uses
   ClpISecureRandom,
   ClpISecureRandom,
   ClpBitOperations,
   ClpBitOperations,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpWNafUtilities,
   ClpWNafUtilities,
   ClpIDHParameters;
   ClpIDHParameters;
 
 
@@ -84,7 +84,7 @@ begin
 
 
   while True do
   while True do
   begin
   begin
-    LX := TBigIntegers.CreateRandomInRange(LMin, LMax, ARandom);
+    LX := TBigIntegerUtilities.CreateRandomInRange(LMin, LMax, ARandom);
     if TWNafUtilities.GetNafWeight(LX) >= LMinWeight then
     if TWNafUtilities.GetNafWeight(LX) >= LMinWeight then
     begin
     begin
       Result := LX;
       Result := LX;

+ 2 - 2
CryptoLib/src/Crypto/Generators/ClpDHParametersHelper.pas

@@ -24,7 +24,7 @@ interface
 uses
 uses
   ClpISecureRandom,
   ClpISecureRandom,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpWNafUtilities,
   ClpWNafUtilities,
   ClpBitOperations,
   ClpBitOperations,
   ClpCryptoLibTypes;
   ClpCryptoLibTypes;
@@ -222,7 +222,7 @@ begin
   LPMinusTwo := AP.Subtract(TBigInteger.Two);
   LPMinusTwo := AP.Subtract(TBigInteger.Two);
 
 
   repeat
   repeat
-    LH := TBigIntegers.CreateRandomInRange(TBigInteger.Two, LPMinusTwo, ARandom);
+    LH := TBigIntegerUtilities.CreateRandomInRange(TBigInteger.Two, LPMinusTwo, ARandom);
     LG := LH.ModPow(TBigInteger.Two, AP);
     LG := LH.ModPow(TBigInteger.Two, AP);
   until not LG.Equals(TBigInteger.One);
   until not LG.Equals(TBigInteger.One);
 
 

+ 3 - 3
CryptoLib/src/Crypto/Generators/ClpDsaGenerators.pas

@@ -33,7 +33,7 @@ uses
   ClpEncoders,
   ClpEncoders,
   ClpDigestUtilities,
   ClpDigestUtilities,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpBitOperations,
   ClpBitOperations,
   ClpWNafUtilities,
   ClpWNafUtilities,
   ClpAsymmetricCipherKeyPair,
   ClpAsymmetricCipherKeyPair,
@@ -208,7 +208,7 @@ begin
   LMinWeight := TBitOperations.Asr32(AQ.BitLength, 2);
   LMinWeight := TBitOperations.Asr32(AQ.BitLength, 2);
   while True do
   while True do
   begin
   begin
-    LX := TBigIntegers.CreateRandomInRange(LOne, AQ.Subtract(LOne), ARandom);
+    LX := TBigIntegerUtilities.CreateRandomInRange(LOne, AQ.Subtract(LOne), ARandom);
     if TWNafUtilities.GetNafWeight(LX) >= LMinWeight then
     if TWNafUtilities.GetNafWeight(LX) >= LMinWeight then
     begin
     begin
       Result := LX;
       Result := LX;
@@ -307,7 +307,7 @@ begin
 
 
   while True do
   while True do
   begin
   begin
-    LH := TBigIntegers.CreateRandomInRange(TBigInteger.Two, LPSub2, ARandom);
+    LH := TBigIntegerUtilities.CreateRandomInRange(TBigInteger.Two, LPSub2, ARandom);
     LG := LH.ModPow(LE, AP);
     LG := LH.ModPow(LE, AP);
     if (LG.BitLength > 1) then
     if (LG.BitLength > 1) then
     begin
     begin

+ 3 - 3
CryptoLib/src/Crypto/Generators/ClpRsaGenerators.pas

@@ -25,7 +25,7 @@ uses
   SysUtils,
   SysUtils,
   ClpArrayUtilities,
   ClpArrayUtilities,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpBitOperations,
   ClpBitOperations,
   ClpIKeyGenerationParameters,
   ClpIKeyGenerationParameters,
   ClpIRsaParameters,
   ClpIRsaParameters,
@@ -183,7 +183,7 @@ begin
       Continue;
       Continue;
     LDP := LD.Remainder(LPSub1);
     LDP := LD.Remainder(LPSub1);
     LDQ := LD.Remainder(LQSub1);
     LDQ := LD.Remainder(LQSub1);
-    LQInv := TBigIntegers.ModOddInverse(LP, LQ);
+    LQInv := TBigIntegerUtilities.ModOddInverse(LP, LQ);
     LPubKey := TRsaKeyParameters.Create(False, LN, LE) as IRsaKeyParameters;
     LPubKey := TRsaKeyParameters.Create(False, LN, LE) as IRsaKeyParameters;
     LPrivKey := TRsaPrivateCrtKeyParameters.Create(LN, LE, LD, LP, LQ, LDP, LDQ, LQInv)
     LPrivKey := TRsaPrivateCrtKeyParameters.Create(LN, LE, LD, LP, LQ, LDP, LDQ, LQInv)
       as IRsaPrivateCrtKeyParameters;
       as IRsaPrivateCrtKeyParameters;
@@ -230,7 +230,7 @@ begin
   repeat
   repeat
     LFactor := TBigInteger.Create(LLen, FRandom);
     LFactor := TBigInteger.Create(LLen, FRandom);
   until (LFactor.CompareTo(TBigInteger.Two) >= 0) and
   until (LFactor.CompareTo(TBigInteger.Two) >= 0) and
-    TBigIntegers.ModOddIsCoprimeVar(LM, LFactor);
+    TBigIntegerUtilities.ModOddIsCoprimeVar(LM, LFactor);
   Result := LFactor;
   Result := LFactor;
 end;
 end;
 
 

+ 2 - 2
CryptoLib/src/Crypto/Parameters/ClpRsaParameters.pas

@@ -24,7 +24,7 @@ interface
 uses
 uses
   SysUtils,
   SysUtils,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpIRsaParameters,
   ClpIRsaParameters,
   ClpAsymmetricKeyParameter,
   ClpAsymmetricKeyParameter,
   ClpKeyGenerationParameters,
   ClpKeyGenerationParameters,
@@ -210,7 +210,7 @@ begin
     LM := AModulus;
     LM := AModulus;
     LX := FSmallPrimesProduct;
     LX := FSmallPrimesProduct;
   end;
   end;
-  Result := not TBigIntegers.ModOddIsCoprimeVar(LM, LX);
+  Result := not TBigIntegerUtilities.ModOddIsCoprimeVar(LM, LX);
 end;
 end;
 
 
 class function TRsaKeyParameters.Validate(
 class function TRsaKeyParameters.Validate(

+ 2 - 2
CryptoLib/src/Crypto/Signers/ClpECNRSigner.pas

@@ -27,7 +27,7 @@ uses
   ClpIECCommon,
   ClpIECCommon,
   ClpIECNRSigner,
   ClpIECNRSigner,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpISecureRandom,
   ClpISecureRandom,
   ClpIECParameters,
   ClpIECParameters,
   ClpICipherParameters,
   ClpICipherParameters,
@@ -338,7 +338,7 @@ begin
 
 
   if (LT.IsInitialized) then
   if (LT.IsInitialized) then
   begin
   begin
-    Result := TBigIntegers.AsUnsignedByteArray(LT);
+    Result := TBigIntegerUtilities.AsUnsignedByteArray(LT);
     Exit;
     Exit;
   end;
   end;
 
 

+ 5 - 5
CryptoLib/src/Crypto/Signers/ClpX931Signer.pas

@@ -31,7 +31,7 @@ uses
   ClpIsoTrailers,
   ClpIsoTrailers,
   ClpParameterUtilities,
   ClpParameterUtilities,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpArrayUtilities,
   ClpArrayUtilities,
   ClpCryptoLibTypes;
   ClpCryptoLibTypes;
 
 
@@ -172,7 +172,7 @@ end;
 
 
 function TX931Signer.GetMaxSignatureSize: Int32;
 function TX931Signer.GetMaxSignatureSize: Int32;
 begin
 begin
-  Result := TBigIntegers.GetUnsignedByteLength(FKParam.Modulus);
+  Result := TBigIntegerUtilities.GetUnsignedByteLength(FKParam.Modulus);
 end;
 end;
 
 
 function TX931Signer.GenerateSignature: TCryptoLibByteArray;
 function TX931Signer.GenerateSignature: TCryptoLibByteArray;
@@ -188,8 +188,8 @@ begin
 
 
   LT := LT.Min(FKParam.Modulus.Subtract(LT));
   LT := LT.Min(FKParam.Modulus.Subtract(LT));
 
 
-  LSize := TBigIntegers.GetUnsignedByteLength(FKParam.Modulus);
-  Result := TBigIntegers.AsUnsignedByteArray(LSize, LT);
+  LSize := TBigIntegerUtilities.GetUnsignedByteLength(FKParam.Modulus);
+  Result := TBigIntegerUtilities.AsUnsignedByteArray(LSize, LT);
 end;
 end;
 
 
 function TX931Signer.VerifySignature(const ASignature: TCryptoLibByteArray): Boolean;
 function TX931Signer.VerifySignature(const ASignature: TCryptoLibByteArray): Boolean;
@@ -228,7 +228,7 @@ begin
   CreateSignatureBlock();
   CreateSignatureBlock();
 
 
   System.SetLength(LFBlock, System.Length(FBlock));
   System.SetLength(LFBlock, System.Length(FBlock));
-  LFBlock := TBigIntegers.AsUnsignedByteArray(System.Length(FBlock), LF);
+  LFBlock := TBigIntegerUtilities.AsUnsignedByteArray(System.Length(FBlock), LF);
 
 
   LRv := TArrayUtilities.FixedTimeEquals(FBlock, LFBlock);
   LRv := TArrayUtilities.FixedTimeEquals(FBlock, LFBlock);
 
 

+ 5 - 5
CryptoLib/src/Crypto/Signers/SignerCalculators/ClpHMacDsaKCalculator.pas

@@ -28,7 +28,7 @@ uses
   ClpIDigest,
   ClpIDigest,
   ClpISecureRandom,
   ClpISecureRandom,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpKeyParameter,
   ClpKeyParameter,
   ClpIKeyParameter,
   ClpIKeyParameter,
   ClpIDsaKCalculator,
   ClpIDsaKCalculator,
@@ -130,10 +130,10 @@ begin
   TArrayUtilities.Fill<Byte>(FV, 0, System.Length(FV), Byte($01));
   TArrayUtilities.Fill<Byte>(FV, 0, System.Length(FV), Byte($01));
   TArrayUtilities.Fill<Byte>(FK, 0, System.Length(FK), Byte(0));
   TArrayUtilities.Fill<Byte>(FK, 0, System.Length(FK), Byte(0));
 
 
-  LSize := TBigIntegers.GetUnsignedByteLength(AN);
+  LSize := TBigIntegerUtilities.GetUnsignedByteLength(AN);
   System.SetLength(LX, LSize);
   System.SetLength(LX, LSize);
 
 
-  LDVal := TBigIntegers.AsUnsignedByteArray(AD);
+  LDVal := TBigIntegerUtilities.AsUnsignedByteArray(AD);
 
 
   System.Move(LDVal[0], LX[System.Length(LX) - System.Length(LDVal)],
   System.Move(LDVal[0], LX[System.Length(LX) - System.Length(LDVal)],
     System.Length(LDVal));
     System.Length(LDVal));
@@ -147,7 +147,7 @@ begin
     LMInt := LMInt.Subtract(AN);
     LMInt := LMInt.Subtract(AN);
   end;
   end;
 
 
-  LMVal := TBigIntegers.AsUnsignedByteArray(LMInt);
+  LMVal := TBigIntegerUtilities.AsUnsignedByteArray(LMInt);
 
 
   System.Move(LMVal[0], LM[System.Length(LM) - System.Length(LMVal)],
   System.Move(LMVal[0], LM[System.Length(LM) - System.Length(LMVal)],
     System.Length(LMVal));
     System.Length(LMVal));
@@ -187,7 +187,7 @@ var
   LTOff, LLength: Int32;
   LTOff, LLength: Int32;
 begin
 begin
   Result := TBigInteger.GetDefault;
   Result := TBigInteger.GetDefault;
-  System.SetLength(LT, TBigIntegers.GetUnsignedByteLength(FN));
+  System.SetLength(LT, TBigIntegerUtilities.GetUnsignedByteLength(FN));
 
 
   while True do
   while True do
 
 

+ 4 - 4
CryptoLib/src/Crypto/Signers/SignerEncodings/ClpPlainDsaEncoding.pas

@@ -27,7 +27,7 @@ uses
   ClpIDsaEncoding,
   ClpIDsaEncoding,
   ClpIPlainDsaEncoding,
   ClpIPlainDsaEncoding,
   ClpArrayUtilities,
   ClpArrayUtilities,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpCryptoLibTypes;
   ClpCryptoLibTypes;
 
 
 resourcestring
 resourcestring
@@ -73,7 +73,7 @@ function TPlainDsaEncoding.Decode(const AN: TBigInteger;
 var
 var
   LValueLength: Int32;
   LValueLength: Int32;
 begin
 begin
-  LValueLength := TBigIntegers.GetUnsignedByteLength(AN);
+  LValueLength := TBigIntegerUtilities.GetUnsignedByteLength(AN);
   if (System.Length(AEncoding) <> (LValueLength * 2)) then
   if (System.Length(AEncoding) <> (LValueLength * 2)) then
     raise EArgumentCryptoLibException.CreateResFmt(@SInvalidEncodingLength,
     raise EArgumentCryptoLibException.CreateResFmt(@SInvalidEncodingLength,
       ['encoding']);
       ['encoding']);
@@ -93,7 +93,7 @@ function TPlainDsaEncoding.Encode(const AN, AR, &AS: TBigInteger)
 var
 var
   LValueLength: Int32;
   LValueLength: Int32;
 begin
 begin
-  LValueLength := TBigIntegers.GetUnsignedByteLength(AN);
+  LValueLength := TBigIntegerUtilities.GetUnsignedByteLength(AN);
   System.SetLength(Result, LValueLength * 2);
   System.SetLength(Result, LValueLength * 2);
   EncodeValue(AN, AR, Result, 0, LValueLength);
   EncodeValue(AN, AR, Result, 0, LValueLength);
   EncodeValue(AN, &AS, Result, LValueLength, LValueLength);
   EncodeValue(AN, &AS, Result, LValueLength, LValueLength);
@@ -115,7 +115,7 @@ end;
 
 
 function TPlainDsaEncoding.GetMaxEncodingSize(const AN: TBigInteger): Int32;
 function TPlainDsaEncoding.GetMaxEncodingSize(const AN: TBigInteger): Int32;
 begin
 begin
-  Result := TBigIntegers.GetUnsignedByteLength(AN) * 2;
+  Result := TBigIntegerUtilities.GetUnsignedByteLength(AN) * 2;
 end;
 end;
 
 
 class function TPlainDsaEncoding.GetInstance: IPlainDsaEncoding;
 class function TPlainDsaEncoding.GetInstance: IPlainDsaEncoding;

+ 18 - 18
CryptoLib/src/Math/ClpBigIntegers.pas → CryptoLib/src/Math/ClpBigIntegerUtilities.pas

@@ -15,7 +15,7 @@
 
 
 (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
 (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
 
 
-unit ClpBigIntegers;
+unit ClpBigIntegerUtilities;
 
 
 {$I ..\Include\CryptoLib.inc}
 {$I ..\Include\CryptoLib.inc}
 
 
@@ -52,7 +52,7 @@ type
   /// <summary>
   /// <summary>
   /// BigInteger utilities.
   /// BigInteger utilities.
   /// </summary>
   /// </summary>
-  TBigIntegers = class sealed(TObject)
+  TBigIntegerUtilities = class sealed(TObject)
   strict private
   strict private
     const
     const
       MaxIterations = 1000;
       MaxIterations = 1000;
@@ -199,21 +199,21 @@ begin
   Result := AValue.GetHashCode();
   Result := AValue.GetHashCode();
 end;
 end;
 
 
-{ TBigIntegers }
+{ TBigIntegerUtilities }
 
 
-class constructor TBigIntegers.Create;
+class constructor TBigIntegerUtilities.Create;
 begin
 begin
   Zero := TBigInteger.Zero;
   Zero := TBigInteger.Zero;
   One := TBigInteger.One;
   One := TBigInteger.One;
   FBigIntegerEqualityComparer := TBigIntegerEqualityComparer.Create();
   FBigIntegerEqualityComparer := TBigIntegerEqualityComparer.Create();
 end;
 end;
 
 
-class function TBigIntegers.AsUnsignedByteArray(const AN: TBigInteger): TCryptoLibByteArray;
+class function TBigIntegerUtilities.AsUnsignedByteArray(const AN: TBigInteger): TCryptoLibByteArray;
 begin
 begin
   Result := AN.ToByteArrayUnsigned();
   Result := AN.ToByteArrayUnsigned();
 end;
 end;
 
 
-class function TBigIntegers.AsUnsignedByteArray(const ALength: Int32; const AN: TBigInteger): TCryptoLibByteArray;
+class function TBigIntegerUtilities.AsUnsignedByteArray(const ALength: Int32; const AN: TBigInteger): TCryptoLibByteArray;
 var
 var
   LBytes: TCryptoLibByteArray;
   LBytes: TCryptoLibByteArray;
   LBytesLength: Int32;
   LBytesLength: Int32;
@@ -241,7 +241,7 @@ begin
   System.Move(LBytes[0], Result[ALength - LBytesLength], LBytesLength * System.SizeOf(Byte));
   System.Move(LBytes[0], Result[ALength - LBytesLength], LBytesLength * System.SizeOf(Byte));
 end;
 end;
 
 
-class procedure TBigIntegers.AsUnsignedByteArray(const AN: TBigInteger; var ABuf: TCryptoLibByteArray; const AOff, ALen: Int32);
+class procedure TBigIntegerUtilities.AsUnsignedByteArray(const AN: TBigInteger; var ABuf: TCryptoLibByteArray; const AOff, ALen: Int32);
 var
 var
   LBytes: TCryptoLibByteArray;
   LBytes: TCryptoLibByteArray;
   LBytesLength: Int32;
   LBytesLength: Int32;
@@ -264,12 +264,12 @@ begin
   System.Move(LBytes[0], ABuf[AOff + LPadLen], LBytesLength * System.SizeOf(Byte));
   System.Move(LBytes[0], ABuf[AOff + LPadLen], LBytesLength * System.SizeOf(Byte));
 end;
 end;
 
 
-class function TBigIntegers.CreateRandomBigInteger(const ABitLength: Int32; const ASecureRandom: ISecureRandom): TBigInteger;
+class function TBigIntegerUtilities.CreateRandomBigInteger(const ABitLength: Int32; const ASecureRandom: ISecureRandom): TBigInteger;
 begin
 begin
   Result := TBigInteger.Create(ABitLength, ASecureRandom);
   Result := TBigInteger.Create(ABitLength, ASecureRandom);
 end;
 end;
 
 
-class function TBigIntegers.CreateRandomInRange(const AMin, AMax: TBigInteger; const ARandom: ISecureRandom): TBigInteger;
+class function TBigIntegerUtilities.CreateRandomInRange(const AMin, AMax: TBigInteger; const ARandom: ISecureRandom): TBigInteger;
 var
 var
   LCmp: Int32;
   LCmp: Int32;
   I: Int32;
   I: Int32;
@@ -305,27 +305,27 @@ begin
   Result := TBigInteger.Create(AMax.Subtract(AMin).BitLength - 1, ARandom).Add(AMin);
   Result := TBigInteger.Create(AMax.Subtract(AMin).BitLength - 1, ARandom).Add(AMin);
 end;
 end;
 
 
-class function TBigIntegers.FromUnsignedByteArray(const ABuf: TCryptoLibByteArray): TBigInteger;
+class function TBigIntegerUtilities.FromUnsignedByteArray(const ABuf: TCryptoLibByteArray): TBigInteger;
 begin
 begin
   Result := TBigInteger.Create(1, ABuf);
   Result := TBigInteger.Create(1, ABuf);
 end;
 end;
 
 
-class function TBigIntegers.FromUnsignedByteArray(const ABuf: TCryptoLibByteArray; const AOff, ALength: Int32): TBigInteger;
+class function TBigIntegerUtilities.FromUnsignedByteArray(const ABuf: TCryptoLibByteArray; const AOff, ALength: Int32): TBigInteger;
 begin
 begin
   Result := TBigInteger.Create(1, ABuf, AOff, ALength);
   Result := TBigInteger.Create(1, ABuf, AOff, ALength);
 end;
 end;
 
 
-class function TBigIntegers.GetByteLength(const AN: TBigInteger): Int32;
+class function TBigIntegerUtilities.GetByteLength(const AN: TBigInteger): Int32;
 begin
 begin
   Result := AN.GetLengthofByteArray();
   Result := AN.GetLengthofByteArray();
 end;
 end;
 
 
-class function TBigIntegers.GetUnsignedByteLength(const AN: TBigInteger): Int32;
+class function TBigIntegerUtilities.GetUnsignedByteLength(const AN: TBigInteger): Int32;
 begin
 begin
   Result := AN.GetLengthofByteArrayUnsigned();
   Result := AN.GetLengthofByteArrayUnsigned();
 end;
 end;
 
 
-class procedure TBigIntegers.WriteUnsignedByteArray(const AOutStr: TStream; const AN: TBigInteger);
+class procedure TBigIntegerUtilities.WriteUnsignedByteArray(const AOutStr: TStream; const AN: TBigInteger);
 var
 var
   LBuffer: TCryptoLibByteArray;
   LBuffer: TCryptoLibByteArray;
 begin
 begin
@@ -333,7 +333,7 @@ begin
   AOutStr.Write(LBuffer, 0, System.Length(LBuffer));
   AOutStr.Write(LBuffer, 0, System.Length(LBuffer));
 end;
 end;
 
 
-class function TBigIntegers.ModOddInverse(const AM, AX: TBigInteger): TBigInteger;
+class function TBigIntegerUtilities.ModOddInverse(const AM, AX: TBigInteger): TBigInteger;
 var
 var
   LBits, LLen: Int32;
   LBits, LLen: Int32;
   LReducedX: TBigInteger;
   LReducedX: TBigInteger;
@@ -361,7 +361,7 @@ begin
   Result := TNat.ToBigInteger(LLen, LZ);
   Result := TNat.ToBigInteger(LLen, LZ);
 end;
 end;
 
 
-class function TBigIntegers.ModOddInverseVar(const AM, AX: TBigInteger): TBigInteger;
+class function TBigIntegerUtilities.ModOddInverseVar(const AM, AX: TBigInteger): TBigInteger;
 var
 var
   LBits, LLen: Int32;
   LBits, LLen: Int32;
   LReducedX: TBigInteger;
   LReducedX: TBigInteger;
@@ -401,7 +401,7 @@ begin
   Result := TNat.ToBigInteger(LLen, LZ);
   Result := TNat.ToBigInteger(LLen, LZ);
 end;
 end;
 
 
-class function TBigIntegers.ModOddIsCoprime(const AM, AX: TBigInteger): Boolean;
+class function TBigIntegerUtilities.ModOddIsCoprime(const AM, AX: TBigInteger): Boolean;
 var
 var
   LBits: Int32;
   LBits: Int32;
   LReducedX: TBigInteger;
   LReducedX: TBigInteger;
@@ -424,7 +424,7 @@ begin
   Result := TMod.ModOddIsCoprime(LM, LX) <> 0;
   Result := TMod.ModOddIsCoprime(LM, LX) <> 0;
 end;
 end;
 
 
-class function TBigIntegers.ModOddIsCoprimeVar(const AM, AX: TBigInteger): Boolean;
+class function TBigIntegerUtilities.ModOddIsCoprimeVar(const AM, AX: TBigInteger): Boolean;
 var
 var
   LBits: Int32;
   LBits: Int32;
   LReducedX: TBigInteger;
   LReducedX: TBigInteger;

+ 3 - 3
CryptoLib/src/Math/ClpPrimes.pas

@@ -25,7 +25,7 @@ uses
   SysUtils,
   SysUtils,
   Math,
   Math,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpPack,
   ClpPack,
   ClpIDigest,
   ClpIDigest,
   ClpISecureRandom,
   ClpISecureRandom,
@@ -280,7 +280,7 @@ begin
 
 
   for LI := 0 to AIterations - 1 do
   for LI := 0 to AIterations - 1 do
   begin
   begin
-    LB := TBigIntegers.CreateRandomInRange(FTwo, LWSubTwo, ARandom);
+    LB := TBigIntegerUtilities.CreateRandomInRange(FTwo, LWSubTwo, ARandom);
     LG := LB.Gcd(LW);
     LG := LB.Gcd(LW);
 
 
     if LG.CompareTo(FOne) > 0 then
     if LG.CompareTo(FOne) > 0 then
@@ -366,7 +366,7 @@ begin
 
 
   for LI := 0 to AIterations - 1 do
   for LI := 0 to AIterations - 1 do
   begin
   begin
-    LB := TBigIntegers.CreateRandomInRange(FTwo, LWSubTwo, ARandom);
+    LB := TBigIntegerUtilities.CreateRandomInRange(FTwo, LWSubTwo, ARandom);
 
 
     if not ImplMRProbablePrimeToBase(LW, LWSubOne, LM, LA, LB) then
     if not ImplMRProbablePrimeToBase(LW, LWSubOne, LM, LA, LB) then
       Exit(False);
       Exit(False);

+ 6 - 6
CryptoLib/src/Math/EC/ClpECCurve.pas

@@ -39,7 +39,7 @@ uses
   ClpIPreCompInfo,
   ClpIPreCompInfo,
   ClpISecureRandom,
   ClpISecureRandom,
   ClpBitOperations,
   ClpBitOperations,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpECLookupTables,
   ClpECLookupTables,
   ClpECCurveConstants,
   ClpECCurveConstants,
   ClpCryptoLibTypes;
   ClpCryptoLibTypes;
@@ -849,7 +849,7 @@ end;
 
 
 class constructor TAbstractFpCurve.Create;
 class constructor TAbstractFpCurve.Create;
 begin
 begin
-  FKnownPrimes := TDictionary<TBigInteger, Boolean>.Create(TBigIntegers.BigIntegerEqualityComparer);
+  FKnownPrimes := TDictionary<TBigInteger, Boolean>.Create(TBigIntegerUtilities.BigIntegerEqualityComparer);
   FLockPrimes := TCriticalSection.Create;
   FLockPrimes := TCriticalSection.Create;
   FMaxFieldSize := 1042; // 2 * 521
   FMaxFieldSize := 1042; // 2 * 521
   FCertainty := 100;
   FCertainty := 100;
@@ -942,7 +942,7 @@ var
   LX: TBigInteger;
   LX: TBigInteger;
 begin
 begin
   repeat
   repeat
-    LX := TBigIntegers.CreateRandomBigInteger(AP.BitLength, ARandom);
+    LX := TBigIntegerUtilities.CreateRandomBigInteger(AP.BitLength, ARandom);
   until LX.CompareTo(AP) < 0;
   until LX.CompareTo(AP) < 0;
   Result := LX;
   Result := LX;
 end;
 end;
@@ -953,7 +953,7 @@ var
   LX: TBigInteger;
   LX: TBigInteger;
 begin
 begin
   repeat
   repeat
-    LX := TBigIntegers.CreateRandomBigInteger(AP.BitLength, ARandom);
+    LX := TBigIntegerUtilities.CreateRandomBigInteger(AP.BitLength, ARandom);
   until (LX.SignValue > 0) and (LX.CompareTo(AP) < 0);
   until (LX.SignValue > 0) and (LX.CompareTo(AP) < 0);
   Result := LX;
   Result := LX;
 end;
 end;
@@ -1138,7 +1138,7 @@ var
   LX: TBigInteger;
   LX: TBigInteger;
 begin
 begin
   repeat
   repeat
-    LX := TBigIntegers.CreateRandomBigInteger(AM, ARandom);
+    LX := TBigIntegerUtilities.CreateRandomBigInteger(AM, ARandom);
   until LX.SignValue > 0;
   until LX.SignValue > 0;
   Result := LX;
   Result := LX;
 end;
 end;
@@ -1177,7 +1177,7 @@ end;
 
 
 function TAbstractF2mCurve.RandomFieldElement(const ARandom: ISecureRandom): IECFieldElement;
 function TAbstractF2mCurve.RandomFieldElement(const ARandom: ISecureRandom): IECFieldElement;
 begin
 begin
-  Result := FromBigInteger(TBigIntegers.CreateRandomBigInteger(GetFieldSize(), ARandom));
+  Result := FromBigInteger(TBigIntegerUtilities.CreateRandomBigInteger(GetFieldSize(), ARandom));
 end;
 end;
 
 
 function TAbstractF2mCurve.RandomFieldElementMult(const ARandom: ISecureRandom): IECFieldElement;
 function TAbstractF2mCurve.RandomFieldElementMult(const ARandom: ISecureRandom): IECFieldElement;

+ 4 - 4
CryptoLib/src/Math/EC/ClpECFieldElement.pas

@@ -24,7 +24,7 @@ interface
 uses
 uses
   SysUtils,
   SysUtils,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers,
+  ClpBigIntegerUtilities,
   ClpIECFieldElement,
   ClpIECFieldElement,
   ClpLongArray,
   ClpLongArray,
   ClpBitOperations,
   ClpBitOperations,
@@ -267,7 +267,7 @@ end;
 
 
 function TECFieldElement.GetEncoded: TCryptoLibByteArray;
 function TECFieldElement.GetEncoded: TCryptoLibByteArray;
 begin
 begin
-  Result := TBigIntegers.AsUnsignedByteArray(GetEncodedLength(), ToBigInteger);
+  Result := TBigIntegerUtilities.AsUnsignedByteArray(GetEncodedLength(), ToBigInteger);
 end;
 end;
 
 
 function TECFieldElement.GetEncodedLength: Int32;
 function TECFieldElement.GetEncodedLength: Int32;
@@ -277,7 +277,7 @@ end;
 
 
 procedure TECFieldElement.EncodeTo(var ABuf: TCryptoLibByteArray; AOff: Int32);
 procedure TECFieldElement.EncodeTo(var ABuf: TCryptoLibByteArray; AOff: Int32);
 begin
 begin
-  TBigIntegers.AsUnsignedByteArray(ToBigInteger, ABuf, AOff, GetEncodedLength());
+  TBigIntegerUtilities.AsUnsignedByteArray(ToBigInteger, ABuf, AOff, GetEncodedLength());
 end;
 end;
 
 
 { TFpFieldElement }
 { TFpFieldElement }
@@ -355,7 +355,7 @@ end;
 
 
 function TFpFieldElement.ModInverse(const AX: TBigInteger): TBigInteger;
 function TFpFieldElement.ModInverse(const AX: TBigInteger): TBigInteger;
 begin
 begin
-  Result := TBigIntegers.ModOddInverse(FQ, AX);
+  Result := TBigIntegerUtilities.ModOddInverse(FQ, AX);
 end;
 end;
 
 
 function TFpFieldElement.ModMult(const AX1, AX2: TBigInteger): TBigInteger;
 function TFpFieldElement.ModMult(const AX1, AX2: TBigInteger): TBigInteger;

+ 2 - 2
CryptoLib/src/Math/EC/ClpLongArray.pas

@@ -30,7 +30,7 @@ uses
   ClpInterleave,
   ClpInterleave,
   ClpArrayUtilities,
   ClpArrayUtilities,
   ClpBigInteger,
   ClpBigInteger,
-  ClpBigIntegers;
+  ClpBigIntegerUtilities;
 
 
 resourcestring
 resourcestring
   SInvalidF2mFieldValue = 'invalid F2m field value';
   SInvalidF2mFieldValue = 'invalid F2m field value';
@@ -308,7 +308,7 @@ var
 begin
 begin
   LUsedLen := GetUsedLength();
   LUsedLen := GetUsedLength();
   if LUsedLen = 0 then
   if LUsedLen = 0 then
-    Exit(TBigIntegers.Zero);
+    Exit(TBigIntegerUtilities.Zero);
 
 
   LHighestInt := FData[LUsedLen - 1];
   LHighestInt := FData[LUsedLen - 1];
   System.SetLength(LTemp, 8);
   System.SetLength(LTemp, 8);

+ 2 - 2
CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk

@@ -1700,8 +1700,8 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel
         <UnitName Value="ClpECPointMaps"/>
         <UnitName Value="ClpECPointMaps"/>
       </Item418>
       </Item418>
       <Item419>
       <Item419>
-        <Filename Value="..\..\Math\ClpBigIntegers.pas"/>
-        <UnitName Value="ClpBigIntegers"/>
+        <Filename Value="..\..\Math\ClpBigIntegerUtilities.pas"/>
+        <UnitName Value="ClpBigIntegerUtilities"/>
       </Item419>
       </Item419>
       <Item420>
       <Item420>
         <Filename Value="..\..\Math\Raw\ClpNat448.pas"/>
         <Filename Value="..\..\Math\Raw\ClpNat448.pas"/>

+ 1 - 1
CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas

@@ -140,7 +140,7 @@ uses
   ClpStreams, ClpStreamUtilities, ClpPrimes, ClpECPoint, ClpSecT283K1Custom, 
   ClpStreams, ClpStreamUtilities, ClpPrimes, ClpECPoint, ClpSecT283K1Custom, 
   ClpWNafUtilities, ClpEndoUtilities, ClpECFieldElement, ClpECCurve, 
   ClpWNafUtilities, ClpEndoUtilities, ClpECFieldElement, ClpECCurve, 
   ClpNat576, ClpFixedPointUtilities, ClpECLookupTables, ClpECPointMaps, 
   ClpNat576, ClpFixedPointUtilities, ClpECLookupTables, ClpECPointMaps, 
-  ClpBigIntegers, ClpNat448, ClpNat224, ClpNat160, ClpNat128, ClpWnaf, 
+  ClpBigIntegerUtilities, ClpNat448, ClpNat224, ClpNat160, ClpNat128, ClpWnaf, 
   ClpScalarUtilities, ClpScalar25519, ClpBits, ClpCodec, ClpBinaryPrimitives, 
   ClpScalarUtilities, ClpScalar25519, ClpBits, ClpCodec, ClpBinaryPrimitives, 
   ClpBitConverter, ClpBitOperations, ClpConverters, ClpCryptoLibComparers, 
   ClpBitConverter, ClpBitOperations, ClpConverters, ClpCryptoLibComparers, 
   ClpCryptoLibTypes, ClpNullable, ClpPack, ClpWeakRef, ClpIPAddressUtilities, 
   ClpCryptoLibTypes, ClpNullable, ClpPack, ClpWeakRef, ClpIPAddressUtilities,