瀏覽代碼

cleanup some compiler hints/warnings.

Ugochukwu Mmaduekwe 7 年之前
父節點
當前提交
40fb9e2fbc
共有 57 個文件被更改,包括 1080 次插入1139 次删除
  1. 0 1
      CryptoLib.Tests/src/Crypto/IESCipherTests.pas
  2. 10 10
      CryptoLib/src/Asn1/ClpAsn1OctetString.pas
  3. 10 10
      CryptoLib/src/Asn1/ClpAsn1TaggedObject.pas
  4. 5 5
      CryptoLib/src/Asn1/ClpBerSequence.pas
  5. 5 5
      CryptoLib/src/Asn1/ClpBerSet.pas
  6. 20 22
      CryptoLib/src/Asn1/ClpDerApplicationSpecific.pas
  7. 26 26
      CryptoLib/src/Asn1/ClpDerBitString.pas
  8. 5 6
      CryptoLib/src/Asn1/ClpDerBmpString.pas
  9. 13 15
      CryptoLib/src/Asn1/ClpDerBoolean.pas
  10. 5 5
      CryptoLib/src/Asn1/ClpDerEnumerated.pas
  11. 17 17
      CryptoLib/src/Asn1/ClpDerGeneralString.pas
  12. 5 5
      CryptoLib/src/Asn1/ClpDerGraphicString.pas
  13. 17 17
      CryptoLib/src/Asn1/ClpDerIA5String.pas
  14. 5 5
      CryptoLib/src/Asn1/ClpDerInteger.pas
  15. 17 17
      CryptoLib/src/Asn1/ClpDerNumericString.pas
  16. 5 5
      CryptoLib/src/Asn1/ClpDerObjectIdentifier.pas
  17. 18 18
      CryptoLib/src/Asn1/ClpDerPrintableString.pas
  18. 5 5
      CryptoLib/src/Asn1/ClpDerSequence.pas
  19. 5 5
      CryptoLib/src/Asn1/ClpDerSet.pas
  20. 17 17
      CryptoLib/src/Asn1/ClpDerT61String.pas
  21. 18 18
      CryptoLib/src/Asn1/ClpDerUniversalString.pas
  22. 17 17
      CryptoLib/src/Asn1/ClpDerUtf8String.pas
  23. 5 5
      CryptoLib/src/Asn1/ClpDerVideotexString.pas
  24. 11 11
      CryptoLib/src/Asn1/ClpDerVisibleString.pas
  25. 12 12
      CryptoLib/src/Asn1/Iana/ClpIanaObjectIdentifiers.pas
  26. 18 18
      CryptoLib/src/Asn1/Misc/ClpMiscObjectIdentifiers.pas
  27. 47 47
      CryptoLib/src/Asn1/Nist/ClpNistObjectIdentifiers.pas
  28. 47 47
      CryptoLib/src/Asn1/RossStandart/ClpRosstandartObjectIdentifiers.pas
  29. 44 44
      CryptoLib/src/Asn1/Sec/ClpSecObjectIdentifiers.pas
  30. 14 14
      CryptoLib/src/Asn1/TeleTrust/ClpTeleTrusTObjectIdentifiers.pas
  31. 25 25
      CryptoLib/src/Asn1/X9/ClpX9ECParameters.pas
  32. 62 62
      CryptoLib/src/Asn1/X9/ClpX9ObjectIdentifiers.pas
  33. 5 5
      CryptoLib/src/Crypto/Macs/ClpHMac.pas
  34. 0 1
      CryptoLib/src/Crypto/Parameters/ClpDsaKeyParameters.pas
  35. 20 20
      CryptoLib/src/Crypto/Parameters/ClpDsaParameters.pas
  36. 5 5
      CryptoLib/src/Crypto/Parameters/ClpDsaPrivateKeyParameters.pas
  37. 5 5
      CryptoLib/src/Crypto/Parameters/ClpDsaPublicKeyParameters.pas
  38. 25 25
      CryptoLib/src/Crypto/Parameters/ClpECDomainParameters.pas
  39. 11 11
      CryptoLib/src/Crypto/Parameters/ClpECKeyParameters.pas
  40. 5 5
      CryptoLib/src/Crypto/Parameters/ClpECPrivateKeyParameters.pas
  41. 5 5
      CryptoLib/src/Crypto/Parameters/ClpECPublicKeyParameters.pas
  42. 0 2
      CryptoLib/src/Interfaces/ClpIDsaKeyParameters.pas
  43. 0 2
      CryptoLib/src/Interfaces/ClpIDsaPrivateKeyParameters.pas
  44. 0 2
      CryptoLib/src/Interfaces/ClpIDsaPublicKeyParameters.pas
  45. 0 26
      CryptoLib/src/Interfaces/ClpIDsaSigner.pas
  46. 0 13
      CryptoLib/src/Interfaces/ClpIECNRSigner.pas
  47. 253 253
      CryptoLib/src/Math/ClpBigInteger.pas
  48. 20 28
      CryptoLib/src/Math/EC/ClpECAlgorithms.pas
  49. 35 35
      CryptoLib/src/Math/EC/ClpECCurve.pas
  50. 30 30
      CryptoLib/src/Math/EC/ClpECFieldElement.pas
  51. 25 25
      CryptoLib/src/Math/EC/ClpECPoint.pas
  52. 68 68
      CryptoLib/src/Math/EC/ClpLongArray.pas
  53. 1 1
      CryptoLib/src/Math/EC/Multiplier/ClpWNafUtilities.pas
  54. 6 6
      CryptoLib/src/Security/ClpMacUtilities.pas
  55. 11 11
      CryptoLib/src/Security/ClpSecureRandom.pas
  56. 5 5
      CryptoLib/src/Utils/ClpTimes.pas
  57. 15 14
      CryptoLib/src/Utils/Randoms/ClpPcgRandomMinimal.pas

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

@@ -183,7 +183,6 @@ var
   RandomInstance: ISecureRandom;
   Lcurve: IX9ECParameters;
   ecSpec: IECDomainParameters;
-  KeyPair: IAsymmetricCipherKeyPair;
 begin
   // Set Up EC Key Pair
 

+ 10 - 10
CryptoLib/src/Asn1/ClpAsn1OctetString.pas

@@ -108,6 +108,16 @@ uses
 
 { TAsn1OctetString }
 
+function TAsn1OctetString.GetStr: TCryptoLibByteArray;
+begin
+  result := FStr;
+end;
+
+function TAsn1OctetString.GetParser: IAsn1OctetStringParser;
+begin
+  result := Self as IAsn1OctetStringParser;
+end;
+
 constructor TAsn1OctetString.Create(Str: TCryptoLibByteArray);
 begin
   Inherited Create();
@@ -201,16 +211,6 @@ begin
   result := TBytesStream.Create(Str);
 end;
 
-function TAsn1OctetString.GetParser: IAsn1OctetStringParser;
-begin
-  result := Self as IAsn1OctetStringParser;
-end;
-
-function TAsn1OctetString.GetStr: TCryptoLibByteArray;
-begin
-  result := FStr;
-end;
-
 function TAsn1OctetString.ToString: String;
 begin
   result := '#' + THex.Encode(Str);

+ 10 - 10
CryptoLib/src/Asn1/ClpAsn1TaggedObject.pas

@@ -140,6 +140,16 @@ begin
   result := Nil;
 end;
 
+function TAsn1TaggedObject.GetTagNo: Int32;
+begin
+  result := FtagNo;
+end;
+
+function TAsn1TaggedObject.Getexplicitly: Boolean;
+begin
+  result := Fexplicitly;
+end;
+
 function TAsn1TaggedObject.Asn1Equals(const asn1Object: IAsn1Object): Boolean;
 var
   other: IAsn1TaggedObject;
@@ -196,11 +206,6 @@ begin
   Fobj := obj;
 end;
 
-function TAsn1TaggedObject.Getexplicitly: Boolean;
-begin
-  result := Fexplicitly;
-end;
-
 class function TAsn1TaggedObject.GetInstance(obj: TObject): IAsn1TaggedObject;
 begin
   if ((obj = Nil) or (obj is TAsn1TaggedObject)) then
@@ -265,11 +270,6 @@ begin
 
 end;
 
-function TAsn1TaggedObject.GetTagNo: Int32;
-begin
-  result := FtagNo;
-end;
-
 class function TAsn1TaggedObject.IsConstructed(isExplicit: Boolean;
   const obj: IAsn1Object): Boolean;
 var

+ 5 - 5
CryptoLib/src/Asn1/ClpBerSequence.pas

@@ -86,6 +86,11 @@ implementation
 
 { TBerSequence }
 
+class function TBerSequence.GetEmpty: IBerSequence;
+begin
+  result := FEmpty;
+end;
+
 constructor TBerSequence.Create(const obj: IAsn1Encodable);
 begin
   Inherited Create(obj);
@@ -158,9 +163,4 @@ begin
 
 end;
 
-class function TBerSequence.GetEmpty: IBerSequence;
-begin
-  result := FEmpty;
-end;
-
 end.

+ 5 - 5
CryptoLib/src/Asn1/ClpBerSet.pas

@@ -91,6 +91,11 @@ implementation
 
 { TBerSet }
 
+class function TBerSet.GetEmpty: IBerSet;
+begin
+  result := FEmpty;
+end;
+
 constructor TBerSet.Create;
 begin
   Inherited Create();
@@ -162,11 +167,6 @@ begin
   end;
 end;
 
-class function TBerSet.GetEmpty: IBerSet;
-begin
-  result := FEmpty;
-end;
-
 class function TBerSet.FromVector(const v: IAsn1EncodableVector): IBerSet;
 begin
   if v.Count < 1 then

+ 20 - 22
CryptoLib/src/Asn1/ClpDerApplicationSpecific.pas

@@ -108,6 +108,21 @@ implementation
 
 { TDerApplicationSpecific }
 
+function TDerApplicationSpecific.GetApplicationTag: Int32;
+begin
+  result := Ftag;
+end;
+
+function TDerApplicationSpecific.GetContents: TCryptoLibByteArray;
+begin
+  result := Foctets;
+end;
+
+function TDerApplicationSpecific.isConstructed: Boolean;
+begin
+  result := FisConstructed;
+end;
+
 function TDerApplicationSpecific.GetLengthOfHeader
   (data: TCryptoLibByteArray): Int32;
 var
@@ -181,13 +196,11 @@ function TDerApplicationSpecific.Asn1GetHashCode: Int32;
 var
   HashCode: Int32;
 begin
-  if isConstructed then
-  begin
-    HashCode := 1
-  end
-  else
-  begin
-    HashCode := 0;
+  case isConstructed of
+    true:
+      HashCode := 1;
+    false:
+      HashCode := 0;
   end;
   result := HashCode xor Ftag xor TArrayUtils.GetArrayHashCode(Foctets);
 end;
@@ -276,16 +289,6 @@ begin
   end;
 end;
 
-function TDerApplicationSpecific.GetApplicationTag: Int32;
-begin
-  result := Ftag;
-end;
-
-function TDerApplicationSpecific.GetContents: TCryptoLibByteArray;
-begin
-  result := Foctets;
-end;
-
 function TDerApplicationSpecific.GetObject: IAsn1Object;
 begin
   result := FromByteArray(GetContents());
@@ -311,11 +314,6 @@ begin
   result := FromByteArray(tmp);
 end;
 
-function TDerApplicationSpecific.isConstructed: Boolean;
-begin
-  result := FisConstructed;
-end;
-
 class function TDerApplicationSpecific.ReplaceTagNumber(newTag: Int32;
   input: TCryptoLibByteArray): TCryptoLibByteArray;
 var

+ 26 - 26
CryptoLib/src/Asn1/ClpDerBitString.pas

@@ -63,14 +63,14 @@ type
     FmData: TCryptoLibByteArray;
     FmPadBits: Int32;
 
-    function GetmData: TCryptoLibByteArray; inline;
-    property mData: TCryptoLibByteArray read GetmData;
-
     function GetmPadBits: Int32; inline;
-    property mPadBits: Int32 read GetmPadBits;
+    function GetmData: TCryptoLibByteArray; inline;
 
     function Asn1GetHashCode(): Int32; override;
     function Asn1Equals(const asn1Object: IAsn1Object): Boolean; override;
+
+    property mPadBits: Int32 read GetmPadBits;
+    property mData: TCryptoLibByteArray read GetmData;
   public
 
     constructor Create(data: TCryptoLibByteArray; padBits: Int32); overload;
@@ -153,6 +153,16 @@ begin
   end;
 end;
 
+function TDerBitString.GetmData: TCryptoLibByteArray;
+begin
+  result := FmData;
+end;
+
+function TDerBitString.GetmPadBits: Int32;
+begin
+  result := FmPadBits;
+end;
+
 function TDerBitString.GetOctets: TCryptoLibByteArray;
 begin
   if (mPadBits <> 0) then
@@ -321,6 +331,18 @@ begin
 
 end;
 
+class function TDerBitString.GetInstance(obj: TObject): IDerBitString;
+begin
+  if ((obj = Nil) or (obj is TDerBitString)) then
+  begin
+    result := obj as TDerBitString;
+    Exit;
+  end;
+
+  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
+    [obj.ClassName]);
+end;
+
 class function TDerBitString.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerBitString;
 var
@@ -356,28 +378,6 @@ begin
   result := value;
 end;
 
-function TDerBitString.GetmData: TCryptoLibByteArray;
-begin
-  result := FmData;
-end;
-
-function TDerBitString.GetmPadBits: Int32;
-begin
-  result := FmPadBits;
-end;
-
-class function TDerBitString.GetInstance(obj: TObject): IDerBitString;
-begin
-  if ((obj = Nil) or (obj is TDerBitString)) then
-  begin
-    result := obj as TDerBitString;
-    Exit;
-  end;
-
-  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
-    [obj.ClassName]);
-end;
-
 function TDerBitString.GetString: String;
 var
   buffer: TStringList;

