Explorar o código

fix some compilation hints

Ugochukwu Mmaduekwe hai 3 días
pai
achega
48daebb63f
Modificáronse 32 ficheiros con 56 adicións e 171 borrados
  1. 15 15
      CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr
  2. 1 1
      CryptoLib/src/Asn1/ClpAsn1Comparers.pas
  3. 1 5
      CryptoLib/src/Asn1/ClpAsn1Objects.pas
  4. 3 6
      CryptoLib/src/Asn1/X509/ClpX509Asn1Objects.pas
  5. 2 2
      CryptoLib/src/Asn1/X509/ClpX509Extension.pas
  6. 0 2
      CryptoLib/src/Asn1/X9/ClpX9ECAsn1Objects.pas
  7. 0 2
      CryptoLib/src/Asn1/X9/ClpX9ObjectIdentifiers.pas
  8. 1 1
      CryptoLib/src/Crypto/Digests/ClpDigestUtilities.pas
  9. 0 4
      CryptoLib/src/Crypto/Randoms/ClpSecureRandom.pas
  10. 0 1
      CryptoLib/src/Factories/ClpPrivateKeyFactory.pas
  11. 0 1
      CryptoLib/src/Factories/ClpPublicKeyFactory.pas
  12. 1 1
      CryptoLib/src/GeneralUtilities/ClpEnumUtilities.pas
  13. 1 1
      CryptoLib/src/Interfaces/X509/ClpIX509CrlEntry.pas
  14. 1 0
      CryptoLib/src/Interfaces/X509/ClpIX509V2AttributeCertificate.pas
  15. 6 98
      CryptoLib/src/Math/ClpBigInteger.pas
  16. 1 1
      CryptoLib/src/Math/EC/ClpECCurve.pas
  17. 1 1
      CryptoLib/src/Math/EC/ClpECFieldElement.pas
  18. 6 5
      CryptoLib/src/Math/EC/ClpECPoint.pas
  19. 0 2
      CryptoLib/src/Math/EC/Custom/Sec/ClpSecT283K1Custom.pas
  20. 0 1
      CryptoLib/src/Math/EC/Rfc8032/ClpEd25519.pas
  21. 0 1
      CryptoLib/src/Math/Field/ClpFiniteFields.pas
  22. 1 1
      CryptoLib/src/Math/Raw/ClpMod.pas
  23. 2 2
      CryptoLib/src/Math/Raw/ClpNat.pas
  24. 1 1
      CryptoLib/src/Misc/ClpCryptoLibComparers.pas
  25. 3 3
      CryptoLib/src/Pem/ClpPemObjects.pas
  26. 1 1
      CryptoLib/src/X509/ClpAttributeCertificateHolder.pas
  27. 1 1
      CryptoLib/src/X509/ClpAttributeCertificateIssuer.pas
  28. 0 2
      CryptoLib/src/X509/ClpX509AttrCertParser.pas
  29. 1 2
      CryptoLib/src/X509/ClpX509CertificateParser.pas
  30. 3 3
      CryptoLib/src/X509/ClpX509CrlEntry.pas
  31. 0 1
      CryptoLib/src/X509/ClpX509CrlParser.pas
  32. 3 3
      CryptoLib/src/X509/ClpX509V2AttributeCertificate.pas

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

@@ -401,6 +401,21 @@ uses
   ClpX509NameTokenizer in '..\..\CryptoLib\src\Asn1\X509\ClpX509NameTokenizer.pas',
   ClpX509ObjectIdentifiers in '..\..\CryptoLib\src\Asn1\X509\ClpX509ObjectIdentifiers.pas',
   ClpX509SignatureUtilities in '..\..\CryptoLib\src\Asn1\X509\ClpX509SignatureUtilities.pas',
+  ClpX509ExtensionUtilities in '..\..\CryptoLib\src\X509\Extension\ClpX509ExtensionUtilities.pas',
+  ClpAttributeCertificateHolder in '..\..\CryptoLib\src\X509\ClpAttributeCertificateHolder.pas',
+  ClpAttributeCertificateIssuer in '..\..\CryptoLib\src\X509\ClpAttributeCertificateIssuer.pas',
+  ClpDeltaCertificateTool in '..\..\CryptoLib\src\X509\ClpDeltaCertificateTool.pas',
+  ClpX509AttrCertParser in '..\..\CryptoLib\src\X509\ClpX509AttrCertParser.pas',
+  ClpX509Attribute in '..\..\CryptoLib\src\X509\ClpX509Attribute.pas',
+  ClpX509Certificate in '..\..\CryptoLib\src\X509\ClpX509Certificate.pas',
+  ClpX509CertificateParser in '..\..\CryptoLib\src\X509\ClpX509CertificateParser.pas',
+  ClpX509Crl in '..\..\CryptoLib\src\X509\ClpX509Crl.pas',
+  ClpX509CrlEntry in '..\..\CryptoLib\src\X509\ClpX509CrlEntry.pas',
+  ClpX509CrlParser in '..\..\CryptoLib\src\X509\ClpX509CrlParser.pas',
+  ClpX509ExtensionBase in '..\..\CryptoLib\src\X509\ClpX509ExtensionBase.pas',
+  ClpX509Generators in '..\..\CryptoLib\src\X509\ClpX509Generators.pas',
+  ClpX509Utilities in '..\..\CryptoLib\src\X509\ClpX509Utilities.pas',
+  ClpX509V2AttributeCertificate in '..\..\CryptoLib\src\X509\ClpX509V2AttributeCertificate.pas',
   ClpIX509Generators in '..\..\CryptoLib\src\Interfaces\X509\ClpIX509Generators.pas',
   ClpIAttributeCertificateHolder in '..\..\CryptoLib\src\Interfaces\X509\ClpIAttributeCertificateHolder.pas',
   ClpIAttributeCertificateIssuer in '..\..\CryptoLib\src\Interfaces\X509\ClpIAttributeCertificateIssuer.pas',
