Ugochukwu Mmaduekwe 3 часов назад
Родитель
Сommit
fee598705f

+ 2 - 2
CryptoLib.Tests/src/Asn1/BitStringTests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,
   ClpX509Asn1Objects,
@@ -81,8 +82,7 @@ begin
 
   LS1.GetBytes();
 
-  LDerBit := TDerBitString.GetInstance
-    (TAsn1Object.FromByteArray(LS1.GetEncoded()));
+  LDerBit := TDerBitString.GetInstance(TAsn1Object.FromByteArray(LS1.GetEncoded()));
 
   if not AreEqual(LS1.GetEncoded(), DecodeHex('030100')) then
   begin

+ 1 - 0
CryptoLib.Tests/src/Asn1/EnumeratedTests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,
   ClpIAsn1Core,

+ 1 - 0
CryptoLib.Tests/src/Asn1/OIDTests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,
   ClpEncoders,

+ 1 - 0
CryptoLib.Tests/src/Asn1/RelativeOidTests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,
   ClpEncoders,

+ 1 - 0
CryptoLib.Tests/src/Asn1/TagTests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,
   ClpAsn1Streams,

+ 1 - 0
CryptoLib.Tests/src/Asn1/X509/CertificateTests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpX509Asn1Objects,
   ClpIX509Asn1Objects,
   ClpAsn1Objects,

+ 1 - 0
CryptoLib.Tests/src/Crypto/DSATests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpISigner,
   ClpIDsaSigner,
   ClpDsaSigner,

+ 1 - 0
CryptoLib.Tests/src/Math/ECNRTests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,
   ClpECCurve,

+ 1 - 0
CryptoLib.Tests/src/Others/CertTests.pas

@@ -35,6 +35,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpBigInteger,
   ClpIECCommon,
   ClpX509Asn1Objects,

+ 1 - 0
CryptoLib.Tests/src/Others/ECDsa5Tests.pas

@@ -31,6 +31,7 @@ uses
 {$ELSE}
   TestFramework,
 {$ENDIF FPC}
+  ClpAsn1Core,
   ClpBigInteger,
   ClpFixedSecureRandom,
   ClpISecureRandom,

+ 2 - 2
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; reintroduce;
+    function GetHashCode(const AValue: IDerObjectIdentifier): {$IFDEF DELPHI}Int32; {$ELSE}UInt32; {$ENDIF DELPHI} reintroduce;
   end;
 
   /// <summary>
@@ -88,7 +88,7 @@ begin
   Result := ALeft.Equals(ARight);
 end;
 
-function TOidEqualityComparer.GetHashCode(const AValue: IDerObjectIdentifier): Integer;
+function TOidEqualityComparer.GetHashCode(const AValue: IDerObjectIdentifier): {$IFDEF DELPHI}Int32; {$ELSE}UInt32; {$ENDIF DELPHI}
 begin
   if AValue = nil then
   begin

+ 9 - 9
CryptoLib/src/Asn1/ClpAsn1Core.pas

@@ -223,6 +223,15 @@ type
     /// </summary>
     function Asn1GetHashCode(): Int32; virtual; abstract;
 
+    /// <summary>
+    /// Call Asn1Equals (internal method).
+    /// </summary>
+    function CallAsn1Equals(const AObj: IAsn1Object): Boolean;
+    /// <summary>
+    /// Call Asn1GetHashCode (internal method).
+    /// </summary>
+    function CallAsn1GetHashCode(): Int32;
+
   public
     /// <summary>
     /// Encode this object to a stream using BER encoding.
@@ -274,15 +283,6 @@ type
     /// Create an ASN.1 object from a fixed buffer stream.
     /// </summary>
     class function FromBufferStream(const ABufferStream: TFixedBufferStream): IAsn1Object; static;
-
-    /// <summary>
-    /// Call Asn1Equals (internal method).
-    /// </summary>
-    function CallAsn1Equals(const AObj: IAsn1Object): Boolean;
-    /// <summary>
-    /// Call Asn1GetHashCode (internal method).
-    /// </summary>
-    function CallAsn1GetHashCode(): Int32;
   end;
 
 implementation

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

@@ -107,12 +107,6 @@ type
     class function Get(ATagNo: Int32): IAsn1UniversalType; static;
   end;
 