+ 5 - 6
CryptoLib/src/Asn1/ClpDerBmpString.pas

@@ -27,7 +27,6 @@ uses
   ClpAsn1Object,
   ClpAsn1Tags,
   ClpAsn1OctetString,
-  ClpDerOutputStream,
   ClpIProxiedInterface,
   ClpIDerBmpString,
   ClpIAsn1TaggedObject,
@@ -99,6 +98,11 @@ implementation
 
 { TDerBmpString }
 
+function TDerBmpString.GetStr: String;
+begin
+  result := FStr;
+end;
+
 function TDerBmpString.Asn1Equals(const asn1Object: IAsn1Object): Boolean;
 var
   other: IDerBmpString;
@@ -212,11 +216,6 @@ begin
     .GetOctets());
 end;
 
-function TDerBmpString.GetStr: String;
-begin
-  result := FStr;
-end;
-
 function TDerBmpString.GetString: String;
 begin
   result := FStr;

+ 13 - 15
CryptoLib/src/Asn1/ClpDerBoolean.pas

@@ -115,6 +115,11 @@ implementation
 
 { TDerBoolean }
 
+function TDerBoolean.GetIsTrue: Boolean;
+begin
+  result := Fvalue <> 0;
+end;
+
 function TDerBoolean.Asn1Equals(const asn1Object: IAsn1Object): Boolean;
 var
   other: IDerBoolean;
@@ -183,17 +188,15 @@ begin
 
   b := value[0];
 
-  if b = 0 then
-  begin
-    result := FFalse;
-  end
-  else if b = $FF then
-  begin
-    result := FTrue;
-  end
+  case b of
+    0:
+      result := FFalse;
+    $FF:
+      result := FTrue
   else
-  begin
-    result := TDerBoolean.Create(value);
+    begin
+      result := TDerBoolean.Create(value);
+    end;
   end;
 
 end;
@@ -243,11 +246,6 @@ begin
   result := FromOctetString((o as IAsn1OctetString).GetOctets());
 end;
 
-function TDerBoolean.GetIsTrue: Boolean;
-begin
-  result := Fvalue <> 0;
-end;
-
 class function TDerBoolean.GetTrue: IDerBoolean;
 begin
   result := FTrue;

+ 5 - 5
CryptoLib/src/Asn1/ClpDerEnumerated.pas

@@ -104,6 +104,11 @@ implementation
 
 { TDerEnumerated }
 
+function TDerEnumerated.GetBytes: TCryptoLibByteArray;
+begin
+  result := Fbytes;
+end;
+
 function TDerEnumerated.Asn1Equals(const asn1Object: IAsn1Object): Boolean;
 var
   other: IDerEnumerated;
@@ -193,11 +198,6 @@ begin
   result := TDerEnumerated.Create(System.Copy(enc));
 end;
 
-function TDerEnumerated.GetBytes: TCryptoLibByteArray;
-begin
-  result := Fbytes;
-end;
-
 class function TDerEnumerated.GetInstance(obj: TObject): IDerEnumerated;
 begin
   if ((obj = Nil) or (obj is TDerEnumerated)) then

+ 17 - 17
CryptoLib/src/Asn1/ClpDerGeneralString.pas

@@ -74,6 +74,11 @@ implementation
 
 { TDerGeneralString }
 
+function TDerGeneralString.GetStr: String;
+begin
+  result := FStr;
+end;
+
 function TDerGeneralString.GetOctets: TCryptoLibByteArray;
 begin
 {$IFDEF FPC}
@@ -122,6 +127,18 @@ begin
   derOut.WriteEncoded(TAsn1Tags.GeneralString, GetOctets());
 end;
 
+class function TDerGeneralString.GetInstance(obj: TObject): IDerGeneralString;
+begin
+  if ((obj = Nil) or (obj is TDerGeneralString)) then
+  begin
+    result := obj as TDerGeneralString;
+    Exit;
+  end;
+
+  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
+    [obj.ClassName]);
+end;
+
 class function TDerGeneralString.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerGeneralString;
 var
@@ -139,23 +156,6 @@ begin
     (TAsn1OctetString.GetInstance(o as TAsn1Object).GetOctets());
 end;
 
-class function TDerGeneralString.GetInstance(obj: TObject): IDerGeneralString;
-begin
-  if ((obj = Nil) or (obj is TDerGeneralString)) then
-  begin
-    result := obj as TDerGeneralString;
-    Exit;
-  end;
-
-  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
-    [obj.ClassName]);
-end;
-
-function TDerGeneralString.GetStr: String;
-begin
-  result := FStr;
-end;
-
 function TDerGeneralString.GetString: String;
 begin
   result := Str;

+ 5 - 5
CryptoLib/src/Asn1/ClpDerGraphicString.pas

@@ -106,6 +106,11 @@ implementation
 
 { TDerGraphicString }
 
+function TDerGraphicString.GetmString: TCryptoLibByteArray;
+begin
+  result := FmString;
+end;
+
 function TDerGraphicString.Asn1Equals(const asn1Object: IAsn1Object): Boolean;
 var
   other: IDerGraphicString;
@@ -180,11 +185,6 @@ begin
   end;
 end;
 
-function TDerGraphicString.GetmString: TCryptoLibByteArray;
-begin
-  result := FmString;
-end;
-
 function TDerGraphicString.GetOctets: TCryptoLibByteArray;
 begin
   result := System.Copy(mString);

+ 17 - 17
CryptoLib/src/Asn1/ClpDerIA5String.pas

@@ -133,6 +133,11 @@ implementation
 
 { TDerIA5String }
 
+function TDerIA5String.GetStr: String;
+begin
+  result := FStr;
+end;
+
 function TDerIA5String.GetOctets: TCryptoLibByteArray;
 begin
 {$IFDEF FPC}
@@ -211,6 +216,18 @@ begin
   derOut.WriteEncoded(TAsn1Tags.IA5String, GetOctets());
 end;
 
+class function TDerIA5String.GetInstance(obj: TObject): IDerIA5String;
+begin
+  if ((obj = Nil) or (obj is TDerIA5String)) then
+  begin
+    result := obj as TDerIA5String;
+    Exit;
+  end;
+
+  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
+    [obj.ClassName]);
+end;
+
 class function TDerIA5String.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerIA5String;
 var
@@ -228,23 +245,6 @@ begin
     .GetOctets());
 end;
 
-class function TDerIA5String.GetInstance(obj: TObject): IDerIA5String;
-begin
-  if ((obj = Nil) or (obj is TDerIA5String)) then
-  begin
-    result := obj as TDerIA5String;
-    Exit;
-  end;
-
-  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
-    [obj.ClassName]);
-end;
-
-function TDerIA5String.GetStr: String;
-begin
-  result := FStr;
-end;
-
 function TDerIA5String.GetString: String;
 begin
   result := Str;

+ 5 - 5
CryptoLib/src/Asn1/ClpDerInteger.pas

@@ -94,6 +94,11 @@ implementation
 
 { TDerInteger }
 
+function TDerInteger.GetBytes: TCryptoLibByteArray;
+begin
+  Result := Fbytes;
+end;
+
 class function TDerInteger.GetInstance(obj: TObject): IDerInteger;
 begin
   if ((obj = Nil) or (obj is TDerInteger)) then
@@ -165,11 +170,6 @@ begin
   derOut.WriteEncoded(TAsn1Tags.Integer, Fbytes);
 end;
 
-function TDerInteger.GetBytes: TCryptoLibByteArray;
-begin
-  Result := Fbytes;
-end;
-
 class function TDerInteger.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerInteger;
 var

+ 17 - 17
CryptoLib/src/Asn1/ClpDerNumericString.pas

@@ -135,6 +135,11 @@ implementation
 
 { TDerNumericString }
 
+function TDerNumericString.GetStr: String;
+begin
+  result := FStr;
+end;
+
 function TDerNumericString.GetOctets: TCryptoLibByteArray;
 begin
 {$IFDEF FPC}
@@ -210,6 +215,18 @@ begin
   derOut.WriteEncoded(TAsn1Tags.NumericString, GetOctets());
 end;
 
+class function TDerNumericString.GetInstance(obj: TObject): IDerNumericString;
+begin
+  if ((obj = Nil) or (obj is TDerNumericString)) then
+  begin
+    result := obj as TDerNumericString;
+    Exit;
+  end;
+
+  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
+    [obj.ClassName]);
+end;
+
 class function TDerNumericString.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerNumericString;
 var
@@ -227,23 +244,6 @@ begin
     (TAsn1OctetString.GetInstance(o as TAsn1Object).GetOctets());
 end;
 
-class function TDerNumericString.GetInstance(obj: TObject): IDerNumericString;
-begin
-  if ((obj = Nil) or (obj is TDerNumericString)) then
-  begin
-    result := obj as TDerNumericString;
-    Exit;
-  end;
-
-  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
-    [obj.ClassName]);
-end;
-
-function TDerNumericString.GetStr: String;
-begin
-  result := FStr;
-end;
-
 function TDerNumericString.GetString: String;
 begin
   result := Str;

+ 5 - 5
CryptoLib/src/Asn1/ClpDerObjectIdentifier.pas

@@ -142,6 +142,11 @@ implementation
 
 { TDerObjectIdentifier }
 
+function TDerObjectIdentifier.GetID: String;
+begin
+  result := Fidentifier;
+end;
+
 function TDerObjectIdentifier.Asn1Equals(const asn1Object: IAsn1Object)
   : Boolean;
 var
@@ -316,11 +321,6 @@ begin
   result := Fbody;
 end;
 
-function TDerObjectIdentifier.GetID: String;
-begin
-  result := Fidentifier;
-end;
-
 class function TDerObjectIdentifier.GetInstance(const obj: IAsn1TaggedObject;
   explicitly: Boolean): IDerObjectIdentifier;
 var

+ 18 - 18
CryptoLib/src/Asn1/ClpDerPrintableString.pas

@@ -137,6 +137,11 @@ implementation
 
 { TDerPrintableString }
 
+function TDerPrintableString.GetString: String;
+begin
+  result := Str;
+end;
+
 function TDerPrintableString.GetOctets: TCryptoLibByteArray;
 begin
 {$IFDEF FPC}
@@ -229,6 +234,19 @@ begin
   derOut.WriteEncoded(TAsn1Tags.PrintableString, GetOctets());
 end;
 
+class function TDerPrintableString.GetInstance(obj: TObject)
+  : IDerPrintableString;
+begin
+  if ((obj = Nil) or (obj is TDerPrintableString)) then
+  begin
+    result := obj as TDerPrintableString;
+    Exit;
+  end;
+
+  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
+    [obj.ClassName]);
+end;
+
 class function TDerPrintableString.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerPrintableString;
 var
@@ -246,27 +264,9 @@ begin
     (TAsn1OctetString.GetInstance(o as TAsn1Object).GetOctets());
 end;
 
-class function TDerPrintableString.GetInstance(obj: TObject)
-  : IDerPrintableString;
-begin
-  if ((obj = Nil) or (obj is TDerPrintableString)) then
-  begin
-    result := obj as TDerPrintableString;
-    Exit;
-  end;
-
-  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
-    [obj.ClassName]);
-end;
-
 function TDerPrintableString.GetStr: String;
 begin
   result := FStr;
 end;
 
-function TDerPrintableString.GetString: String;
-begin
-  result := Str;
-end;
-
 end.

+ 5 - 5
CryptoLib/src/Asn1/ClpDerSequence.pas

@@ -85,6 +85,11 @@ implementation
 
 { TDerSequence }
 
+class function TDerSequence.GetEmpty: IDerSequence;
+begin
+  result := FEmpty;
+end;
+
 constructor TDerSequence.Create(const obj: IAsn1Encodable);
 begin
   Inherited Create(1);
@@ -175,9 +180,4 @@ begin
 
 end;
 
-class function TDerSequence.GetEmpty: IDerSequence;
-begin
-  result := FEmpty;
-end;
-
 end.

+ 5 - 5
CryptoLib/src/Asn1/ClpDerSet.pas

@@ -91,6 +91,11 @@ implementation
 
 { TDerSet }
 
+class function TDerSet.GetEmpty: IDerSet;
+begin
+  result := FEmpty;
+end;
+
 constructor TDerSet.Create(v: array of IAsn1Encodable);
 var
   o: IAsn1Encodable;
@@ -193,11 +198,6 @@ begin
   end;
 end;
 
-class function TDerSet.GetEmpty: IDerSet;
-begin
-  result := FEmpty;
-end;
-
 class function TDerSet.FromVector(const v: IAsn1EncodableVector): IDerSet;
 begin
   if v.Count < 1 then

+ 17 - 17
CryptoLib/src/Asn1/ClpDerT61String.pas

@@ -106,6 +106,11 @@ implementation
 
 { TDerT61String }
 
+function TDerT61String.GetStr: String;
+begin
+  result := FStr;
+end;
+
 function TDerT61String.GetOctets: TCryptoLibByteArray;
 begin
 {$IFDEF FPC}
@@ -154,6 +159,18 @@ begin
   derOut.WriteEncoded(TAsn1Tags.T61String, GetOctets());
 end;
 
+class function TDerT61String.GetInstance(obj: TObject): IDerT61String;
+begin
+  if ((obj = Nil) or (obj is TDerT61String)) then
+  begin
+    result := obj as TDerT61String;
+    Exit;
+  end;
+
+  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
+    [obj.ClassName]);
+end;
+
 class function TDerT61String.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerT61String;
 var
@@ -171,23 +188,6 @@ begin
     .GetOctets());
 end;
 
-class function TDerT61String.GetInstance(obj: TObject): IDerT61String;
-begin
-  if ((obj = Nil) or (obj is TDerT61String)) then
-  begin
-    result := obj as TDerT61String;
-    Exit;
-  end;
-
-  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
-    [obj.ClassName]);
-end;
-
-function TDerT61String.GetStr: String;
-begin
-  result := FStr;
-end;
-
 function TDerT61String.GetString: String;
 begin
   result := Str;