@@ -434,27 +449,12 @@ uses
   ClpAsn1Generators in '..\..\CryptoLib\src\Asn1\ClpAsn1Generators.pas',
   ClpIAsn1Generators in '..\..\CryptoLib\src\Interfaces\Asn1\ClpIAsn1Generators.pas',
   ClpPkcs10CertificationRequest in '..\..\CryptoLib\src\Pkcs\ClpPkcs10CertificationRequest.pas',
-  ClpAttributeCertificateHolder in '..\..\CryptoLib\src\X509\ClpAttributeCertificateHolder.pas',
-  ClpAttributeCertificateIssuer in '..\..\CryptoLib\src\X509\ClpAttributeCertificateIssuer.pas',
-  ClpDeltaCertificateTool in '..\..\CryptoLib\src\X509\ClpDeltaCertificateTool.pas',
-  ClpX509Attribute in '..\..\CryptoLib\src\X509\ClpX509Attribute.pas',
-  ClpX509Certificate in '..\..\CryptoLib\src\X509\ClpX509Certificate.pas',
-  ClpX509CertificateParser in '..\..\CryptoLib\src\X509\ClpX509CertificateParser.pas',
-  ClpX509ExtensionBase in '..\..\CryptoLib\src\X509\ClpX509ExtensionBase.pas',
-  ClpX509Generators in '..\..\CryptoLib\src\X509\ClpX509Generators.pas',
-  ClpX509Utilities in '..\..\CryptoLib\src\X509\ClpX509Utilities.pas',
-  ClpX509ExtensionUtilities in '..\..\CryptoLib\src\X509\Extension\ClpX509ExtensionUtilities.pas',
-  ClpX509V2AttributeCertificate in '..\..\CryptoLib\src\X509\ClpX509V2AttributeCertificate.pas',
-  ClpX509CrlEntry in '..\..\CryptoLib\src\X509\ClpX509CrlEntry.pas',
-  ClpX509Crl in '..\..\CryptoLib\src\X509\ClpX509Crl.pas',
-  ClpX509CrlParser in '..\..\CryptoLib\src\X509\ClpX509CrlParser.pas',
   ClpIX509Certificate in '..\..\CryptoLib\src\Interfaces\X509\ClpIX509Certificate.pas',
   ClpIX509CertificateParser in '..\..\CryptoLib\src\Interfaces\X509\ClpIX509CertificateParser.pas',
   ClpIX509CrlEntry in '..\..\CryptoLib\src\Interfaces\X509\ClpIX509CrlEntry.pas',
   ClpIX509Crl in '..\..\CryptoLib\src\Interfaces\X509\ClpIX509Crl.pas',
   ClpIX509CrlParser in '..\..\CryptoLib\src\Interfaces\X509\ClpIX509CrlParser.pas',
   ClpIX509AttrCertParser in '..\..\CryptoLib\src\Interfaces\X509\ClpIX509AttrCertParser.pas',
-  ClpX509AttrCertParser in '..\..\CryptoLib\src\X509\ClpX509AttrCertParser.pas',
   ClpIX509Extension in '..\..\CryptoLib\src\Interfaces\X509\ClpIX509Extension.pas',
   ClpIPkcs10CertificationRequest in '..\..\CryptoLib\src\Interfaces\Pkcs\ClpIPkcs10CertificationRequest.pas',
   ClpX9IntegerConverter in '..\..\CryptoLib\src\Asn1\X9\ClpX9IntegerConverter.pas',

+ 1 - 1
CryptoLib/src/Asn1/ClpAsn1Comparers.pas

@@ -33,7 +33,7 @@ type
   TOidEqualityComparer = class(TInterfacedObject, IEqualityComparer<IDerObjectIdentifier>)
   strict private
     function Equals(const ALeft, ARight: IDerObjectIdentifier): Boolean; reintroduce;
-    function GetHashCode(const AValue: IDerObjectIdentifier): Integer;
+    function GetHashCode(const AValue: IDerObjectIdentifier): Integer; reintroduce;
   end;
 
   /// <summary>