-  // Moved to ClpAsn1Encodings.pas (kept here as a backward-compatibility alias)
-  TDerEncoding = ClpAsn1Encodings.TDerEncoding;
-
-  // Moved to ClpAsn1Core.pas (kept here as a backward-compatibility alias)
-  TAsn1Object = ClpAsn1Core.TAsn1Object;
-
   /// <summary>
   /// Abstract base class for ASN.1 octet strings.
   /// </summary>
@@ -8235,7 +8229,7 @@ begin
     System.SetLength(FCache, 1024);
 
   LOriginalEntry := FCache[LIndex];
-  if (LOriginalEntry <> nil) and TArrayUtilities.AreEqual<Byte>(AContents, LOriginalEntry.Contents) then
+  if (LOriginalEntry <> nil) and (TArrayUtilities.AreEqual<Byte>(AContents, LOriginalEntry.Contents)) then
   begin
     Result := LOriginalEntry;
     Exit;
@@ -8252,7 +8246,7 @@ begin
   LExchangedEntry := FCache[LIndex];
   if LExchangedEntry <> LOriginalEntry then
   begin
-    if (LExchangedEntry <> nil) and TArrayUtilities.AreEqual<Byte>(AContents, LExchangedEntry.Contents) then
+    if (LExchangedEntry <> nil) and (TArrayUtilities.AreEqual<Byte>(AContents, LExchangedEntry.Contents)) then
     begin
       Result := LExchangedEntry;
       Exit;
@@ -8487,7 +8481,7 @@ begin
   LStemLength := System.Length(LStemContents);
   // Compare the first LStemLength bytes of both arrays
   Result := (System.Length(FContents) > LStemLength) and
-    TArrayUtilities.AreEqual<Byte>(System.Copy(FContents, 0, LStemLength), System.Copy(LStemContents, 0, LStemLength));
+    (TArrayUtilities.AreEqual<Byte>(System.Copy(FContents, 0, LStemLength), System.Copy(LStemContents, 0, LStemLength)));
 end;
 
 function TDerObjectIdentifier.ToString(): String;
@@ -9201,7 +9195,7 @@ begin
     System.SetLength(FCache, 64);
 
   LOriginalEntry := FCache[LIndex];
-  if (LOriginalEntry <> nil) and TArrayUtilities.AreEqual<Byte>(AContents, LOriginalEntry.Contents) then
+  if (LOriginalEntry <> nil) and (TArrayUtilities.AreEqual<Byte>(AContents, LOriginalEntry.Contents)) then
   begin
     Result := LOriginalEntry;
     Exit;
@@ -9219,7 +9213,7 @@ begin
   LExchangedEntry := FCache[LIndex];
   if LExchangedEntry <> LOriginalEntry then
   begin
-    if (LExchangedEntry <> nil) and TArrayUtilities.AreEqual<Byte>(AContents, LExchangedEntry.Contents) then
+    if (LExchangedEntry <> nil) and (TArrayUtilities.AreEqual<Byte>(AContents, LExchangedEntry.Contents)) then
     begin
       Result := LExchangedEntry;
       Exit;
@@ -13211,4 +13205,3 @@ begin
 end;
 
 end.
-

+ 1 - 0
CryptoLib/src/Asn1/ClpAsn1Utilities.pas

@@ -25,6 +25,7 @@ uses
   SysUtils,
   TypInfo,
   ClpAsn1Tags,
+  ClpAsn1Core,
   ClpIAsn1Objects,
   ClpIAsn1Core,
   ClpIAsn1Parsers,

+ 1 - 0
CryptoLib/src/Asn1/X509/ClpX509Extension.pas

@@ -23,6 +23,7 @@ interface
 
 uses
   SysUtils,
+  ClpAsn1Core,
   ClpIAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,

+ 1 - 0
CryptoLib/src/Asn1/X509/ClpX509NameEntryConverter.pas

@@ -23,6 +23,7 @@ interface
 
 uses
   SysUtils,
+  ClpAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,
   ClpIAsn1Core,

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

@@ -248,8 +248,8 @@ begin
     Result := True;
     Exit;
   end;