+ 18 - 18
CryptoLib/src/Asn1/ClpDerUniversalString.pas

@@ -107,6 +107,11 @@ implementation
 
 { TDerUniversalString }
 
+function TDerUniversalString.GetStr: TCryptoLibByteArray;
+begin
+  result := FStr;
+end;
+
 function TDerUniversalString.GetOctets: TCryptoLibByteArray;
 begin
   result := System.Copy(Str);
@@ -142,6 +147,19 @@ begin
   derOut.WriteEncoded(TAsn1Tags.UniversalString, Str);
 end;
 
+class function TDerUniversalString.GetInstance(obj: TObject)
+  : IDerUniversalString;
+begin
+  if ((obj = Nil) or (obj is TDerUniversalString)) then
+  begin
+    result := obj as TDerUniversalString;
+    Exit;
+  end;
+
+  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
+    [obj.ClassName]);
+end;
+
 class function TDerUniversalString.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerUniversalString;
 var
@@ -159,24 +177,6 @@ begin
     (TAsn1OctetString.GetInstance(o as TAsn1Object).GetOctets());
 end;
 
-class function TDerUniversalString.GetInstance(obj: TObject)
-  : IDerUniversalString;
-begin
-  if ((obj = Nil) or (obj is TDerUniversalString)) then
-  begin
-    result := obj as TDerUniversalString;
-    Exit;
-  end;
-
-  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
-    [obj.ClassName]);
-end;
-
-function TDerUniversalString.GetStr: TCryptoLibByteArray;
-begin
-  result := FStr;
-end;
-
 function TDerUniversalString.GetString: String;
 var
   buffer: TStringList;

+ 17 - 17
CryptoLib/src/Asn1/ClpDerUtf8String.pas

@@ -106,6 +106,11 @@ implementation
 
 { TDerUtf8String }
 
+function TDerUtf8String.GetStr: String;
+begin
+  result := FStr;
+end;
+
 function TDerUtf8String.GetOctets: TCryptoLibByteArray;
 begin
 {$IFDEF FPC}
@@ -159,6 +164,18 @@ begin
 {$ENDIF FPC}
 end;
 
+class function TDerUtf8String.GetInstance(obj: TObject): IDerUtf8String;
+begin
+  if ((obj = Nil) or (obj is TDerUtf8String)) then
+  begin
+    result := obj as TDerUtf8String;
+    Exit;
+  end;
+
+  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
+    [obj.ClassName]);
+end;
+
 class function TDerUtf8String.GetInstance(const obj: IAsn1TaggedObject;
   isExplicit: Boolean): IDerUtf8String;
 var
@@ -176,23 +193,6 @@ begin
     .GetOctets());
 end;
 
-class function TDerUtf8String.GetInstance(obj: TObject): IDerUtf8String;
-begin
-  if ((obj = Nil) or (obj is TDerUtf8String)) then
-  begin
-    result := obj as TDerUtf8String;
-    Exit;
-  end;
-
-  raise EArgumentCryptoLibException.CreateResFmt(@SIllegalObject,
-    [obj.ClassName]);
-end;
-
-function TDerUtf8String.GetStr: String;
-begin
-  result := FStr;
-end;
-
 function TDerUtf8String.GetString: String;
 begin
   result := Str;

+ 5 - 5
CryptoLib/src/Asn1/ClpDerVideotexString.pas

@@ -106,6 +106,11 @@ implementation
 
 { TDerVideotexString }
 
+function TDerVideotexString.GetmString: TCryptoLibByteArray;
+begin
+  result := FmString;
+end;
+
 function TDerVideotexString.Asn1Equals(const asn1Object: IAsn1Object): Boolean;
 var
   other: IDerVideotexString;
@@ -180,11 +185,6 @@ begin
   end;
 end;
 
-function TDerVideotexString.GetmString: TCryptoLibByteArray;
-begin
-  result := FmString;
-end;
-
 function TDerVideotexString.GetOctets: TCryptoLibByteArray;
 begin
   result := System.Copy(mString);

+ 11 - 11
CryptoLib/src/Asn1/ClpDerVisibleString.pas

@@ -108,6 +108,11 @@ implementation
 
 { TDerVisibleString }
 
+function TDerVisibleString.GetStr: String;
+begin
+  result := FStr;
+end;
+
 function TDerVisibleString.GetOctets: TCryptoLibByteArray;
 begin
 {$IFDEF FPC}
@@ -161,15 +166,6 @@ begin
   derOut.WriteEncoded(TAsn1Tags.VisibleString, GetOctets());
 end;
 
-{$IFNDEF _FIXINSIGHT_}
-
-class function TDerVisibleString.GetInstance(const obj: IAsn1TaggedObject;
-  isExplicit: Boolean): IDerVisibleString;
-begin
-  result := GetInstance(obj.GetObject() as TAsn1Object);
-end;
-{$ENDIF}
-
 class function TDerVisibleString.GetInstance(obj: TObject): IDerVisibleString;
 var
   asn1OctetString: IAsn1OctetString;
@@ -197,10 +193,14 @@ begin
     [obj.ClassName]);
 end;
 
-function TDerVisibleString.GetStr: String;
+{$IFNDEF _FIXINSIGHT_}
+
+class function TDerVisibleString.GetInstance(const obj: IAsn1TaggedObject;
+  isExplicit: Boolean): IDerVisibleString;
 begin
-  result := FStr;
+  result := GetInstance(obj.GetObject() as TAsn1Object);
 end;
+{$ENDIF}
 
 function TDerVisibleString.GetString: String;
 begin

+ 12 - 12
CryptoLib/src/Asn1/Iana/ClpIanaObjectIdentifiers.pas

@@ -68,18 +68,6 @@ implementation
 
 { TIanaObjectIdentifiers }
 
-class procedure TIanaObjectIdentifiers.Boot;
-begin
-  FIsakmpOakley := TDerObjectIdentifier.Create('1.3.6.1.5.5.8.1');
-
-  FHmacMD5 := TDerObjectIdentifier.Create(IsakmpOakley.ID + '.1');
-  FHmacSha1 := TDerObjectIdentifier.Create(IsakmpOakley.ID + '.2');
-
-  FHmacTiger := TDerObjectIdentifier.Create(IsakmpOakley.ID + '.3');
-
-  FHmacRipeMD160 := TDerObjectIdentifier.Create(IsakmpOakley.ID + '.4');
-end;
-
 class function TIanaObjectIdentifiers.GetHmacMD5: IDerObjectIdentifier;
 begin
   result := FHmacMD5;
@@ -105,6 +93,18 @@ begin
   result := FIsakmpOakley;
 end;
 
+class procedure TIanaObjectIdentifiers.Boot;
+begin
+  FIsakmpOakley := TDerObjectIdentifier.Create('1.3.6.1.5.5.8.1');
+
+  FHmacMD5 := TDerObjectIdentifier.Create(IsakmpOakley.ID + '.1');
+  FHmacSha1 := TDerObjectIdentifier.Create(IsakmpOakley.ID + '.2');
+
+  FHmacTiger := TDerObjectIdentifier.Create(IsakmpOakley.ID + '.3');
+
+  FHmacRipeMD160 := TDerObjectIdentifier.Create(IsakmpOakley.ID + '.4');
+end;
+
 class constructor TIanaObjectIdentifiers.IanaObjectIdentifiers;
 begin
   TIanaObjectIdentifiers.Boot;

+ 18 - 18
CryptoLib/src/Asn1/Misc/ClpMiscObjectIdentifiers.pas

@@ -72,24 +72,6 @@ implementation
 
 { TMiscObjectIdentifiers }
 
-class procedure TMiscObjectIdentifiers.Boot;
-begin
-  //
-  // Blake2b and Blake2s
-  //
-  Fblake2 := TDerObjectIdentifier.Create('1.3.6.1.4.1.1722.12.2');
-
-  Fid_blake2b160 := blake2.Branch('1.5');
-  Fid_blake2b256 := blake2.Branch('1.8');
-  Fid_blake2b384 := blake2.Branch('1.12');
-  Fid_blake2b512 := blake2.Branch('1.16');
-
-  Fid_blake2s128 := blake2.Branch('2.4');
-  Fid_blake2s160 := blake2.Branch('2.5');
-  Fid_blake2s224 := blake2.Branch('2.7');
-  Fid_blake2s256 := blake2.Branch('2.8');
-end;
-
 class function TMiscObjectIdentifiers.Getblake2: IDerObjectIdentifier;
 begin
   result := Fblake2;
@@ -135,6 +117,24 @@ begin
   result := Fid_blake2s256;
 end;
 
+class procedure TMiscObjectIdentifiers.Boot;
+begin
+  //
+  // Blake2b and Blake2s
+  //
+  Fblake2 := TDerObjectIdentifier.Create('1.3.6.1.4.1.1722.12.2');
+
+  Fid_blake2b160 := blake2.Branch('1.5');
+  Fid_blake2b256 := blake2.Branch('1.8');
+  Fid_blake2b384 := blake2.Branch('1.12');
+  Fid_blake2b512 := blake2.Branch('1.16');
+
+  Fid_blake2s128 := blake2.Branch('2.4');
+  Fid_blake2s160 := blake2.Branch('2.5');
+  Fid_blake2s224 := blake2.Branch('2.7');
+  Fid_blake2s256 := blake2.Branch('2.8');
+end;
+
 class constructor TMiscObjectIdentifiers.MiscObjectIdentifiers;
 begin
   TMiscObjectIdentifiers.Boot;

+ 47 - 47
CryptoLib/src/Asn1/Nist/ClpNistObjectIdentifiers.pas

@@ -144,53 +144,6 @@ implementation
 
 { TNistObjectIdentifiers }
 
-class procedure TNistObjectIdentifiers.Boot;
-begin
-  FNistAlgorithm := TDerObjectIdentifier.Create('2.16.840.1.101.3.4');
-  FHashAlgs := NistAlgorithm.Branch('2');
-
-  FIdSha256 := HashAlgs.Branch('1');
-  FIdSha384 := HashAlgs.Branch('2');
-  FIdSha512 := HashAlgs.Branch('3');
-  FIdSha224 := HashAlgs.Branch('4');
-  FIdSha512_224 := HashAlgs.Branch('5');
-  FIdSha512_256 := HashAlgs.Branch('6');
-  FIdSha3_224 := HashAlgs.Branch('7');
-  FIdSha3_256 := HashAlgs.Branch('8');
-  FIdSha3_384 := HashAlgs.Branch('9');
-  FIdSha3_512 := HashAlgs.Branch('10');
-
-  FIdHMacWithSha3_224 := HashAlgs.Branch('13');
-  FIdHMacWithSha3_256 := HashAlgs.Branch('14');
-  FIdHMacWithSha3_384 := HashAlgs.Branch('15');
-  FIdHMacWithSha3_512 := HashAlgs.Branch('16');
-
-  FAES := TDerObjectIdentifier.Create(NistAlgorithm.id + '.1');
-
-  FIdAES128Ecb := TDerObjectIdentifier.Create(AES.id + '.1');
-  FIdAes128Cbc := TDerObjectIdentifier.Create(AES.id + '.2');
-  FIdAes128Ofb := TDerObjectIdentifier.Create(AES.id + '.3');
-  FIdAes128Cfb := TDerObjectIdentifier.Create(AES.id + '.4');
-  FidAes192Ecb := TDerObjectIdentifier.Create(AES.id + '.21');
-  FIdAes192Cbc := TDerObjectIdentifier.Create(AES.id + '.22');
-  FIdAes192Ofb := TDerObjectIdentifier.Create(AES.id + '.23');
-  FIdAes192Cfb := TDerObjectIdentifier.Create(AES.id + '.24');
-  FIdAes256Ecb := TDerObjectIdentifier.Create(AES.id + '.41');
-  FIdAes256Cbc := TDerObjectIdentifier.Create(AES.id + '.42');
-  FIdAes256Ofb := TDerObjectIdentifier.Create(AES.id + '.43');
-  FIdAes256Cfb := TDerObjectIdentifier.Create(AES.id + '.44');
-
-  //
-  // signatures
-  //
-  FIdDsaWithSha2 := TDerObjectIdentifier.Create(NistAlgorithm.id + '.3');
-
-  FDsaWithSha224 := TDerObjectIdentifier.Create(IdDsaWithSha2.id + '.1');
-  FDsaWithSha256 := TDerObjectIdentifier.Create(IdDsaWithSha2.id + '.2');
-  FDsaWithSha384 := TDerObjectIdentifier.Create(IdDsaWithSha2.id + '.3');
-  FDsaWithSha512 := TDerObjectIdentifier.Create(IdDsaWithSha2.id + '.4');
-end;
-
 class function TNistObjectIdentifiers.GetAES: IDerObjectIdentifier;
 begin
   result := FAES;
@@ -370,4 +323,51 @@ begin
   TNistObjectIdentifiers.Boot;
 end;
 