+ 1 - 5
CryptoLib/src/Asn1/ClpAsn1Objects.pas

@@ -9617,19 +9617,15 @@ begin
 end;
 
 constructor TAsn1UtcTime.CreateFromUtc(const AUtcDateTime: TDateTime);
-const
-  DefaultTwoDigitYearMax = 2049;
 var
   LUtc: TDateTime;
 begin
   inherited Create();
   // truncate to seconds precision
   LUtc := TDateTimeUtilities.WithPrecisionSecond(AUtcDateTime);
-  Validate(LUtc, DefaultTwoDigitYearMax);
   FDateTime := LUtc;
   FDateTimeLocked := True;
-  FTimeString := ToStringCanonical(LUtc);
-  FTwoDigitYearMax := DefaultTwoDigitYearMax;
+  FTimeString := ToStringCanonical(LUtc, FTwoDigitYearMax);
 end;
 
 constructor TAsn1UtcTime.CreateFromUtc(const AUtcDateTime: TDateTime; ATwoDigitYearMax: Int32);

+ 3 - 6
CryptoLib/src/Asn1/X509/ClpX509Asn1Objects.pas

@@ -889,9 +889,9 @@ type
     function GetOidList: TCryptoLibGenericArray<IDerObjectIdentifier>;
     function GetValueList(const AOid: IDerObjectIdentifier = nil): TCryptoLibStringArray; overload;
     function Equivalent(const AOther: IX509Name; AInOrder: Boolean = False): Boolean;
-    function ToString(AReverse: Boolean; const AOidSymbols: TDictionary<IDerObjectIdentifier, String>): String; overload;
+    function ToString(AReverse: Boolean; const AOidSymbols: TDictionary<IDerObjectIdentifier, String>): String; reintroduce; overload;
     function ToString: String; overload; override;
-    function ToString(const AOid: IDerObjectIdentifier): String; overload;
+    function ToString(const AOid: IDerObjectIdentifier): String; reintroduce; overload;
 
     function ToAsn1Object: IAsn1Object; override;
 
@@ -5578,7 +5578,6 @@ begin
   FOrdering.AddRange(AOids);
   FExtensions := TDictionary<IDerObjectIdentifier, IX509Extension>.Create(TAsn1Comparers.OidEqualityComparer);
 
-  I := 0;
   for I := 0 to FOrdering.Count - 1 do
   begin
     FExtensions.Add(FOrdering[I], AValues[I]);
@@ -6053,13 +6052,11 @@ constructor TX509Name.Create(const AReverse: Boolean; const ALookup: TDictionary
   const ADirName: String; const AConverter: IX509NameEntryConverter);
 var
   LNameTokenizer, LRdnTokenizer: IX509NameTokenizer;
-  LRdn, LTypeToken, LValueToken: String;
+  LRdn: String;
   LOidList: TList<IDerObjectIdentifier>;
   LValueList: TList<String>;
   LAddedList: TList<Boolean>;
   I, LCount: Int32;
-  LOid: IDerObjectIdentifier;
-  LUnescapedValue: String;
   LO: TList<IDerObjectIdentifier>;
   LV: TList<String>;
   LA: TList<Boolean>;

+ 2 - 2
CryptoLib/src/Asn1/X509/ClpX509Extension.pas

@@ -55,7 +55,7 @@ type
     constructor Create(const ACritical: IDerBoolean; const AValue: IAsn1OctetString); overload;
     constructor Create(ACritical: Boolean; const AValue: IAsn1OctetString); overload;
 
-    function GetHashCode: Int32;
+    function GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
     function Equals(AObj: IX509Extension): Boolean; reintroduce;
 
     property IsCritical: Boolean read GetIsCritical;
@@ -112,7 +112,7 @@ begin
   Result := ConvertValueToObject(Self);
 end;
 
-function TX509Extension.GetHashCode: Int32;
+function TX509Extension.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
 var
   LVH: Int32;
 begin

+ 0 - 2
CryptoLib/src/Asn1/X9/ClpX9ECAsn1Objects.pas

@@ -521,8 +521,6 @@ var
   LRepresentation: IDerObjectIdentifier;
   LK1, LK2, LK3: Int32;
   LPentanomial: IAsn1Sequence;
-  LPolynomialField: IPolynomialExtensionField;
-  LExponents: TCryptoLibInt32Array;
 begin
   inherited Create();
   if AFieldID = nil then

+ 0 - 2
CryptoLib/src/Asn1/X9/ClpX9ObjectIdentifiers.pas

@@ -187,8 +187,6 @@ begin
 end;
 
 class procedure TX9ObjectIdentifiers.Boot;
-var
-  LHashAlgs, LAes, FSigAlgs, FKems: IDerObjectIdentifier;
 begin
   if not FIsBooted then
   begin

+ 1 - 1
CryptoLib/src/Crypto/Digests/ClpDigestUtilities.pas

