Browse Source

some refactorings

- Add and use IntValueExact properties
- ASN.1 updates
- Add IntValueExact and LongValueExact to TBigInteger
- Use GetInstance instead of cast
- Integer cannot have empty contents octets
- Enumerated values can't be negative
- rewrite Sort() method for TAsn1Set
Ugochukwu Mmaduekwe 6 years ago
parent
commit
8e93ae0068

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

@@ -459,6 +459,7 @@ uses
   DigestTests in '..\src\Others\DigestTests.pas',
   ScryptTests in '..\src\Crypto\ScryptTests.pas',
   DHTests in '..\src\Crypto\DHTests.pas',
+  Asn1IntegerTests in '..\src\Asn1\Asn1IntegerTests.pas',
   CryptoLibTestBase in '..\src\CryptoLibTestBase.pas';
 
 begin

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

@@ -462,6 +462,7 @@ uses
   DigestTests in '..\src\Others\DigestTests.pas',
   ScryptTests in '..\src\Crypto\ScryptTests.pas',
   DHTests in '..\src\Crypto\DHTests.pas',
+  Asn1IntegerTests in '..\src\Asn1\Asn1IntegerTests.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="72">
+    <Units Count="73">
       <Unit0>
         <Filename Value="CryptoLib.lpr"/>
         <IsPartOfProject Value="True"/>
@@ -367,6 +367,10 @@
         <Filename Value="..\src\CryptoLibTestBase.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit71>
+      <Unit72>
+        <Filename Value="..\src\Asn1\Asn1IntegerTests.pas"/>
+        <IsPartOfProject Value="True"/>
+      </Unit72>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

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

@@ -72,6 +72,7 @@ uses
   DigestTests,
   DigestUtilitiesTests,
   DHTests,
+  Asn1IntegerTests,
   CryptoLibTestBase,
   ClpFixedSecureRandom,
   ClpIFixedSecureRandom,

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

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

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

@@ -70,6 +70,7 @@ uses
   DigestTests,
   DigestUtilitiesTests,
   DHTests,
+  Asn1IntegerTests,
   CryptoLibTestBase,
   ClpFixedSecureRandom,
   ClpIFixedSecureRandom,

+ 467 - 0
CryptoLib.Tests/src/Asn1/Asn1IntegerTests.pas