+class procedure TNistObjectIdentifiers.Boot;
+begin
+  FNistAlgorithm := TDerObjectIdentifier.Create('2.16.840.1.101.3.4');
+  FHashAlgs := NistAlgorithm.Branch('2');
+
+  FIdSha256 := HashAlgs.Branch('1');
+  FIdSha384 := HashAlgs.Branch('2');
+  FIdSha512 := HashAlgs.Branch('3');
+  FIdSha224 := HashAlgs.Branch('4');
+  FIdSha512_224 := HashAlgs.Branch('5');
+  FIdSha512_256 := HashAlgs.Branch('6');
+  FIdSha3_224 := HashAlgs.Branch('7');
+  FIdSha3_256 := HashAlgs.Branch('8');
+  FIdSha3_384 := HashAlgs.Branch('9');
+  FIdSha3_512 := HashAlgs.Branch('10');
+
+  FIdHMacWithSha3_224 := HashAlgs.Branch('13');
+  FIdHMacWithSha3_256 := HashAlgs.Branch('14');
+  FIdHMacWithSha3_384 := HashAlgs.Branch('15');
+  FIdHMacWithSha3_512 := HashAlgs.Branch('16');
+
+  FAES := TDerObjectIdentifier.Create(NistAlgorithm.id + '.1');
+
+  FIdAES128Ecb := TDerObjectIdentifier.Create(AES.id + '.1');
+  FIdAes128Cbc := TDerObjectIdentifier.Create(AES.id + '.2');
+  FIdAes128Ofb := TDerObjectIdentifier.Create(AES.id + '.3');
+  FIdAes128Cfb := TDerObjectIdentifier.Create(AES.id + '.4');
+  FidAes192Ecb := TDerObjectIdentifier.Create(AES.id + '.21');
+  FIdAes192Cbc := TDerObjectIdentifier.Create(AES.id + '.22');
+  FIdAes192Ofb := TDerObjectIdentifier.Create(AES.id + '.23');
+  FIdAes192Cfb := TDerObjectIdentifier.Create(AES.id + '.24');
+  FIdAes256Ecb := TDerObjectIdentifier.Create(AES.id + '.41');
+  FIdAes256Cbc := TDerObjectIdentifier.Create(AES.id + '.42');
+  FIdAes256Ofb := TDerObjectIdentifier.Create(AES.id + '.43');
+  FIdAes256Cfb := TDerObjectIdentifier.Create(AES.id + '.44');
+
+  //
+  // signatures
+  //
+  FIdDsaWithSha2 := TDerObjectIdentifier.Create(NistAlgorithm.id + '.3');
+
+  FDsaWithSha224 := TDerObjectIdentifier.Create(IdDsaWithSha2.id + '.1');
+  FDsaWithSha256 := TDerObjectIdentifier.Create(IdDsaWithSha2.id + '.2');
+  FDsaWithSha384 := TDerObjectIdentifier.Create(IdDsaWithSha2.id + '.3');
+  FDsaWithSha512 := TDerObjectIdentifier.Create(IdDsaWithSha2.id + '.4');
+end;
+
 end.

+ 47 - 47
CryptoLib/src/Asn1/RossStandart/ClpRosstandartObjectIdentifiers.pas

@@ -142,53 +142,6 @@ begin
   result := Frosstandart;
 end;
 
-class procedure TRosstandartObjectIdentifiers.Boot;
-begin
-  Frosstandart := TDerObjectIdentifier.Create('1.2.643.7');
-
-  Fid_tc26 := rosstandart.Branch('1');
-
-  Fid_tc26_gost_3411_12_256 := id_tc26.Branch('1.2.2');
-
-  Fid_tc26_gost_3411_12_512 := id_tc26.Branch('1.2.3');
-
-  Fid_tc26_hmac_gost_3411_12_256 := id_tc26.Branch('1.4.1');
-
-  Fid_tc26_hmac_gost_3411_12_512 := id_tc26.Branch('1.4.2');
-
-  Fid_tc26_gost_3410_12_256 := id_tc26.Branch('1.1.1');
-
-  Fid_tc26_gost_3410_12_512 := id_tc26.Branch('1.1.2');
-
-  Fid_tc26_signwithdigest_gost_3410_12_256 := id_tc26.Branch('1.3.2');
-
-  Fid_tc26_signwithdigest_gost_3410_12_512 := id_tc26.Branch('1.3.3');
-
-  Fid_tc26_agreement := id_tc26.Branch('1.6');
-
-  Fid_tc26_agreement_gost_3410_12_256 := id_tc26_agreement.Branch('1');
-
-  Fid_tc26_agreement_gost_3410_12_512 := id_tc26_agreement.Branch('2');
-
-  Fid_tc26_gost_3410_12_256_paramSet := id_tc26.Branch('2.1.1');
-
-  Fid_tc26_gost_3410_12_256_paramSetA :=
-    id_tc26_gost_3410_12_256_paramSet.Branch('1');
-
-  Fid_tc26_gost_3410_12_512_paramSet := id_tc26.Branch('2.1.2');
-
-  Fid_tc26_gost_3410_12_512_paramSetA :=
-    id_tc26_gost_3410_12_512_paramSet.Branch('1');
-
-  Fid_tc26_gost_3410_12_512_paramSetB :=
-    id_tc26_gost_3410_12_512_paramSet.Branch('2');
-
-  Fid_tc26_gost_3410_12_512_paramSetC :=
-    id_tc26_gost_3410_12_512_paramSet.Branch('3');
-
-  Fid_tc26_gost_28147_param_Z := id_tc26.Branch('2.5.1.1');
-end;
-
 class function TRosstandartObjectIdentifiers.Getid_tc26: IDerObjectIdentifier;
 begin
   result := Fid_tc26;
@@ -302,4 +255,51 @@ begin
   result := Fid_tc26_signwithdigest_gost_3410_12_512;
 end;
 
+class procedure TRosstandartObjectIdentifiers.Boot;
+begin
+  Frosstandart := TDerObjectIdentifier.Create('1.2.643.7');
+
+  Fid_tc26 := rosstandart.Branch('1');
+
+  Fid_tc26_gost_3411_12_256 := id_tc26.Branch('1.2.2');
+
+  Fid_tc26_gost_3411_12_512 := id_tc26.Branch('1.2.3');
+
+  Fid_tc26_hmac_gost_3411_12_256 := id_tc26.Branch('1.4.1');
+
+  Fid_tc26_hmac_gost_3411_12_512 := id_tc26.Branch('1.4.2');
+
+  Fid_tc26_gost_3410_12_256 := id_tc26.Branch('1.1.1');
+
+  Fid_tc26_gost_3410_12_512 := id_tc26.Branch('1.1.2');
+
+  Fid_tc26_signwithdigest_gost_3410_12_256 := id_tc26.Branch('1.3.2');
+
+  Fid_tc26_signwithdigest_gost_3410_12_512 := id_tc26.Branch('1.3.3');
+
+  Fid_tc26_agreement := id_tc26.Branch('1.6');
+
+  Fid_tc26_agreement_gost_3410_12_256 := id_tc26_agreement.Branch('1');
+
+  Fid_tc26_agreement_gost_3410_12_512 := id_tc26_agreement.Branch('2');
+
+  Fid_tc26_gost_3410_12_256_paramSet := id_tc26.Branch('2.1.1');
+
+  Fid_tc26_gost_3410_12_256_paramSetA :=
+    id_tc26_gost_3410_12_256_paramSet.Branch('1');
+
+  Fid_tc26_gost_3410_12_512_paramSet := id_tc26.Branch('2.1.2');
+
+  Fid_tc26_gost_3410_12_512_paramSetA :=
+    id_tc26_gost_3410_12_512_paramSet.Branch('1');
+
+  Fid_tc26_gost_3410_12_512_paramSetB :=
+    id_tc26_gost_3410_12_512_paramSet.Branch('2');
+
+  Fid_tc26_gost_3410_12_512_paramSetC :=
+    id_tc26_gost_3410_12_512_paramSet.Branch('3');
+
+  Fid_tc26_gost_28147_param_Z := id_tc26.Branch('2.5.1.1');
+end;
+
 end.

+ 44 - 44
CryptoLib/src/Asn1/Sec/ClpSecObjectIdentifiers.pas

@@ -130,50 +130,6 @@ implementation
 
 { TClpSecObjectIdentifiers }
 
-class procedure TSecObjectIdentifiers.Boot;
-begin
-  FEllipticCurve := TDerObjectIdentifier.Create('1.3.132.0');
-
-  FSecT163k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.1');
-  FSecT163r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.2');
-  FSecT239k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.3');
-  FSecT113r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.4');
-  FSecT113r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.5');
-  FSecP112r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.6');
-  FSecP112r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.7');
-  FSecP160r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.8');
-  FSecP160k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.9');
-  FSecP256k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.10');
-  FSecT163r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.15');
-  FSecT283k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.16');
-  FSecT283r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.17');
-  FSecT131r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.22');
-  FSecT131r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.23');
-  FSecT193r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.24');
-  FSecT193r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.25');
-  FSecT233k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.26');
-  FSecT233r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.27');
-  FSecP128r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.28');
-  FSecP128r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.29');
-  FSecP160r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.30');
-  FSecP192k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.31');
-  FSecP224k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.32');
-  FSecP224r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.33');
-  FSecP384r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.34');
-  FSecP521r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.35');
-  FSecT409k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.36');
-  FSecT409r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.37');
-  FSecT571k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.38');
-  FSecT571r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.39');
-
-  TX9ObjectIdentifiers.Boot;
-
-  FSecP192r1 := TX9ObjectIdentifiers.Prime192v1;
-
-  FSecP256r1 := TX9ObjectIdentifiers.Prime256v1;
-
-end;
-
 class function TSecObjectIdentifiers.GetEllipticCurve: IDerObjectIdentifier;
 begin
   result := FEllipticCurve;
@@ -344,6 +300,50 @@ begin
   result := FSecT571r1;
 end;
 
+class procedure TSecObjectIdentifiers.Boot;
+begin
+  FEllipticCurve := TDerObjectIdentifier.Create('1.3.132.0');
+
+  FSecT163k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.1');
+  FSecT163r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.2');
+  FSecT239k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.3');
+  FSecT113r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.4');
+  FSecT113r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.5');
+  FSecP112r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.6');
+  FSecP112r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.7');
+  FSecP160r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.8');
+  FSecP160k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.9');
+  FSecP256k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.10');
+  FSecT163r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.15');
+  FSecT283k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.16');
+  FSecT283r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.17');
+  FSecT131r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.22');
+  FSecT131r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.23');
+  FSecT193r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.24');
+  FSecT193r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.25');
+  FSecT233k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.26');
+  FSecT233r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.27');
+  FSecP128r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.28');
+  FSecP128r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.29');
+  FSecP160r2 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.30');
+  FSecP192k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.31');
+  FSecP224k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.32');
+  FSecP224r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.33');
+  FSecP384r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.34');
+  FSecP521r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.35');
+  FSecT409k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.36');
+  FSecT409r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.37');
+  FSecT571k1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.38');
+  FSecT571r1 := TDerObjectIdentifier.Create(EllipticCurve.Id + '.39');
+
+  TX9ObjectIdentifiers.Boot;
+
+  FSecP192r1 := TX9ObjectIdentifiers.Prime192v1;
+
+  FSecP256r1 := TX9ObjectIdentifiers.Prime256v1;
+
+end;
+
 class constructor TSecObjectIdentifiers.SecObjectIdentifiers;
 begin
   TSecObjectIdentifiers.Boot;

+ 14 - 14
CryptoLib/src/Asn1/TeleTrust/ClpTeleTrusTObjectIdentifiers.pas

@@ -71,20 +71,6 @@ begin
   result := FTeleTrusTAlgorithm;
 end;
 
-class procedure TTeleTrusTObjectIdentifiers.Boot;
-begin
-  FTeleTrusTAlgorithm := TDerObjectIdentifier.Create('1.3.36.3');
-  FRipeMD160 := TDerObjectIdentifier.Create(TeleTrusTAlgorithm.ID + '.2.1');
-  FRipeMD128 := TDerObjectIdentifier.Create(TeleTrusTAlgorithm.ID + '.2.2');
-  FRipeMD256 := TDerObjectIdentifier.Create(TeleTrusTAlgorithm.ID + '.2.3');
-
-  FECSign := TDerObjectIdentifier.Create(TeleTrusTAlgorithm.ID + '.3.2');
-
-  FECSignWithSha1 := TDerObjectIdentifier.Create(ECSign.ID + '.1');
-  FECSignWithRipeMD160 := TDerObjectIdentifier.Create(ECSign.ID + '.2');
-
-end;
-
 class function TTeleTrusTObjectIdentifiers.GetECSign: IDerObjectIdentifier;
 begin
   result := FECSign;
@@ -117,6 +103,20 @@ begin
   result := FRipeMD256;
 end;
 
+class procedure TTeleTrusTObjectIdentifiers.Boot;
+begin
+  FTeleTrusTAlgorithm := TDerObjectIdentifier.Create('1.3.36.3');
+  FRipeMD160 := TDerObjectIdentifier.Create(TeleTrusTAlgorithm.ID + '.2.1');
+  FRipeMD128 := TDerObjectIdentifier.Create(TeleTrusTAlgorithm.ID + '.2.2');
+  FRipeMD256 := TDerObjectIdentifier.Create(TeleTrusTAlgorithm.ID + '.2.3');
+
+  FECSign := TDerObjectIdentifier.Create(TeleTrusTAlgorithm.ID + '.3.2');
+
+  FECSignWithSha1 := TDerObjectIdentifier.Create(ECSign.ID + '.1');
+  FECSignWithRipeMD160 := TDerObjectIdentifier.Create(ECSign.ID + '.2');
+
+end;
+
 class constructor TTeleTrusTObjectIdentifiers.TeleTrusTObjectIdentifiers;
 begin
   TTeleTrusTObjectIdentifiers.Boot;

+ 25 - 25
CryptoLib/src/Asn1/X9/ClpX9ECParameters.pas

@@ -108,6 +108,31 @@ implementation
 
 { TX9ECParameters }
 
+function TX9ECParameters.GetBaseEntry: IX9ECPoint;
+begin
+  Result := Fg;
+end;
+
+function TX9ECParameters.GetFieldIDEntry: IX9FieldID;
+begin
+  Result := FfieldID;
+end;
+
+function TX9ECParameters.GetG: IECPoint;
+begin
+  Result := Fg.Point;
+end;
+
+function TX9ECParameters.GetH: TBigInteger;
+begin
+  Result := Fh;
+end;
+
+function TX9ECParameters.GetCurve: IECCurve;
+begin
+  Result := Fcurve;
+end;
+
 constructor TX9ECParameters.Create(const curve: IECCurve; const g: IX9ECPoint;
   const n, h: TBigInteger);
 begin