@@ -118,7 +118,7 @@ type
     /// <returns>A DerObjectIdentifier, null if the Oid is not available.</returns>
     class function GetObjectIdentifier(const AMechanism: String)
       : IDerObjectIdentifier; static;
-    class function GetDigest(const AOid: IDerObjectIdentifier): IDigest; overload; static; inline;
+    class function GetDigest(const AOid: IDerObjectIdentifier): IDigest; overload; static;
     class function GetDigest(const AAlgorithm: String): IDigest; overload; static;
 
     class function GetAlgorithmName(const AOid: IDerObjectIdentifier): String; static; inline;

+ 0 - 4
CryptoLib/src/Crypto/Randoms/ClpSecureRandom.pas

@@ -195,7 +195,6 @@ begin
   end;
 
   while True do
-
   begin
     LI := NextInt32();
 
@@ -205,9 +204,6 @@ begin
       Exit;
     end;
   end;
-
-  Result := 0; // to make FixInsight Happy :)
-
 end;
 
 function TSecureRandom.Next: Int32;

+ 0 - 1
CryptoLib/src/Factories/ClpPrivateKeyFactory.pas

@@ -92,7 +92,6 @@ var
   LDsaParams: IDsaParameters;
   LDsaPara: IDsaParameter;
   LX962Params: IX962Parameters;
-  LX9ECParams: IX9ECParameters;
   LECParams: IECDomainParameters;
   LECPrivateKeyObj: IAsn1Object;
   LECPrivateKeySeq: IECPrivateKeyStructure;

+ 0 - 1
CryptoLib/src/Factories/ClpPublicKeyFactory.pas

@@ -82,7 +82,6 @@ var
   LDsaParams: IDsaParameters;
   LDsaPara: IDsaParameter;
   LX962Params: IX962Parameters;
-  LX9ECParams: IX9ECParameters;
   LECParams: IECDomainParameters;
   LQ: IECPoint;
   LPublicKeyBytes: TCryptoLibByteArray;

+ 1 - 1
CryptoLib/src/GeneralUtilities/ClpEnumUtilities.pas

@@ -142,7 +142,7 @@ begin
     Result := False;
     Exit;
   end;
-  if not (S[1] in ['A'..'Z', 'a'..'z']) then
+  if not CharInSet(S[1], ['A'..'Z', 'a'..'z']) then
   begin
     Result := False;
     Exit;

+ 1 - 1
CryptoLib/src/Interfaces/X509/ClpIX509CrlEntry.pas

@@ -42,7 +42,7 @@ type
     function GetHasExtensions: Boolean;
     function GetExtensionValue(const AOid: IDerObjectIdentifier): IAsn1OctetString;
     function Equals(const AOther: IX509CrlEntry): Boolean;
-    function GetHashCode: Int32;
+    function GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
     function ToString: String;
 
     property CrlEntry: ICrlEntry read GetCrlEntry;

+ 1 - 0
CryptoLib/src/Interfaces/X509/ClpIX509V2AttributeCertificate.pas

@@ -65,6 +65,7 @@ type
     function GetAttributes: TCryptoLibGenericArray<IX509Attribute>; overload;
     function GetAttributes(const AOid: String): TCryptoLibGenericArray<IX509Attribute>; overload;
     function Equals(const AOther: IX509V2AttributeCertificate): Boolean;
+    function GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
 
     property AttributeCertificate: IAttributeCertificate read GetAttributeCertificate;
     property Version: Int32 read GetVersion;

+ 6 - 98
CryptoLib/src/Math/ClpBigInteger.pas

@@ -59,26 +59,6 @@ type
     IMASK = Int64($FFFFFFFF);
     UIMASK = UInt64($FFFFFFFF);
 
-    BitLengthTable: array [0 .. 255] of Byte =
-    (
-      0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
-      5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
-    );
-
     /// <summary>
     /// These are the threshold bit-lengths (of an exponent) where we increase the window size.
     /// They are calculated according to the expected savings in multiplications.
@@ -112,7 +92,6 @@ type
     function GetBitLength: Int32;
     function GetBitCount: Int32;
     function ModInversePow2(const AM: TBigInteger): TBigInteger;
-    function ModPowSimple(const AB, AE, AM: TBigInteger): TBigInteger;
     class function ModPowBarrett(const AB, AE, AM: TBigInteger): TBigInteger; static;
     class function ReduceBarrett(const AX, AM, AMr, AYu: TBigInteger): TBigInteger; static;
     class function ModPowMonty(var AYAccum: TCryptoLibUInt32Array; const AB, AE, AM: TBigInteger; const AConvert: Boolean): TBigInteger; static;
@@ -311,8 +290,6 @@ var
   I, J, LProduct: Int32;
   LPrimeList: TCryptoLibInt32Array;
   LSmallConstant: TBigInteger;
-  LByteVal: UInt32;
-  LBitLen: Byte;
   LZeroMagnitude: TCryptoLibUInt32Array;
 begin
   TSecureRandom.Boot;