@@ -0,0 +1,467 @@
+{ *********************************************************************************** }
+{ *                              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 Asn1IntegerTests;
+
+interface
+
+{$IFDEF FPC}
+{$MODE DELPHI}
+{$ENDIF FPC}
+
+uses
+  SysUtils,
+{$IFDEF FPC}
+  fpcunit,
+  testregistry,
+{$ELSE}
+  TestFramework,
+{$ENDIF FPC}
+  ClpBigInteger,
+  ClpAsn1Objects,
+  ClpIAsn1Objects,
+  CryptoLibTestBase,
+  ClpCryptoLibTypes;
+
+type
+  TTestAsn1Integer = class(TCryptoLibAlgorithmTestCase)
+  var
+  private
+    FSuspectKey: TBytes;
+
+    procedure SetAllowUnsafeProperty(allowUnsafe: Boolean);
+
+    // Ensure existing single byte behavior.
+    procedure DoTestValidEncodingSingleByte();
+
+    procedure DoTestValidEncodingMultiByte();
+
+    procedure DoTestInvalidEncoding_00();
+
+    procedure DoTestInvalidEncoding_ff();
+
+    procedure DoTestInvalidEncoding_00_32bits();
+
+    procedure DoTestInvalidEncoding_ff_32bits();
+
+    procedure DoTestLooseValidEncoding_zero_32BAligned();
+
+    procedure DoTestLooseValidEncoding_FF_32BAligned();
+
+    procedure DoTestLooseValidEncoding_FF_32BAligned_1not0();
+
+    procedure DoTestLooseValidEncoding_FF_32BAligned_2not0();
+
+    procedure DoTestOversizedEncoding();
+
+  protected
+    procedure SetUp; override;
+    procedure TearDown; override;
+  published
+    procedure TestAsn1Integer;
+  end;
+
+implementation
+
+{ TTestAsn1Integer }
+
+procedure TTestAsn1Integer.SetAllowUnsafeProperty(allowUnsafe: Boolean);
+begin
+  TDerInteger.AllowUnsafeInteger := allowUnsafe;
+end;
+
+procedure TTestAsn1Integer.SetUp;
+begin
+  inherited;
+  FSuspectKey := DecodeBase64
+    ('MIGJAoGBAHNc+iExm94LUrJdPSJ4QJ9tDRuvaNmGVHpJ4X7a5zKI02v+2E7RotuiR2MHDJfVJkb9LUs2kb3XBlyENhtMLsbeH+3Muy3'
+    + 'hGDlh/mLJSh1s4c5jDKBRYOHom7Uc8wP0P2+zBCA+OEdikNDFBaP5PbR2Xq9okG2kPh35M2quAiMTAgMBAAE=');
+end;
+
+procedure TTestAsn1Integer.TearDown;
+begin
+  inherited;
+
+end;
+
+procedure TTestAsn1Integer.DoTestValidEncodingSingleByte;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  SetAllowUnsafeProperty(false);
+
+  //
+  // Without property, single byte.
+  //
+  rawInt := DecodeHex('10');
+  i := TDerInteger.Create(rawInt);
+  CheckEquals(i.Value.Int32Value, 16);
+
+  //
+  // With property set.
+  //
+  SetAllowUnsafeProperty(true);
+
+  rawInt := DecodeHex('10');
+  i := TDerInteger.Create(rawInt);
+  CheckEquals(i.Value.Int32Value, 16);
+end;
+
+procedure TTestAsn1Integer.DoTestValidEncodingMultiByte;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  SetAllowUnsafeProperty(false);
+
+  //
+  // Without property, single byte.
+  //
+  rawInt := DecodeHex('10FF');
+  i := TDerInteger.Create(rawInt);
+  CheckEquals(i.Value.Int32Value, 4351);
+
+  //
+  // With property set.
+  //
+  SetAllowUnsafeProperty(true);
+
+  rawInt := DecodeHex('10FF');
+  i := TDerInteger.Create(rawInt);
+  CheckEquals(i.Value.Int32Value, 4351);
+end;
+
+procedure TTestAsn1Integer.DoTestInvalidEncoding_00;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  SetAllowUnsafeProperty(false);
+
+  try
+
+    rawInt := DecodeHex('0010FF');
+    i := TDerInteger.Create(rawInt);
+    CheckEquals(i.Value.Int32Value, 4351);
+
+    Fail('Expecting EArgumentCryptoLibException');
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Integer', e.Message);
+    end;
+
+  end;
+
+end;
+
+procedure TTestAsn1Integer.DoTestInvalidEncoding_ff;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  SetAllowUnsafeProperty(false);
+
+  try
+
+    rawInt := DecodeHex('FF81FF');
+    i := TDerInteger.Create(rawInt);
+    CheckEquals(i.Value.Int32Value, 4351);
+
+    Fail('Expecting EArgumentCryptoLibException');
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Integer', e.Message);
+    end;
+
+  end;
+
+end;
+
+procedure TTestAsn1Integer.DoTestInvalidEncoding_00_32bits;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  SetAllowUnsafeProperty(false);
+
+  // Check what would pass loose validation fails outside of loose validation.
+
+  try
+
+    rawInt := DecodeHex('0000000010FF');
+    i := TDerInteger.Create(rawInt);
+    CheckEquals(i.Value.Int32Value, 4351);
+
+    Fail('Expecting EArgumentCryptoLibException');
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Integer', e.Message);
+    end;
+
+  end;
+
+end;
+
+procedure TTestAsn1Integer.DoTestInvalidEncoding_ff_32bits;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  SetAllowUnsafeProperty(false);
+
+  // Check what would pass loose validation fails outside of loose validation.
+
+  try
+
+    rawInt := DecodeHex('FFFFFFFF01FF');
+    i := TDerInteger.Create(rawInt);
+    CheckEquals(i.Value.Int32Value, 4351);
+
+    Fail('Expecting EArgumentCryptoLibException');
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Integer', e.Message);
+    end;
+
+  end;
+
+end;
+
+procedure TTestAsn1Integer.DoTestLooseValidEncoding_zero_32BAligned;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  //
+  // Should pass as loose validation permits 3 leading 0x00 bytes.
+  //
+  SetAllowUnsafeProperty(true);
+
+  rawInt := DecodeHex('00000010FF000000');
+  i := TDerInteger.Create(rawInt);
+  CheckEquals(i.Value.Int64Value, Int64(72997666816));
+
+end;
+
+procedure TTestAsn1Integer.DoTestLooseValidEncoding_FF_32BAligned;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  //
+  // Should pass as loose validation permits 3 leading 0xFF bytes
+  //
+  SetAllowUnsafeProperty(true);
+
+  rawInt := DecodeHex('FFFFFF10FF000000');
+  i := TDerInteger.Create(rawInt);
+  CheckEquals(i.Value.Int64Value, Int64(-1026513960960));
+
+end;
+
+procedure TTestAsn1Integer.DoTestLooseValidEncoding_FF_32BAligned_1not0;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  //
+  // Should pass as loose validation permits 3 leading 0xFF bytes.
+  //
+  SetAllowUnsafeProperty(true);
+
+  rawInt := DecodeHex('FFFEFF10FF000000');
+  i := TDerInteger.Create(rawInt);
+  CheckEquals(i.Value.Int64Value, Int64(-282501490671616));
+
+end;
+
+procedure TTestAsn1Integer.DoTestLooseValidEncoding_FF_32BAligned_2not0;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  //
+  // Should pass as loose validation permits 3 leading 0xFF bytes.
+  //
+  SetAllowUnsafeProperty(true);
+
+  rawInt := DecodeHex('FFFFFE10FF000000');
+  i := TDerInteger.Create(rawInt);
+  CheckEquals(i.Value.Int64Value, Int64(-2126025588736));
+
+end;
+
+procedure TTestAsn1Integer.DoTestOversizedEncoding;
+var
+  rawInt: TBytes;
+  i: IDerInteger;
+begin
+  //
+  // Should pass as loose validation permits 3 leading 0xFF bytes.
+  //
+  SetAllowUnsafeProperty(true);
+
+  rawInt := DecodeHex('FFFFFFFE10FF000000000000');
+  i := TDerInteger.Create(rawInt);
+  CheckTrue(TBigInteger.Create(DecodeHex('FFFFFFFE10FF000000000000'))
+    .Equals(i.Value));
+
+  rawInt := DecodeHex('FFFFFFFFFE10FF000000000000');
+
+  try
+
+    TDerInteger.Create(rawInt);
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Integer', e.Message);
+    end;
+
+  end;
+
+end;
+
+procedure TTestAsn1Integer.TestAsn1Integer;
+begin
+  SetAllowUnsafeProperty(true);
+
+  TAsn1Sequence.GetInstance(FSuspectKey);
+
+  DoTestValidEncodingSingleByte();
+  DoTestValidEncodingMultiByte();
+  DoTestInvalidEncoding_00();
+  DoTestInvalidEncoding_ff();
+  DoTestInvalidEncoding_00_32bits();
+  DoTestInvalidEncoding_ff_32bits();
+  DoTestLooseValidEncoding_zero_32BAligned();
+  DoTestLooseValidEncoding_FF_32BAligned();
+  DoTestLooseValidEncoding_FF_32BAligned_1not0();
+  DoTestLooseValidEncoding_FF_32BAligned_2not0();
+  DoTestOversizedEncoding();
+
+  SetAllowUnsafeProperty(true);
+
+  TDerInteger.Create
+    (DecodeHex
+    ('ffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e'));
+
+  TDerEnumerated.Create
+    (DecodeHex
+    ('005a47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e'));
+
+  SetAllowUnsafeProperty(false);
+
+  try
+
+    TDerInteger.Create
+      (DecodeHex
+      ('ffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b'));
+
+    Fail('No Exception');
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Integer', e.Message);
+    end;
+
+  end;
+
+  try
+
+    TAsn1Sequence.GetInstance(FSuspectKey);
+
+    Fail('No Exception');
+
+  except
+    on e: EAsn1CryptoLibException do
+    begin
+      CheckEquals('Corrupted Stream Detected: Malformed Integer', e.Message);
+    end;
+
+  end;
+
+  try
+
+    TDerInteger.Create
+      (DecodeHex
+      ('ffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e'));
+
+    Fail('No Exception');
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Integer', e.Message);
+    end;
+
+  end;
+
+  try
+
+    TDerEnumerated.Create
+      (DecodeHex
+      ('ffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e'));
+
+    Fail('No Exception');
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Enumerated', e.Message);
+    end;
+
+  end;
+
+  try
+
+    TDerEnumerated.Create
+      (DecodeHex
+      ('005a47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e'));
+
+    Fail('No Exception');
+
+  except
+    on e: EArgumentCryptoLibException do
+    begin
+      CheckEquals('Malformed Enumerated', e.Message);
+    end;
+
+  end;
+end;
+
+initialization
+
+// Register any test cases with the test runner
+
+{$IFDEF FPC}
+  RegisterTest(TTestAsn1Integer);
+{$ELSE}
+  RegisterTest(TTestAsn1Integer.Suite);
+{$ENDIF FPC}
+
+end.

+ 1 - 1
CryptoLib.Tests/src/Asn1/EqualsAndHashCodeTests.pas

@@ -93,7 +93,7 @@ begin
 
     TDerTaggedObject.Create(0, TDerPrintableString.Create('hello world')
     as IDerPrintableString),
-    //
+
     TBerSequence.Create(TDerPrintableString.Create('hello world')
     as IDerPrintableString),
     TBerSet.Create(TDerPrintableString.Create('hello world')

File diff suppressed because it is too large
+ 463 - 138
CryptoLib/src/Asn1/ClpAsn1Objects.pas


+ 31 - 9
CryptoLib/src/Interfaces/ClpIAsn1Objects.pas

@@ -43,7 +43,7 @@ type
     function GetEncoded(): TCryptoLibByteArray; overload;
     function GetEncoded(const encoding: String): TCryptoLibByteArray; overload;
 
-    function GetDerEncoded(): TCryptoLibByteArray;
+    function GetDerEncoded(): TCryptoLibByteArray; overload;
 
     function Equals(const obj: IAsn1Convertible): Boolean;
     function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
@@ -96,16 +96,27 @@ type
     function GetCount: Int32;
     function GetSelf(Index: Int32): IAsn1Encodable;
 
-    procedure Add(const objs: array of IAsn1Encodable);
+    procedure Add(const objs: array of IAsn1Encodable); overload;
+
+    procedure Add(const element: IAsn1Encodable); overload;
+
+    procedure AddAll(const other: IAsn1EncodableVector);
 
     procedure AddOptional(const objs: array of IAsn1Encodable);
 
+    procedure AddOptionalTagged(isExplicit: Boolean; tagNo: Int32;
+      const obj: IAsn1Encodable);
+
     property Self[Index: Int32]: IAsn1Encodable read GetSelf; default;
 
-    property Count: Int32 read GetCount;
+    property count: Int32 read GetCount;
 
     function GetEnumerable: TCryptoLibGenericArray<IAsn1Encodable>;
 
+    function CopyElements(): TCryptoLibGenericArray<IAsn1Encodable>;
+
+    function TakeElements(): TCryptoLibGenericArray<IAsn1Encodable>;
+
   end;
 
 type
@@ -208,9 +219,7 @@ type
     function GetCount: Int32;
     function GetParser: IAsn1SequenceParser;
     function GetSelf(Index: Int32): IAsn1Encodable;
-    function GetCurrent(const e: IAsn1Encodable): IAsn1Encodable;
-
-    procedure AddObject(const obj: IAsn1Encodable);
+    function GetElements: TCryptoLibGenericArray<IAsn1Encodable>;
 
     function ToString(): String;
 
@@ -219,7 +228,8 @@ type
     property Self[Index: Int32]: IAsn1Encodable read GetSelf; default;
 
     property Parser: IAsn1SequenceParser read GetParser;
-    property Count: Int32 read GetCount;
+    property count: Int32 read GetCount;
+    property Elements: TCryptoLibGenericArray<IAsn1Encodable> read GetElements;
 
   end;
 
@@ -295,7 +305,7 @@ type
     function GetCount: Int32;
     function GetParser: IAsn1SetParser;
     function GetSelf(Index: Int32): IAsn1Encodable;
-    function GetCurrent(const e: IAsn1Encodable): IAsn1Encodable;
+    function GetElements: TCryptoLibGenericArray<IAsn1Encodable>;
 
     function ToString(): String;
 
@@ -306,7 +316,8 @@ type
     property Self[Index: Int32]: IAsn1Encodable read GetSelf; default;
 
     property Parser: IAsn1SetParser read GetParser;
-    property Count: Int32 read GetCount;
+    property count: Int32 read GetCount;
+    property Elements: TCryptoLibGenericArray<IAsn1Encodable> read GetElements;
 
   end;
 
@@ -549,9 +560,13 @@ type
 
     function GetValue: TBigInteger;
     function GetBytes: TCryptoLibByteArray;
+    function GetIntValueExact: Int32;
+
+    function HasValue(const x: TBigInteger): Boolean;
 
     property Value: TBigInteger read GetValue;
     property bytes: TCryptoLibByteArray read GetBytes;
+    property IntValueExact: Int32 read GetIntValueExact;
 
   end;
 
@@ -576,11 +591,18 @@ type
     function GetPositiveValue: TBigInteger;
     function GetValue: TBigInteger;
 
+    function GetIntPositiveValueExact: Int32;
+    function GetIntValueExact: Int32;
+
+    function HasValue(const x: TBigInteger): Boolean;
+
     function ToString(): String;
 
     property Value: TBigInteger read GetValue;
     property PositiveValue: TBigInteger read GetPositiveValue;
     property bytes: TCryptoLibByteArray read GetBytes;
+    property IntPositiveValueExact: Int32 read GetIntPositiveValueExact;
+    property IntValueExact: Int32 read GetIntValueExact;
 
   end;
 

+ 24 - 0
CryptoLib/src/Math/ClpBigInteger.pas

@@ -49,6 +49,8 @@ resourcestring
   SBadCharacterRadix8 = 'Bad Character in radix 8 string: %s';
   SBadCharacterRadix2 = 'Bad Character in radix 2 string: %s';
   SUnSupportedBase = 'Only bases 2, 8, 10, 16 are allowed';
+  SBigIntegerOutOfInt32Range = 'BigInteger out of Int32 range';
+  SBigIntegerOutOfInt64Range = 'BigInteger out of Int64 range';
 
 type
 {$SCOPEDENUMS ON}
@@ -125,6 +127,8 @@ type
     function GetBitCount: Int32; inline;
     function GetInt32Value: Int32; inline;
     function GetInt64Value: Int64; inline;
+    function GetInt32ValueExact: Int32; inline;
+    function GetInt64ValueExact: Int64; inline;
     function GetIsInitialized: Boolean; inline;
     function GetSignValue: Int32; inline;
 
@@ -342,6 +346,8 @@ type
     property IsInitialized: Boolean read GetIsInitialized;
     property Int32Value: Int32 read GetInt32Value;
     property Int64Value: Int64 read GetInt64Value;
+    property Int32ValueExact: Int32 read GetInt32ValueExact;
+    property Int64ValueExact: Int64 read GetInt64ValueExact;
     property SignValue: Int32 read GetSignValue;
 
     class property Zero: TBigInteger read GetZero;
@@ -656,6 +662,24 @@ begin
 
 end;
 
+function TBigInteger.GetInt32ValueExact: Int32;
+begin
+  if (BitLength > 31) then
+  begin
+    raise EArithmeticCryptoLibException.CreateRes(@SBigIntegerOutOfInt32Range);
+  end;
+  Result := Int32Value;
+end;
+
+function TBigInteger.GetInt64ValueExact: Int64;
+begin
+  if (BitLength > 63) then
+  begin
+    raise EArithmeticCryptoLibException.CreateRes(@SBigIntegerOutOfInt64Range);
+  end;
+  Result := Int64Value;
+end;
+
 function TBigInteger.GetIsInitialized: Boolean;
 begin
   Result := FIsInitialized;

+ 4 - 4
CryptoLib/src/Utils/ClpArrayUtils.pas

@@ -122,12 +122,12 @@ class function TArrayUtils.NoZeroes(const data: TCryptoLibByteArray): Boolean;
 var
   i: Int32;
 begin
-  Result := True;
+  Result := true;
   for i := System.Low(data) to System.High(data) do
   begin
     if data[i] = 0 then
     begin
-      Result := False;
+      Result := false;
       Exit;
     end;
   end;
@@ -190,7 +190,7 @@ class function TArrayUtils.AreEqual(const A, B: TCryptoLibByteArray): Boolean;
 begin
   if System.Length(A) <> System.Length(B) then
   begin
-    Result := False;
+    Result := false;
     Exit;
   end;
 
@@ -215,7 +215,7 @@ class function TArrayUtils.AreEqual(const A, B: TCryptoLibInt32Array): Boolean;
 begin
   if System.Length(A) <> System.Length(B) then
   begin
-    Result := False;
+    Result := false;
     Exit;
   end;
 

+ 1 - 0
CryptoLib/src/Utils/ClpCryptoLibTypes.pas

@@ -37,6 +37,7 @@ type
   EInvalidParameterCryptoLibException = class(ECryptoLibException);
   EIndexOutOfRangeCryptoLibException = class(ECryptoLibException);
   EArgumentCryptoLibException = class(ECryptoLibException);
+  EInvalidArgumentCryptoLibException = class(ECryptoLibException);
   EArgumentNilCryptoLibException = class(ECryptoLibException);
   EArgumentOutOfRangeCryptoLibException = class(ECryptoLibException);
   ENullReferenceCryptoLibException = class(ECryptoLibException);

Some files were not shown because too many files changed in this diff