@@ -214,36 +239,11 @@ begin
   Create(curve, g, n, h, Nil);
 end;
 
-function TX9ECParameters.GetBaseEntry: IX9ECPoint;
-begin
-  Result := Fg;
-end;
-
-function TX9ECParameters.GetCurve: IECCurve;
-begin
-  Result := Fcurve;
-end;
-
 function TX9ECParameters.GetCurveEntry: IX9Curve;
 begin
   Result := TX9Curve.Create(Fcurve, Fseed);
 end;
 
-function TX9ECParameters.GetFieldIDEntry: IX9FieldID;
-begin
-  Result := FfieldID;
-end;
-
-function TX9ECParameters.GetG: IECPoint;
-begin
-  Result := Fg.Point;
-end;
-
-function TX9ECParameters.GetH: TBigInteger;
-begin
-  Result := Fh;
-end;
-
 class function TX9ECParameters.GetInstance(obj: TObject): IX9ECParameters;
 var
   instance: IX9ECParameters;

+ 62 - 62
CryptoLib/src/Asn1/X9/ClpX9ObjectIdentifiers.pas

@@ -132,68 +132,6 @@ implementation
 
 { TX9ObjectIdentifiers }
 
-class procedure TX9ObjectIdentifiers.Boot;
-begin
-  Fansi_X9_62 := TDerObjectIdentifier.Create(AnsiX962);
-
-  FIdFieldType := ansi_X9_62.Branch('1');
-
-  FPrimeField := IdFieldType.Branch('1');
-
-  FCharacteristicTwoField := IdFieldType.Branch('2');
-
-  FGNBasis := CharacteristicTwoField.Branch('3.1');
-  FTPBasis := CharacteristicTwoField.Branch('3.2');
-  FPPBasis := CharacteristicTwoField.Branch('3.3');
-
-  Fid_ecSigType := ansi_X9_62.Branch('4');
-  //
-  FECDsaWithSha1 := id_ecSigType.Branch('1');
-
-  Fid_publicKeyType := ansi_X9_62.Branch('2');
-
-  FIdECPublicKey := id_publicKeyType.Branch('1');
-
-  FECDsaWithSha2 := id_ecSigType.Branch('3');
-
-  FECDsaWithSha224 := ECDsaWithSha2.Branch('1');
-  FECDsaWithSha256 := ECDsaWithSha2.Branch('2');
-  FECDsaWithSha384 := ECDsaWithSha2.Branch('3');
-  FECDsaWithSha512 := ECDsaWithSha2.Branch('4');
-  //
-  //
-  // named curves
-  //
-  FEllipticCurve := ansi_X9_62.Branch('3');
-
-  //
-  // Prime
-  //
-  FPrimeCurve := EllipticCurve.Branch('1');
-
-  FPrime192v1 := PrimeCurve.Branch('1');
-  FPrime192v2 := PrimeCurve.Branch('2');
-  FPrime192v3 := PrimeCurve.Branch('3');
-  FPrime239v1 := PrimeCurve.Branch('4');
-  FPrime239v2 := PrimeCurve.Branch('5');
-  FPrime239v3 := PrimeCurve.Branch('6');
-  FPrime256v1 := PrimeCurve.Branch('7');
-
-  //
-  // DSA
-  //
-  // dsapublicnumber OBJECT IDENTIFIER ::= { iso(1) member-body(2)
-  // us(840) ansi-x957(10040) number-type(4) 1 }
-  FIdDsa := TDerObjectIdentifier.Create('1.2.840.10040.4.1');
-
-  // /**
-  // *   id-dsa-with-sha1 OBJECT IDENTIFIER ::=  { iso(1) member-body(2)
-  // *         us(840) x9-57 (10040) x9cm(4) 3 }
-  // */
-  FIdDsaWithSha1 := TDerObjectIdentifier.Create('1.2.840.10040.4.3');
-
-end;
-
 class function TX9ObjectIdentifiers.Getansi_X9_62: IDerObjectIdentifier;
 begin
   result := Fansi_X9_62;
@@ -330,6 +268,68 @@ begin
   result := FPrimeCurve;
 end;
 
+class procedure TX9ObjectIdentifiers.Boot;
+begin
+  Fansi_X9_62 := TDerObjectIdentifier.Create(AnsiX962);
+
+  FIdFieldType := ansi_X9_62.Branch('1');
+
+  FPrimeField := IdFieldType.Branch('1');
+
+  FCharacteristicTwoField := IdFieldType.Branch('2');
+
+  FGNBasis := CharacteristicTwoField.Branch('3.1');
+  FTPBasis := CharacteristicTwoField.Branch('3.2');
+  FPPBasis := CharacteristicTwoField.Branch('3.3');
+
+  Fid_ecSigType := ansi_X9_62.Branch('4');
+  //
+  FECDsaWithSha1 := id_ecSigType.Branch('1');
+
+  Fid_publicKeyType := ansi_X9_62.Branch('2');
+
+  FIdECPublicKey := id_publicKeyType.Branch('1');
+
+  FECDsaWithSha2 := id_ecSigType.Branch('3');
+
+  FECDsaWithSha224 := ECDsaWithSha2.Branch('1');
+  FECDsaWithSha256 := ECDsaWithSha2.Branch('2');
+  FECDsaWithSha384 := ECDsaWithSha2.Branch('3');
+  FECDsaWithSha512 := ECDsaWithSha2.Branch('4');
+  //
+  //
+  // named curves
+  //
+  FEllipticCurve := ansi_X9_62.Branch('3');
+
+  //
+  // Prime
+  //
+  FPrimeCurve := EllipticCurve.Branch('1');
+
+  FPrime192v1 := PrimeCurve.Branch('1');
+  FPrime192v2 := PrimeCurve.Branch('2');
+  FPrime192v3 := PrimeCurve.Branch('3');
+  FPrime239v1 := PrimeCurve.Branch('4');
+  FPrime239v2 := PrimeCurve.Branch('5');
+  FPrime239v3 := PrimeCurve.Branch('6');
+  FPrime256v1 := PrimeCurve.Branch('7');
+
+  //
+  // DSA
+  //
+  // dsapublicnumber OBJECT IDENTIFIER ::= { iso(1) member-body(2)
+  // us(840) ansi-x957(10040) number-type(4) 1 }
+  FIdDsa := TDerObjectIdentifier.Create('1.2.840.10040.4.1');
+
+  // /**
+  // *   id-dsa-with-sha1 OBJECT IDENTIFIER ::=  { iso(1) member-body(2)
+  // *         us(840) x9-57 (10040) x9cm(4) 3 }
+  // */
+  FIdDsaWithSha1 := TDerObjectIdentifier.Create('1.2.840.10040.4.3');
+
+end;
+
 class constructor TX9ObjectIdentifiers.X9ObjectIdentifiers;
 begin
   TX9ObjectIdentifiers.Boot;

+ 5 - 5
CryptoLib/src/Crypto/Macs/ClpHMac.pas

@@ -74,6 +74,11 @@ implementation
 
 { THMac }
 
+function THMac.GetMacSize: Int32;
+begin
+  result := FHMAC.HashSize;
+end;
+
 procedure THMac.BlockUpdate(input: TCryptoLibByteArray; inOff, len: Int32);
 begin
   FHMAC.TransformBytes(input, inOff, len);
@@ -114,11 +119,6 @@ begin
   result := FDigest.Name + '/HMAC';
 end;
 
-function THMac.GetMacSize: Int32;
-begin
-  result := FHMAC.HashSize;
-end;
-
 function THMac.GetUnderlyingDigest: IDigest;
 begin
   result := FDigest;

+ 0 - 1
CryptoLib/src/Crypto/Parameters/ClpDsaKeyParameters.pas

@@ -24,7 +24,6 @@ interface
 uses
   ClpIDsaParameters,
   ClpIDsaKeyParameters,
-  ClpIAsymmetricKeyParameter,
   ClpAsymmetricKeyParameter;
 
 type

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

@@ -67,6 +67,26 @@ implementation
 
 { TDsaParameters }
 
+function TDsaParameters.GetG: TBigInteger;
+begin
+  result := Fg;
+end;
+
+function TDsaParameters.GetP: TBigInteger;
+begin
+  result := Fp;
+end;
+
+function TDsaParameters.GetQ: TBigInteger;
+begin
+  result := Fq;
+end;
+
+function TDsaParameters.GetValidationParameters: IDsaValidationParameters;
+begin
+  result := Fvalidation;
+end;
+
 constructor TDsaParameters.Create(const p, q, g: TBigInteger);
 begin
   Create(p, q, g, Nil);
@@ -118,24 +138,4 @@ begin
   result := p.GetHashCode() xor q.GetHashCode() xor g.GetHashCode();
 end;
 
-function TDsaParameters.GetG: TBigInteger;
-begin
-  result := Fg;
-end;
-
-function TDsaParameters.GetP: TBigInteger;
-begin
-  result := Fp;
-end;
-
-function TDsaParameters.GetQ: TBigInteger;
-begin
-  result := Fq;
-end;
-
-function TDsaParameters.GetValidationParameters: IDsaValidationParameters;
-begin
-  result := Fvalidation;
-end;
-
 end.

+ 5 - 5
CryptoLib/src/Crypto/Parameters/ClpDsaPrivateKeyParameters.pas

@@ -56,6 +56,11 @@ implementation
 
 { TDsaPrivateKeyParameters }
 
+function TDsaPrivateKeyParameters.GetX: TBigInteger;
+begin
+  result := Fx;
+end;
+
 constructor TDsaPrivateKeyParameters.Create(const x: TBigInteger;
   const parameters: IDsaParameters);
 begin
@@ -90,9 +95,4 @@ begin
   result := x.GetHashCode() xor (Inherited GetHashCode());
 end;
 
-function TDsaPrivateKeyParameters.GetX: TBigInteger;
-begin
-  result := Fx;
-end;
-
 end.

+ 5 - 5
CryptoLib/src/Crypto/Parameters/ClpDsaPublicKeyParameters.pas

@@ -59,6 +59,11 @@ implementation
 
 { TDsaPublicKeyParameters }
 
+function TDsaPublicKeyParameters.GetY: TBigInteger;
+begin
+  result := Fy;
+end;
+
 class function TDsaPublicKeyParameters.Validate(const y: TBigInteger;
   const parameters: IDsaParameters): TBigInteger;
 begin
@@ -110,9 +115,4 @@ begin
   result := y.GetHashCode() xor (Inherited GetHashCode());
 end;
 
-function TDsaPublicKeyParameters.GetY: TBigInteger;
-begin
-  result := Fy;
-end;
-
 end.

+ 25 - 25
CryptoLib/src/Crypto/Parameters/ClpECDomainParameters.pas

@@ -73,6 +73,31 @@ implementation
 
 { TECDomainParameters }
 
+function TECDomainParameters.GetCurve: IECCurve;
+begin
+  Result := Fcurve;
+end;
+
+function TECDomainParameters.GetG: IECPoint;
+begin
+  Result := Fg;
+end;
+
+function TECDomainParameters.GetH: TBigInteger;
+begin
+  Result := Fh;
+end;
+
+function TECDomainParameters.GetN: TBigInteger;
+begin
+  Result := Fn;
+end;
+
+function TECDomainParameters.GetSeed: TCryptoLibByteArray;
+begin
+  Result := Fseed;
+end;
+
 constructor TECDomainParameters.Create(const curve: IECCurve; const g: IECPoint;
   const n: TBigInteger);
 begin
@@ -130,21 +155,6 @@ begin
 
 end;
 
-function TECDomainParameters.GetCurve: IECCurve;
-begin
-  Result := Fcurve;
-end;
-
-function TECDomainParameters.GetG: IECPoint;
-begin
-  Result := Fg;
-end;
-
-function TECDomainParameters.GetH: TBigInteger;
-begin
-  Result := Fh;
-end;
-
 function TECDomainParameters.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
 {$ENDIF DELPHI}
 begin
@@ -157,14 +167,4 @@ begin
   Result := Result xor h.GetHashCode();
 end;
 
-function TECDomainParameters.GetN: TBigInteger;
-begin
-  Result := Fn;
-end;
-
-function TECDomainParameters.GetSeed: TCryptoLibByteArray;
-begin
-  Result := Fseed;
-end;
-
 end.

+ 11 - 11
CryptoLib/src/Crypto/Parameters/ClpECKeyParameters.pas

@@ -78,7 +78,7 @@ type
 
   public
     class function VerifyAlgorithmName(const algorithm: String): String;
-      static; inline;
+      static;
     class function LookupParameters(const publicKeyParamSet
       : IDerObjectIdentifier): IECDomainParameters; static;
     property AlgorithmName: String read GetAlgorithmName;
@@ -96,6 +96,16 @@ uses
 
 { TECKeyParameters }
 
+function TECKeyParameters.GetPublicKeyParamSet: IDerObjectIdentifier;
+begin
+  result := FpublicKeyParamSet;
+end;
+
+function TECKeyParameters.GetParameters: IECDomainParameters;
+begin
+  result := Fparameters;
+end;
+
 class function TECKeyParameters.LookupParameters(const publicKeyParamSet
   : IDerObjectIdentifier): IECDomainParameters;
 var
@@ -216,16 +226,6 @@ begin
   result := Falgorithm;
 end;
 
-function TECKeyParameters.GetPublicKeyParamSet: IDerObjectIdentifier;
-begin
-  result := FpublicKeyParamSet;
-end;
-
-function TECKeyParameters.GetParameters: IECDomainParameters;
-begin
-  result := Fparameters;
-end;
-
 function TECKeyParameters.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
 {$ENDIF DELPHI}
 begin

+ 5 - 5
CryptoLib/src/Crypto/Parameters/ClpECPrivateKeyParameters.pas

@@ -64,6 +64,11 @@ implementation
 
 { TECPrivateKeyParameters }
 