@@ -450,33 +427,11 @@ end;
 
 class function TBigInteger.BitLen(const AValue: Byte): Int32;
 begin
-  //Result := BitLengthTable[AValue];
   Result := 32 - TBitOperations.NumberOfLeadingZeros32(AValue);
 end;
 
 class function TBigInteger.BitLen(const AValue: UInt32): Int32;
-var
-  LT: UInt32;
 begin
- (* LT := AValue shr 24;
-  if LT <> 0 then
-  begin
-    Result := 24 + BitLengthTable[LT];
-    Exit;
-  end;
-  LT := AValue shr 16;
-  if LT <> 0 then
-  begin
-    Result := 16 + BitLengthTable[LT];
-    Exit;
-  end;
-  LT := AValue shr 8;
-  if LT <> 0 then
-  begin
-    Result := 8 + BitLengthTable[LT];
-    Exit;
-  end;
-  Result := BitLengthTable[AValue]; *)
   Result := 32 - TBitOperations.NumberOfLeadingZeros32(AValue);
 end;
 
@@ -626,7 +581,7 @@ end;
 
 class function TBigInteger.MakeMagnitudeBE(const ABytes: TCryptoLibByteArray; const AOffset, ALength: Int32): TCryptoLibUInt32Array;
 var
-  LEnd, LStart, LNBytes, LNInts, LFirst, I: Int32;
+  LEnd, LStart, LNBytes, LNInts, LFirst: Int32;
   LMagnitude: TCryptoLibUInt32Array;
 begin
   LEnd := AOffset + ALength;
@@ -786,7 +741,6 @@ var
   LTI, LVI: Int32;
   LM: UInt64;
   LResult: TCryptoLibUInt32Array;
-  I: Int32;
 begin
   LResult := AA;
   LTI := System.Length(LResult) - 1;
@@ -821,7 +775,7 @@ var
 begin
   LIT := System.Length(AX);
   LIV := System.Length(AY);
-  LM := 0;
+
   LBorrow := 0;
   repeat
     System.Dec(LIT);