-  Result := (Counter = AOther.Counter) and TArrayUtilities.AreEqual<Byte>(Seed,
-    AOther.Seed);
+  Result := (Counter = AOther.Counter) and (TArrayUtilities.AreEqual<Byte>(Seed,
+    AOther.Seed));
 end;
 
 function TDsaValidationParameters.GetCounter: Int32;

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

@@ -24,6 +24,7 @@ interface
 uses
   Classes,
   SysUtils,
+  ClpAsn1Core,
   ClpIAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,

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

@@ -23,6 +23,7 @@ interface
 
 uses
   Classes,
+  ClpAsn1Core,
   ClpIAsn1Objects,
   ClpIAsymmetricKeyParameter,
   ClpRsaParameters,

+ 2 - 2
CryptoLib/src/Math/ClpBigIntegers.pas

@@ -46,7 +46,7 @@ type
   TBigIntegerEqualityComparer = class(TInterfacedObject, IEqualityComparer<TBigInteger>)
   strict private
     function Equals(const ALeft, ARight: TBigInteger): Boolean; reintroduce;
-    function GetHashCode(const AValue: TBigInteger): Integer; reintroduce;
+    function GetHashCode(const AValue: TBigInteger): {$IFDEF DELPHI}Int32; {$ELSE}UInt32; {$ENDIF DELPHI} reintroduce;
   end;
 
   /// <summary>
@@ -194,7 +194,7 @@ begin
   Result := ALeft.Equals(ARight);
 end;
 
-function TBigIntegerEqualityComparer.GetHashCode(const AValue: TBigInteger): Integer;
+function TBigIntegerEqualityComparer.GetHashCode(const AValue: TBigInteger): {$IFDEF DELPHI}Int32; {$ELSE}UInt32; {$ENDIF DELPHI}
 begin
   Result := AValue.GetHashCode();
 end;

+ 2 - 2
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; reintroduce;
+    function GetHashCode(const AValue: String): {$IFDEF DELPHI}Int32; {$ELSE}UInt32; {$ENDIF DELPHI} reintroduce;
   end;
 
   /// <summary>
@@ -62,7 +62,7 @@ begin
   Result := TStringUtilities.EqualsIgnoreCase(ALeft, ARight);
 end;
 
-function TOrdinalIgnoreCaseEqualityComparer.GetHashCode(const AValue: String): Integer;
+function TOrdinalIgnoreCaseEqualityComparer.GetHashCode(const AValue: String): {$IFDEF DELPHI}Int32; {$ELSE}UInt32; {$ENDIF DELPHI}
 var
   LLowerValue: String;
   I: Int32;

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

@@ -164,7 +164,7 @@ end;
 
 class operator TNullable<T>.Equal(const A: TNullable<T>; const B: T): Boolean;
 begin
-  Result := A.FHasValue and TEqualityComparer<T>.Default.Equals(A.FValue, B);
+  Result := A.FHasValue and (TEqualityComparer<T>.Default.Equals(A.FValue, B));
 end;
 
 class operator TNullable<T>.NotEqual(const A: TNullable<T>; const B: T): Boolean;

+ 1 - 0
CryptoLib/src/Pem/ClpPemObjects.pas

@@ -25,6 +25,7 @@ uses
   SysUtils,
   Classes,
   Generics.Collections,
+  ClpAsn1Core,
   ClpIAsn1Core,
   ClpIPemObjects,
   ClpCryptoLibTypes,

+ 1 - 0
CryptoLib/src/Pkcs/ClpPkcs10CertificationRequest.pas

@@ -25,6 +25,7 @@ uses
   SysUtils,
   Classes,
   Generics.Collections,
+  ClpAsn1Core,
   ClpIAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,

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

@@ -25,6 +25,7 @@ uses
   Classes,
   SysUtils,
   Generics.Collections,
+  ClpAsn1Core,
   ClpIAsn1Core,
   ClpIAsn1Objects,
   ClpIX509Asn1Objects,

+ 1 - 0
CryptoLib/src/X509/Extension/ClpX509ExtensionUtilities.pas

@@ -23,6 +23,7 @@ interface
 
 uses
   SysUtils,
+  ClpAsn1Core,
   ClpIAsn1Core,
   ClpAsn1Objects,
   ClpIAsn1Objects,