+function TECPrivateKeyParameters.GetD: TBigInteger;
+begin
+  result := Fd;
+end;
+
 constructor TECPrivateKeyParameters.Create(const d: TBigInteger;
   const parameters: IECDomainParameters);
 begin
@@ -107,11 +112,6 @@ begin
   result := d.Equals(other.d) and (inherited Equals(other));
 end;
 
-function TECPrivateKeyParameters.GetD: TBigInteger;
-begin
-  result := Fd;
-end;
-
 function TECPrivateKeyParameters.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
 {$ENDIF DELPHI}
 begin

+ 5 - 5
CryptoLib/src/Crypto/Parameters/ClpECPublicKeyParameters.pas

@@ -68,6 +68,11 @@ implementation
 
 { TECPublicKeyParameters }
 
+function TECPublicKeyParameters.GetQ: IECPoint;
+begin
+  result := Fq;
+end;
+
 class function TECPublicKeyParameters.Validate(const q: IECPoint): IECPoint;
 begin
   if (q = Nil) then
@@ -132,9 +137,4 @@ begin
   result := q.GetHashCode() xor (inherited GetHashCode());
 end;
 
-function TECPublicKeyParameters.GetQ: IECPoint;
-begin
-  result := Fq;
-end;
-
 end.

+ 0 - 2
CryptoLib/src/Interfaces/ClpIDsaKeyParameters.pas

@@ -32,8 +32,6 @@ type
     function GetParameters: IDsaParameters;
 
     function Equals(const other: IDsaKeyParameters): Boolean;
-    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
-{$ENDIF DELPHI}
     property parameters: IDsaParameters read GetParameters;
 
   end;

+ 0 - 2
CryptoLib/src/Interfaces/ClpIDsaPrivateKeyParameters.pas

@@ -29,8 +29,6 @@ type
     function GetX: TBigInteger;
 
     function Equals(const other: IDsaPrivateKeyParameters): Boolean;
-    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
-{$ENDIF DELPHI}
     property X: TBigInteger read GetX;
 
   end;

+ 0 - 2
CryptoLib/src/Interfaces/ClpIDsaPublicKeyParameters.pas

@@ -29,8 +29,6 @@ type
     function GetY: TBigInteger;
 
     function Equals(const other: IDsaPublicKeyParameters): Boolean;
-    function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
-{$ENDIF DELPHI}
     property y: TBigInteger read GetY;
 
   end;

+ 0 - 26
CryptoLib/src/Interfaces/ClpIDsaSigner.pas

@@ -24,7 +24,6 @@ interface
 uses
   ClpIDsa,
   ClpISecureRandom,
-  ClpICipherParameters,
   ClpBigInteger,
   ClpCryptoLibTypes;
 
@@ -32,37 +31,12 @@ type
   IDsaSigner = interface(IDsa)
     ['{687C14CD-F126-4886-87FC-535DEB083C2F}']
 
-    function GetAlgorithmName: String;
-
     function CalculateE(const n: TBigInteger; &message: TCryptoLibByteArray)
       : TBigInteger;
 
     function InitSecureRandom(needed: Boolean; const provided: ISecureRandom)
       : ISecureRandom;
 
-    procedure Init(forSigning: Boolean; const parameters: ICipherParameters);
-
-    /// <summary>
-    /// Generate a signature for the given message using the key we were <br />
-    /// initialised with. For conventional DSA the message should be a SHA-1 <br />
-    /// hash of the message of interest.
-    /// </summary>
-    /// <param name="&amp;message">
-    /// the message that will be verified later.
-    /// </param>
-    function GenerateSignature(&message: TCryptoLibByteArray)
-      : TCryptoLibGenericArray<TBigInteger>;
-
-    /// <summary>
-    /// return true if the value r and s represent a DSA signature for <br />
-    /// the passed in message for standard DSA the message should be a <br />
-    /// SHA-1 hash of the real message to be verified.
-    /// </summary>
-    function VerifySignature(&message: TCryptoLibByteArray;
-      const r, s: TBigInteger): Boolean;
-
-    property AlgorithmName: String read GetAlgorithmName;
-
   end;
 
 implementation

+ 0 - 13
CryptoLib/src/Interfaces/ClpIECNRSigner.pas

@@ -23,7 +23,6 @@ interface
 
 uses
   ClpIDsa,
-  ClpICipherParameters,
   ClpBigInteger,
   ClpCryptoLibTypes;
 
@@ -31,18 +30,6 @@ type
   IECNRSigner = interface(IDsa)
     ['{C136F005-404E-4022-886E-DE5EFCECFF9C}']
 
-    function GetAlgorithmName: String;
-
-    property AlgorithmName: String read GetAlgorithmName;
-
-    procedure Init(forSigning: Boolean; const parameters: ICipherParameters);
-
-    function GenerateSignature(&message: TCryptoLibByteArray)
-      : TCryptoLibGenericArray<TBigInteger>;
-
-    function VerifySignature(&message: TCryptoLibByteArray;
-      const r, s: TBigInteger): Boolean;
-
   end;
 
 implementation

+ 253 - 253
CryptoLib/src/Math/ClpBigInteger.pas

@@ -443,6 +443,201 @@ uses
 
 { TBigInteger }
 
+class function TBigInteger.BitLen(w: Int32): Int32;
+var
+  v, t: UInt32;
+begin
+  v := UInt32(w);
+  t := v shr 24;
+  if (t <> 0) then
+  begin
+    Result := 24 + BitLengthTable[t];
+    Exit;
+  end;
+  t := v shr 16;
+  if (t <> 0) then
+  begin
+    Result := 16 + BitLengthTable[t];
+    Exit;
+  end;
+  t := v shr 8;
+  if (t <> 0) then
+  begin
+    Result := 8 + BitLengthTable[t];
+    Exit;
+  end;
+  Result := BitLengthTable[v];
+end;
+
+class function TBigInteger.CalcBitLength(sign, indx: Int32;
+  mag: TCryptoLibInt32Array): Int32;
+var
+  BitLength, firstMag: Int32;
+begin
+  while True do
+
+  begin
+    if (indx >= System.length(mag)) then
+    begin
+      Result := 0;
+      Exit;
+    end;
+
+    if (mag[indx] <> 0) then
+    begin
+      break;
+    end;
+
+    System.Inc(indx);
+  end;
+
+  // bit length for everything after the first int
+  BitLength := 32 * ((System.length(mag) - indx) - 1);
+
+  // and determine bitlength of first int
+  firstMag := mag[indx];
+  BitLength := BitLength + BitLen(firstMag);
+
+  // Check for negative powers of two
+  if ((sign < 0) and ((firstMag and Int32(-firstMag)) = firstMag)) then
+  begin
+    repeat
+      System.Inc(indx);
+      if (indx >= System.length(mag)) then
+      begin
+        System.Dec(BitLength);
+        break;
+      end;
+    until (not(mag[indx] = 0));
+  end;
+
+  Result := BitLength;
+end;
+
+class function TBigInteger.GetZero: TBigInteger;
+begin
+  Result := FZero;
+end;
+
+class function TBigInteger.GetOne: TBigInteger;
+begin
+  Result := FOne;
+end;
+
+class function TBigInteger.GetTwo: TBigInteger;
+begin
+  Result := FTwo;
+end;
+
+class function TBigInteger.GetThree: TBigInteger;
+begin
+  Result := FThree;
+end;
+
+class function TBigInteger.GetTen: TBigInteger;
+begin
+  Result := FTen;
+end;
+
+class function TBigInteger.GetprimeLists: TCryptoLibMatrixInt32Array;
+begin
+  Result := FprimeLists;
+end;
+
+class function TBigInteger.GetprimeProducts: TCryptoLibInt32Array;
+begin
+  Result := FprimeProducts;
+end;
+
+class function TBigInteger.GetRandomSource: ISecureRandom;
+begin
+  Result := FRandomSource;
+end;
+
+function TBigInteger.GetSignValue: Int32;
+begin
+  Result := Fsign;
+end;
+
+function TBigInteger.GetBitLength: Int32;
+begin
+  if (FnBitLength = -1) then
+  begin
+    if Fsign = 0 then
+    begin
+      FnBitLength := 0;
+    end
+    else
+    begin
+      FnBitLength := CalcBitLength(Fsign, 0, Fmagnitude);
+    end;
+
+  end;
+  Result := FnBitLength;
+end;
+
+function TBigInteger.GetInt32Value: Int32;
+var
+  n, v: Int32;
+begin
+  if (Fsign = 0) then
+  begin
+    Result := 0;
+    Exit;
+  end;
+
+  n := System.length(Fmagnitude);
+
+  v := Fmagnitude[n - 1];
+
+  if Fsign < 0 then
+  begin
+    Result := -v;
+  end
+  else
+  begin
+    Result := v;
+  end;
+end;
+
+function TBigInteger.GetInt64Value: Int64;
+var
+  n: Int32;
+  v: Int64;
+begin
+  if (Fsign = 0) then
+  begin
+    Result := 0;
+    Exit;
+  end;
+
+  n := System.length(Fmagnitude);
+
+  v := Fmagnitude[n - 1] and IMASK;
+  if (n > 1) then
+  begin
+    v := v or ((Fmagnitude[n - 2] and IMASK) shl 32);
+  end;
+
+  if Fsign < 0 then
+
+  begin
+    Result := -v;
+    Exit;
+  end
+  else
+  begin
+    Result := v;
+    Exit;
+  end;
+
+end;
+
+function TBigInteger.GetIsInitialized: Boolean;
+begin
+  Result := FIsInitialized;
+end;
+
 class function TBigInteger.BitCnt(i: Int32): Int32;
 var
   u: UInt32;
@@ -548,32 +743,6 @@ begin
   Result := CreateUValueOf(UInt64(value));
 end;
 
-class function TBigInteger.BitLen(w: Int32): Int32;
-var
-  v, t: UInt32;
-begin
-  v := UInt32(w);
-  t := v shr 24;
-  if (t <> 0) then
-  begin
-    Result := 24 + BitLengthTable[t];
-    Exit;
-  end;
-  t := v shr 16;
-  if (t <> 0) then
-  begin
-    Result := 16 + BitLengthTable[t];
-    Exit;
-  end;
-  t := v shr 8;
-  if (t <> 0) then
-  begin
-    Result := 8 + BitLengthTable[t];
-    Exit;
-  end;
-  Result := BitLengthTable[v];
-end;
-
 class function TBigInteger.CreateUValueOf(value: UInt64): TBigInteger;
 var
   msw, lsw: Int32;
@@ -1180,6 +1349,24 @@ begin
   Result := TBigInteger.Create(sizeInBits, RandomSource);
 end;
 
+function TBigInteger.Remainder(m: Int32): Int32;
+var
+  acc, posVal: Int64;
+  &pos: Int32;
+begin
+{$IFDEF DEBUG}
+  System.Assert(m > 0);
+{$ENDIF DEBUG}
+  acc := 0;
+  for pos := 0 to System.Pred(System.length(Fmagnitude)) do
+  begin
+    posVal := UInt32(Fmagnitude[pos]);
+    acc := ((acc shl 32) or posVal) mod m;
+  end;
+
+  Result := Int32(acc);
+end;
+
 function TBigInteger.Remainder(const n: TBigInteger): TBigInteger;
 var
   val, rem: Int32;
@@ -1802,23 +1989,6 @@ begin
   Result := FnBits;
 end;
 
-function TBigInteger.GetBitLength: Int32;
-begin
-  if (FnBitLength = -1) then
-  begin
-    if Fsign = 0 then
-    begin
-      FnBitLength := 0;
-    end
-    else
-    begin
-      FnBitLength := CalcBitLength(Fsign, 0, Fmagnitude);
-    end;
-
-  end;
-  Result := FnBitLength;
-end;
-
 function TBigInteger.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
 {$ENDIF DELPHI}
 
@@ -1847,68 +2017,6 @@ begin
 
 end;
 
-function TBigInteger.GetInt32Value: Int32;
-var
-  n, v: Int32;
-begin
-  if (Fsign = 0) then
-  begin
-    Result := 0;
-    Exit;
-  end;
-
-  n := System.length(Fmagnitude);
-
-  v := Fmagnitude[n - 1];
-
-  if Fsign < 0 then
-  begin
-    Result := -v;
-  end
-  else
-  begin
-    Result := v;
-  end;
-end;
-
-function TBigInteger.GetInt64Value: Int64;
-var
-  n: Int32;
-  v: Int64;
-begin
-  if (Fsign = 0) then
-  begin
-    Result := 0;
-    Exit;
-  end;
-
-  n := System.length(Fmagnitude);
-
-  v := Fmagnitude[n - 1] and IMASK;
-  if (n > 1) then
-  begin
-    v := v or ((Fmagnitude[n - 2] and IMASK) shl 32);
-  end;
-
-  if Fsign < 0 then
-
-  begin
-    Result := -v;
-    Exit;
-  end
-  else
-  begin
-    Result := v;
-    Exit;
-  end;
-
-end;
-
-function TBigInteger.GetIsInitialized: Boolean;
-begin
-  Result := FIsInitialized;
-end;
-
 function TBigInteger.GetLowestSetBit: Int32;
 begin
   if (Fsign = 0) then
@@ -1999,11 +2107,6 @@ begin
   Result := FmQuote;
 end;
 
-class function TBigInteger.GetZero: TBigInteger;
-begin
-  Result := FZero;
-end;
-
 function TBigInteger.IsEqualMagnitude(const x: TBigInteger): Boolean;
 var
   i: Integer;
@@ -3332,6 +3435,46 @@ begin
   Result := y;
 end;
 