@@ -1052,7 +1006,7 @@ class function TBigInteger.Divide(var AX: TCryptoLibUInt32Array; const AY: TCryp
 var
   LXStart, LYStart, LXYCmp, LYBitLength, LXBitLength, LShift: Int32;
   LCount, LICount: TCryptoLibUInt32Array;
-  LICountStart, LCStart, LCBitLength, I, J: Int32;
+  LICountStart, LCStart, LCBitLength: Int32;
   LC: TCryptoLibUInt32Array;
   LFirstC, LFirstX: UInt32;
 begin
@@ -1171,7 +1125,7 @@ end;
 class function TBigInteger.Remainder(var AX: TCryptoLibUInt32Array; const AY: TCryptoLibUInt32Array): TCryptoLibUInt32Array;
 var
   LXStart, LYStart, LXYCmp, LYBitLength, LXBitLength, LShift: Int32;
-  LCStart, LCBitLength, I: Int32;
+  LCStart, LCBitLength: Int32;
   LC: TCryptoLibUInt32Array;
   LFirstC, LFirstX: UInt32;
 begin
@@ -1609,9 +1563,8 @@ end;
 
 constructor TBigInteger.Create(const ASizeInBits: Int32; const ARandom: IRandom);
 var
-  LNBytes, LXBits, I: Int32;
+  LNBytes, LXBits: Int32;
   LB: TCryptoLibByteArray;
-  LByte: Byte;
 begin
   if ASizeInBits < 0 then
     raise EArgumentCryptoLibException.Create(SSizeInBitsMustBeNonNegative);
@@ -1789,7 +1742,6 @@ var
   LLimit: UInt32;
   LPossibleOverflow: Boolean;
   LBigCopy: TCryptoLibUInt32Array;
-  I: Int32;
 begin
   if System.Length(FMagnitude) < System.Length(AMagToAdd) then
   begin
@@ -1888,7 +1840,6 @@ var
   LResLength: Int32;
   LRes: TCryptoLibUInt32Array;
   LResSign: Int32;
-  I: Int32;
 begin
   if Equals(AValue) then
   begin
@@ -1956,7 +1907,6 @@ end;
 function TBigInteger.Divide(const AValue: TBigInteger): TBigInteger;
 var
   LMag: TCryptoLibUInt32Array;
-  I: Int32;
 begin
   if AValue.FSign = 0 then
     raise EArithmeticCryptoLibException.Create('Division by zero error');
@@ -2237,8 +2187,6 @@ begin
 end;
 
 function TBigInteger.Negate(): TBigInteger;
-var
-  I: Int32;
 begin
   if FSign = 0 then
   begin
@@ -2629,7 +2577,6 @@ end;
 function TBigInteger.FlipExistingBit(const AN: Int32): TBigInteger;
 var
   LMag: TCryptoLibUInt32Array;
-  I: Int32;
 begin
   // Clone magnitude
   LMag := System.Copy(FMagnitude);
@@ -2668,18 +2615,6 @@ begin
   end;
 
   LOffset := LOffset + TBitOperations.NumberOfTrailingZeros32(LWord);
- (*
-  while (LWord and $FF) = 0 do
-  begin
-    LWord := LWord shr 8;
-    LOffset := LOffset + 8;
-  end;
-
-  while (LWord and 1) = 0 do
-  begin
-    LWord := LWord shr 1;
-    System.Inc(LOffset);
-  end;   *)
 
   Result := LOffset;
 
@@ -2740,7 +2675,6 @@ end;
 class function TBigInteger.UInt32ToBin(const AValue: UInt32): String;
 var
   LValue: UInt32;
-  I: Int32;
 begin
   if AValue = 0 then
   begin
@@ -3188,7 +3122,7 @@ end;
 
 function TBigInteger.ToByteArrayInternal(const AUnsigned: Boolean): TCryptoLibByteArray;
 var
-  LNBits, LNBytes, LMagIndex, LBytesIndex, J: Int32;
+  LNBits, LNBytes, LMagIndex, LBytesIndex: Int32;
   LLastMag: UInt32;
   LCarry: Boolean;
   LMag: UInt32;
@@ -3280,7 +3214,6 @@ var
   LSb: String;
   LU: TBigInteger;
   LBits: Int32;
-  LS: String;
   LQ: TBigInteger;
   LModuli: TCryptoLibGenericArray<TBigInteger>;
   LOctStrings: TCryptoLibStringArray;
@@ -3415,8 +3348,6 @@ begin
 end;
 
 function TBigInteger.IsProbablePrime(const ACertainty: Int32): Boolean;
-var
-  LN: TBigInteger;
 begin
   Result := IsProbablePrime(ACertainty, False);
 end;
@@ -3512,29 +3443,6 @@ begin
   Result := LX;
 end;
 
-function TBigInteger.ModPowSimple(const AB, AE, AM: TBigInteger): TBigInteger;
-var
-  LY, LZ: TBigInteger;
-  LExp: TBigInteger;
-begin
-  LY := FOne;
-  LZ := AB;
-  LExp := AE;
-  while LExp.FSign > 0 do
-  begin
-    if LExp.TestBit(0) then
-    begin
-      LY := LY.Multiply(LZ).&Mod(AM);
-    end;
-    LExp := LExp.ShiftRight(1);
-    if LExp.FSign > 0 then
-    begin
-      LZ := LZ.Multiply(LZ).&Mod(AM);
-    end;
-  end;
-  Result := LY;
-end;
-
 class function TBigInteger.ReduceBarrett(const AX, AM, AMr, AYu: TBigInteger): TBigInteger;
 var
   LXLen, LMLen, LK: Int32;

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

@@ -156,7 +156,7 @@ type
     function Configure: IECCurveConfig; virtual;
     procedure ApplyConfig(ACoord: Int32; const AEndomorphism: IECEndomorphism;
       const AMultiplier: IECMultiplier); virtual;
-    function Equals(const AOther: IECCurve): Boolean; virtual;
+    function Equals(const AOther: IECCurve): Boolean; reintroduce; virtual;
     function GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
   end;
 

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

@@ -65,7 +65,7 @@ type
     function SquarePow(APow: Int32): IECFieldElement; virtual;
     function TestBitZero: Boolean; virtual;
 
-    function Equals(const AOther: IECFieldElement): Boolean; virtual;
+    function Equals(const AOther: IECFieldElement): Boolean; reintroduce; virtual;
     function GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
     function ToString: String; override;
     function GetEncoded: TCryptoLibByteArray; virtual;

+ 6 - 5
CryptoLib/src/Math/EC/ClpECPoint.pas

@@ -87,6 +87,9 @@ type
 
     function Detach: IECPoint; virtual; abstract;  // called from GetDetachedPoint on normalized point
     function GetCompressionYTilde: Boolean; virtual; abstract;
+
+    function SatisfiesCurveEquation: Boolean; virtual; abstract;
+    function SatisfiesOrder: Boolean; virtual;
   public
     constructor Create(const ACurve: IECCurve; const AX, AY: IECFieldElement); overload;
     constructor Create(const ACurve: IECCurve; const AX, AY: IECFieldElement;
@@ -136,12 +139,10 @@ type
     function ThreeTimes: IECPoint; virtual;
 
     function ImplIsValid(ADecompressed, ACheckOrder: Boolean): Boolean; virtual;
-    function SatisfiesCurveEquation: Boolean; virtual; abstract;
-    function SatisfiesOrder: Boolean; virtual;
     function IsValid: Boolean; virtual;
     function IsValidPartial: Boolean; virtual;
 
-    function Equals(const AOther: IECPoint): Boolean;
+    function Equals(const AOther: IECPoint): Boolean; reintroduce;
     function GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
     function ToString: String; override;
   end;
@@ -192,8 +193,8 @@ type
   TAbstractF2mPoint = class abstract(TECPointBase, IAbstractF2mPoint)
   strict protected
     function SatisfiesOrder: Boolean; override;
-  public
     function SatisfiesCurveEquation: Boolean; override;
+  public
     function ScaleX(const AScale: IECFieldElement): IECPoint; override;
     function ScaleXNegateY(const AScale: IECFieldElement): IECPoint; override;
     function ScaleY(const AScale: IECFieldElement): IECPoint; override;
@@ -971,7 +972,7 @@ var
   Z1, Z2, LU1, LU2, LV1, LV2, LU, LV, LW: IECFieldElement;
   LVSquared, LVCubed, LVSquaredV2, LA: IECFieldElement;
   LZ1IsOne, LZ2IsOne: Boolean;
-  LZ1Squared, LS2, LZ2Squared, LS1, LH, LR: IECFieldElement;
+  LZ1Squared, LZ2Squared, LH, LR: IECFieldElement;
   LHSquared, LG: IECFieldElement;
   LZ1Cubed, LZ2Cubed, LU2b, LS2b, LU1b, LS1b: IECFieldElement;
   LC, LW1, LW2b, LA1: IECFieldElement;

+ 0 - 2
CryptoLib/src/Math/EC/Custom/Sec/ClpSecT283K1Custom.pas

@@ -932,8 +932,6 @@ var
   LTT0: TCryptoLibUInt64Array;
   LT1, LT2, LT3: TCryptoLibUInt64Array;
   LZ1IsOne, LZ2IsOne: Boolean;
-  LU2, LS2, LU1, LS1: TCryptoLibUInt64Array;
-  LA, LB: TCryptoLibUInt64Array;
   LX3Arr, LZ3Arr, LL3Arr: TCryptoLibUInt64Array;
   LX3, LL3, LZ3: ISecT283FieldElement;
   LZs: TCryptoLibGenericArray<IECFieldElement>;

+ 0 - 1
CryptoLib/src/Math/EC/Rfc8032/ClpEd25519.pas

@@ -898,7 +898,6 @@ end;
 
 class procedure TEd25519.PointPrecompute(const AP: TPointAffine; var APoints: TCryptoLibGenericArray<TPointExtended>; APointsOff, APointsLen: Int32; var AT: TPointTemp);
 var
-  LInit: TPointExtended;
   LD: TPointExtended;
   LI: Int32;
 begin

+ 0 - 1
CryptoLib/src/Math/Field/ClpFiniteFields.pas

@@ -65,7 +65,6 @@ end;
 class function TFiniteFields.GetBinaryExtensionField
   (const AExponents: TCryptoLibInt32Array): IPolynomialExtensionField;
 var
-  LExponents: TCryptoLibInt32Array;
   I: Int32;
 begin
   if System.Length(AExponents) = 0 then

+ 1 - 1
CryptoLib/src/Math/Raw/ClpMod.pas

@@ -152,7 +152,7 @@ end;
 class function TMod.ModOddInverse(const AM: TCryptoLibUInt32Array; const AX: TCryptoLibUInt32Array;
   const AZ: TCryptoLibUInt32Array): UInt32;
 var
-  LLen32, LBits, LLen30, LAllocSize: Int32;
+  LLen32, LBits, LLen30: Int32;
   LT, LD, LE, LF, LG, LM: TCryptoLibInt32Array;
   LTheta, LM0Inv32, LMaxDivsteps, LSignF: Int32;
   LDivSteps: Int32;

+ 2 - 2
CryptoLib/src/Math/Raw/ClpNat.pas

@@ -564,10 +564,10 @@ var
   LDiff: UInt32;
 begin
   LMASK := UInt32(-(AMask and 1));
-  LZI := AZ[AZOff + LI];
-  LDiff := LZI xor AX[AXOff + LI];
   for LI := 0 to ALen - 1 do
   begin
+    LZI := AZ[AZOff + LI];
+    LDiff := LZI xor AX[AXOff + LI];
     LZI := LZI xor (LDiff and LMASK);
     AZ[AZOff + LI] := LZI;
   end;

+ 1 - 1
CryptoLib/src/Misc/ClpCryptoLibComparers.pas

@@ -34,7 +34,7 @@ type
   TOrdinalIgnoreCaseEqualityComparer = class(TInterfacedObject, IEqualityComparer<String>)
   strict private
     function Equals(const ALeft, ARight: String): Boolean; reintroduce;
-    function GetHashCode(const AValue: String): Integer;
+    function GetHashCode(const AValue: String): Integer; reintroduce;
   end;
 
   /// <summary>

+ 3 - 3
CryptoLib/src/Pem/ClpPemObjects.pas

@@ -52,8 +52,8 @@ type
   public
     constructor Create(const AName, AValue: String);
 
-    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
-    function Equals(const AObj: IPemHeader): Boolean;
+    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
+    function Equals(const AObj: IPemHeader): Boolean; reintroduce;
     function ToString(): String; override;
 
     property Name: String read GetName;
@@ -340,7 +340,7 @@ function TPemReader.SeekColon(AUpTo: Int32): Boolean;
 var
   LC: Int32;
   LRead: TList<Int32>;
-  I, LReadPos: Int32;
+  LReadPos: Int32;
   LColonFound: Boolean;
 begin
   LC := 0;

+ 1 - 1
CryptoLib/src/X509/ClpAttributeCertificateHolder.pas

@@ -92,7 +92,7 @@ type
     function GetIssuer: TCryptoLibGenericArray<IX509Name>;
     function Clone: IAttributeCertificateHolder;
     function Match(const AX509Cert: IX509Certificate): Boolean;
-    function Equals(const AOther: IAttributeCertificateHolder): Boolean;
+    function Equals(const AOther: IAttributeCertificateHolder): Boolean; reintroduce;
   end;
 
 implementation

+ 1 - 1
CryptoLib/src/X509/ClpAttributeCertificateIssuer.pas

@@ -61,7 +61,7 @@ type
     function GetPrincipals: TCryptoLibGenericArray<IX509Name>;
     function Clone: IAttributeCertificateIssuer;
     function Match(const AX509Cert: IX509Certificate): Boolean;
-    function Equals(const AOther: IAttributeCertificateIssuer): Boolean;
+    function Equals(const AOther: IAttributeCertificateIssuer): Boolean; reintroduce;
   end;
 
 implementation

+ 0 - 2
CryptoLib/src/X509/ClpX509AttrCertParser.pas

@@ -111,7 +111,6 @@ var
   LSeq: IAsn1Sequence;
   LContentType: IDerObjectIdentifier;
   LSignedData: ISignedData;
-  LAttributeCertificate: IAttributeCertificate;
 begin
   LSeq := ADIn.ReadObject() as IAsn1Sequence;
 
@@ -229,7 +228,6 @@ var
   LPushbackStream: TPushbackStream;
   LStreamToUse: TStream;
 begin
-  LPushbackStream := nil;
   if AInStream = nil then
     raise EArgumentNilCryptoLibException.Create('inStream');
 

+ 1 - 2
CryptoLib/src/X509/ClpX509CertificateParser.pas

@@ -218,7 +218,6 @@ var
   LPushbackStream: TPushbackStream;
   LStreamToUse: TStream;
 begin
-  LPushbackStream := nil;
   if AInStream = nil then
     raise EArgumentNilCryptoLibException.Create('inStream');
 
@@ -282,7 +281,7 @@ begin
 
         Result := ReadDerCertificateFromStream(LStreamToUse);
       finally
-        LPushbackStream.Free();
+        LPushbackStream.Free;
       end;
       Exit;
     end;

+ 3 - 3
CryptoLib/src/X509/ClpX509CrlEntry.pas

@@ -61,8 +61,8 @@ type
     function GetSerialNumber: TBigInteger;
     function GetRevocationDate: TDateTime;
     function GetHasExtensions: Boolean;
-    function Equals(const AOther: IX509CrlEntry): Boolean;
-    function GetHashCode: Int32; reintroduce;
+    function Equals(const AOther: IX509CrlEntry): Boolean; reintroduce;
+    function GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
     function ToString: String; override;
 
     property CrlEntry: ICrlEntry read GetCrlEntry;
@@ -205,7 +205,7 @@ begin
   Result := FCrlEntry.Equals(AOther.CrlEntry);
 end;
 
-function TX509CrlEntry.GetHashCode: Int32;
+function TX509CrlEntry.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
 begin
   if not FHashValueSet then
   begin

+ 0 - 1
CryptoLib/src/X509/ClpX509CrlParser.pas

@@ -206,7 +206,6 @@ var
   LPushbackStream: TPushbackStream;
   LStreamToUse: TStream;
 begin
-  LPushbackStream := nil;
   if AInStream = nil then
     raise EArgumentNilCryptoLibException.Create('inStream');
 

+ 3 - 3
CryptoLib/src/X509/ClpX509V2AttributeCertificate.pas

@@ -98,8 +98,8 @@ type
     function GetAttributes: TCryptoLibGenericArray<IX509Attribute>; overload;
     function GetAttributes(const AOid: String): TCryptoLibGenericArray<IX509Attribute>; overload;
 
-    function Equals(const AOther: IX509V2AttributeCertificate): Boolean;
-    function GetHashCode: Int32; override;
+    function Equals(const AOther: IX509V2AttributeCertificate): Boolean; reintroduce;
+    function GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI} override;
   end;
 
 implementation
@@ -376,7 +376,7 @@ begin
   Result := FCert.ToAsn1Object.Equals(AOther.AttributeCertificate.ToAsn1Object);
 end;
 
-function TX509V2AttributeCertificate.GetHashCode: Int32;
+function TX509V2AttributeCertificate.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt; {$ENDIF DELPHI}
 begin
   Result := FCert.ToAsn1Object.GetHashCode;
 end;