+function TBigInteger.DivideWords(w: Int32): TBigInteger;
+var
+  n: Int32;
+  mag: TCryptoLibInt32Array;
+begin
+{$IFDEF DEBUG}
+  System.Assert(w >= 0);
+{$ENDIF DEBUG}
+  n := System.length(Fmagnitude);
+  if (w >= n) then
+  begin
+    Result := Zero;
+    Exit;
+  end;
+
+  System.SetLength(mag, n - w);
+  System.Move(Fmagnitude[0], mag[0], (n - w) * System.SizeOf(Int32));
+  Result := TBigInteger.Create(Fsign, mag, false);
+end;
+
+function TBigInteger.RemainderWords(w: Int32): TBigInteger;
+var
+  n: Int32;
+  mag: TCryptoLibInt32Array;
+begin
+{$IFDEF DEBUG}
+  System.Assert(w >= 0);
+{$ENDIF DEBUG}
+  n := System.length(Fmagnitude);
+  if (w >= n) then
+  begin
+    Result := Self;
+    Exit;
+  end;
+
+  System.SetLength(mag, w);
+  System.Move(Fmagnitude[n - w], mag[0], w * System.SizeOf(Int32));
+  Result := TBigInteger.Create(Fsign, mag, false);
+end;
+
 class function TBigInteger.ProbablePrime(BitLength: Int32;
   const random: IRandom): TBigInteger;
 begin
@@ -3480,24 +3623,6 @@ begin
   Result := x;
 end;
 
-function TBigInteger.Remainder(m: Int32): Int32;
-var
-  acc, posVal: Int64;
-  &pos: Int32;
-begin
-{$IFDEF DEBUG}
-  System.Assert(m > 0);
-{$ENDIF DEBUG}
-  acc := 0;
-  for pos := 0 to System.Pred(System.length(Fmagnitude)) do
-  begin
-    posVal := UInt32(Fmagnitude[pos]);
-    acc := ((acc shl 32) or posVal) mod m;
-  end;
-
-  Result := Int32(acc);
-end;
-
 function TBigInteger.Remainder(x, y: TCryptoLibInt32Array)
   : TCryptoLibInt32Array;
 var
@@ -3628,26 +3753,6 @@ begin
   Result := x;
 end;
 
-function TBigInteger.RemainderWords(w: Int32): TBigInteger;
-var
-  n: Int32;
-  mag: TCryptoLibInt32Array;
-begin
-{$IFDEF DEBUG}
-  System.Assert(w >= 0);
-{$ENDIF DEBUG}
-  n := System.length(Fmagnitude);
-  if (w >= n) then
-  begin
-    Result := Self;
-    Exit;
-  end;
-
-  System.SetLength(mag, w);
-  System.Move(Fmagnitude[n - w], mag[0], w * System.SizeOf(Int32));
-  Result := TBigInteger.Create(Fsign, mag, false);
-end;
-
 function TBigInteger.SetBit(n: Int32): TBigInteger;
 begin
   if (n < 0) then
@@ -4304,36 +4409,6 @@ begin
   Result := ToString(10);
 end;
 
-class function TBigInteger.GetOne: TBigInteger;
-begin
-  Result := FOne;
-end;
-
-class function TBigInteger.GetprimeLists: TCryptoLibMatrixInt32Array;
-begin
-  Result := FprimeLists;
-end;
-
-class function TBigInteger.GetprimeProducts: TCryptoLibInt32Array;
-begin
-  Result := FprimeProducts;
-end;
-
-class function TBigInteger.GetRandomSource: ISecureRandom;
-begin
-  Result := FRandomSource;
-end;
-
-function TBigInteger.GetSignValue: Int32;
-begin
-  Result := Fsign;
-end;
-
-class function TBigInteger.GetTwo: TBigInteger;
-begin
-  Result := FTwo;
-end;
-
 class function TBigInteger.GetWindowList(mag: TCryptoLibInt32Array;
   extraBits: Int32): TCryptoLibInt32Array;
 var
@@ -4402,61 +4477,6 @@ begin
 
 end;
 
-class function TBigInteger.GetThree: TBigInteger;
-begin
-  Result := FThree;
-end;
-
-class function TBigInteger.GetTen: TBigInteger;
-begin
-  Result := FTen;
-end;
-
-class function TBigInteger.CalcBitLength(sign, indx: Int32;
-  mag: TCryptoLibInt32Array): Int32;
-var
-  BitLength, firstMag: Int32;
-begin
-  while True do
-
-  begin
-    if (indx >= System.length(mag)) then
-    begin
-      Result := 0;
-      Exit;
-    end;
-
-    if (mag[indx] <> 0) then
-    begin
-      break;
-    end;
-
-    System.Inc(indx);
-  end;
-
-  // bit length for everything after the first int
-  BitLength := 32 * ((System.length(mag) - indx) - 1);
-
-  // and determine bitlength of first int
-  firstMag := mag[indx];
-  BitLength := BitLength + BitLen(firstMag);
-
-  // Check for negative powers of two
-  if ((sign < 0) and ((firstMag and Int32(-firstMag)) = firstMag)) then
-  begin
-    repeat
-      System.Inc(indx);
-      if (indx >= System.length(mag)) then
-      begin
-        System.Dec(BitLength);
-        break;
-      end;
-    until (not(mag[indx] = 0));
-  end;
-
-  Result := BitLength;
-end;
-
 function TBigInteger.CheckProbablePrime(certainty: Int32; const random: IRandom;
   randomlySelected: Boolean): Boolean;
 var
@@ -4833,26 +4853,6 @@ begin
   Result := biggies;
 end;
 
-function TBigInteger.DivideWords(w: Int32): TBigInteger;
-var
-  n: Int32;
-  mag: TCryptoLibInt32Array;
-begin
-{$IFDEF DEBUG}
-  System.Assert(w >= 0);
-{$ENDIF DEBUG}
-  n := System.length(Fmagnitude);
-  if (w >= n) then
-  begin
-    Result := Zero;
-    Exit;
-  end;
-
-  System.SetLength(mag, n - w);
-  System.Move(Fmagnitude[0], mag[0], (n - w) * System.SizeOf(Int32));
-  Result := TBigInteger.Create(Fsign, mag, false);
-end;
-
 function TBigInteger.ToByteArray(unsigned: Boolean): TCryptoLibByteArray;
 var
   nBits, nBytes, magIndex, bytesIndex: Int32;

+ 20 - 28
CryptoLib/src/Math/EC/ClpECAlgorithms.pas

@@ -217,40 +217,32 @@ begin
   infoP := TWNafUtilities.GetWNafPreCompInfo(P);
   infoQ := TWNafUtilities.GetWNafPreCompInfo(Q);
 
-  if negK then
-  begin
-    preCompP := infoP.PreCompNeg
-  end
-  else
-  begin
-    preCompP := infoP.PreComp
+  case negK of
+    true:
+      preCompP := infoP.PreCompNeg;
+    False:
+      preCompP := infoP.PreComp;
   end;
 
-  if negL then
-  begin
-    preCompQ := infoQ.PreCompNeg
-  end
-  else
-  begin
-    preCompQ := infoQ.PreComp
+  case negL of
+    true:
+      preCompQ := infoQ.PreCompNeg;
+    False:
+      preCompQ := infoQ.PreComp
   end;
 
-  if negK then
-  begin
-    preCompNegP := infoP.PreComp
-  end
-  else
-  begin
-    preCompNegP := infoP.PreCompNeg
+  case negK of
+    true:
+      preCompNegP := infoP.PreComp;
+    False:
+      preCompNegP := infoP.PreCompNeg;
   end;
 
-  if negL then
-  begin
-    preCompNegQ := infoQ.PreComp
-  end
-  else
-  begin
-    preCompNegQ := infoQ.PreCompNeg
+  case negL of
+    true:
+      preCompNegQ := infoQ.PreComp;
+    False:
+      preCompNegQ := infoQ.PreCompNeg
   end;
 
   wnafP := TWNafUtilities.GenerateWindowNaf(width, k);

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

@@ -1564,6 +1564,41 @@ end;
 
 { TF2mCurve }
 
+function TF2mCurve.GetFieldSize: Int32;
+begin
+  Result := Fm;
+end;
+
+function TF2mCurve.GetInfinity: IECPoint;
+begin
+  Result := Fm_infinity;
+end;
+
+function TF2mCurve.GetK1: Int32;
+begin
+  Result := Fk1;
+end;
+
+function TF2mCurve.GetK2: Int32;
+begin
+  Result := Fk2;
+end;
+
+function TF2mCurve.GetK3: Int32;
+begin
+  Result := Fk3;
+end;
+
+function TF2mCurve.GetM: Int32;
+begin
+  Result := Fm;
+end;
+
+function TF2mCurve.IsTrinomial: Boolean;
+begin
+  Result := (k2 = 0) and (k3 = 0);
+end;
+
 function TF2mCurve.CloneCurve: IECCurve;
 begin
   Result := TF2mCurve.Create(m, k1, k2, k3, Fm_a, Fm_b, Fm_order, Fm_cofactor);
@@ -1703,41 +1738,6 @@ begin
   Result := TF2mFieldElement.Create(Fm, Fk1, Fk2, Fk3, x);
 end;
 
-function TF2mCurve.GetFieldSize: Int32;
-begin
-  Result := Fm;
-end;
-
-function TF2mCurve.GetInfinity: IECPoint;
-begin
-  Result := Fm_infinity;
-end;
-
-function TF2mCurve.GetK1: Int32;
-begin
-  Result := Fk1;
-end;
-
-function TF2mCurve.GetK2: Int32;
-begin
-  Result := Fk2;
-end;
-
-function TF2mCurve.GetK3: Int32;
-begin
-  Result := Fk3;
-end;
-
-function TF2mCurve.GetM: Int32;
-begin
-  Result := Fm;
-end;
-
-function TF2mCurve.IsTrinomial: Boolean;
-begin
-  Result := (k2 = 0) and (k3 = 0);
-end;
-
 function TF2mCurve.SupportsCoordinateSystem(coord: Int32): Boolean;
 begin
   case coord of

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

@@ -394,6 +394,26 @@ implementation
 
 { TF2mFieldElement }
 
+function TF2mFieldElement.GetKs: TCryptoLibInt32Array;
+begin
+  result := FKs;
+end;
+
+function TF2mFieldElement.GetM: Int32;
+begin
+  result := Fm;
+end;
+
+function TF2mFieldElement.GetRepresentation: Int32;
+begin
+  result := Frepresentation;
+end;
+
+function TF2mFieldElement.GetX: TLongArray;
+begin
+  result := Fx;
+end;
+
 function TF2mFieldElement.Add(const b: IECFieldElement): IECFieldElement;
 var
   iarrClone: TLongArray;
@@ -580,26 +600,6 @@ begin
   end;
 end;
 
-function TF2mFieldElement.GetKs: TCryptoLibInt32Array;
-begin
-  result := FKs;
-end;
-
-function TF2mFieldElement.GetM: Int32;
-begin
-  result := Fm;
-end;
-
-function TF2mFieldElement.GetRepresentation: Int32;
-begin
-  result := Frepresentation;
-end;
-
-function TF2mFieldElement.GetX: TLongArray;
-begin
-  result := Fx;
-end;
-
 function TF2mFieldElement.Invert: IECFieldElement;
 begin
   result := TF2mFieldElement.Create(Fm, FKs, Fx.ModInverse(Fm, FKs));
@@ -834,6 +834,16 @@ end;
 
 { TFpFieldElement }
 
+function TFpFieldElement.GetQ: TBigInteger;
+begin
+  result := Fq;
+end;
+
+function TFpFieldElement.GetFieldSize: Int32;
+begin
+  result := Q.BitLength;
+end;
+
 function TFpFieldElement.Add(const b: IECFieldElement): IECFieldElement;
 begin
   result := TFpFieldElement.Create(Fq, Fr, ModAdd(Fx, b.ToBigInteger()));
@@ -938,22 +948,12 @@ begin
   result := 'Fp';
 end;
 
-function TFpFieldElement.GetFieldSize: Int32;
-begin
-  result := Q.BitLength;
-end;
-
 function TFpFieldElement.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
 {$ENDIF DELPHI}
 begin
   result := Q.GetHashCode() xor (Inherited GetHashCode());
 end;
 
-function TFpFieldElement.GetQ: TBigInteger;
-begin
-  result := Fq;
-end;
-
 function TFpFieldElement.Invert: IECFieldElement;
 begin
   // TODO Modular inversion can be faster for a (Generalized) Mersenne Prime.

+ 25 - 25
CryptoLib/src/Math/EC/ClpECPoint.pas

@@ -478,6 +478,31 @@ uses
 
 { TECPoint }
 
+function TECPoint.GetIsCompressed: Boolean;
+begin
+  result := Fm_withCompression;
+end;
+
+function TECPoint.GetIsInfinity: Boolean;
+begin
+  result := (Fm_x = Nil) and (Fm_y = Nil);
+end;
+
+function TECPoint.RawXCoord: IECFieldElement;
+begin
+  result := Fm_x;
+end;
+
+function TECPoint.RawYCoord: IECFieldElement;
+begin
+  result := Fm_y;
+end;
+
+function TECPoint.RawZCoords: TCryptoLibGenericArray<IECFieldElement>;
+begin
+  result := Fm_zs;
+end;
+
 function TECPoint.Normalize: IECPoint;
 var
   Z1: IECFieldElement;
@@ -811,16 +836,6 @@ begin
 
 end;
 
-function TECPoint.GetIsCompressed: Boolean;
-begin
-  result := Fm_withCompression;
-end;
-
-function TECPoint.GetIsInfinity: Boolean;
-begin
-  result := (Fm_x = Nil) and (Fm_y = Nil);
-end;
-
 function TECPoint.GetpreCompTable: TDictionary<String, IPreCompInfo>;
 begin
   result := Fm_preCompTable;
@@ -977,21 +992,6 @@ begin
   result := Normalize().Detach();
 end;
 
-function TECPoint.RawXCoord: IECFieldElement;
-begin
-  result := Fm_x;
-end;
-
-function TECPoint.RawYCoord: IECFieldElement;
-begin
-  result := Fm_y;
-end;
-
-function TECPoint.RawZCoords: TCryptoLibGenericArray<IECFieldElement>;
-begin
-  result := Fm_zs;
-end;
-
 { TF2mPoint }
 
 constructor TF2mPoint.Create(const curve: IECCurve;

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

@@ -492,7 +492,7 @@ type
       ks: TCryptoLibInt32Array): TLongArray; static; inline;
 
     class function ReduceInPlace(buf: TCryptoLibInt64Array; off, len, m: Int32;
-      ks: TCryptoLibInt32Array): Int32; static; inline;
+      ks: TCryptoLibInt32Array): Int32; static;
 
     class procedure ReduceBitWise(buf: TCryptoLibInt64Array;
       off, BitLength, m: Int32; ks: TCryptoLibInt32Array); static; inline;
@@ -795,6 +795,27 @@ begin
   end;
 end;
 
+class function TLongArray.Interleave3_21to63(x: Int32): Int64;
+var
+  r00, r21, r42: Int32;
+begin
+  r00 := INTERLEAVE3_TABLE[x and $7F];
+  r21 := INTERLEAVE3_TABLE[(UInt32(x) shr 7) and $7F];
+  r42 := INTERLEAVE3_TABLE[UInt32(x) shr 14];
+  Result := (r42 and Int64($FFFFFFFF)) shl 42 or (r21 and Int64($FFFFFFFF))
+    shl 21 or (r00 and Int64($FFFFFFFF));
+end;
+
+class function TLongArray.Interleave3(x: Int64): Int64;
+var
+  z: Int64;
+begin
+  z := x and (Int64(1) shl 63);
+  Result := z or Interleave3_21to63(Int32(x) and $1FFFFF) or
+    Interleave3_21to63(Int32(UInt64(x) shr 21) and $1FFFFF) shl 1 or
+    Interleave3_21to63(Int32(UInt64(x) shr 42) and $1FFFFF) shl 2;
+end;
+
 class procedure TLongArray.Interleave3(x: TCryptoLibInt64Array; xOff: Int32;
   z: TCryptoLibInt64Array; zOff, count: Int32);
 var
@@ -806,15 +827,22 @@ begin
   end;
 end;
 
-class function TLongArray.Interleave3_21to63(x: Int32): Int64;
+class function TLongArray.Interleave3_13to65(x: Int32): Int64;
 var
-  r00, r21, r42: Int32;
+  r00, r35: Int32;
 begin
-  r00 := INTERLEAVE3_TABLE[x and $7F];
-  r21 := INTERLEAVE3_TABLE[(UInt32(x) shr 7) and $7F];
-  r42 := INTERLEAVE3_TABLE[UInt32(x) shr 14];
-  Result := (r42 and Int64($FFFFFFFF)) shl 42 or (r21 and Int64($FFFFFFFF))
-    shl 21 or (r00 and Int64($FFFFFFFF));
+  r00 := INTERLEAVE5_TABLE[x and $7F];
+  r35 := INTERLEAVE5_TABLE[UInt32(x) shr 7];
+  Result := (r35 and Int64($FFFFFFFF)) shl 35 or (r00 and Int64($FFFFFFFF));
+end;
+
+class function TLongArray.Interleave5(x: Int64): Int64;
+begin
+  Result := Interleave3_13to65(Int32(x) and $1FFF) or
+    Interleave3_13to65(Int32(UInt64(x) shr 13) and $1FFF) shl 1 or
+    Interleave3_13to65(Int32(UInt64(x) shr 26) and $1FFF) shl 2 or
+    Interleave3_13to65(Int32(UInt64(x) shr 39) and $1FFF) shl 3 or
+    Interleave3_13to65(Int32(UInt64(x) shr 52) and $1FFF) shl 4;
 end;
 
 class procedure TLongArray.Interleave5(x: TCryptoLibInt64Array; xOff: Int32;
@@ -828,6 +856,20 @@ begin
   end;
 end;
 
+class function TLongArray.Interleave7(x: Int64): Int64;
+var
+  z: Int64;
+begin
+  z := x and (Int64(1) shl 63);
+  Result := z or INTERLEAVE7_TABLE[Int32(x) and $1FF] or
+    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 9) and $1FF] shl 1 or
+    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 18) and $1FF] shl 2 or
+    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 27) and $1FF] shl 3 or
+    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 36) and $1FF] shl 4 or
+    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 45) and $1FF] shl 5 or
+    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 54) and $1FF] shl 6;
+end;
+
 class procedure TLongArray.Interleave7(x: TCryptoLibInt64Array; xOff: Int32;
   z: TCryptoLibInt64Array; zOff, count: Int32);
 var
@@ -848,6 +890,24 @@ begin
   Result := (r32 and Int64($FFFFFFFF)) shl 32 or (r00 and Int64($FFFFFFFF));
 end;
 
+class function TLongArray.Interleave2_n(x: Int64; rounds: Int32): Int64;
+begin
+  while (rounds > 1) do
+  begin
+    rounds := rounds - 2;
+    x := Interleave4_16to64(Int32(x) and $FFFF) or
+      Interleave4_16to64(Int32(UInt64(x) shr 16) and $FFFF) shl 1 or
+      Interleave4_16to64(Int32(UInt64(x) shr 32) and $FFFF) shl 2 or
+      Interleave4_16to64(Int32(UInt64(x) shr 48) and $FFFF) shl 3;
+  end;
+  if (rounds > 0) then
+  begin
+    x := Interleave2_32to64(Int32(x)) or
+      Interleave2_32to64(Int32(UInt64(x) shr 32)) shl 1;
+  end;
+  Result := x;
+end;
+
 class procedure TLongArray.Interleave2_n(x: TCryptoLibInt64Array; xOff: Int32;
   z: TCryptoLibInt64Array; zOff, count, rounds: Int32);
 var
@@ -1351,66 +1411,6 @@ begin
 
 end;
 
-class function TLongArray.Interleave2_n(x: Int64; rounds: Int32): Int64;
-begin
-  while (rounds > 1) do
-  begin
-    rounds := rounds - 2;
-    x := Interleave4_16to64(Int32(x) and $FFFF) or
-      Interleave4_16to64(Int32(UInt64(x) shr 16) and $FFFF) shl 1 or
-      Interleave4_16to64(Int32(UInt64(x) shr 32) and $FFFF) shl 2 or
-      Interleave4_16to64(Int32(UInt64(x) shr 48) and $FFFF) shl 3;
-  end;
-  if (rounds > 0) then
-  begin
-    x := Interleave2_32to64(Int32(x)) or
-      Interleave2_32to64(Int32(UInt64(x) shr 32)) shl 1;
-  end;
-  Result := x;
-end;
-
-class function TLongArray.Interleave3(x: Int64): Int64;
-var
-  z: Int64;
-begin
-  z := x and (Int64(1) shl 63);
-  Result := z or Interleave3_21to63(Int32(x) and $1FFFFF) or
-    Interleave3_21to63(Int32(UInt64(x) shr 21) and $1FFFFF) shl 1 or
-    Interleave3_21to63(Int32(UInt64(x) shr 42) and $1FFFFF) shl 2;
-end;
-
-class function TLongArray.Interleave3_13to65(x: Int32): Int64;
-var
-  r00, r35: Int32;
-begin
-  r00 := INTERLEAVE5_TABLE[x and $7F];
-  r35 := INTERLEAVE5_TABLE[UInt32(x) shr 7];
-  Result := (r35 and Int64($FFFFFFFF)) shl 35 or (r00 and Int64($FFFFFFFF));
-end;
-
-class function TLongArray.Interleave5(x: Int64): Int64;
-begin
-  Result := Interleave3_13to65(Int32(x) and $1FFF) or
-    Interleave3_13to65(Int32(UInt64(x) shr 13) and $1FFF) shl 1 or
-    Interleave3_13to65(Int32(UInt64(x) shr 26) and $1FFF) shl 2 or
-    Interleave3_13to65(Int32(UInt64(x) shr 39) and $1FFF) shl 3 or
-    Interleave3_13to65(Int32(UInt64(x) shr 52) and $1FFF) shl 4;
-end;
-
-class function TLongArray.Interleave7(x: Int64): Int64;
-var
-  z: Int64;
-begin
-  z := x and (Int64(1) shl 63);
-  Result := z or INTERLEAVE7_TABLE[Int32(x) and $1FF] or
-    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 9) and $1FF] shl 1 or
-    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 18) and $1FF] shl 2 or
-    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 27) and $1FF] shl 3 or
-    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 36) and $1FF] shl 4 or
-    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 45) and $1FF] shl 5 or
-    INTERLEAVE7_TABLE[Int32(UInt64(x) shr 54) and $1FF] shl 6;
-end;
-
 class function TLongArray.Int64ToBin(input: Int64): string;
 var
   bits: TCryptoLibCharArray;

+ 1 - 1
CryptoLib/src/Math/EC/Multiplier/ClpWNafUtilities.pas

@@ -125,7 +125,7 @@ type
     /// the window size to use
     /// </returns>
     class function GetWindowSize(bits: Int32;
-      windowSizeCutoffs: TCryptoLibInt32Array): Int32; overload; static; inline;
+      windowSizeCutoffs: TCryptoLibInt32Array): Int32; overload; static;
 
     class function MapPointWithPrecomp(const p: IECPoint; width: Int32;
       includeNegated: Boolean; const pointMap: IECPointMap): IECPoint; static;

+ 6 - 6
CryptoLib/src/Security/ClpMacUtilities.pas

@@ -153,6 +153,12 @@ begin
     [mechanism]);
 end;
 
+class function TMacUtilities.DoFinal(const mac: IMac): TCryptoLibByteArray;
+begin
+  System.SetLength(result, mac.GetMacSize());
+  mac.DoFinal(result, 0);
+end;
+
 class function TMacUtilities.DoFinal(const mac: IMac;
   input: TCryptoLibByteArray): TCryptoLibByteArray;
 begin
@@ -160,12 +166,6 @@ begin
   result := DoFinal(mac);
 end;
 
-class function TMacUtilities.DoFinal(const mac: IMac): TCryptoLibByteArray;
-begin
-  System.SetLength(result, mac.GetMacSize());
-  mac.DoFinal(result, 0);
-end;
-
 class function TMacUtilities.CalculateMac(const algorithm: String;
   const cp: ICipherParameters; input: TCryptoLibByteArray): TCryptoLibByteArray;
 var

+ 11 - 11
CryptoLib/src/Security/ClpSecureRandom.pas

@@ -320,17 +320,6 @@ begin
   Create(CreatePrng('SHA256', True));
 end;
 
-class function TSecureRandom.GetInstance(const algorithm: String)
-  : ISecureRandom;
-begin
-  Result := GetInstance(algorithm, True);
-end;
-
-function TSecureRandom.GenerateSeed(length: Int32): TCryptoLibByteArray;
-begin
-  Result := GetNextBytes(Master, length);
-end;
-
 class function TSecureRandom.GetInstance(const algorithm: String;
   autoSeed: Boolean): ISecureRandom;
 var
@@ -365,4 +354,15 @@ begin
 
 end;
 
+class function TSecureRandom.GetInstance(const algorithm: String)
+  : ISecureRandom;
+begin
+  Result := GetInstance(algorithm, True);
+end;
+
+function TSecureRandom.GenerateSeed(length: Int32): TCryptoLibByteArray;
+begin
+  Result := GetNextBytes(Master, length);
+end;
+
 end.

+ 5 - 5
CryptoLib/src/Utils/ClpTimes.pas

@@ -51,11 +51,6 @@ implementation
 
 { TTimes }
 
-class function TTimes.NanoTime: Int64;
-begin
-  Result := Ticks * NanosecondsPerTick;
-end;
-
 class function TTimes.Now: TDateTime;
 begin
   Result := SysUtils.Now;
@@ -72,4 +67,9 @@ begin
   Result := Int64(value and TicksMask);
 end;
 
+class function TTimes.NanoTime: Int64;
+begin
+  Result := Ticks * NanosecondsPerTick;
+end;
+
 end.

+ 15 - 14
CryptoLib/src/Utils/Randoms/ClpPcgRandomMinimal.pas

@@ -89,7 +89,7 @@ type
   /// <param name="initState">Initial state.</param>
   /// <param name="initSeq">Initial sequence</param>
 
-  class procedure Seed(initState: UInt64; initSeq: UInt64); static; inline;
+  class procedure Seed(initState: UInt64; initSeq: UInt64); static;
 
   /// <summary>
   /// Generates a uniformly distributed number, r,
@@ -162,6 +162,20 @@ type
 
 implementation
 
+class function TPcg.NextUInt32(): UInt32;
+var
+  oldState, LValue: UInt64;
+  xorShifted: UInt32;
+  rot: Int32;
+begin
+  oldState := Fm_state;
+  LValue := UInt64(6364136223846793005);
+  Fm_state := oldState * LValue + Fm_inc;
+  xorShifted := UInt32(((oldState shr 18) xor oldState) shr 27);
+  rot := Int32(oldState shr 59);
+  result := (xorShifted shr rot) or (xorShifted shl ((-rot) and 31));
+end;
+
 class function TPcg.NextUInt32(minimum: UInt32; exclusiveBound: UInt32): UInt32;
 var
   boundRange, rangeResult: UInt32;
@@ -275,17 +289,4 @@ begin
   result := Integer(rangeResult) + Integer(minimum);
 end;
 
-class function TPcg.NextUInt32(): UInt32;
-var
-  oldState: UInt64;
-  xorShifted: UInt32;
-  rot: Integer;
-begin
-  oldState := Fm_state;
-  Fm_state := oldState * UInt64(6364136223846793005) + Fm_inc;
-  xorShifted := UInt32(((oldState shr 18) xor oldState) shr 27);
-  rot := Integer(oldState shr 59);
-  result := (xorShifted shr rot) or (xorShifted shl ((-rot) and 31));
-end;
-
 end.