Browse Source

Merge branch 'master' into travis

Ugochukwu Mmaduekwe 7 years ago
parent
commit
c63a9db39b
100 changed files with 716 additions and 646 deletions
  1. 4 4
      CryptoLib.Tests/src/Asn1/Asn1SequenceParserTests.pas
  2. 2 2
      CryptoLib.Tests/src/Asn1/OIDTests.pas
  3. 3 2
      CryptoLib.Tests/src/Crypto/AESTests.pas
  4. 8 8
      CryptoLib.Tests/src/Crypto/DSATests.pas
  5. 2 2
      CryptoLib.Tests/src/Crypto/DeterministicDsaTests.pas
  6. 16 14
      CryptoLib.Tests/src/Crypto/DigestRandomNumberTests.pas
  7. 5 4
      CryptoLib.Tests/src/Crypto/HMacTests.pas
  8. 2 2
      CryptoLib.Tests/src/Crypto/HkdfGeneratorTests.pas
  9. 5 4
      CryptoLib.Tests/src/Crypto/PaddingTests.pas
  10. 2 2
      CryptoLib.Tests/src/Math/EC/Custom/Sec/SecP384R1FieldTests.pas
  11. 9 7
      CryptoLib.Tests/src/Math/ECAlgorithmsTests.pas
  12. 5 4
      CryptoLib.Tests/src/Math/ECIESTests.pas
  13. 5 5
      CryptoLib.Tests/src/Math/ECNRTests.pas
  14. 17 14
      CryptoLib.Tests/src/Math/ECPointTests.pas
  15. 2 2
      CryptoLib.Tests/src/Others/ECDsa5Tests.pas
  16. 34 31
      CryptoLib.Tests/src/Utils/ClpFixedSecureRandom.pas
  17. 9 9
      CryptoLib/src/Asn1/ClpAsn1EncodableVector.pas
  18. 32 28
      CryptoLib/src/Asn1/ClpAsn1InputStream.pas
  19. 2 2
      CryptoLib/src/Asn1/ClpAsn1Object.pas
  20. 5 4
      CryptoLib/src/Asn1/ClpAsn1OctetString.pas
  21. 5 4
      CryptoLib/src/Asn1/ClpAsn1Sequence.pas
  22. 7 7
      CryptoLib/src/Asn1/ClpAsn1Set.pas
  23. 6 6
      CryptoLib/src/Asn1/ClpAsn1StreamParser.pas
  24. 6 4
      CryptoLib/src/Asn1/ClpBerBitString.pas
  25. 4 4
      CryptoLib/src/Asn1/ClpBerOctetString.pas
  26. 2 2
      CryptoLib/src/Asn1/ClpBerSequence.pas
  27. 2 2
      CryptoLib/src/Asn1/ClpDefiniteLengthInputStream.pas
  28. 9 9
      CryptoLib/src/Asn1/ClpDerApplicationSpecific.pas
  29. 12 10
      CryptoLib/src/Asn1/ClpDerBitString.pas
  30. 4 4
      CryptoLib/src/Asn1/ClpDerBmpString.pas
  31. 6 6
      CryptoLib/src/Asn1/ClpDerBoolean.pas
  32. 6 6
      CryptoLib/src/Asn1/ClpDerEnumerated.pas
  33. 5 4
      CryptoLib/src/Asn1/ClpDerGeneralString.pas
  34. 18 16
      CryptoLib/src/Asn1/ClpDerGenerator.pas
  35. 8 7
      CryptoLib/src/Asn1/ClpDerGraphicString.pas
  36. 4 4
      CryptoLib/src/Asn1/ClpDerIA5String.pas
  37. 5 4
      CryptoLib/src/Asn1/ClpDerInteger.pas
  38. 5 4
      CryptoLib/src/Asn1/ClpDerNumericString.pas
  39. 21 20
      CryptoLib/src/Asn1/ClpDerObjectIdentifier.pas
  40. 7 6
      CryptoLib/src/Asn1/ClpDerOctetString.pas
  41. 13 11
      CryptoLib/src/Asn1/ClpDerOutputStream.pas
  42. 5 5
      CryptoLib/src/Asn1/ClpDerPrintableString.pas
  43. 2 2
      CryptoLib/src/Asn1/ClpDerSequence.pas
  44. 2 2
      CryptoLib/src/Asn1/ClpDerSet.pas
  45. 4 4
      CryptoLib/src/Asn1/ClpDerT61String.pas
  46. 5 5
      CryptoLib/src/Asn1/ClpDerUniversalString.pas
  47. 4 4
      CryptoLib/src/Asn1/ClpDerUtf8String.pas
  48. 9 8
      CryptoLib/src/Asn1/ClpDerVideotexString.pas
  49. 5 4
      CryptoLib/src/Asn1/ClpDerVisibleString.pas
  50. 3 2
      CryptoLib/src/Asn1/X9/ClpX9Curve.pas
  51. 4 4
      CryptoLib/src/Asn1/X9/ClpX9ECParameters.pas
  52. 3 2
      CryptoLib/src/Asn1/X9/ClpX9ECPoint.pas
  53. 15 13
      CryptoLib/src/Crypto/ClpBufferedBlockCipher.pas
  54. 30 27
      CryptoLib/src/Crypto/ClpBufferedCipherBase.pas
  55. 16 13
      CryptoLib/src/Crypto/ClpIESCipher.pas
  56. 6 4
      CryptoLib/src/Crypto/Digests/ClpDigest.pas
  57. 14 14
      CryptoLib/src/Crypto/Engines/ClpAesEngine.pas
  58. 16 14
      CryptoLib/src/Crypto/Engines/ClpAesLightEngine.pas
  59. 17 15
      CryptoLib/src/Crypto/Engines/ClpIESEngine.pas
  60. 10 9
      CryptoLib/src/Crypto/Engines/ClpPascalCoinIESEngine.pas
  61. 8 7
      CryptoLib/src/Crypto/Generators/ClpDsaParametersGenerator.pas
  62. 2 2
      CryptoLib/src/Crypto/Generators/ClpHkdfBytesGenerator.pas
  63. 3 3
      CryptoLib/src/Crypto/Generators/ClpPbeParametersGenerator.pas
  64. 3 3
      CryptoLib/src/Crypto/Generators/ClpPkcs5S2ParametersGenerator.pas
  65. 5 4
      CryptoLib/src/Crypto/Macs/ClpHMac.pas
  66. 12 12
      CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas
  67. 12 12
      CryptoLib/src/Crypto/Modes/ClpCfbBlockCipher.pas
  68. 4 4
      CryptoLib/src/Crypto/Modes/ClpOfbBlockCipher.pas
  69. 4 4
      CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas
  70. 4 4
      CryptoLib/src/Crypto/Paddings/ClpISO10126d2Padding.pas
  71. 4 4
      CryptoLib/src/Crypto/Paddings/ClpISO7816d4Padding.pas
  72. 10 8
      CryptoLib/src/Crypto/Paddings/ClpPaddedBufferedBlockCipher.pas
  73. 4 4
      CryptoLib/src/Crypto/Paddings/ClpPkcs7Padding.pas
  74. 4 4
      CryptoLib/src/Crypto/Paddings/ClpTTBCPadding.pas
  75. 4 4
      CryptoLib/src/Crypto/Paddings/ClpX923Padding.pas
  76. 4 4
      CryptoLib/src/Crypto/Paddings/ClpZeroBytePadding.pas
  77. 5 4
      CryptoLib/src/Crypto/Parameters/ClpDsaValidationParameters.pas
  78. 2 2
      CryptoLib/src/Crypto/Parameters/ClpECDomainParameters.pas
  79. 11 11
      CryptoLib/src/Crypto/Parameters/ClpHkdfParameters.pas
  80. 3 3
      CryptoLib/src/Crypto/Parameters/ClpIESParameters.pas
  81. 11 10
      CryptoLib/src/Crypto/Parameters/ClpIESWithCipherParameters.pas
  82. 2 2
      CryptoLib/src/Crypto/Parameters/ClpIso18033KdfParameters.pas
  83. 2 2
      CryptoLib/src/Crypto/Parameters/ClpKdfParameters.pas
  84. 4 4
      CryptoLib/src/Crypto/Parameters/ClpKeyParameter.pas
  85. 4 4
      CryptoLib/src/Crypto/Parameters/ClpParametersWithIV.pas
  86. 2 2
      CryptoLib/src/Crypto/Parsers/ClpECIESPublicKeyParser.pas
  87. 8 6
      CryptoLib/src/Crypto/Prng/ClpCryptoApiRandomGenerator.pas
  88. 15 11
      CryptoLib/src/Crypto/Prng/ClpDigestRandomGenerator.pas
  89. 8 7
      CryptoLib/src/Crypto/Signers/ClpDsaDigestSigner.pas
  90. 7 7
      CryptoLib/src/Crypto/Signers/ClpDsaSigner.pas
  91. 7 7
      CryptoLib/src/Crypto/Signers/ClpECDsaSigner.pas
  92. 4 4
      CryptoLib/src/Crypto/Signers/ClpECNRSigner.pas
  93. 10 9
      CryptoLib/src/Crypto/Signers/ClpECSchnorrSigner.pas
  94. 5 4
      CryptoLib/src/Crypto/Signers/ClpHMacDsaKCalculator.pas
  95. 3 3
      CryptoLib/src/Crypto/Signers/ClpRandomDsaKCalculator.pas
  96. 2 2
      CryptoLib/src/Interfaces/ClpIAsn1EncodableVector.pas
  97. 2 2
      CryptoLib/src/Interfaces/ClpIBlockCipher.pas
  98. 2 2
      CryptoLib/src/Interfaces/ClpIBlockCipherPadding.pas
  99. 15 13
      CryptoLib/src/Interfaces/ClpIBufferedCipher.pas
  100. 1 1
      CryptoLib/src/Interfaces/ClpIDerApplicationSpecific.pas

+ 4 - 4
CryptoLib.Tests/src/Asn1/Asn1SequenceParserTests.pas

@@ -66,8 +66,8 @@ type
       FberDerNestedSeqData, FberNestedSeqData, FberExpTagSeqData,
       FberDerNestedSeqData, FberNestedSeqData, FberExpTagSeqData,
       FberSeqWithDERNullData: TCryptoLibByteArray;
       FberSeqWithDERNullData: TCryptoLibByteArray;
 
 
-    procedure doTestNestedReading(data: TCryptoLibByteArray);
-    procedure doTestParseWithNull(data: TCryptoLibByteArray);
+    procedure doTestNestedReading(const data: TCryptoLibByteArray);
+    procedure doTestParseWithNull(const data: TCryptoLibByteArray);
 
 
   protected
   protected
     procedure SetUp; override;
     procedure SetUp; override;
@@ -97,7 +97,7 @@ implementation
 { TTestAsn1SequenceParser }
 { TTestAsn1SequenceParser }
 
 
 procedure TTestAsn1SequenceParser.doTestNestedReading
 procedure TTestAsn1SequenceParser.doTestNestedReading
-  (data: TCryptoLibByteArray);
+  (const data: TCryptoLibByteArray);
 var
 var
   aIn: IAsn1StreamParser;
   aIn: IAsn1StreamParser;
   seq, s: IAsn1SequenceParser;
   seq, s: IAsn1SequenceParser;
@@ -147,7 +147,7 @@ begin
 end;
 end;
 
 
 procedure TTestAsn1SequenceParser.doTestParseWithNull
 procedure TTestAsn1SequenceParser.doTestParseWithNull
-  (data: TCryptoLibByteArray);
+  (const data: TCryptoLibByteArray);
 var
 var
   aIn: IAsn1StreamParser;
   aIn: IAsn1StreamParser;
   seq: IAsn1SequenceParser;
   seq: IAsn1SequenceParser;

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

@@ -54,7 +54,7 @@ type
     Foid: string;
     Foid: string;
     Freq1, Freq2: TCryptoLibByteArray;
     Freq1, Freq2: TCryptoLibByteArray;
 
 
-    procedure recodeCheck(const oid: String; enc: TBytes);
+    procedure recodeCheck(const oid: String; const enc: TBytes);
     procedure validOidCheck(const oid: String);
     procedure validOidCheck(const oid: String);
     procedure invalidOidCheck;
     procedure invalidOidCheck;
     procedure branchCheck(const stem, branch: String);
     procedure branchCheck(const stem, branch: String);
@@ -116,7 +116,7 @@ begin
   CheckEquals(expected, actual, 'failed "on" check for ' + stem + '"/"' + test);
   CheckEquals(expected, actual, 'failed "on" check for ' + stem + '"/"' + test);
 end;
 end;
 
 
-procedure TTestOID.recodeCheck(const oid: String; enc: TBytes);
+procedure TTestOID.recodeCheck(const oid: String; const enc: TBytes);
 var
 var
   o, encO: IDerObjectIdentifier;
   o, encO: IDerObjectIdentifier;
   bytes: TBytes;
   bytes: TBytes;

+ 3 - 2
CryptoLib.Tests/src/Crypto/AESTests.pas

@@ -74,7 +74,8 @@ type
   TTestAES = class(TCryptoLibTestCase)
   TTestAES = class(TCryptoLibTestCase)
   private
   private
 
 
-    procedure dooidTest(oids, names: TCryptoLibStringArray; groupSize: Int32);
+    procedure dooidTest(const oids, names: TCryptoLibStringArray;
+      groupSize: Int32);
 
 
     procedure doAESTest(const cipher: IBufferedCipher;
     procedure doAESTest(const cipher: IBufferedCipher;
       const param: ICipherParameters; const input, output: String;
       const param: ICipherParameters; const input, output: String;
@@ -161,7 +162,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TTestAES.dooidTest(oids, names: TCryptoLibStringArray;
+procedure TTestAES.dooidTest(const oids, names: TCryptoLibStringArray;
   groupSize: Int32);
   groupSize: Int32);
 var
 var
   data, result, IV: TBytes;
   data, result, IV: TBytes;

+ 8 - 8
CryptoLib.Tests/src/Crypto/DSATests.pas

@@ -98,9 +98,9 @@ type
     Ffirst: Boolean;
     Ffirst: Boolean;
 
 
   public
   public
-    constructor Create(value: TCryptoLibByteArray);
+    constructor Create(const value: TCryptoLibByteArray);
 
 
-    procedure NextBytes(bytes: TCryptoLibByteArray); override;
+    procedure NextBytes(const bytes: TCryptoLibByteArray); override;
 
 
   end;
   end;
 
 
@@ -129,12 +129,12 @@ type
 
 
     procedure DoCheckMessage(const sgr: ISigner;
     procedure DoCheckMessage(const sgr: ISigner;
       const sKey: IECPrivateKeyParameters; const vKey: IECPublicKeyParameters;
       const sKey: IECPrivateKeyParameters; const vKey: IECPublicKeyParameters;
-      &message, sig: TCryptoLibByteArray);
+      const &message, sig: TCryptoLibByteArray);
 
 
     procedure DoTestKeyGeneration(keysize: Int32);
     procedure DoTestKeyGeneration(keysize: Int32);
     procedure DoTestBadStrength(strength: Int32);
     procedure DoTestBadStrength(strength: Int32);
 
 
-    function DoDerDecode(encoding: TCryptoLibByteArray)
+    function DoDerDecode(const encoding: TCryptoLibByteArray)
       : TCryptoLibGenericArray<TBigInteger>;
       : TCryptoLibGenericArray<TBigInteger>;
 
 
   protected
   protected
@@ -184,7 +184,7 @@ implementation
 
 
 procedure TTestDSA.DoCheckMessage(const sgr: ISigner;
 procedure TTestDSA.DoCheckMessage(const sgr: ISigner;
   const sKey: IECPrivateKeyParameters; const vKey: IECPublicKeyParameters;
   const sKey: IECPrivateKeyParameters; const vKey: IECPublicKeyParameters;
-  &message, sig: TCryptoLibByteArray);
+  const &message, sig: TCryptoLibByteArray);
 var
 var
   kData, sigBytes: TCryptoLibByteArray;
   kData, sigBytes: TCryptoLibByteArray;
   k: ISecureRandom;
   k: ISecureRandom;
@@ -218,7 +218,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TTestDSA.DoDerDecode(encoding: TCryptoLibByteArray)
+function TTestDSA.DoDerDecode(const encoding: TCryptoLibByteArray)
   : TCryptoLibGenericArray<TBigInteger>;
   : TCryptoLibGenericArray<TBigInteger>;
 var
 var
   s: IAsn1Sequence;
   s: IAsn1Sequence;
@@ -1946,13 +1946,13 @@ end;
 
 
 { TDSATestSecureRandom }
 { TDSATestSecureRandom }
 
 
-constructor TDSATestSecureRandom.Create(value: TCryptoLibByteArray);
+constructor TDSATestSecureRandom.Create(const value: TCryptoLibByteArray);
 begin
 begin
   Inherited Create(System.Copy(value));
   Inherited Create(System.Copy(value));
   Ffirst := true;
   Ffirst := true;
 end;
 end;
 
 
-procedure TDSATestSecureRandom.NextBytes(bytes: TCryptoLibByteArray);
+procedure TDSATestSecureRandom.NextBytes(const bytes: TCryptoLibByteArray);
 begin
 begin
   if (Ffirst) then
   if (Ffirst) then
   begin
   begin

+ 2 - 2
CryptoLib.Tests/src/Crypto/DeterministicDsaTests.pas

@@ -91,7 +91,7 @@ type
       const privKey: IECPrivateKeyParameters; const r, s: TBigInteger);
       const privKey: IECPrivateKeyParameters; const r, s: TBigInteger);
 
 
     procedure DoTestHMacDetECDsa(const detSigner: IDsa; const digest: IDigest;
     procedure DoTestHMacDetECDsa(const detSigner: IDsa; const digest: IDigest;
-      data: TCryptoLibByteArray; const privKey: ICipherParameters;
+      const data: TCryptoLibByteArray; const privKey: ICipherParameters;
       const r, s: TBigInteger);
       const r, s: TBigInteger);
 
 
   protected
   protected
@@ -221,7 +221,7 @@ begin
 end;
 end;
 
 
 procedure TTestDeterministicDsa.DoTestHMacDetECDsa(const detSigner: IDsa;
 procedure TTestDeterministicDsa.DoTestHMacDetECDsa(const detSigner: IDsa;
-  const digest: IDigest; data: TCryptoLibByteArray;
+  const digest: IDigest; const data: TCryptoLibByteArray;
   const privKey: ICipherParameters; const r, s: TBigInteger);
   const privKey: ICipherParameters; const r, s: TBigInteger);
 var
 var
   m: TCryptoLibByteArray;
   m: TCryptoLibByteArray;

+ 16 - 14
CryptoLib.Tests/src/Crypto/DigestRandomNumberTests.pas

@@ -56,12 +56,14 @@ type
       FnoCycle0SHA256, Fexpected100SHA1, Fexpected100SHA256, FexpectedTestSHA1,
       FnoCycle0SHA256, Fexpected100SHA1, Fexpected100SHA256, FexpectedTestSHA1,
       FexpectedTestSHA256, Fsha1Xors, Fsha256Xors: TBytes;
       FexpectedTestSHA256, Fsha1Xors, Fsha256Xors: TBytes;
 
 
-    procedure doExpectedTest(digest: IDigest; seed: Int32;
-      expected: TBytes); overload;
-    procedure doExpectedTest(digest: IDigest; seed, expected: TBytes); overload;
-    procedure doExpectedTest(digest: IDigest; seed: Int32;
-      expected, noCycle: TBytes); overload;
-    procedure doCountTest(digest: IDigest; seed, expectedXors: TBytes);
+    procedure doExpectedTest(const digest: IDigest; seed: Int32;
+      const expected: TBytes); overload;
+    procedure doExpectedTest(const digest: IDigest;
+      const seed, expected: TBytes); overload;
+    procedure doExpectedTest(const digest: IDigest; seed: Int32;
+      const expected, noCycle: TBytes); overload;
+    procedure doCountTest(const digest: IDigest;
+      const seed, expectedXors: TBytes);
 
 
   protected
   protected
     procedure SetUp; override;
     procedure SetUp; override;
@@ -75,8 +77,8 @@ implementation
 
 
 { TTestDigestRandomNumber }
 { TTestDigestRandomNumber }
 
 
-procedure TTestDigestRandomNumber.doCountTest(digest: IDigest;
-  seed, expectedXors: TBytes);
+procedure TTestDigestRandomNumber.doCountTest(const digest: IDigest;
+  const seed, expectedXors: TBytes);
 var
 var
   rGen: IDigestRandomGenerator;
   rGen: IDigestRandomGenerator;
   output, ands, xors, ors: TBytes;
   output, ands, xors, ors: TBytes;
@@ -133,14 +135,14 @@ begin
 
 
 end;
 end;
 
 
-procedure TTestDigestRandomNumber.doExpectedTest(digest: IDigest; seed: Int32;
-  expected: TBytes);
+procedure TTestDigestRandomNumber.doExpectedTest(const digest: IDigest;
+  seed: Int32; const expected: TBytes);
 begin
 begin
   doExpectedTest(digest, seed, expected, Nil);
   doExpectedTest(digest, seed, expected, Nil);
 end;
 end;
 
 
-procedure TTestDigestRandomNumber.doExpectedTest(digest: IDigest; seed: Int32;
-  expected, noCycle: TBytes);
+procedure TTestDigestRandomNumber.doExpectedTest(const digest: IDigest;
+  seed: Int32; const expected, noCycle: TBytes);
 var
 var
   rGen: IDigestRandomGenerator;
   rGen: IDigestRandomGenerator;
   output: TBytes;
   output: TBytes;
@@ -173,8 +175,8 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TTestDigestRandomNumber.doExpectedTest(digest: IDigest;
-  seed, expected: TBytes);
+procedure TTestDigestRandomNumber.doExpectedTest(const digest: IDigest;
+  const seed, expected: TBytes);
 var
 var
   rGen: IDigestRandomGenerator;
   rGen: IDigestRandomGenerator;
   output: TBytes;
   output: TBytes;

+ 5 - 4
CryptoLib.Tests/src/Crypto/HMacTests.pas

@@ -66,9 +66,10 @@ type
       FoutputSha3_224, FoutputSha3_256, FoutputSha3_384, FoutputSha3_512,
       FoutputSha3_224, FoutputSha3_256, FoutputSha3_384, FoutputSha3_512,
       FoutputGost2012_256, FoutputGost2012_512: TBytes;
       FoutputGost2012_256, FoutputGost2012_512: TBytes;
 
 
-    procedure DoTestHMac(const hmacName: String; output: TBytes); overload;
+    procedure DoTestHMac(const hmacName: String; const output: TBytes);
+      overload;
     procedure DoTestHMac(const hmacName: String; defKeySize: Int32;
     procedure DoTestHMac(const hmacName: String; defKeySize: Int32;
-      output: TBytes); overload;
+      const output: TBytes); overload;
     procedure DoTestExceptions();
     procedure DoTestExceptions();
 
 
   protected
   protected
@@ -100,7 +101,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TTestHMac.DoTestHMac(const hmacName: String; output: TBytes);
+procedure TTestHMac.DoTestHMac(const hmacName: String; const output: TBytes);
 var
 var
   key: IKeyParameter;
   key: IKeyParameter;
   mac: IMac;
   mac: IMac;
@@ -129,7 +130,7 @@ begin
 end;
 end;
 
 
 procedure TTestHMac.DoTestHMac(const hmacName: String; defKeySize: Int32;
 procedure TTestHMac.DoTestHMac(const hmacName: String; defKeySize: Int32;
-  output: TBytes);
+  const output: TBytes);
 var
 var
   key: IKeyParameter;
   key: IKeyParameter;
   mac: IMac;
   mac: IMac;

+ 2 - 2
CryptoLib.Tests/src/Crypto/HkdfGeneratorTests.pas

@@ -56,7 +56,7 @@ type
   private
   private
 
 
     procedure CompareOkm(test: Int32;
     procedure CompareOkm(test: Int32;
-      calculatedOkm, testOkm: TCryptoLibByteArray);
+      const calculatedOkm, testOkm: TCryptoLibByteArray);
     procedure DoTestHKDF();
     procedure DoTestHKDF();
 
 
   protected
   protected
@@ -73,7 +73,7 @@ implementation
 { TTestHkdfGenerator }
 { TTestHkdfGenerator }
 
 
 procedure TTestHkdfGenerator.CompareOkm(test: Int32;
 procedure TTestHkdfGenerator.CompareOkm(test: Int32;
-  calculatedOkm, testOkm: TCryptoLibByteArray);
+  const calculatedOkm, testOkm: TCryptoLibByteArray);
 begin
 begin
   if (not TArrayUtils.AreEqual(calculatedOkm, testOkm)) then
   if (not TArrayUtils.AreEqual(calculatedOkm, testOkm)) then
   begin
   begin

+ 5 - 4
CryptoLib.Tests/src/Crypto/PaddingTests.pas

@@ -72,9 +72,10 @@ type
 
 
     procedure DoBlockCheck(const cipher: IPaddedBufferedBlockCipher;
     procedure DoBlockCheck(const cipher: IPaddedBufferedBlockCipher;
       const padding: IBlockCipherPadding; const key: IKeyParameter;
       const padding: IBlockCipherPadding; const key: IKeyParameter;
-      data: TCryptoLibByteArray);
+      const data: TCryptoLibByteArray);
     procedure DoTestPadding(const padding: IBlockCipherPadding;
     procedure DoTestPadding(const padding: IBlockCipherPadding;
-      const rand: ISecureRandom; ffVector, ZeroVector: TCryptoLibByteArray);
+      const rand: ISecureRandom;
+      const ffVector, ZeroVector: TCryptoLibByteArray);
 
 
   protected
   protected
     procedure SetUp; override;
     procedure SetUp; override;
@@ -93,7 +94,7 @@ implementation
 
 
 procedure TTestPadding.DoBlockCheck(const cipher: IPaddedBufferedBlockCipher;
 procedure TTestPadding.DoBlockCheck(const cipher: IPaddedBufferedBlockCipher;
   const padding: IBlockCipherPadding; const key: IKeyParameter;
   const padding: IBlockCipherPadding; const key: IKeyParameter;
-  data: TCryptoLibByteArray);
+  const data: TCryptoLibByteArray);
 var
 var
   &out, dec: TBytes;
   &out, dec: TBytes;
   len, decLen: Int32;
   len, decLen: Int32;
@@ -231,7 +232,7 @@ begin
 end;
 end;
 
 
 procedure TTestPadding.DoTestPadding(const padding: IBlockCipherPadding;
 procedure TTestPadding.DoTestPadding(const padding: IBlockCipherPadding;
-  const rand: ISecureRandom; ffVector, ZeroVector: TCryptoLibByteArray);
+  const rand: ISecureRandom; const ffVector, ZeroVector: TCryptoLibByteArray);
 var
 var
   cipher: IPaddedBufferedBlockCipher;
   cipher: IPaddedBufferedBlockCipher;
   key: IKeyParameter;
   key: IKeyParameter;

+ 2 - 2
CryptoLib.Tests/src/Math/EC/Custom/Sec/SecP384R1FieldTests.pas

@@ -62,7 +62,7 @@ type
     function GenerateMultiplyInput_Random(): IECFieldElement;
     function GenerateMultiplyInput_Random(): IECFieldElement;
     function GenerateSquareInput_CarryBug(): IECFieldElement;
     function GenerateSquareInput_CarryBug(): IECFieldElement;
     function Nat_Create(len: Int32): TCryptoLibUInt32Array;
     function Nat_Create(len: Int32): TCryptoLibUInt32Array;
-    function Nat_ToBigInteger(len: Int32; x: TCryptoLibUInt32Array)
+    function Nat_ToBigInteger(len: Int32; const x: TCryptoLibUInt32Array)
       : TBigInteger;
       : TBigInteger;
 
 
   protected
   protected
@@ -122,7 +122,7 @@ begin
 end;
 end;
 
 
 function TTestSecP384R1Field.Nat_ToBigInteger(len: Int32;
 function TTestSecP384R1Field.Nat_ToBigInteger(len: Int32;
-  x: TCryptoLibUInt32Array): TBigInteger;
+  const x: TCryptoLibUInt32Array): TBigInteger;
 var
 var
   bs, temp: TCryptoLibByteArray;
   bs, temp: TCryptoLibByteArray;
   i: Int32;
   i: Int32;

+ 9 - 7
CryptoLib.Tests/src/Math/ECAlgorithmsTests.pas

@@ -69,10 +69,10 @@ type
     procedure DoTestSumOfMultiplies(const x9: IX9ECParameters);
     procedure DoTestSumOfMultiplies(const x9: IX9ECParameters);
     procedure DoTestSumOfTwoMultiplies(const x9: IX9ECParameters);
     procedure DoTestSumOfTwoMultiplies(const x9: IX9ECParameters);
     procedure AssertPointsEqual(const msg: String; const a, b: IECPoint);
     procedure AssertPointsEqual(const msg: String; const a, b: IECPoint);
-    function CopyPoints(ps: TCryptoLibGenericArray<IECPoint>; len: Int32)
+    function CopyPoints(const ps: TCryptoLibGenericArray<IECPoint>; len: Int32)
       : TCryptoLibGenericArray<IECPoint>;
       : TCryptoLibGenericArray<IECPoint>;
-    function CopyScalars(ks: TCryptoLibGenericArray<TBigInteger>; len: Int32)
-      : TCryptoLibGenericArray<TBigInteger>;
+    function CopyScalars(const ks: TCryptoLibGenericArray<TBigInteger>;
+      len: Int32): TCryptoLibGenericArray<TBigInteger>;
 
 
     function GetRandomPoint(const x9: IX9ECParameters): IECPoint;
     function GetRandomPoint(const x9: IX9ECParameters): IECPoint;
     function GetRandomScalar(const x9: IX9ECParameters): TBigInteger;
     function GetRandomScalar(const x9: IX9ECParameters): TBigInteger;
@@ -133,15 +133,17 @@ begin
   CheckEquals(True, a.Equals(b), msg);
   CheckEquals(True, a.Equals(b), msg);
 end;
 end;
 
 
-function TTestECAlgorithms.CopyPoints(ps: TCryptoLibGenericArray<IECPoint>;
-  len: Int32): TCryptoLibGenericArray<IECPoint>;
+function TTestECAlgorithms.CopyPoints
+  (const ps: TCryptoLibGenericArray<IECPoint>; len: Int32)
+  : TCryptoLibGenericArray<IECPoint>;
 begin
 begin
   System.SetLength(Result, len);
   System.SetLength(Result, len);
   Result := System.Copy(ps, 0, len);
   Result := System.Copy(ps, 0, len);
 end;
 end;
 
 
-function TTestECAlgorithms.CopyScalars(ks: TCryptoLibGenericArray<TBigInteger>;
-  len: Int32): TCryptoLibGenericArray<TBigInteger>;
+function TTestECAlgorithms.CopyScalars
+  (const ks: TCryptoLibGenericArray<TBigInteger>; len: Int32)
+  : TCryptoLibGenericArray<TBigInteger>;
 begin
 begin
   System.SetLength(Result, len);
   System.SetLength(Result, len);
   Result := System.Copy(ks, 0, len);
   Result := System.Copy(ks, 0, len);

+ 5 - 4
CryptoLib.Tests/src/Math/ECIESTests.pas

@@ -94,10 +94,10 @@ type
   var
   var
     FAES_IV: TBytes;
     FAES_IV: TBytes;
 
 
-    procedure DoStaticTest(iv: TBytes);
+    procedure DoStaticTest(const iv: TBytes);
     procedure DoShortTest();
     procedure DoShortTest();
     procedure DoTest(const p1, p2: IAsymmetricCipherKeyPair);
     procedure DoTest(const p1, p2: IAsymmetricCipherKeyPair);
-    procedure DoEphemeralTest(iv: TBytes; usePointCompression: Boolean);
+    procedure DoEphemeralTest(const iv: TBytes; usePointCompression: Boolean);
 
 
   protected
   protected
     procedure SetUp; override;
     procedure SetUp; override;
@@ -112,7 +112,8 @@ implementation
 
 
 { TTestECIES }
 { TTestECIES }
 
 
-procedure TTestECIES.DoEphemeralTest(iv: TBytes; usePointCompression: Boolean);
+procedure TTestECIES.DoEphemeralTest(const iv: TBytes;
+  usePointCompression: Boolean);
 var
 var
   n: TBigInteger;
   n: TBigInteger;
   curve: IFpCurve;
   curve: IFpCurve;
@@ -382,7 +383,7 @@ begin
 
 
 end;
 end;
 
 
-procedure TTestECIES.DoStaticTest(iv: TBytes);
+procedure TTestECIES.DoStaticTest(const iv: TBytes);
 var
 var
   n: TBigInteger;
   n: TBigInteger;
   curve: IFpCurve;
   curve: IFpCurve;

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

@@ -72,10 +72,10 @@ type
 
 
     procedure DoCheckSignature(size: Int32; const sKey: IECPrivateKeyParameters;
     procedure DoCheckSignature(size: Int32; const sKey: IECPrivateKeyParameters;
       const vKey: IECPublicKeyParameters; const sgr: ISigner;
       const vKey: IECPublicKeyParameters; const sgr: ISigner;
-      const k: ISecureRandom; &message: TCryptoLibByteArray;
+      const k: ISecureRandom; const &message: TCryptoLibByteArray;
       const r, s: TBigInteger);
       const r, s: TBigInteger);
 
 
-    function DoDerDecode(encoding: TCryptoLibByteArray)
+    function DoDerDecode(const encoding: TCryptoLibByteArray)
       : TCryptoLibGenericArray<TBigInteger>;
       : TCryptoLibGenericArray<TBigInteger>;
 
 
   protected
   protected
@@ -137,8 +137,8 @@ implementation
 
 
 procedure TTestECNR.DoCheckSignature(size: Int32;
 procedure TTestECNR.DoCheckSignature(size: Int32;
   const sKey: IECPrivateKeyParameters; const vKey: IECPublicKeyParameters;
   const sKey: IECPrivateKeyParameters; const vKey: IECPublicKeyParameters;
-  const sgr: ISigner; const k: ISecureRandom; &message: TCryptoLibByteArray;
-  const r, s: TBigInteger);
+  const sgr: ISigner; const k: ISecureRandom;
+  const &message: TCryptoLibByteArray; const r, s: TBigInteger);
 var
 var
   sigBytes: TBytes;
   sigBytes: TBytes;
   sig: TCryptoLibGenericArray<TBigInteger>;
   sig: TCryptoLibGenericArray<TBigInteger>;
@@ -176,7 +176,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TTestECNR.DoDerDecode(encoding: TCryptoLibByteArray)
+function TTestECNR.DoDerDecode(const encoding: TCryptoLibByteArray)
   : TCryptoLibGenericArray<TBigInteger>;
   : TCryptoLibGenericArray<TBigInteger>;
 var
 var
   s: IAsn1Sequence;
   s: IAsn1Sequence;

+ 17 - 14
CryptoLib.Tests/src/Math/ECPointTests.pas

@@ -113,10 +113,11 @@ type
     F2mInstance: TF2m;
     F2mInstance: TF2m;
 
 
     procedure AssertPointsEqual(const msg: String; const a, b: IECPoint);
     procedure AssertPointsEqual(const msg: String; const a, b: IECPoint);
-    procedure AssertBigIntegersEqual(a, b: TBigInteger);
-    procedure AssertIFiniteFieldsEqual(a, b: IFiniteField);
-    procedure AssertOptionalValuesAgree(a, b: TBigInteger); overload;
-    procedure AssertOptionalValuesAgree(a, b: TCryptoLibByteArray); overload;
+    procedure AssertBigIntegersEqual(const a, b: TBigInteger);
+    procedure AssertIFiniteFieldsEqual(const a, b: IFiniteField);
+    procedure AssertOptionalValuesAgree(const a, b: TBigInteger); overload;
+    procedure AssertOptionalValuesAgree(const a,
+      b: TCryptoLibByteArray); overload;
 
 
     procedure AssertECFieldElementsEqual(const a, b: IECFieldElement);
     procedure AssertECFieldElementsEqual(const a, b: IECFieldElement);
 
 
@@ -128,7 +129,7 @@ type
     // * @param infinity
     // * @param infinity
     // *            The point at infinity on the respective curve.
     // *            The point at infinity on the respective curve.
     // */
     // */
-    procedure ImplTestAdd(p: TCryptoLibGenericArray<IECPoint>;
+    procedure ImplTestAdd(const p: TCryptoLibGenericArray<IECPoint>;
       const infinity: IECPoint);
       const infinity: IECPoint);
 
 
     // /**
     // /**
@@ -137,9 +138,9 @@ type
     // * @param p
     // * @param p
     // *            The array of literature values.
     // *            The array of literature values.
     // */
     // */
-    procedure ImplTestTwice(p: TCryptoLibGenericArray<IECPoint>);
+    procedure ImplTestTwice(const p: TCryptoLibGenericArray<IECPoint>);
 
 
-    procedure ImplTestThreeTimes(p: TCryptoLibGenericArray<IECPoint>);
+    procedure ImplTestThreeTimes(const p: TCryptoLibGenericArray<IECPoint>);
 
 
     // /**
     // /**
     // * Goes through all points on an elliptic curve and checks, if adding a
     // * Goes through all points on an elliptic curve and checks, if adding a
@@ -263,17 +264,17 @@ begin
   CheckEquals(True, a.Equals(b));
   CheckEquals(True, a.Equals(b));
 end;
 end;
 
 
-procedure TTestECPoint.AssertBigIntegersEqual(a, b: TBigInteger);
+procedure TTestECPoint.AssertBigIntegersEqual(const a, b: TBigInteger);
 begin
 begin
   CheckEquals(True, a.Equals(b));
   CheckEquals(True, a.Equals(b));
 end;
 end;
 
 
-procedure TTestECPoint.AssertIFiniteFieldsEqual(a, b: IFiniteField);
+procedure TTestECPoint.AssertIFiniteFieldsEqual(const a, b: IFiniteField);
 begin
 begin
   CheckEquals(True, (a as TObject).Equals(b as TObject));
   CheckEquals(True, (a as TObject).Equals(b as TObject));
 end;
 end;
 
 
-procedure TTestECPoint.AssertOptionalValuesAgree(a, b: TBigInteger);
+procedure TTestECPoint.AssertOptionalValuesAgree(const a, b: TBigInteger);
 begin
 begin
   if ((a.IsInitialized) and (b.IsInitialized)) then
   if ((a.IsInitialized) and (b.IsInitialized)) then
   begin
   begin
@@ -281,7 +282,8 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TTestECPoint.AssertOptionalValuesAgree(a, b: TCryptoLibByteArray);
+procedure TTestECPoint.AssertOptionalValuesAgree(const a,
+  b: TCryptoLibByteArray);
 begin
 begin
   if ((a <> Nil) and (b <> Nil)) then
   if ((a <> Nil) and (b <> Nil)) then
   begin
   begin
@@ -405,7 +407,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TTestECPoint.ImplTestAdd(p: TCryptoLibGenericArray<IECPoint>;
+procedure TTestECPoint.ImplTestAdd(const p: TCryptoLibGenericArray<IECPoint>;
   const infinity: IECPoint);
   const infinity: IECPoint);
 var
 var
   i: Int32;
   i: Int32;
@@ -496,7 +498,8 @@ begin
 
 
 end;
 end;
 
 
-procedure TTestECPoint.ImplTestThreeTimes(p: TCryptoLibGenericArray<IECPoint>);
+procedure TTestECPoint.ImplTestThreeTimes
+  (const p: TCryptoLibGenericArray<IECPoint>);
 var
 var
   Lp, _3P: IECPoint;
   Lp, _3P: IECPoint;
 begin
 begin
@@ -506,7 +509,7 @@ begin
   AssertPointsEqual('TwicePlus incorrect', _3P, Lp.TwicePlus(Lp));
   AssertPointsEqual('TwicePlus incorrect', _3P, Lp.TwicePlus(Lp));
 end;
 end;
 
 
-procedure TTestECPoint.ImplTestTwice(p: TCryptoLibGenericArray<IECPoint>);
+procedure TTestECPoint.ImplTestTwice(const p: TCryptoLibGenericArray<IECPoint>);
 begin
 begin
   AssertPointsEqual('Twice incorrect', p[3], p[0].Twice());
   AssertPointsEqual('Twice incorrect', p[3], p[0].Twice());
   AssertPointsEqual('Add same point incorrect', p[3], p[0].Add(p[0]));
   AssertPointsEqual('Add same point incorrect', p[3], p[0].Add(p[0]));

+ 2 - 2
CryptoLib.Tests/src/Others/ECDsa5Tests.pas

@@ -69,7 +69,7 @@ type
   TTestECDsa5 = class(TCryptoLibTestCase)
   TTestECDsa5 = class(TCryptoLibTestCase)
 
 
   private
   private
-    function derDecode(encoding: TCryptoLibByteArray)
+    function derDecode(const encoding: TCryptoLibByteArray)
       : TCryptoLibGenericArray<TBigInteger>;
       : TCryptoLibGenericArray<TBigInteger>;
 
 
   protected
   protected
@@ -98,7 +98,7 @@ implementation
 
 
 { TTestECDsa5 }
 { TTestECDsa5 }
 
 
-function TTestECDsa5.derDecode(encoding: TCryptoLibByteArray)
+function TTestECDsa5.derDecode(const encoding: TCryptoLibByteArray)
   : TCryptoLibGenericArray<TBigInteger>;
   : TCryptoLibGenericArray<TBigInteger>;
 var
 var
   s: IAsn1Sequence;
   s: IAsn1Sequence;

+ 34 - 31
CryptoLib.Tests/src/Utils/ClpFixedSecureRandom.pas

@@ -66,15 +66,15 @@ type
       Findex: Int32;
       Findex: Int32;
       constructor Create();
       constructor Create();
 
 
-      procedure NextBytes(bytes: TCryptoLibByteArray); override;
+      procedure NextBytes(const bytes: TCryptoLibByteArray); override;
 
 
     end;
     end;
 
 
-  class function ExpandToBitLength(bitLength: Int32; v: TCryptoLibByteArray)
-    : TCryptoLibByteArray; static;
+  class function ExpandToBitLength(bitLength: Int32;
+    const v: TCryptoLibByteArray): TCryptoLibByteArray; static;
 
 
   strict protected
   strict protected
-    constructor Create(data: TCryptoLibByteArray); overload;
+    constructor Create(const data: TCryptoLibByteArray); overload;
 
 
   public
   public
 
 
@@ -93,7 +93,7 @@ type
 
 
     public
     public
       property data: TCryptoLibByteArray read GetData;
       property data: TCryptoLibByteArray read GetData;
-      constructor Create(data: TCryptoLibByteArray);
+      constructor Create(const data: TCryptoLibByteArray);
 
 
     end;
     end;
 
 
@@ -106,7 +106,7 @@ type
 
 
     public
     public
 
 
-      constructor Create(data: TCryptoLibByteArray);
+      constructor Create(const data: TCryptoLibByteArray);
 
 
     end;
     end;
 
 
@@ -121,8 +121,9 @@ type
 
 
     public
     public
 
 
-      constructor Create(data: TCryptoLibByteArray); overload;
-      constructor Create(bitLength: Int32; data: TCryptoLibByteArray); overload;
+      constructor Create(const data: TCryptoLibByteArray); overload;
+      constructor Create(bitLength: Int32;
+        const data: TCryptoLibByteArray); overload;
       constructor Create(const hexData: String); overload;
       constructor Create(const hexData: String); overload;
       constructor Create(bitLength: Int32; const hexData: String); overload;
       constructor Create(bitLength: Int32; const hexData: String); overload;
 
 
@@ -130,15 +131,15 @@ type
 
 
   function GenerateSeed(numBytes: Int32): TCryptoLibByteArray; override;
   function GenerateSeed(numBytes: Int32): TCryptoLibByteArray; override;
 
 
-  procedure NextBytes(buf: TCryptoLibByteArray); overload; override;
-  procedure NextBytes(buf: TCryptoLibByteArray; off, len: Int32);
+  procedure NextBytes(const buf: TCryptoLibByteArray); overload; override;
+  procedure NextBytes(const buf: TCryptoLibByteArray; off, len: Int32);
     overload; override;
     overload; override;
 
 
   property IsExhausted: Boolean read GetIsExhausted;
   property IsExhausted: Boolean read GetIsExhausted;
 
 
-  constructor Create(sources: TCryptoLibGenericArray<ISource>); overload;
+  constructor Create(const sources: TCryptoLibGenericArray<ISource>); overload;
 
 
-  class function From(values: TCryptoLibMatrixByteArray)
+  class function From(const values: TCryptoLibMatrixByteArray)
     : IFixedSecureRandom; static;
     : IFixedSecureRandom; static;
 
 
   end;
   end;
@@ -147,13 +148,14 @@ implementation
 
 
 { TFixedSecureRandom }
 { TFixedSecureRandom }
 
 
-constructor TFixedSecureRandom.Create(data: TCryptoLibByteArray);
+constructor TFixedSecureRandom.Create(const data: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   F_data := data;
   F_data := data;
 end;
 end;
 
 
-constructor TFixedSecureRandom.Create(sources: TCryptoLibGenericArray<ISource>);
+constructor TFixedSecureRandom.Create(const sources
+  : TCryptoLibGenericArray<ISource>);
 var
 var
   bOut: TMemoryStream;
   bOut: TMemoryStream;
   data: TCryptoLibByteArray;
   data: TCryptoLibByteArray;
@@ -294,17 +296,18 @@ begin
 end;
 end;
 
 
 class function TFixedSecureRandom.ExpandToBitLength(bitLength: Int32;
 class function TFixedSecureRandom.ExpandToBitLength(bitLength: Int32;
-  v: TCryptoLibByteArray): TCryptoLibByteArray;
+  const v: TCryptoLibByteArray): TCryptoLibByteArray;
 var
 var
-  tmp: TCryptoLibByteArray;
+  tmp, lv: TCryptoLibByteArray;
   i: UInt32;
   i: UInt32;
 begin
 begin
-  if (((bitLength + 7) div 8) > System.Length(v)) then
+  lv := v;
+  if (((bitLength + 7) div 8) > System.Length(lv)) then
   begin
   begin
     System.SetLength(tmp, (bitLength + 7) div 8);
     System.SetLength(tmp, (bitLength + 7) div 8);
 
 
-    System.Move(v[0], tmp[System.Length(tmp) - System.Length(v)],
-      System.Length(v));
+    System.Move(lv[0], tmp[System.Length(tmp) - System.Length(lv)],
+      System.Length(lv));
 
 
     if (FisAndroidStyle) then
     if (FisAndroidStyle) then
     begin
     begin
@@ -321,18 +324,18 @@ begin
   end
   end
   else
   else
   begin
   begin
-    if (FisAndroidStyle and (bitLength < (System.Length(v) * 8))) then
+    if (FisAndroidStyle and (bitLength < (System.Length(lv) * 8))) then
     begin
     begin
       if (bitLength mod 8 <> 0) then
       if (bitLength mod 8 <> 0) then
       begin
       begin
-        i := TConverters.ReadBytesAsUInt32BE(PByte(v), 0);
-        v := TConverters.ReadUInt32AsBytesBE(i shl (8 - (bitLength mod 8)));
+        i := TConverters.ReadBytesAsUInt32BE(PByte(lv), 0);
+        lv := TConverters.ReadUInt32AsBytesBE(i shl (8 - (bitLength mod 8)));
 
 
       end;
       end;
     end;
     end;
   end;
   end;
 
 
-  result := v;
+  result := lv;
 end;
 end;
 
 
 class constructor TFixedSecureRandom.FixedSecureRandom;
 class constructor TFixedSecureRandom.FixedSecureRandom;
@@ -351,7 +354,7 @@ begin
   FisClasspathStyle := Fcheck2.Equals(FCLASSPATH);
   FisClasspathStyle := Fcheck2.Equals(FCLASSPATH);
 end;
 end;
 
 
-class function TFixedSecureRandom.From(values: TCryptoLibMatrixByteArray)
+class function TFixedSecureRandom.From(const values: TCryptoLibMatrixByteArray)
   : IFixedSecureRandom;
   : IFixedSecureRandom;
 var
 var
   bOut: TMemoryStream;
   bOut: TMemoryStream;
@@ -399,7 +402,7 @@ begin
   result := F_index = System.Length(F_data);
   result := F_index = System.Length(F_data);
 end;
 end;
 
 
-procedure TFixedSecureRandom.NextBytes(buf: TCryptoLibByteArray);
+procedure TFixedSecureRandom.NextBytes(const buf: TCryptoLibByteArray);
 begin
 begin
   System.Move(F_data[F_index], buf[0], System.Length(buf) *
   System.Move(F_data[F_index], buf[0], System.Length(buf) *
     System.SizeOf(Byte));
     System.SizeOf(Byte));
@@ -407,7 +410,7 @@ begin
   F_index := F_index + System.Length(buf);
   F_index := F_index + System.Length(buf);
 end;
 end;
 
 
-procedure TFixedSecureRandom.NextBytes(buf: TCryptoLibByteArray;
+procedure TFixedSecureRandom.NextBytes(const buf: TCryptoLibByteArray;
   off, len: Int32);
   off, len: Int32);
 begin
 begin
   System.Move(F_data[F_index], buf[off], len * System.SizeOf(Byte));
   System.Move(F_data[F_index], buf[off], len * System.SizeOf(Byte));
@@ -425,7 +428,7 @@ begin
 end;
 end;
 
 
 procedure TFixedSecureRandom.TRandomChecker.NextBytes
 procedure TFixedSecureRandom.TRandomChecker.NextBytes
-  (bytes: TCryptoLibByteArray);
+  (const bytes: TCryptoLibByteArray);
 begin
 begin
 
 
   System.Move(Fdata[Findex], bytes[0], System.Length(bytes) *
   System.Move(Fdata[Findex], bytes[0], System.Length(bytes) *
@@ -437,7 +440,7 @@ end;
 
 
 { TFixedSecureRandom.TSource }
 { TFixedSecureRandom.TSource }
 
 
-constructor TFixedSecureRandom.TSource.Create(data: TCryptoLibByteArray);
+constructor TFixedSecureRandom.TSource.Create(const data: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   Fdata := data;
   Fdata := data;
@@ -450,7 +453,7 @@ end;
 
 
 { TFixedSecureRandom.TData }
 { TFixedSecureRandom.TData }
 
 
-constructor TFixedSecureRandom.TData.Create(data: TCryptoLibByteArray);
+constructor TFixedSecureRandom.TData.Create(const data: TCryptoLibByteArray);
 begin
 begin
   Inherited Create(data);
   Inherited Create(data);
 end;
 end;
@@ -458,13 +461,13 @@ end;
 { TFixedSecureRandom.TBigIntegerSource }
 { TFixedSecureRandom.TBigIntegerSource }
 
 
 constructor TFixedSecureRandom.TBigIntegerSource.Create(bitLength: Int32;
 constructor TFixedSecureRandom.TBigIntegerSource.Create(bitLength: Int32;
-  data: TCryptoLibByteArray);
+  const data: TCryptoLibByteArray);
 begin
 begin
   Inherited Create(ExpandToBitLength(bitLength, data));
   Inherited Create(ExpandToBitLength(bitLength, data));
 end;
 end;
 
 
 constructor TFixedSecureRandom.TBigIntegerSource.Create
 constructor TFixedSecureRandom.TBigIntegerSource.Create
-  (data: TCryptoLibByteArray);
+  (const data: TCryptoLibByteArray);
 begin
 begin
   Inherited Create(data);
   Inherited Create(data);
 end;
 end;

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

@@ -39,17 +39,17 @@ type
     function GetSelf(Index: Int32): IAsn1Encodable;
     function GetSelf(Index: Int32): IAsn1Encodable;
 
 
   public
   public
-    class function FromEnumerable(e: TList<IAsn1Encodable>)
+    class function FromEnumerable(const e: TList<IAsn1Encodable>)
       : IAsn1EncodableVector; static;
       : IAsn1EncodableVector; static;
 
 
     constructor Create(); overload;
     constructor Create(); overload;
-    constructor Create(v: array of IAsn1Encodable); overload;
+    constructor Create(const v: array of IAsn1Encodable); overload;
 
 
     destructor Destroy(); override;
     destructor Destroy(); override;
 
 
-    procedure Add(objs: array of IAsn1Encodable);
+    procedure Add(const objs: array of IAsn1Encodable);
 
 
-    procedure AddOptional(objs: array of IAsn1Encodable);
+    procedure AddOptional(const objs: array of IAsn1Encodable);
 
 
     property Self[Index: Int32]: IAsn1Encodable read GetSelf; default;
     property Self[Index: Int32]: IAsn1Encodable read GetSelf; default;
 
 
@@ -63,7 +63,7 @@ implementation
 
 
 { TAsn1EncodableVector }
 { TAsn1EncodableVector }
 
 
-procedure TAsn1EncodableVector.Add(objs: array of IAsn1Encodable);
+procedure TAsn1EncodableVector.Add(const objs: array of IAsn1Encodable);
 var
 var
   obj: IAsn1Encodable;
   obj: IAsn1Encodable;
 begin
 begin
@@ -73,7 +73,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TAsn1EncodableVector.AddOptional(objs: array of IAsn1Encodable);
+procedure TAsn1EncodableVector.AddOptional(const objs: array of IAsn1Encodable);
 var
 var
   obj: IAsn1Encodable;
   obj: IAsn1Encodable;
 begin
 begin
@@ -89,7 +89,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-constructor TAsn1EncodableVector.Create(v: array of IAsn1Encodable);
+constructor TAsn1EncodableVector.Create(const v: array of IAsn1Encodable);
 begin
 begin
   inherited Create();
   inherited Create();
   Flist := TList<IAsn1Encodable>.Create();
   Flist := TList<IAsn1Encodable>.Create();
@@ -108,8 +108,8 @@ begin
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
-class function TAsn1EncodableVector.FromEnumerable(e: TList<IAsn1Encodable>)
-  : IAsn1EncodableVector;
+class function TAsn1EncodableVector.FromEnumerable
+  (const e: TList<IAsn1Encodable>): IAsn1EncodableVector;
 var
 var
   v: IAsn1EncodableVector;
   v: IAsn1EncodableVector;
   obj: IAsn1Encodable;
   obj: IAsn1Encodable;

+ 32 - 28
CryptoLib/src/Asn1/ClpAsn1InputStream.pas

@@ -106,7 +106,7 @@ type
 
 
   public
   public
 
 
-    constructor Create(inputStream: TStream); overload;
+    constructor Create(const inputStream: TStream); overload;
 
 
     /// <summary>
     /// <summary>
     /// Create an ASN1InputStream where no DER object will be longer than
     /// Create an ASN1InputStream where no DER object will be longer than
@@ -118,7 +118,7 @@ type
     /// <param name="limit">
     /// <param name="limit">
     /// maximum size of a DER encoded object.
     /// maximum size of a DER encoded object.
     /// </param>
     /// </param>
-    constructor Create(inputStream: TStream; limit: Int32); overload;
+    constructor Create(const inputStream: TStream; limit: Int32); overload;
 
 
     destructor Destroy(); override;
     destructor Destroy(); override;
 
 
@@ -128,33 +128,34 @@ type
     /// <param name="input">
     /// <param name="input">
     /// array containing ASN.1 encoded data.
     /// array containing ASN.1 encoded data.
     /// </param>
     /// </param>
-    constructor Create(input: TCryptoLibByteArray); overload;
+    constructor Create(const input: TCryptoLibByteArray); overload;
 
 
     function ReadObject(): IAsn1Object;
     function ReadObject(): IAsn1Object;
 
 
     function BuildEncodableVector(): IAsn1EncodableVector;
     function BuildEncodableVector(): IAsn1EncodableVector;
 
 
-    function BuildDerEncodableVector(dIn: TDefiniteLengthInputStream)
+    function BuildDerEncodableVector(const dIn: TDefiniteLengthInputStream)
       : IAsn1EncodableVector; virtual;
       : IAsn1EncodableVector; virtual;
 
 
-    function CreateDerSequence(dIn: TDefiniteLengthInputStream)
+    function CreateDerSequence(const dIn: TDefiniteLengthInputStream)
       : IDerSequence; virtual;
       : IDerSequence; virtual;
 
 
-    function CreateDerSet(dIn: TDefiniteLengthInputStream): IDerSet; virtual;
+    function CreateDerSet(const dIn: TDefiniteLengthInputStream)
+      : IDerSet; virtual;
 
 
-    class function FindLimit(input: TStream): Int32; static;
+    class function FindLimit(const input: TStream): Int32; static;
 
 
-    class function ReadTagNumber(s: TStream; tag: Int32): Int32; static;
+    class function ReadTagNumber(const s: TStream; tag: Int32): Int32; static;
 
 
-    class function ReadLength(s: TStream; limit: Int32): Int32; static;
+    class function ReadLength(const s: TStream; limit: Int32): Int32; static;
 
 
-    class function GetBuffer(defIn: TDefiniteLengthInputStream;
-      tmpBuffers: TCryptoLibMatrixByteArray): TCryptoLibByteArray;
+    class function GetBuffer(const defIn: TDefiniteLengthInputStream;
+      const tmpBuffers: TCryptoLibMatrixByteArray): TCryptoLibByteArray;
       static; inline;
       static; inline;
 
 
     class function CreatePrimitiveDerObject(tagNo: Int32;
     class function CreatePrimitiveDerObject(tagNo: Int32;
-      defIn: TDefiniteLengthInputStream; tmpBuffers: TCryptoLibMatrixByteArray)
-      : IAsn1Object; static;
+      const defIn: TDefiniteLengthInputStream;
+      const tmpBuffers: TCryptoLibMatrixByteArray): IAsn1Object; static;
   end;
   end;
 
 
 implementation
 implementation
@@ -177,7 +178,7 @@ uses
 
 
 { TAsn1InputStream }
 { TAsn1InputStream }
 
 
-class function TAsn1InputStream.FindLimit(input: TStream): Int32;
+class function TAsn1InputStream.FindLimit(const input: TStream): Int32;
 var
 var
   limitedInputStream: TLimitedInputStream;
   limitedInputStream: TLimitedInputStream;
   mem: TMemoryStream;
   mem: TMemoryStream;
@@ -198,8 +199,9 @@ begin
   result := System.High(Int32);
   result := System.High(Int32);
 end;
 end;
 
 
-class function TAsn1InputStream.GetBuffer(defIn: TDefiniteLengthInputStream;
-  tmpBuffers: TCryptoLibMatrixByteArray): TCryptoLibByteArray;
+class function TAsn1InputStream.GetBuffer(const defIn
+  : TDefiniteLengthInputStream; const tmpBuffers: TCryptoLibMatrixByteArray)
+  : TCryptoLibByteArray;
 var
 var
   len: Int32;
   len: Int32;
   buf, temp: TCryptoLibByteArray;
   buf, temp: TCryptoLibByteArray;
@@ -225,8 +227,8 @@ begin
 end;
 end;
 
 
 class function TAsn1InputStream.CreatePrimitiveDerObject(tagNo: Int32;
 class function TAsn1InputStream.CreatePrimitiveDerObject(tagNo: Int32;
-  defIn: TDefiniteLengthInputStream; tmpBuffers: TCryptoLibMatrixByteArray)
-  : IAsn1Object;
+  const defIn: TDefiniteLengthInputStream;
+  const tmpBuffers: TCryptoLibMatrixByteArray): IAsn1Object;
 var
 var
   bytes: TCryptoLibByteArray;
   bytes: TCryptoLibByteArray;
 begin
 begin
@@ -354,19 +356,19 @@ begin
   inherited Destroy; // dont free
   inherited Destroy; // dont free
 end;
 end;
 
 
-constructor TAsn1InputStream.Create(inputStream: TStream; limit: Int32);
+constructor TAsn1InputStream.Create(const inputStream: TStream; limit: Int32);
 begin
 begin
   Inherited Create(inputStream);
   Inherited Create(inputStream);
   Flimit := limit;
   Flimit := limit;
   System.SetLength(FtmpBuffers, 16);
   System.SetLength(FtmpBuffers, 16);
 end;
 end;
 
 
-constructor TAsn1InputStream.Create(inputStream: TStream);
+constructor TAsn1InputStream.Create(const inputStream: TStream);
 begin
 begin
   Create(inputStream, FindLimit(inputStream));
   Create(inputStream, FindLimit(inputStream));
 end;
 end;
 
 
-constructor TAsn1InputStream.Create(input: TCryptoLibByteArray);
+constructor TAsn1InputStream.Create(const input: TCryptoLibByteArray);
 begin
 begin
   // used TBytesStream here for one pass creation and population with byte array :)
   // used TBytesStream here for one pass creation and population with byte array :)
   FStream := TBytesStream.Create(input);
   FStream := TBytesStream.Create(input);
@@ -374,7 +376,8 @@ begin
 
 
 end;
 end;
 
 
-class function TAsn1InputStream.ReadLength(s: TStream; limit: Int32): Int32;
+class function TAsn1InputStream.ReadLength(const s: TStream;
+  limit: Int32): Int32;
 var
 var
   &length, Size, next, I: Int32;
   &length, Size, next, I: Int32;
 begin
 begin
@@ -540,7 +543,7 @@ begin
 end;
 end;
 
 
 function TAsn1InputStream.BuildDerEncodableVector
 function TAsn1InputStream.BuildDerEncodableVector
-  (dIn: TDefiniteLengthInputStream): IAsn1EncodableVector;
+  (const dIn: TDefiniteLengthInputStream): IAsn1EncodableVector;
 var
 var
   res: TAsn1InputStream;
   res: TAsn1InputStream;
 begin
 begin
@@ -671,19 +674,20 @@ begin
 
 
 end;
 end;
 
 
-function TAsn1InputStream.CreateDerSequence(dIn: TDefiniteLengthInputStream)
-  : IDerSequence;
+function TAsn1InputStream.CreateDerSequence
+  (const dIn: TDefiniteLengthInputStream): IDerSequence;
 begin
 begin
   result := TDerSequence.FromVector(BuildDerEncodableVector(dIn));
   result := TDerSequence.FromVector(BuildDerEncodableVector(dIn));
 end;
 end;
 
 
-function TAsn1InputStream.CreateDerSet(dIn: TDefiniteLengthInputStream)
-  : IDerSet;
+function TAsn1InputStream.CreateDerSet(const dIn
+  : TDefiniteLengthInputStream): IDerSet;
 begin
 begin
   result := TDerSet.FromVector(BuildDerEncodableVector(dIn), false);
   result := TDerSet.FromVector(BuildDerEncodableVector(dIn), false);
 end;
 end;
 
 
-class function TAsn1InputStream.ReadTagNumber(s: TStream; tag: Int32): Int32;
+class function TAsn1InputStream.ReadTagNumber(const s: TStream;
+  tag: Int32): Int32;
 var
 var
   tagNo, b: Int32;
   tagNo, b: Int32;
 begin
 begin

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

@@ -51,7 +51,7 @@ type
     /// <exception cref="IOException">
     /// <exception cref="IOException">
     /// If there is a problem parsing the data, or parsing an object did not exhaust the available data.
     /// If there is a problem parsing the data, or parsing an object did not exhaust the available data.
     /// </exception>
     /// </exception>
-    class function FromByteArray(data: TCryptoLibByteArray)
+    class function FromByteArray(const data: TCryptoLibByteArray)
       : IAsn1Object; static;
       : IAsn1Object; static;
 
 
     /// <summary>Read a base ASN.1 object from a stream.</summary>
     /// <summary>Read a base ASN.1 object from a stream.</summary>
@@ -88,7 +88,7 @@ begin
   result := Asn1GetHashCode();
   result := Asn1GetHashCode();
 end;
 end;
 
 
-class function TAsn1Object.FromByteArray(data: TCryptoLibByteArray)
+class function TAsn1Object.FromByteArray(const data: TCryptoLibByteArray)
   : IAsn1Object;
   : IAsn1Object;
 var
 var
   asn1: TAsn1InputStream;
   asn1: TAsn1InputStream;

+ 5 - 4
CryptoLib/src/Asn1/ClpAsn1OctetString.pas

@@ -83,13 +83,13 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IAsn1OctetString;
+    class function GetInstance(const obj: TObject): IAsn1OctetString;
       overload; static;
       overload; static;
 
 
     /// <param name="Str">
     /// <param name="Str">
     /// the octets making up the octet string.
     /// the octets making up the octet string.
     /// </param>
     /// </param>
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     constructor Create(const obj: IAsn1Encodable); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
 
 
@@ -118,7 +118,7 @@ begin
   result := Self as IAsn1OctetStringParser;
   result := Self as IAsn1OctetStringParser;
 end;
 end;
 
 
-constructor TAsn1OctetString.Create(Str: TCryptoLibByteArray);
+constructor TAsn1OctetString.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   if (Str = Nil) then
   if (Str = Nil) then
@@ -179,7 +179,8 @@ begin
     (TAsn1Sequence.GetInstance(o as TAsn1Object));
     (TAsn1Sequence.GetInstance(o as TAsn1Object));
 end;
 end;
 
 
-class function TAsn1OctetString.GetInstance(obj: TObject): IAsn1OctetString;
+class function TAsn1OctetString.GetInstance(const obj: TObject)
+  : IAsn1OctetString;
 var
 var
   asn1TaggedObject: IAsn1TaggedObject;
   asn1TaggedObject: IAsn1TaggedObject;
 begin
 begin

+ 5 - 4
CryptoLib/src/Asn1/ClpAsn1Sequence.pas

@@ -108,7 +108,8 @@ type
     /// <exception cref="EArgumentCryptoLibException">
     /// <exception cref="EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IAsn1Sequence; overload; static;
+    class function GetInstance(const obj: TObject): IAsn1Sequence;
+      overload; static;
 
 
     /// <summary>
     /// <summary>
     /// return an Asn1Sequence from the given object.
     /// return an Asn1Sequence from the given object.
@@ -119,7 +120,7 @@ type
     /// <exception cref="EArgumentCryptoLibException">
     /// <exception cref="EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TCryptoLibByteArray): IAsn1Sequence;
+    class function GetInstance(const obj: TCryptoLibByteArray): IAsn1Sequence;
       overload; static;
       overload; static;
 
 
     // /**
     // /**
@@ -262,7 +263,7 @@ begin
   result := FSeq.ToArray;
   result := FSeq.ToArray;
 end;
 end;
 
 
-class function TAsn1Sequence.GetInstance(obj: TObject): IAsn1Sequence;
+class function TAsn1Sequence.GetInstance(const obj: TObject): IAsn1Sequence;
 var
 var
   primitive: IAsn1Object;
   primitive: IAsn1Object;
   sequence: IAsn1Sequence;
   sequence: IAsn1Sequence;
@@ -297,7 +298,7 @@ begin
 
 
 end;
 end;
 
 
-class function TAsn1Sequence.GetInstance(obj: TCryptoLibByteArray)
+class function TAsn1Sequence.GetInstance(const obj: TCryptoLibByteArray)
   : IAsn1Sequence;
   : IAsn1Sequence;
 begin
 begin
   try
   try

+ 7 - 7
CryptoLib/src/Asn1/ClpAsn1Set.pas

@@ -65,7 +65,7 @@ type
     /// <summary>
     /// <summary>
     /// return true if a &lt;= b (arrays are assumed padded with zeros).
     /// return true if a &lt;= b (arrays are assumed padded with zeros).
     /// </summary>
     /// </summary>
-    function lessThanOrEqual(a, b: TCryptoLibByteArray): Boolean; inline;
+    function LessThanOrEqual(const a, b: TCryptoLibByteArray): Boolean; inline;
 
 
   type
   type
     TAsn1SetParserImpl = class sealed(TInterfacedObject, IAsn1SetParserImpl,
     TAsn1SetParserImpl = class sealed(TInterfacedObject, IAsn1SetParserImpl,
@@ -118,7 +118,7 @@ type
     /// <exception cref="EArgumentCryptoLibException">
     /// <exception cref="EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IAsn1Set; overload; static;
+    class function GetInstance(const obj: TObject): IAsn1Set; overload; static;
 
 
     /// <summary>
     /// <summary>
     /// return an Asn1Set from the given object.
     /// return an Asn1Set from the given object.
@@ -129,7 +129,7 @@ type
     /// <exception cref="EArgumentCryptoLibException">
     /// <exception cref="EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TCryptoLibByteArray): IAsn1Set;
+    class function GetInstance(const obj: TCryptoLibByteArray): IAsn1Set;
       overload; static;
       overload; static;
 
 
     // /**
     // /**
@@ -273,7 +273,7 @@ begin
   result := F_set.ToArray;
   result := F_set.ToArray;
 end;
 end;
 
 
-class function TAsn1Set.GetInstance(obj: TCryptoLibByteArray): IAsn1Set;
+class function TAsn1Set.GetInstance(const obj: TCryptoLibByteArray): IAsn1Set;
 begin
 begin
   try
   try
     result := TAsn1Set.GetInstance(FromByteArray(obj) as TAsn1Object);
     result := TAsn1Set.GetInstance(FromByteArray(obj) as TAsn1Object);
@@ -348,7 +348,7 @@ begin
 
 
 end;
 end;
 
 
-class function TAsn1Set.GetInstance(obj: TObject): IAsn1Set;
+class function TAsn1Set.GetInstance(const obj: TObject): IAsn1Set;
 var
 var
   primitive: IAsn1Object;
   primitive: IAsn1Object;
   asn1Set: IAsn1Set;
   asn1Set: IAsn1Set;
@@ -393,7 +393,7 @@ begin
   result := F_set[index];
   result := F_set[index];
 end;
 end;
 
 
-function TAsn1Set.lessThanOrEqual(a, b: TCryptoLibByteArray): Boolean;
+function TAsn1Set.LessThanOrEqual(const a, b: TCryptoLibByteArray): Boolean;
 var
 var
   len, I: Int32;
   len, I: Int32;
 begin
 begin
@@ -443,7 +443,7 @@ begin
         begin
         begin
           b := F_set[index + 1].GetEncoded(TAsn1Encodable.Der);
           b := F_set[index + 1].GetEncoded(TAsn1Encodable.Der);
 
 
-          if (lessThanOrEqual(a, b)) then
+          if (LessThanOrEqual(a, b)) then
           begin
           begin
             a := b;
             a := b;
           end
           end

+ 6 - 6
CryptoLib/src/Asn1/ClpAsn1StreamParser.pas

@@ -70,9 +70,9 @@ type
     procedure Set00Check(enabled: Boolean); inline;
     procedure Set00Check(enabled: Boolean); inline;
 
 
   public
   public
-    constructor Create(inStream: TStream); overload;
-    constructor Create(inStream: TStream; limit: Int32); overload;
-    constructor Create(encoding: TCryptoLibByteArray); overload;
+    constructor Create(const inStream: TStream); overload;
+    constructor Create(const inStream: TStream; limit: Int32); overload;
+    constructor Create(const encoding: TCryptoLibByteArray); overload;
 
 
     destructor Destroy; override;
     destructor Destroy; override;
 
 
@@ -105,12 +105,12 @@ begin
   end;
   end;
 end;
 end;
 
 
-constructor TAsn1StreamParser.Create(inStream: TStream);
+constructor TAsn1StreamParser.Create(const inStream: TStream);
 begin
 begin
   Create(inStream, TAsn1InputStream.FindLimit(inStream));
   Create(inStream, TAsn1InputStream.FindLimit(inStream));
 end;
 end;
 
 
-constructor TAsn1StreamParser.Create(inStream: TStream; limit: Int32);
+constructor TAsn1StreamParser.Create(const inStream: TStream; limit: Int32);
 begin
 begin
   Inherited Create();
   Inherited Create();
   F_in := inStream;
   F_in := inStream;
@@ -118,7 +118,7 @@ begin
   System.SetLength(FtmpBuffers, 16);
   System.SetLength(FtmpBuffers, 16);
 end;
 end;
 
 
-constructor TAsn1StreamParser.Create(encoding: TCryptoLibByteArray);
+constructor TAsn1StreamParser.Create(const encoding: TCryptoLibByteArray);
 begin
 begin
   // used TBytesStream here for one pass creation and population with byte array :)
   // used TBytesStream here for one pass creation and population with byte array :)
   Create(TBytesStream.Create(encoding), System.Length(encoding));
   Create(TBytesStream.Create(encoding), System.Length(encoding));

+ 6 - 4
CryptoLib/src/Asn1/ClpBerBitString.pas

@@ -35,8 +35,9 @@ type
   TBerBitString = class(TDerBitString, IBerBitString)
   TBerBitString = class(TDerBitString, IBerBitString)
 
 
   public
   public
-    constructor Create(data: TCryptoLibByteArray; padBits: Int32); overload;
-    constructor Create(data: TCryptoLibByteArray); overload;
+    constructor Create(const data: TCryptoLibByteArray;
+      padBits: Int32); overload;
+    constructor Create(const data: TCryptoLibByteArray); overload;
     constructor Create(namedBits: Int32); overload;
     constructor Create(namedBits: Int32); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
 
 
@@ -48,12 +49,13 @@ implementation
 
 
 { TBerBitString }
 { TBerBitString }
 
 
-constructor TBerBitString.Create(data: TCryptoLibByteArray);
+constructor TBerBitString.Create(const data: TCryptoLibByteArray);
 begin
 begin
   Inherited Create(data);
   Inherited Create(data);
 end;
 end;
 
 
-constructor TBerBitString.Create(data: TCryptoLibByteArray; padBits: Int32);
+constructor TBerBitString.Create(const data: TCryptoLibByteArray;
+  padBits: Int32);
 begin
 begin
   Inherited Create(data, padBits);
   Inherited Create(data, padBits);
 end;
 end;

+ 4 - 4
CryptoLib/src/Asn1/ClpBerOctetString.pas

@@ -55,8 +55,8 @@ type
 
 
     /// <inheritdoc />
     /// <inheritdoc />
     /// <param name="str">The octets making up the octet string.</param>
     /// <param name="str">The octets making up the octet string.</param>
-    constructor Create(str: TCryptoLibByteArray); overload;
-    constructor Create(octets: TList<IDerOctetString>); overload;
+    constructor Create(const str: TCryptoLibByteArray); overload;
+    constructor Create(const octets: TList<IDerOctetString>); overload;
     constructor Create(const obj: IAsn1Object); overload;
     constructor Create(const obj: IAsn1Object); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
 
 
@@ -80,13 +80,13 @@ implementation
 
 
 { TBerOctetString }
 { TBerOctetString }
 
 
-constructor TBerOctetString.Create(octets: TList<IDerOctetString>);
+constructor TBerOctetString.Create(const octets: TList<IDerOctetString>);
 begin
 begin
   Inherited Create(ToBytes(octets));
   Inherited Create(ToBytes(octets));
   Focts := octets;
   Focts := octets;
 end;
 end;
 
 
-constructor TBerOctetString.Create(str: TCryptoLibByteArray);
+constructor TBerOctetString.Create(const str: TCryptoLibByteArray);
 begin
 begin
   Inherited Create(str);
   Inherited Create(str);
 end;
 end;

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

@@ -60,7 +60,7 @@ type
     /// </summary>
     /// </summary>
     constructor Create(const obj: IAsn1Encodable); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
 
 
-    constructor Create(v: array of IAsn1Encodable); overload;
+    constructor Create(const v: array of IAsn1Encodable); overload;
 
 
     /// <summary>
     /// <summary>
     /// create a sequence containing a vector of objects.
     /// create a sequence containing a vector of objects.
@@ -112,7 +112,7 @@ begin
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
-constructor TBerSequence.Create(v: array of IAsn1Encodable);
+constructor TBerSequence.Create(const v: array of IAsn1Encodable);
 begin
 begin
   Inherited Create(v);
   Inherited Create(v);
 end;
 end;

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

@@ -56,7 +56,7 @@ type
 
 
     function Read(buf: TCryptoLibByteArray; off, len: Int32): Int32; override;
     function Read(buf: TCryptoLibByteArray; off, len: Int32): Int32; override;
 
 
-    procedure ReadAllIntoByteArray(buf: TCryptoLibByteArray);
+    procedure ReadAllIntoByteArray(var buf: TCryptoLibByteArray);
 
 
     function ToArray: TCryptoLibByteArray;
     function ToArray: TCryptoLibByteArray;
 
 
@@ -137,7 +137,7 @@ begin
 end;
 end;
 
 
 procedure TDefiniteLengthInputStream.ReadAllIntoByteArray
 procedure TDefiniteLengthInputStream.ReadAllIntoByteArray
-  (buf: TCryptoLibByteArray);
+  (var buf: TCryptoLibByteArray);
 begin
 begin
   if (F_remaining <> System.length(buf)) then
   if (F_remaining <> System.length(buf)) then
   begin
   begin

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

@@ -53,10 +53,10 @@ type
     Foctets: TCryptoLibByteArray;
     Foctets: TCryptoLibByteArray;
 
 
     function GetApplicationTag: Int32; inline;
     function GetApplicationTag: Int32; inline;
-    function GetLengthOfHeader(data: TCryptoLibByteArray): Int32; inline;
+    function GetLengthOfHeader(const data: TCryptoLibByteArray): Int32; inline;
 
 
-    class function ReplaceTagNumber(newTag: Int32; input: TCryptoLibByteArray)
-      : TCryptoLibByteArray; static;
+    class function ReplaceTagNumber(newTag: Int32;
+      const input: TCryptoLibByteArray): TCryptoLibByteArray; static;
 
 
   strict protected
   strict protected
     function Asn1Equals(const asn1Object: IAsn1Object): Boolean; override;
     function Asn1Equals(const asn1Object: IAsn1Object): Boolean; override;
@@ -64,8 +64,8 @@ type
 
 
   public
   public
     constructor Create(isConstructed: Boolean; tag: Int32;
     constructor Create(isConstructed: Boolean; tag: Int32;
-      octets: TCryptoLibByteArray); overload;
-    constructor Create(tag: Int32; octets: TCryptoLibByteArray); overload;
+      const octets: TCryptoLibByteArray); overload;
+    constructor Create(tag: Int32; const octets: TCryptoLibByteArray); overload;
     constructor Create(tag: Int32; const obj: IAsn1Encodable); overload;
     constructor Create(tag: Int32; const obj: IAsn1Encodable); overload;
     constructor Create(isExplicit: Boolean; tag: Int32;
     constructor Create(isExplicit: Boolean; tag: Int32;
       const obj: IAsn1Encodable); overload;
       const obj: IAsn1Encodable); overload;
@@ -124,7 +124,7 @@ begin
 end;
 end;
 
 
 function TDerApplicationSpecific.GetLengthOfHeader
 function TDerApplicationSpecific.GetLengthOfHeader
-  (data: TCryptoLibByteArray): Int32;
+  (const data: TCryptoLibByteArray): Int32;
 var
 var
   &length, Size: Int32;
   &length, Size: Int32;
 begin
 begin
@@ -161,13 +161,13 @@ begin
 end;
 end;
 
 
 constructor TDerApplicationSpecific.Create(tag: Int32;
 constructor TDerApplicationSpecific.Create(tag: Int32;
-  octets: TCryptoLibByteArray);
+  const octets: TCryptoLibByteArray);
 begin
 begin
   Create(false, tag, octets);
   Create(false, tag, octets);
 end;
 end;
 
 
 constructor TDerApplicationSpecific.Create(isConstructed: Boolean; tag: Int32;
 constructor TDerApplicationSpecific.Create(isConstructed: Boolean; tag: Int32;
-  octets: TCryptoLibByteArray);
+  const octets: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   FisConstructed := isConstructed;
   FisConstructed := isConstructed;
@@ -315,7 +315,7 @@ begin
 end;
 end;
 
 
 class function TDerApplicationSpecific.ReplaceTagNumber(newTag: Int32;
 class function TDerApplicationSpecific.ReplaceTagNumber(newTag: Int32;
-  input: TCryptoLibByteArray): TCryptoLibByteArray;
+  const input: TCryptoLibByteArray): TCryptoLibByteArray;
 var
 var
   tagNo, index, b: Int32;
   tagNo, index, b: Int32;
   tmp: TCryptoLibByteArray;
   tmp: TCryptoLibByteArray;

+ 12 - 10
CryptoLib/src/Asn1/ClpDerBitString.pas

@@ -73,9 +73,10 @@ type
     property mData: TCryptoLibByteArray read GetmData;
     property mData: TCryptoLibByteArray read GetmData;
   public
   public
 
 
-    constructor Create(data: TCryptoLibByteArray; padBits: Int32); overload;
+    constructor Create(const data: TCryptoLibByteArray;
+      padBits: Int32); overload;
 
 
-    constructor Create(data: TCryptoLibByteArray); overload;
+    constructor Create(const data: TCryptoLibByteArray); overload;
 
 
     constructor Create(namedBits: Int32); overload;
     constructor Create(namedBits: Int32); overload;
 
 
@@ -104,10 +105,10 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerBitString; overload;
+    class function GetInstance(const obj: TObject): IDerBitString; overload;
       static; inline;
       static; inline;
 
 
-    class function GetInstance(obj: TCryptoLibByteArray): IDerBitString;
+    class function GetInstance(const obj: TCryptoLibByteArray): IDerBitString;
       overload; static;
       overload; static;
 
 
     /// <summary>
     /// <summary>
@@ -125,7 +126,7 @@ type
     class function GetInstance(const obj: IAsn1TaggedObject;
     class function GetInstance(const obj: IAsn1TaggedObject;
       isExplicit: Boolean): IDerBitString; overload; static; inline;
       isExplicit: Boolean): IDerBitString; overload; static; inline;
 
 
-    class function FromAsn1Octets(octets: TCryptoLibByteArray)
+    class function FromAsn1Octets(const octets: TCryptoLibByteArray)
       : IDerBitString; static;
       : IDerBitString; static;
 
 
   end;
   end;
@@ -138,7 +139,7 @@ uses
 
 
 { TDerBitString }
 { TDerBitString }
 
 
-class function TDerBitString.GetInstance(obj: TCryptoLibByteArray)
+class function TDerBitString.GetInstance(const obj: TCryptoLibByteArray)
   : IDerBitString;
   : IDerBitString;
 begin
 begin
   try
   try
@@ -187,7 +188,8 @@ begin
     (TArrayUtils.AreEqual(mData, other.mData));
     (TArrayUtils.AreEqual(mData, other.mData));
 end;
 end;
 
 
-constructor TDerBitString.Create(data: TCryptoLibByteArray; padBits: Int32);
+constructor TDerBitString.Create(const data: TCryptoLibByteArray;
+  padBits: Int32);
 begin
 begin
   Inherited Create();
   Inherited Create();
   if (data = Nil) then
   if (data = Nil) then
@@ -210,7 +212,7 @@ begin
 
 
 end;
 end;
 
 
-constructor TDerBitString.Create(data: TCryptoLibByteArray);
+constructor TDerBitString.Create(const data: TCryptoLibByteArray);
 begin
 begin
   Create(data, 0);
   Create(data, 0);
 end;
 end;
@@ -289,7 +291,7 @@ begin
   derOut.WriteEncoded(TAsn1Tags.BitString, Byte(mPadBits), mData);
   derOut.WriteEncoded(TAsn1Tags.BitString, Byte(mPadBits), mData);
 end;
 end;
 
 
-class function TDerBitString.FromAsn1Octets(octets: TCryptoLibByteArray)
+class function TDerBitString.FromAsn1Octets(const octets: TCryptoLibByteArray)
   : IDerBitString;
   : IDerBitString;
 var
 var
   padBits, last, mask: Int32;
   padBits, last, mask: Int32;
@@ -331,7 +333,7 @@ begin
 
 
 end;
 end;
 
 
-class function TDerBitString.GetInstance(obj: TObject): IDerBitString;
+class function TDerBitString.GetInstance(const obj: TObject): IDerBitString;
 begin
 begin
   if ((obj = Nil) or (obj is TDerBitString)) then
   if ((obj = Nil) or (obj is TDerBitString)) then
   begin
   begin

+ 4 - 4
CryptoLib/src/Asn1/ClpDerBmpString.pas

@@ -54,7 +54,7 @@ type
     /// <summary>
     /// <summary>
     /// basic constructor - byte encoded string.
     /// basic constructor - byte encoded string.
     /// </summary>
     /// </summary>
-    constructor Create(astr: TCryptoLibByteArray); overload;
+    constructor Create(const astr: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// basic constructor
     /// basic constructor
@@ -74,7 +74,7 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerBmpString; overload;
+    class function GetInstance(const obj: TObject): IDerBmpString; overload;
       static; inline;
       static; inline;
 
 
     /// <summary>
     /// <summary>
@@ -117,7 +117,7 @@ begin
   result := Str = other.Str;
   result := Str = other.Str;
 end;
 end;
 
 
-constructor TDerBmpString.Create(astr: TCryptoLibByteArray);
+constructor TDerBmpString.Create(const astr: TCryptoLibByteArray);
 var
 var
   cs: TCryptoLibCharArray;
   cs: TCryptoLibCharArray;
   i: Int32;
   i: Int32;
@@ -187,7 +187,7 @@ begin
 
 
 end;
 end;
 
 
-class function TDerBmpString.GetInstance(obj: TObject): IDerBmpString;
+class function TDerBmpString.GetInstance(const obj: TObject): IDerBmpString;
 begin
 begin
   if ((obj = Nil) or (obj is TDerBmpString)) then
   if ((obj = Nil) or (obj is TDerBmpString)) then
   begin
   begin

+ 6 - 6
CryptoLib/src/Asn1/ClpDerBoolean.pas

@@ -63,7 +63,7 @@ type
 
 
   public
   public
 
 
-    constructor Create(val: TCryptoLibByteArray); overload;
+    constructor Create(const val: TCryptoLibByteArray); overload;
 
 
     procedure Encode(const derOut: IDerOutputStream); override;
     procedure Encode(const derOut: IDerOutputStream); override;
 
 
@@ -81,7 +81,7 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerBoolean; overload;
+    class function GetInstance(const obj: TObject): IDerBoolean; overload;
       static; inline;
       static; inline;
 
 
     /// <summary>
     /// <summary>
@@ -106,7 +106,7 @@ type
     class function GetInstance(const obj: IAsn1TaggedObject;
     class function GetInstance(const obj: IAsn1TaggedObject;
       isExplicit: Boolean): IDerBoolean; overload; static; inline;
       isExplicit: Boolean): IDerBoolean; overload; static; inline;
 
 
-    class function FromOctetString(value: TCryptoLibByteArray)
+    class function FromOctetString(const value: TCryptoLibByteArray)
       : IDerBoolean; static;
       : IDerBoolean; static;
 
 
   end;
   end;
@@ -139,7 +139,7 @@ begin
   result := Ord(IsTrue);
   result := Ord(IsTrue);
 end;
 end;
 
 
-constructor TDerBoolean.Create(val: TCryptoLibByteArray);
+constructor TDerBoolean.Create(const val: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   if (System.Length(val) <> 1) then
   if (System.Length(val) <> 1) then
@@ -176,7 +176,7 @@ begin
   derOut.WriteEncoded(TAsn1Tags.Boolean, TCryptoLibByteArray.Create(Fvalue));
   derOut.WriteEncoded(TAsn1Tags.Boolean, TCryptoLibByteArray.Create(Fvalue));
 end;
 end;
 
 
-class function TDerBoolean.FromOctetString(value: TCryptoLibByteArray)
+class function TDerBoolean.FromOctetString(const value: TCryptoLibByteArray)
   : IDerBoolean;
   : IDerBoolean;
 var
 var
   b: Byte;
   b: Byte;
@@ -213,7 +213,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-class function TDerBoolean.GetInstance(obj: TObject): IDerBoolean;
+class function TDerBoolean.GetInstance(const obj: TObject): IDerBoolean;
 begin
 begin
   if ((obj = Nil) or (obj is TDerBoolean)) then
   if ((obj = Nil) or (obj is TDerBoolean)) then
   begin
   begin

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

@@ -63,7 +63,7 @@ type
 
 
     constructor Create(val: Int32); overload;
     constructor Create(val: Int32); overload;
     constructor Create(const val: TBigInteger); overload;
     constructor Create(const val: TBigInteger); overload;
-    constructor Create(bytes: TCryptoLibByteArray); overload;
+    constructor Create(const bytes: TCryptoLibByteArray); overload;
 
 
     procedure Encode(const derOut: IDerOutputStream); override;
     procedure Encode(const derOut: IDerOutputStream); override;
 
 
@@ -77,7 +77,7 @@ type
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
 
 
-    class function GetInstance(obj: TObject): IDerEnumerated; overload;
+    class function GetInstance(const obj: TObject): IDerEnumerated; overload;
       static; inline;
       static; inline;
 
 
     /// <summary>
     /// <summary>
@@ -95,7 +95,7 @@ type
     class function GetInstance(const obj: IAsn1TaggedObject;
     class function GetInstance(const obj: IAsn1TaggedObject;
       isExplicit: Boolean): IDerEnumerated; overload; static; inline;
       isExplicit: Boolean): IDerEnumerated; overload; static; inline;
 
 
-    class function FromOctetString(enc: TCryptoLibByteArray)
+    class function FromOctetString(const enc: TCryptoLibByteArray)
       : IDerEnumerated; static;
       : IDerEnumerated; static;
 
 
   end;
   end;
@@ -140,7 +140,7 @@ begin
   Fbytes := val.ToByteArray();
   Fbytes := val.ToByteArray();
 end;
 end;
 
 
-constructor TDerEnumerated.Create(bytes: TCryptoLibByteArray);
+constructor TDerEnumerated.Create(const bytes: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   if (System.Length(bytes) > 1) then
   if (System.Length(bytes) > 1) then
@@ -167,7 +167,7 @@ begin
   derOut.WriteEncoded(TAsn1Tags.Enumerated, Fbytes);
   derOut.WriteEncoded(TAsn1Tags.Enumerated, Fbytes);
 end;
 end;
 
 
-class function TDerEnumerated.FromOctetString(enc: TCryptoLibByteArray)
+class function TDerEnumerated.FromOctetString(const enc: TCryptoLibByteArray)
   : IDerEnumerated;
   : IDerEnumerated;
 var
 var
   LValue: Int32;
   LValue: Int32;
@@ -198,7 +198,7 @@ begin
   result := TDerEnumerated.Create(System.Copy(enc));
   result := TDerEnumerated.Create(System.Copy(enc));
 end;
 end;
 
 
-class function TDerEnumerated.GetInstance(obj: TObject): IDerEnumerated;
+class function TDerEnumerated.GetInstance(const obj: TObject): IDerEnumerated;
 begin
 begin
   if ((obj = Nil) or (obj is TDerEnumerated)) then
   if ((obj = Nil) or (obj is TDerEnumerated)) then
   begin
   begin

+ 5 - 4
CryptoLib/src/Asn1/ClpDerGeneralString.pas

@@ -52,7 +52,7 @@ type
     function Asn1Equals(const asn1Object: IAsn1Object): Boolean; override;
     function Asn1Equals(const asn1Object: IAsn1Object): Boolean; override;
   public
   public
 
 
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     constructor Create(const Str: String); overload;
     constructor Create(const Str: String); overload;
 
 
@@ -62,7 +62,7 @@ type
 
 
     procedure Encode(const derOut: IDerOutputStream); override;
     procedure Encode(const derOut: IDerOutputStream); override;
 
 
-    class function GetInstance(obj: TObject): IDerGeneralString; overload;
+    class function GetInstance(const obj: TObject): IDerGeneralString; overload;
       static; inline;
       static; inline;
 
 
     class function GetInstance(const obj: IAsn1TaggedObject;
     class function GetInstance(const obj: IAsn1TaggedObject;
@@ -98,7 +98,7 @@ begin
   result := Str = other.Str;
   result := Str = other.Str;
 end;
 end;
 
 
-constructor TDerGeneralString.Create(Str: TCryptoLibByteArray);
+constructor TDerGeneralString.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Create(String(TEncoding.ASCII.GetString(Str)));
   Create(String(TEncoding.ASCII.GetString(Str)));
 end;
 end;
@@ -119,7 +119,8 @@ begin
   derOut.WriteEncoded(TAsn1Tags.GeneralString, GetOctets());
   derOut.WriteEncoded(TAsn1Tags.GeneralString, GetOctets());
 end;
 end;
 
 
-class function TDerGeneralString.GetInstance(obj: TObject): IDerGeneralString;
+class function TDerGeneralString.GetInstance(const obj: TObject)
+  : IDerGeneralString;
 begin
 begin
   if ((obj = Nil) or (obj is TDerGeneralString)) then
   if ((obj = Nil) or (obj is TDerGeneralString)) then
   begin
   begin

+ 18 - 16
CryptoLib/src/Asn1/ClpDerGenerator.pas

@@ -39,20 +39,21 @@ type
     F_tagged, F_isExplicit: Boolean;
     F_tagged, F_isExplicit: Boolean;
     F_tagNo: Int32;
     F_tagNo: Int32;
 
 
-    class procedure WriteLength(outStr: TStream; length: Int32); static;
+    class procedure WriteLength(const outStr: TStream; length: Int32); static;
 
 
   strict protected
   strict protected
-    constructor Create(outStream: TStream); overload;
-    constructor Create(outStream: TStream; tagNo: Int32;
+    constructor Create(const outStream: TStream); overload;
+    constructor Create(const outStream: TStream; tagNo: Int32;
       isExplicit: Boolean); overload;
       isExplicit: Boolean); overload;
 
 
   public
   public
-    procedure WriteDerEncoded(tag: Int32; bytes: TCryptoLibByteArray); overload;
-    class procedure WriteDerEncoded(outStream: TStream; tag: Int32;
-      bytes: TCryptoLibByteArray); overload; static;
+    procedure WriteDerEncoded(tag: Int32;
+      const bytes: TCryptoLibByteArray); overload;
+    class procedure WriteDerEncoded(const outStream: TStream; tag: Int32;
+      const bytes: TCryptoLibByteArray); overload; static;
 
 
-    class procedure WriteDerEncoded(outStr: TStream; tag: Int32;
-      inStr: TStream); overload; static;
+    class procedure WriteDerEncoded(const outStr: TStream; tag: Int32;
+      const inStr: TStream); overload; static;
 
 
   end;
   end;
 
 
@@ -60,12 +61,12 @@ implementation
 
 
 { TDerGenerator }
 { TDerGenerator }
 
 
-constructor TDerGenerator.Create(outStream: TStream);
+constructor TDerGenerator.Create(const outStream: TStream);
 begin
 begin
   Inherited Create(outStream);
   Inherited Create(outStream);
 end;
 end;
 
 
-constructor TDerGenerator.Create(outStream: TStream; tagNo: Int32;
+constructor TDerGenerator.Create(const outStream: TStream; tagNo: Int32;
   isExplicit: Boolean);
   isExplicit: Boolean);
 begin
 begin
   Inherited Create(outStream);
   Inherited Create(outStream);
@@ -74,15 +75,16 @@ begin
   F_tagNo := tagNo;
   F_tagNo := tagNo;
 end;
 end;
 
 
-class procedure TDerGenerator.WriteDerEncoded(outStream: TStream; tag: Int32;
-  bytes: TCryptoLibByteArray);
+class procedure TDerGenerator.WriteDerEncoded(const outStream: TStream;
+  tag: Int32; const bytes: TCryptoLibByteArray);
 begin
 begin
   outStream.WriteByte(Byte(tag));
   outStream.WriteByte(Byte(tag));
   WriteLength(outStream, System.length(bytes));
   WriteLength(outStream, System.length(bytes));
   outStream.Write(bytes[0], System.length(bytes));
   outStream.Write(bytes[0], System.length(bytes));
 end;
 end;
 
 
-procedure TDerGenerator.WriteDerEncoded(tag: Int32; bytes: TCryptoLibByteArray);
+procedure TDerGenerator.WriteDerEncoded(tag: Int32;
+  const bytes: TCryptoLibByteArray);
 var
 var
   tagNum, newTag: Int32;
   tagNum, newTag: Int32;
   bOut: TMemoryStream;
   bOut: TMemoryStream;
@@ -122,13 +124,13 @@ begin
   end;
   end;
 end;
 end;
 
 
-class procedure TDerGenerator.WriteDerEncoded(outStr: TStream; tag: Int32;
-  inStr: TStream);
+class procedure TDerGenerator.WriteDerEncoded(const outStr: TStream; tag: Int32;
+  const inStr: TStream);
 begin
 begin
   WriteDerEncoded(outStr, tag, TStreams.ReadAll(inStr));
   WriteDerEncoded(outStr, tag, TStreams.ReadAll(inStr));
 end;
 end;
 
 
-class procedure TDerGenerator.WriteLength(outStr: TStream; length: Int32);
+class procedure TDerGenerator.WriteLength(const outStr: TStream; length: Int32);
 var
 var
   Size, val, i: Int32;
   Size, val, i: Int32;
 begin
 begin

+ 8 - 7
CryptoLib/src/Asn1/ClpDerGraphicString.pas

@@ -59,7 +59,7 @@ type
     /// <param name="encoding">
     /// <param name="encoding">
     /// the byte encoding of the characters making up the string.
     /// the byte encoding of the characters making up the string.
     /// </param>
     /// </param>
-    constructor Create(encoding: TCryptoLibByteArray);
+    constructor Create(const encoding: TCryptoLibByteArray);
 
 
     function GetString(): String; override;
     function GetString(): String; override;
 
 
@@ -79,11 +79,11 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerGraphicString; overload;
+    class function GetInstance(const obj: TObject): IDerGraphicString; overload;
       static; inline;
       static; inline;
 
 
-    class function GetInstance(obj: TCryptoLibByteArray): IDerGraphicString;
-      overload; static;
+    class function GetInstance(const obj: TCryptoLibByteArray)
+      : IDerGraphicString; overload; static;
 
 
     /// <summary>
     /// <summary>
     /// return a Graphic string from a tagged object.
     /// return a Graphic string from a tagged object.
@@ -130,7 +130,7 @@ begin
   result := TArrayUtils.GetArrayHashCode(mString);
   result := TArrayUtils.GetArrayHashCode(mString);
 end;
 end;
 
 
-constructor TDerGraphicString.Create(encoding: TCryptoLibByteArray);
+constructor TDerGraphicString.Create(const encoding: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   FmString := System.Copy(encoding);
   FmString := System.Copy(encoding);
@@ -141,7 +141,8 @@ begin
   derOut.WriteEncoded(TAsn1Tags.GraphicString, mString);
   derOut.WriteEncoded(TAsn1Tags.GraphicString, mString);
 end;
 end;
 
 
-class function TDerGraphicString.GetInstance(obj: TObject): IDerGraphicString;
+class function TDerGraphicString.GetInstance(const obj: TObject)
+  : IDerGraphicString;
 begin
 begin
   if ((obj = Nil) or (obj is TDerGraphicString)) then
   if ((obj = Nil) or (obj is TDerGraphicString)) then
   begin
   begin
@@ -170,7 +171,7 @@ begin
     (TAsn1OctetString.GetInstance(o as TAsn1Object).GetOctets());
     (TAsn1OctetString.GetInstance(o as TAsn1Object).GetOctets());
 end;
 end;
 
 
-class function TDerGraphicString.GetInstance(obj: TCryptoLibByteArray)
+class function TDerGraphicString.GetInstance(const obj: TCryptoLibByteArray)
   : IDerGraphicString;
   : IDerGraphicString;
 begin
 begin
   try
   try

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

@@ -60,7 +60,7 @@ type
     /// <summary>
     /// <summary>
     /// basic constructor - with bytes.
     /// basic constructor - with bytes.
     /// </summary>
     /// </summary>
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// basic constructor - without validation.
     /// basic constructor - without validation.
@@ -100,7 +100,7 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerIA5String; overload;
+    class function GetInstance(const obj: TObject): IDerIA5String; overload;
       static; inline;
       static; inline;
 
 
     /// <summary>
     /// <summary>
@@ -178,7 +178,7 @@ begin
   result := TStringUtils.GetStringHashCode(FStr);
   result := TStringUtils.GetStringHashCode(FStr);
 end;
 end;
 
 
-constructor TDerIA5String.Create(Str: TCryptoLibByteArray);
+constructor TDerIA5String.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Create(String(TEncoding.ASCII.GetString(Str)), false);
   Create(String(TEncoding.ASCII.GetString(Str)), false);
 end;
 end;
@@ -208,7 +208,7 @@ begin
   derOut.WriteEncoded(TAsn1Tags.IA5String, GetOctets());
   derOut.WriteEncoded(TAsn1Tags.IA5String, GetOctets());
 end;
 end;
 
 
-class function TDerIA5String.GetInstance(obj: TObject): IDerIA5String;
+class function TDerIA5String.GetInstance(const obj: TObject): IDerIA5String;
 begin
 begin
   if ((obj = Nil) or (obj is TDerIA5String)) then
   if ((obj = Nil) or (obj is TDerIA5String)) then
   begin
   begin

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

@@ -57,7 +57,7 @@ type
 
 
     constructor Create(value: Int32); overload;
     constructor Create(value: Int32); overload;
     constructor Create(const value: TBigInteger); overload;
     constructor Create(const value: TBigInteger); overload;
-    constructor Create(bytes: TCryptoLibByteArray); overload;
+    constructor Create(const bytes: TCryptoLibByteArray); overload;
 
 
     property value: TBigInteger read GetValue;
     property value: TBigInteger read GetValue;
     property PositiveValue: TBigInteger read GetPositiveValue;
     property PositiveValue: TBigInteger read GetPositiveValue;
@@ -73,7 +73,8 @@ type
     // * @exception ArgumentException if the object cannot be converted.
     // * @exception ArgumentException if the object cannot be converted.
     // */
     // */
 
 
-    class function GetInstance(obj: TObject): IDerInteger; overload; static;
+    class function GetInstance(const obj: TObject): IDerInteger;
+      overload; static;
 
 
     // /**
     // /**
     // * return an Integer from a tagged object.
     // * return an Integer from a tagged object.
@@ -98,7 +99,7 @@ begin
   Result := Fbytes;
   Result := Fbytes;
 end;
 end;
 
 
-class function TDerInteger.GetInstance(obj: TObject): IDerInteger;
+class function TDerInteger.GetInstance(const obj: TObject): IDerInteger;
 begin
 begin
   if ((obj = Nil) or (obj is TDerInteger)) then
   if ((obj = Nil) or (obj is TDerInteger)) then
   begin
   begin
@@ -147,7 +148,7 @@ begin
   Fbytes := TBigInteger.ValueOf(value).ToByteArray();
   Fbytes := TBigInteger.ValueOf(value).ToByteArray();
 end;
 end;
 
 
-constructor TDerInteger.Create(bytes: TCryptoLibByteArray);
+constructor TDerInteger.Create(const bytes: TCryptoLibByteArray);
 begin
 begin
   inherited Create();
   inherited Create();
   if (System.Length(bytes) > 1) then
   if (System.Length(bytes) > 1) then

+ 5 - 4
CryptoLib/src/Asn1/ClpDerNumericString.pas

@@ -59,7 +59,7 @@ type
     /// <summary>
     /// <summary>
     /// basic constructor - with bytes.
     /// basic constructor - with bytes.
     /// </summary>
     /// </summary>
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// basic constructor - without validation.
     /// basic constructor - without validation.
@@ -99,7 +99,7 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerNumericString; overload;
+    class function GetInstance(const obj: TObject): IDerNumericString; overload;
       static; inline;
       static; inline;
 
 
     /// <summary>
     /// <summary>
@@ -177,7 +177,7 @@ begin
   result := Str = other.Str;
   result := Str = other.Str;
 end;
 end;
 
 
-constructor TDerNumericString.Create(Str: TCryptoLibByteArray);
+constructor TDerNumericString.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Create(String(TEncoding.ASCII.GetString(Str)), false);
   Create(String(TEncoding.ASCII.GetString(Str)), false);
 end;
 end;
@@ -207,7 +207,8 @@ begin
   derOut.WriteEncoded(TAsn1Tags.NumericString, GetOctets());
   derOut.WriteEncoded(TAsn1Tags.NumericString, GetOctets());
 end;
 end;
 
 
-class function TDerNumericString.GetInstance(obj: TObject): IDerNumericString;
+class function TDerNumericString.GetInstance(const obj: TObject)
+  : IDerNumericString;
 begin
 begin
   if ((obj = Nil) or (obj is TDerNumericString)) then
   if ((obj = Nil) or (obj is TDerNumericString)) then
   begin
   begin

+ 21 - 20
CryptoLib/src/Asn1/ClpDerObjectIdentifier.pas

@@ -69,19 +69,20 @@ type
 
 
     constructor Create(const oid: IDerObjectIdentifier;
     constructor Create(const oid: IDerObjectIdentifier;
       const branchID: String); overload;
       const branchID: String); overload;
-    constructor Create(bytes: TCryptoLibByteArray); overload;
+    constructor Create(const bytes: TCryptoLibByteArray); overload;
 
 
     function GetID: String; inline;
     function GetID: String; inline;
 
 
-    procedure WriteField(outputStream: TStream; fieldValue: Int64); overload;
-    procedure WriteField(outputStream: TStream;
-      fieldValue: TBigInteger); overload;
-    procedure DoOutput(bOut: TMemoryStream); overload;
+    procedure WriteField(const outputStream: TStream;
+      fieldValue: Int64); overload;
+    procedure WriteField(const outputStream: TStream;
+      const fieldValue: TBigInteger); overload;
+    procedure DoOutput(const bOut: TMemoryStream); overload;
     function GetBody(): TCryptoLibByteArray;
     function GetBody(): TCryptoLibByteArray;
     class function IsValidBranchID(const branchID: String; start: Int32)
     class function IsValidBranchID(const branchID: String; start: Int32)
       : Boolean; static;
       : Boolean; static;
     class function IsValidIdentifier(const identifier: String): Boolean; static;
     class function IsValidIdentifier(const identifier: String): Boolean; static;
-    class function MakeOidStringFromBytes(bytes: TCryptoLibByteArray)
+    class function MakeOidStringFromBytes(const bytes: TCryptoLibByteArray)
       : String; static;
       : String; static;
 
 
   strict protected
   strict protected
@@ -94,14 +95,14 @@ type
     // *
     // *
     // * @exception ArgumentException if the object cannot be converted.
     // * @exception ArgumentException if the object cannot be converted.
     // */
     // */
-    class function GetInstance(obj: TObject): IDerObjectIdentifier;
+    class function GetInstance(const obj: TObject): IDerObjectIdentifier;
       overload; static;
       overload; static;
 
 
     // /**
     // /**
     // * return an Oid from the passed in byte array
     // * return an Oid from the passed in byte array
     // */
     // */
-    class function GetInstance(obj: TCryptoLibByteArray): IDerObjectIdentifier;
-      overload; static; inline;
+    class function GetInstance(const obj: TCryptoLibByteArray)
+      : IDerObjectIdentifier; overload; static; inline;
 
 
     // /**
     // /**
     // * return an object Identifier from a tagged object.
     // * return an object Identifier from a tagged object.
@@ -115,7 +116,7 @@ type
     class function GetInstance(const obj: IAsn1TaggedObject;
     class function GetInstance(const obj: IAsn1TaggedObject;
       explicitly: Boolean): IDerObjectIdentifier; overload; static; inline;
       explicitly: Boolean): IDerObjectIdentifier; overload; static; inline;
 
 
-    class function FromOctetString(enc: TCryptoLibByteArray)
+    class function FromOctetString(const enc: TCryptoLibByteArray)
       : IDerObjectIdentifier; static;
       : IDerObjectIdentifier; static;
 
 
     constructor Create(const identifier: String); overload;
     constructor Create(const identifier: String); overload;
@@ -200,7 +201,7 @@ begin
   Fidentifier := identifier;
   Fidentifier := identifier;
 end;
 end;
 
 
-constructor TDerObjectIdentifier.Create(bytes: TCryptoLibByteArray);
+constructor TDerObjectIdentifier.Create(const bytes: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   Fidentifier := MakeOidStringFromBytes(bytes);
   Fidentifier := MakeOidStringFromBytes(bytes);
@@ -229,7 +230,7 @@ begin
   FLock.Free;
   FLock.Free;
 end;
 end;
 
 
-procedure TDerObjectIdentifier.DoOutput(bOut: TMemoryStream);
+procedure TDerObjectIdentifier.DoOutput(const bOut: TMemoryStream);
 var
 var
   tok: IOidTokenizer;
   tok: IOidTokenizer;
   token: String;
   token: String;
@@ -267,8 +268,8 @@ begin
   derOut.WriteEncoded(TAsn1Tags.ObjectIdentifier, GetBody());
   derOut.WriteEncoded(TAsn1Tags.ObjectIdentifier, GetBody());
 end;
 end;
 
 
-class function TDerObjectIdentifier.FromOctetString(enc: TCryptoLibByteArray)
-  : IDerObjectIdentifier;
+class function TDerObjectIdentifier.FromOctetString
+  (const enc: TCryptoLibByteArray): IDerObjectIdentifier;
 var
 var
   HashCode, first: Int32;
   HashCode, first: Int32;
   entry: IDerObjectIdentifier;
   entry: IDerObjectIdentifier;
@@ -339,7 +340,7 @@ begin
     .GetOctets());
     .GetOctets());
 end;
 end;
 
 
-class function TDerObjectIdentifier.GetInstance(obj: TObject)
+class function TDerObjectIdentifier.GetInstance(const obj: TObject)
   : IDerObjectIdentifier;
   : IDerObjectIdentifier;
 begin
 begin
   if ((obj = Nil) or (obj is TDerObjectIdentifier)) then
   if ((obj = Nil) or (obj is TDerObjectIdentifier)) then
@@ -352,7 +353,7 @@ begin
     [obj.ClassName]);
     [obj.ClassName]);
 end;
 end;
 
 
-class function TDerObjectIdentifier.GetInstance(obj: TCryptoLibByteArray)
+class function TDerObjectIdentifier.GetInstance(const obj: TCryptoLibByteArray)
   : IDerObjectIdentifier;
   : IDerObjectIdentifier;
 begin
 begin
   result := FromOctetString(obj);
   result := FromOctetString(obj);
@@ -435,7 +436,7 @@ begin
 end;
 end;
 
 
 class function TDerObjectIdentifier.MakeOidStringFromBytes
 class function TDerObjectIdentifier.MakeOidStringFromBytes
-  (bytes: TCryptoLibByteArray): String;
+  (const bytes: TCryptoLibByteArray): String;
 var
 var
   objId: TStringList;
   objId: TStringList;
   value: Int64;
   value: Int64;
@@ -530,8 +531,8 @@ begin
   result := ID;
   result := ID;
 end;
 end;
 
 
-procedure TDerObjectIdentifier.WriteField(outputStream: TStream;
-  fieldValue: TBigInteger);
+procedure TDerObjectIdentifier.WriteField(const outputStream: TStream;
+  const fieldValue: TBigInteger);
 var
 var
   byteCount, i: Int32;
   byteCount, i: Int32;
   tmpValue: TBigInteger;
   tmpValue: TBigInteger;
@@ -561,7 +562,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TDerObjectIdentifier.WriteField(outputStream: TStream;
+procedure TDerObjectIdentifier.WriteField(const outputStream: TStream;
   fieldValue: Int64);
   fieldValue: Int64);
 var
 var
   tempRes: TCryptoLibByteArray;
   tempRes: TCryptoLibByteArray;

+ 7 - 6
CryptoLib/src/Asn1/ClpDerOctetString.pas

@@ -34,14 +34,15 @@ type
 
 
   public
   public
     /// <param name="str">The octets making up the octet string.</param>
     /// <param name="str">The octets making up the octet string.</param>
-    constructor Create(str: TCryptoLibByteArray); overload;
+    constructor Create(const str: TCryptoLibByteArray); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
 
 
     destructor Destroy(); override;
     destructor Destroy(); override;
 
 
     procedure Encode(const derOut: IDerOutputStream); overload; override;
     procedure Encode(const derOut: IDerOutputStream); overload; override;
-    class procedure Encode(derOut: TDerOutputStream; bytes: TCryptoLibByteArray;
-      offset, length: Int32); reintroduce; overload; static; inline;
+    class procedure Encode(const derOut: TDerOutputStream;
+      const bytes: TCryptoLibByteArray; offset, length: Int32); reintroduce;
+      overload; static; inline;
 
 
   end;
   end;
 
 
@@ -49,7 +50,7 @@ implementation
 
 
 { TDerOctetString }
 { TDerOctetString }
 
 
-constructor TDerOctetString.Create(str: TCryptoLibByteArray);
+constructor TDerOctetString.Create(const str: TCryptoLibByteArray);
 begin
 begin
   Inherited Create(str);
   Inherited Create(str);
 end;
 end;
@@ -69,8 +70,8 @@ begin
   derOut.WriteEncoded(TAsn1Tags.OctetString, str);
   derOut.WriteEncoded(TAsn1Tags.OctetString, str);
 end;
 end;
 
 
-class procedure TDerOctetString.Encode(derOut: TDerOutputStream;
-  bytes: TCryptoLibByteArray; offset, length: Int32);
+class procedure TDerOctetString.Encode(const derOut: TDerOutputStream;
+  const bytes: TCryptoLibByteArray; offset, length: Int32);
 begin
 begin
   derOut.WriteEncoded(TAsn1Tags.OctetString, bytes, offset, length);
   derOut.WriteEncoded(TAsn1Tags.OctetString, bytes, offset, length);
 end;
 end;

+ 13 - 11
CryptoLib/src/Asn1/ClpDerOutputStream.pas

@@ -40,14 +40,15 @@ type
     procedure WriteNull();
     procedure WriteNull();
 
 
   public
   public
-    constructor Create(os: TStream);
-    procedure WriteEncoded(tag: Int32; bytes: TCryptoLibByteArray); overload;
+    constructor Create(const os: TStream);
+    procedure WriteEncoded(tag: Int32;
+      const bytes: TCryptoLibByteArray); overload;
     procedure WriteEncoded(tag: Int32; first: Byte;
     procedure WriteEncoded(tag: Int32; first: Byte;
-      bytes: TCryptoLibByteArray); overload;
-    procedure WriteEncoded(tag: Int32; bytes: TCryptoLibByteArray;
+      const bytes: TCryptoLibByteArray); overload;
+    procedure WriteEncoded(tag: Int32; const bytes: TCryptoLibByteArray;
       offset, length: Int32); overload;
       offset, length: Int32); overload;
     procedure WriteEncoded(flags, tagNo: Int32;
     procedure WriteEncoded(flags, tagNo: Int32;
-      bytes: TCryptoLibByteArray); overload;
+      const bytes: TCryptoLibByteArray); overload;
     procedure WriteTag(flags, tagNo: Int32);
     procedure WriteTag(flags, tagNo: Int32);
 
 
     procedure WriteObject(const obj: IAsn1Encodable); overload; virtual;
     procedure WriteObject(const obj: IAsn1Encodable); overload; virtual;
@@ -59,13 +60,13 @@ implementation
 
 
 { TDerOutputStream }
 { TDerOutputStream }
 
 
-constructor TDerOutputStream.Create(os: TStream);
+constructor TDerOutputStream.Create(const os: TStream);
 begin
 begin
   Inherited Create(os);
   Inherited Create(os);
 end;
 end;
 
 
 procedure TDerOutputStream.WriteEncoded(tag: Int32; first: Byte;
 procedure TDerOutputStream.WriteEncoded(tag: Int32; first: Byte;
-  bytes: TCryptoLibByteArray);
+  const bytes: TCryptoLibByteArray);
 begin
 begin
   WriteByte(Byte(tag));
   WriteByte(Byte(tag));
   WriteLength(System.length(bytes) + 1);
   WriteLength(System.length(bytes) + 1);
@@ -73,7 +74,8 @@ begin
   Write(bytes[0], System.length(bytes));
   Write(bytes[0], System.length(bytes));
 end;
 end;
 
 
-procedure TDerOutputStream.WriteEncoded(tag: Int32; bytes: TCryptoLibByteArray);
+procedure TDerOutputStream.WriteEncoded(tag: Int32;
+  const bytes: TCryptoLibByteArray);
 begin
 begin
   WriteByte(Byte(tag));
   WriteByte(Byte(tag));
   WriteLength(System.length(bytes));
   WriteLength(System.length(bytes));
@@ -81,15 +83,15 @@ begin
 end;
 end;
 
 
 procedure TDerOutputStream.WriteEncoded(flags, tagNo: Int32;
 procedure TDerOutputStream.WriteEncoded(flags, tagNo: Int32;
-  bytes: TCryptoLibByteArray);
+  const bytes: TCryptoLibByteArray);
 begin
 begin
   WriteTag(flags, tagNo);
   WriteTag(flags, tagNo);
   WriteLength(System.length(bytes));
   WriteLength(System.length(bytes));
   Write(bytes[0], System.length(bytes));
   Write(bytes[0], System.length(bytes));
 end;
 end;
 
 
-procedure TDerOutputStream.WriteEncoded(tag: Int32; bytes: TCryptoLibByteArray;
-  offset, length: Int32);
+procedure TDerOutputStream.WriteEncoded(tag: Int32;
+  const bytes: TCryptoLibByteArray; offset, length: Int32);
 begin
 begin
   WriteByte(Byte(tag));
   WriteByte(Byte(tag));
   WriteLength(length);
   WriteLength(length);

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

@@ -58,7 +58,7 @@ type
     /// <summary>
     /// <summary>
     /// basic constructor - with bytes.
     /// basic constructor - with bytes.
     /// </summary>
     /// </summary>
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// basic constructor - without validation.
     /// basic constructor - without validation.
@@ -100,8 +100,8 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerPrintableString; overload;
-      static; inline;
+    class function GetInstance(const obj: TObject): IDerPrintableString;
+      overload; static; inline;
 
 
     /// <summary>
     /// <summary>
     /// return a Printable string from a tagged object.
     /// return a Printable string from a tagged object.
@@ -201,7 +201,7 @@ begin
   result := Str = other.Str;
   result := Str = other.Str;
 end;
 end;
 
 
-constructor TDerPrintableString.Create(Str: TCryptoLibByteArray);
+constructor TDerPrintableString.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Create(String(TEncoding.ASCII.GetString(Str)), false);
   Create(String(TEncoding.ASCII.GetString(Str)), false);
 end;
 end;
@@ -231,7 +231,7 @@ begin
   derOut.WriteEncoded(TAsn1Tags.PrintableString, GetOctets());
   derOut.WriteEncoded(TAsn1Tags.PrintableString, GetOctets());
 end;
 end;
 
 
-class function TDerPrintableString.GetInstance(obj: TObject)
+class function TDerPrintableString.GetInstance(const obj: TObject)
   : IDerPrintableString;
   : IDerPrintableString;
 begin
 begin
   if ((obj = Nil) or (obj is TDerPrintableString)) then
   if ((obj = Nil) or (obj is TDerPrintableString)) then

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

@@ -59,7 +59,7 @@ type
     /// </summary>
     /// </summary>
     constructor Create(const obj: IAsn1Encodable); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
 
 
-    constructor Create(v: array of IAsn1Encodable); overload;
+    constructor Create(const v: array of IAsn1Encodable); overload;
 
 
     /// <summary>
     /// <summary>
     /// create a sequence containing a vector of objects.
     /// create a sequence containing a vector of objects.
@@ -114,7 +114,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-constructor TDerSequence.Create(v: array of IAsn1Encodable);
+constructor TDerSequence.Create(const v: array of IAsn1Encodable);
 var
 var
   ae: IAsn1Encodable;
   ae: IAsn1Encodable;
 begin
 begin

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

@@ -62,7 +62,7 @@ type
     /// </param>
     /// </param>
     constructor Create(const obj: IAsn1Encodable); overload;
     constructor Create(const obj: IAsn1Encodable); overload;
 
 
-    constructor Create(v: array of IAsn1Encodable); overload;
+    constructor Create(const v: array of IAsn1Encodable); overload;
 
 
     /// <param name="v">
     /// <param name="v">
     /// a vector of objects making up the set.
     /// a vector of objects making up the set.
@@ -96,7 +96,7 @@ begin
   result := FEmpty;
   result := FEmpty;
 end;
 end;
 
 
-constructor TDerSet.Create(v: array of IAsn1Encodable);
+constructor TDerSet.Create(const v: array of IAsn1Encodable);
 var
 var
   o: IAsn1Encodable;
   o: IAsn1Encodable;
 begin
 begin

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

@@ -57,7 +57,7 @@ type
     /// <summary>
     /// <summary>
     /// basic constructor - with bytes.
     /// basic constructor - with bytes.
     /// </summary>
     /// </summary>
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// basic constructor
     /// basic constructor
@@ -82,7 +82,7 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerT61String; overload;
+    class function GetInstance(const obj: TObject): IDerT61String; overload;
       static; inline;
       static; inline;
 
 
     /// <summary>
     /// <summary>
@@ -130,7 +130,7 @@ begin
   result := Str = other.Str;
   result := Str = other.Str;
 end;
 end;
 
 
-constructor TDerT61String.Create(Str: TCryptoLibByteArray);
+constructor TDerT61String.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Create(String(TEncoding.ASCII.GetString(Str)));
   Create(String(TEncoding.ASCII.GetString(Str)));
 end;
 end;
@@ -151,7 +151,7 @@ begin
   derOut.WriteEncoded(TAsn1Tags.T61String, GetOctets());
   derOut.WriteEncoded(TAsn1Tags.T61String, GetOctets());
 end;
 end;
 
 
-class function TDerT61String.GetInstance(obj: TObject): IDerT61String;
+class function TDerT61String.GetInstance(const obj: TObject): IDerT61String;
 begin
 begin
   if ((obj = Nil) or (obj is TDerT61String)) then
   if ((obj = Nil) or (obj is TDerT61String)) then
   begin
   begin

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

@@ -63,7 +63,7 @@ type
     /// <summary>
     /// <summary>
     /// basic constructor - byte encoded string.
     /// basic constructor - byte encoded string.
     /// </summary>
     /// </summary>
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     function GetString(): String; override;
     function GetString(): String; override;
 
 
@@ -83,8 +83,8 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerUniversalString; overload;
-      static; inline;
+    class function GetInstance(const obj: TObject): IDerUniversalString;
+      overload; static; inline;
 
 
     /// <summary>
     /// <summary>
     /// return a Der UniversalString from a tagged object.
     /// return a Der UniversalString from a tagged object.
@@ -131,7 +131,7 @@ begin
   result := TArrayUtils.AreEqual(Str, other.Str);
   result := TArrayUtils.AreEqual(Str, other.Str);
 end;
 end;
 
 
-constructor TDerUniversalString.Create(Str: TCryptoLibByteArray);
+constructor TDerUniversalString.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   if (Str = Nil) then
   if (Str = Nil) then
@@ -147,7 +147,7 @@ begin
   derOut.WriteEncoded(TAsn1Tags.UniversalString, Str);
   derOut.WriteEncoded(TAsn1Tags.UniversalString, Str);
 end;
 end;
 
 
-class function TDerUniversalString.GetInstance(obj: TObject)
+class function TDerUniversalString.GetInstance(const obj: TObject)
   : IDerUniversalString;
   : IDerUniversalString;
 begin
 begin
   if ((obj = Nil) or (obj is TDerUniversalString)) then
   if ((obj = Nil) or (obj is TDerUniversalString)) then

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

@@ -57,7 +57,7 @@ type
     /// <summary>
     /// <summary>
     /// basic constructor - with bytes.
     /// basic constructor - with bytes.
     /// </summary>
     /// </summary>
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// basic constructor
     /// basic constructor
@@ -82,7 +82,7 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerUtf8String; overload;
+    class function GetInstance(const obj: TObject): IDerUtf8String; overload;
       static; inline;
       static; inline;
 
 
     /// <summary>
     /// <summary>
@@ -130,7 +130,7 @@ begin
   result := Str = other.Str;
   result := Str = other.Str;
 end;
 end;
 
 
-constructor TDerUtf8String.Create(Str: TCryptoLibByteArray);
+constructor TDerUtf8String.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Create(String(TEncoding.UTF8.GetString(Str)));
   Create(String(TEncoding.UTF8.GetString(Str)));
 end;
 end;
@@ -152,7 +152,7 @@ begin
     TEncoding.UTF8.GetBytes(UnicodeString(Str)));
     TEncoding.UTF8.GetBytes(UnicodeString(Str)));
 end;
 end;
 
 
-class function TDerUtf8String.GetInstance(obj: TObject): IDerUtf8String;
+class function TDerUtf8String.GetInstance(const obj: TObject): IDerUtf8String;
 begin
 begin
   if ((obj = Nil) or (obj is TDerUtf8String)) then
   if ((obj = Nil) or (obj is TDerUtf8String)) then
   begin
   begin

+ 9 - 8
CryptoLib/src/Asn1/ClpDerVideotexString.pas

@@ -59,7 +59,7 @@ type
     /// <param name="encoding">
     /// <param name="encoding">
     /// the byte encoding of the characters making up the string.
     /// the byte encoding of the characters making up the string.
     /// </param>
     /// </param>
-    constructor Create(encoding: TCryptoLibByteArray);
+    constructor Create(const encoding: TCryptoLibByteArray);
 
 
     function GetString(): String; override;
     function GetString(): String; override;
 
 
@@ -79,11 +79,11 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerVideotexString; overload;
-      static; inline;
+    class function GetInstance(const obj: TObject): IDerVideotexString;
+      overload; static; inline;
 
 
-    class function GetInstance(obj: TCryptoLibByteArray): IDerVideotexString;
-      overload; static;
+    class function GetInstance(const obj: TCryptoLibByteArray)
+      : IDerVideotexString; overload; static;
 
 
     /// <summary>
     /// <summary>
     /// return a Videotex string from a tagged object.
     /// return a Videotex string from a tagged object.
@@ -130,7 +130,7 @@ begin
   result := TArrayUtils.GetArrayHashCode(mString);
   result := TArrayUtils.GetArrayHashCode(mString);
 end;
 end;
 
 
-constructor TDerVideotexString.Create(encoding: TCryptoLibByteArray);
+constructor TDerVideotexString.Create(const encoding: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   FmString := System.Copy(encoding);
   FmString := System.Copy(encoding);
@@ -141,7 +141,8 @@ begin
   derOut.WriteEncoded(TAsn1Tags.VideotexString, mString);
   derOut.WriteEncoded(TAsn1Tags.VideotexString, mString);
 end;
 end;
 
 
-class function TDerVideotexString.GetInstance(obj: TObject): IDerVideotexString;
+class function TDerVideotexString.GetInstance(const obj: TObject)
+  : IDerVideotexString;
 begin
 begin
   if ((obj = Nil) or (obj is TDerVideotexString)) then
   if ((obj = Nil) or (obj is TDerVideotexString)) then
   begin
   begin
@@ -170,7 +171,7 @@ begin
     (TAsn1OctetString.GetInstance(o as TAsn1Object).GetOctets());
     (TAsn1OctetString.GetInstance(o as TAsn1Object).GetOctets());
 end;
 end;
 
 
-class function TDerVideotexString.GetInstance(obj: TCryptoLibByteArray)
+class function TDerVideotexString.GetInstance(const obj: TCryptoLibByteArray)
   : IDerVideotexString;
   : IDerVideotexString;
 begin
 begin
   try
   try

+ 5 - 4
CryptoLib/src/Asn1/ClpDerVisibleString.pas

@@ -59,7 +59,7 @@ type
     /// <summary>
     /// <summary>
     /// basic constructor - byte encoded string.
     /// basic constructor - byte encoded string.
     /// </summary>
     /// </summary>
-    constructor Create(Str: TCryptoLibByteArray); overload;
+    constructor Create(const Str: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// basic constructor
     /// basic constructor
@@ -84,7 +84,7 @@ type
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// <exception cref="ClpCryptoLibTypes|EArgumentCryptoLibException">
     /// if the object cannot be converted.
     /// if the object cannot be converted.
     /// </exception>
     /// </exception>
-    class function GetInstance(obj: TObject): IDerVisibleString; overload;
+    class function GetInstance(const obj: TObject): IDerVisibleString; overload;
       static; inline;
       static; inline;
 
 
     /// <summary>
     /// <summary>
@@ -137,7 +137,7 @@ begin
   result := TStringUtils.GetStringHashCode(FStr);
   result := TStringUtils.GetStringHashCode(FStr);
 end;
 end;
 
 
-constructor TDerVisibleString.Create(Str: TCryptoLibByteArray);
+constructor TDerVisibleString.Create(const Str: TCryptoLibByteArray);
 begin
 begin
   Create(String(TEncoding.ASCII.GetString(Str)));
   Create(String(TEncoding.ASCII.GetString(Str)));
 end;
 end;
@@ -158,7 +158,8 @@ begin
   derOut.WriteEncoded(TAsn1Tags.VisibleString, GetOctets());
   derOut.WriteEncoded(TAsn1Tags.VisibleString, GetOctets());
 end;
 end;
 
 
-class function TDerVisibleString.GetInstance(obj: TObject): IDerVisibleString;
+class function TDerVisibleString.GetInstance(const obj: TObject)
+  : IDerVisibleString;
 var
 var
   asn1OctetString: IAsn1OctetString;
   asn1OctetString: IAsn1OctetString;
   asn1TaggedObject: IAsn1TaggedObject;
   asn1TaggedObject: IAsn1TaggedObject;

+ 3 - 2
CryptoLib/src/Asn1/X9/ClpX9Curve.pas

@@ -71,7 +71,7 @@ type
   public
   public
     constructor Create(const curve: IECCurve); overload;
     constructor Create(const curve: IECCurve); overload;
     constructor Create(const curve: IECCurve;
     constructor Create(const curve: IECCurve;
-      seed: TCryptoLibByteArray); overload;
+      const seed: TCryptoLibByteArray); overload;
     constructor Create(const fieldID: IX9FieldID; const seq: IAsn1Sequence);
     constructor Create(const fieldID: IX9FieldID; const seq: IAsn1Sequence);
       overload; deprecated 'Use constructor including order/cofactor';
       overload; deprecated 'Use constructor including order/cofactor';
 
 
@@ -103,7 +103,8 @@ implementation
 
 
 { TX9Curve }
 { TX9Curve }
 
 
-constructor TX9Curve.Create(const curve: IECCurve; seed: TCryptoLibByteArray);
+constructor TX9Curve.Create(const curve: IECCurve;
+  const seed: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   if (curve = Nil) then
   if (curve = Nil) then

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

@@ -84,9 +84,9 @@ type
     constructor Create(const curve: IECCurve; const g: IECPoint;
     constructor Create(const curve: IECCurve; const g: IECPoint;
       const n, h: TBigInteger); overload;
       const n, h: TBigInteger); overload;
     constructor Create(const curve: IECCurve; const g: IECPoint;
     constructor Create(const curve: IECCurve; const g: IECPoint;
-      const n, h: TBigInteger; seed: TCryptoLibByteArray); overload;
+      const n, h: TBigInteger; const seed: TCryptoLibByteArray); overload;
     constructor Create(const curve: IECCurve; const g: IX9ECPoint;
     constructor Create(const curve: IECCurve; const g: IX9ECPoint;
-      const n, h: TBigInteger; seed: TCryptoLibByteArray); overload;
+      const n, h: TBigInteger; const seed: TCryptoLibByteArray); overload;
 
 
     property curve: IECCurve read GetCurve;
     property curve: IECCurve read GetCurve;
     property g: IECPoint read GetG;
     property g: IECPoint read GetG;
@@ -185,7 +185,7 @@ begin
 end;
 end;
 
 
 constructor TX9ECParameters.Create(const curve: IECCurve; const g: IX9ECPoint;
 constructor TX9ECParameters.Create(const curve: IECCurve; const g: IX9ECPoint;
-  const n, h: TBigInteger; seed: TCryptoLibByteArray);
+  const n, h: TBigInteger; const seed: TCryptoLibByteArray);
 var
 var
   exponents: TCryptoLibInt32Array;
   exponents: TCryptoLibInt32Array;
   Field: IPolynomialExtensionField;
   Field: IPolynomialExtensionField;
@@ -228,7 +228,7 @@ begin
 end;
 end;
 
 
 constructor TX9ECParameters.Create(const curve: IECCurve; const g: IECPoint;
 constructor TX9ECParameters.Create(const curve: IECCurve; const g: IECPoint;
-  const n, h: TBigInteger; seed: TCryptoLibByteArray);
+  const n, h: TBigInteger; const seed: TCryptoLibByteArray);
 begin
 begin
   Create(curve, TX9ECPoint.Create(g) as IX9ECPoint, n, h, seed)
   Create(curve, TX9ECPoint.Create(g) as IX9ECPoint, n, h, seed)
 end;
 end;

+ 3 - 2
CryptoLib/src/Asn1/X9/ClpX9ECPoint.pas

@@ -50,7 +50,7 @@ type
     constructor Create(const p: IECPoint); overload;
     constructor Create(const p: IECPoint); overload;
     constructor Create(const p: IECPoint; compressed: Boolean); overload;
     constructor Create(const p: IECPoint; compressed: Boolean); overload;
     constructor Create(const c: IECCurve;
     constructor Create(const c: IECCurve;
-      encoding: TCryptoLibByteArray); overload;
+      const encoding: TCryptoLibByteArray); overload;
     constructor Create(const c: IECCurve; const s: IAsn1OctetString); overload;
     constructor Create(const c: IECCurve; const s: IAsn1OctetString); overload;
 
 
     property Point: IECPoint read GetPoint;
     property Point: IECPoint read GetPoint;
@@ -74,7 +74,8 @@ implementation
 
 
 { TX9ECPoint }
 { TX9ECPoint }
 
 
-constructor TX9ECPoint.Create(const c: IECCurve; encoding: TCryptoLibByteArray);
+constructor TX9ECPoint.Create(const c: IECCurve;
+  const encoding: TCryptoLibByteArray);
 begin
 begin
   inherited Create();
   inherited Create();
   Fc := c;
   Fc := c;

+ 15 - 13
CryptoLib/src/Crypto/ClpBufferedBlockCipher.pas

@@ -149,13 +149,13 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function ProcessByte(input: Byte; output: TCryptoLibByteArray;
+    function ProcessByte(input: Byte; const output: TCryptoLibByteArray;
       outOff: Int32): Int32; overload; override;
       outOff: Int32): Int32; overload; override;
 
 
     function ProcessByte(input: Byte): TCryptoLibByteArray; overload; override;
     function ProcessByte(input: Byte): TCryptoLibByteArray; overload; override;
 
 
-    function ProcessBytes(input: TCryptoLibByteArray; inOff, length: Int32)
-      : TCryptoLibByteArray; overload; override;
+    function ProcessBytes(const input: TCryptoLibByteArray;
+      inOff, length: Int32): TCryptoLibByteArray; overload; override;
 
 
     /// <summary>
     /// <summary>
     /// process an array of bytes, producing output if necessary.
     /// process an array of bytes, producing output if necessary.
@@ -183,11 +183,12 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function ProcessBytes(input: TCryptoLibByteArray; inOff, length: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32; overload; override;
+    function ProcessBytes(const input: TCryptoLibByteArray;
+      inOff, length: Int32; const output: TCryptoLibByteArray; outOff: Int32)
+      : Int32; overload; override;
 
 
     function DoFinal(): TCryptoLibByteArray; overload; override;
     function DoFinal(): TCryptoLibByteArray; overload; override;
-    function DoFinal(input: TCryptoLibByteArray; inOff, inLen: Int32)
+    function DoFinal(const input: TCryptoLibByteArray; inOff, inLen: Int32)
       : TCryptoLibByteArray; overload; override;
       : TCryptoLibByteArray; overload; override;
 
 
     /// <summary>
     /// <summary>
@@ -215,7 +216,7 @@ type
     /// <exception cref="EDataLengthCryptoLibException">
     /// <exception cref="EDataLengthCryptoLibException">
     /// if the input is not block size aligned.
     /// if the input is not block size aligned.
     /// </exception>
     /// </exception>
-    function DoFinal(output: TCryptoLibByteArray; outOff: Int32): Int32;
+    function DoFinal(const output: TCryptoLibByteArray; outOff: Int32): Int32;
       overload; override;
       overload; override;
 
 
     /// <summary>
     /// <summary>
@@ -251,7 +252,7 @@ begin
   Inherited Create();
   Inherited Create();
 end;
 end;
 
 
-function TBufferedBlockCipher.DoFinal(output: TCryptoLibByteArray;
+function TBufferedBlockCipher.DoFinal(const output: TCryptoLibByteArray;
   outOff: Int32): Int32;
   outOff: Int32): Int32;
 begin
 begin
   try
   try
@@ -274,7 +275,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TBufferedBlockCipher.DoFinal(input: TCryptoLibByteArray;
+function TBufferedBlockCipher.DoFinal(const input: TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
 var
 var
   &length, &pos: Int32;
   &length, &pos: Int32;
@@ -393,7 +394,7 @@ begin
 end;
 end;
 
 
 function TBufferedBlockCipher.ProcessByte(input: Byte;
 function TBufferedBlockCipher.ProcessByte(input: Byte;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+  const output: TCryptoLibByteArray; outOff: Int32): Int32;
 begin
 begin
 
 
   Fbuf[FbufOff] := input;
   Fbuf[FbufOff] := input;
@@ -443,8 +444,9 @@ begin
   result := outBytes;
   result := outBytes;
 end;
 end;
 
 
-function TBufferedBlockCipher.ProcessBytes(input: TCryptoLibByteArray;
-  inOff, length: Int32; output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TBufferedBlockCipher.ProcessBytes(const input: TCryptoLibByteArray;
+  inOff, length: Int32; const output: TCryptoLibByteArray;
+  outOff: Int32): Int32;
 var
 var
   blockSize, outLength, resultLen, gapLen: Int32;
   blockSize, outLength, resultLen, gapLen: Int32;
 begin
 begin
@@ -494,7 +496,7 @@ begin
   result := resultLen;
   result := resultLen;
 end;
 end;
 
 
-function TBufferedBlockCipher.ProcessBytes(input: TCryptoLibByteArray;
+function TBufferedBlockCipher.ProcessBytes(const input: TCryptoLibByteArray;
   inOff, length: Int32): TCryptoLibByteArray;
   inOff, length: Int32): TCryptoLibByteArray;
 var
 var
   outLength, &pos: Int32;
   outLength, &pos: Int32;

+ 30 - 27
CryptoLib/src/Crypto/ClpBufferedCipherBase.pas

@@ -60,38 +60,39 @@ type
     function ProcessByte(input: Byte): TCryptoLibByteArray; overload;
     function ProcessByte(input: Byte): TCryptoLibByteArray; overload;
       virtual; abstract;
       virtual; abstract;
 
 
-    function ProcessByte(input: Byte; output: TCryptoLibByteArray;
+    function ProcessByte(input: Byte; const output: TCryptoLibByteArray;
       outOff: Int32): Int32; overload; virtual;
       outOff: Int32): Int32; overload; virtual;
 
 
-    function ProcessBytes(input: TCryptoLibByteArray): TCryptoLibByteArray;
-      overload; virtual;
+    function ProcessBytes(const input: TCryptoLibByteArray)
+      : TCryptoLibByteArray; overload; virtual;
 
 
-    function ProcessBytes(input: TCryptoLibByteArray; inOff, length: Int32)
-      : TCryptoLibByteArray; overload; virtual; abstract;
+    function ProcessBytes(const input: TCryptoLibByteArray;
+      inOff, length: Int32): TCryptoLibByteArray; overload; virtual; abstract;
 
 
-    function ProcessBytes(input, output: TCryptoLibByteArray; outOff: Int32)
-      : Int32; overload; virtual;
+    function ProcessBytes(const input, output: TCryptoLibByteArray;
+      outOff: Int32): Int32; overload; virtual;
 
 
-    function ProcessBytes(input: TCryptoLibByteArray; inOff: Int32;
-      length: Int32; output: TCryptoLibByteArray; outOff: Int32): Int32;
+    function ProcessBytes(const input: TCryptoLibByteArray; inOff: Int32;
+      length: Int32; const output: TCryptoLibByteArray; outOff: Int32): Int32;
       overload; virtual;
       overload; virtual;
 
 
     function DoFinal(): TCryptoLibByteArray; overload; virtual; abstract;
     function DoFinal(): TCryptoLibByteArray; overload; virtual; abstract;
 
 
-    function DoFinal(input: TCryptoLibByteArray): TCryptoLibByteArray;
+    function DoFinal(const input: TCryptoLibByteArray): TCryptoLibByteArray;
       overload; virtual;
       overload; virtual;
 
 
-    function DoFinal(input: TCryptoLibByteArray; inOff, length: Int32)
+    function DoFinal(const input: TCryptoLibByteArray; inOff, length: Int32)
       : TCryptoLibByteArray; overload; virtual; abstract;
       : TCryptoLibByteArray; overload; virtual; abstract;
 
 
-    function DoFinal(output: TCryptoLibByteArray; outOff: Int32): Int32;
+    function DoFinal(const output: TCryptoLibByteArray; outOff: Int32): Int32;
       overload; virtual;
       overload; virtual;
 
 
-    function DoFinal(input, output: TCryptoLibByteArray; outOff: Int32): Int32;
-      overload; virtual;
+    function DoFinal(const input, output: TCryptoLibByteArray; outOff: Int32)
+      : Int32; overload; virtual;
 
 
-    function DoFinal(input: TCryptoLibByteArray; inOff, length: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32; overload; virtual;
+    function DoFinal(const input: TCryptoLibByteArray; inOff, length: Int32;
+      const output: TCryptoLibByteArray; outOff: Int32): Int32;
+      overload; virtual;
 
 
     procedure Reset(); virtual; abstract;
     procedure Reset(); virtual; abstract;
 
 
@@ -109,7 +110,7 @@ begin
   System.SetLength(FEmptyBuffer, 0);
   System.SetLength(FEmptyBuffer, 0);
 end;
 end;
 
 
-function TBufferedCipherBase.DoFinal(output: TCryptoLibByteArray;
+function TBufferedCipherBase.DoFinal(const output: TCryptoLibByteArray;
   outOff: Int32): Int32;
   outOff: Int32): Int32;
 var
 var
   outBytes: TCryptoLibByteArray;
   outBytes: TCryptoLibByteArray;
@@ -123,14 +124,15 @@ begin
   result := System.length(outBytes);
   result := System.length(outBytes);
 end;
 end;
 
 
-function TBufferedCipherBase.DoFinal(input: TCryptoLibByteArray)
+function TBufferedCipherBase.DoFinal(const input: TCryptoLibByteArray)
   : TCryptoLibByteArray;
   : TCryptoLibByteArray;
 begin
 begin
   result := DoFinal(input, 0, System.length(input));
   result := DoFinal(input, 0, System.length(input));
 end;
 end;
 
 
-function TBufferedCipherBase.DoFinal(input: TCryptoLibByteArray;
-  inOff, length: Int32; output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TBufferedCipherBase.DoFinal(const input: TCryptoLibByteArray;
+  inOff, length: Int32; const output: TCryptoLibByteArray;
+  outOff: Int32): Int32;
 var
 var
   len: Int32;
   len: Int32;
 begin
 begin
@@ -139,7 +141,7 @@ begin
   result := len;
   result := len;
 end;
 end;
 
 
-function TBufferedCipherBase.DoFinal(input, output: TCryptoLibByteArray;
+function TBufferedCipherBase.DoFinal(const input, output: TCryptoLibByteArray;
   outOff: Int32): Int32;
   outOff: Int32): Int32;
 begin
 begin
   result := DoFinal(input, 0, System.length(input), output, outOff);
   result := DoFinal(input, 0, System.length(input), output, outOff);
@@ -151,7 +153,7 @@ begin
 end;
 end;
 
 
 function TBufferedCipherBase.ProcessByte(input: Byte;
 function TBufferedCipherBase.ProcessByte(input: Byte;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+  const output: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   outBytes: TCryptoLibByteArray;
   outBytes: TCryptoLibByteArray;
 begin
 begin
@@ -169,14 +171,15 @@ begin
   result := System.length(outBytes);
   result := System.length(outBytes);
 end;
 end;
 
 
-function TBufferedCipherBase.ProcessBytes(input: TCryptoLibByteArray)
+function TBufferedCipherBase.ProcessBytes(const input: TCryptoLibByteArray)
   : TCryptoLibByteArray;
   : TCryptoLibByteArray;
 begin
 begin
   result := ProcessBytes(input, 0, System.length(input));
   result := ProcessBytes(input, 0, System.length(input));
 end;
 end;
 
 
-function TBufferedCipherBase.ProcessBytes(input: TCryptoLibByteArray;
-  inOff, length: Int32; output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TBufferedCipherBase.ProcessBytes(const input: TCryptoLibByteArray;
+  inOff, length: Int32; const output: TCryptoLibByteArray;
+  outOff: Int32): Int32;
 var
 var
   outBytes: TCryptoLibByteArray;
   outBytes: TCryptoLibByteArray;
 begin
 begin
@@ -194,8 +197,8 @@ begin
   result := System.length(outBytes);
   result := System.length(outBytes);
 end;
 end;
 
 
-function TBufferedCipherBase.ProcessBytes(input, output: TCryptoLibByteArray;
-  outOff: Int32): Int32;
+function TBufferedCipherBase.ProcessBytes(const input,
+  output: TCryptoLibByteArray; outOff: Int32): Int32;
 begin
 begin
   result := ProcessBytes(input, 0, System.length(input), output, outOff);
   result := ProcessBytes(input, 0, System.length(input), output, outOff);
 end;
 end;

+ 16 - 13
CryptoLib/src/Crypto/ClpIESCipher.pas

@@ -78,17 +78,19 @@ type
       const IESCipherParameters: IIESWithCipherParameters;
       const IESCipherParameters: IIESWithCipherParameters;
       const Random: ISecureRandom);
       const Random: ISecureRandom);
 
 
-    procedure ProcessBytes(input: TCryptoLibByteArray); overload;
-    procedure ProcessBytes(input: TCryptoLibByteArray;
+    procedure ProcessBytes(const input: TCryptoLibByteArray); overload;
+    procedure ProcessBytes(const input: TCryptoLibByteArray;
       inputOffset, inputLen: Int32); overload;
       inputOffset, inputLen: Int32); overload;
 
 
-    function DoFinal(input: TCryptoLibByteArray): TCryptoLibByteArray; overload;
-
-    function DoFinal(input: TCryptoLibByteArray; inputOffset, inputLen: Int32)
+    function DoFinal(const input: TCryptoLibByteArray)
       : TCryptoLibByteArray; overload;
       : TCryptoLibByteArray; overload;
 
 
-    function DoFinal(input: TCryptoLibByteArray; inputOffset, inputLen: Int32;
-      output: TCryptoLibByteArray; outputOffset: Int32): Int32; overload;
+    function DoFinal(const input: TCryptoLibByteArray;
+      inputOffset, inputLen: Int32): TCryptoLibByteArray; overload;
+
+    function DoFinal(const input: TCryptoLibByteArray;
+      inputOffset, inputLen: Int32; const output: TCryptoLibByteArray;
+      outputOffset: Int32): Int32; overload;
 
 
     constructor Create(const Engine: IIESEngine); overload;
     constructor Create(const Engine: IIESEngine); overload;
     constructor Create(const Engine: IIESEngine; ivLength: Int32); overload;
     constructor Create(const Engine: IIESEngine; ivLength: Int32); overload;
@@ -120,7 +122,7 @@ begin
   FBuffer := TMemoryStream.Create();
   FBuffer := TMemoryStream.Create();
 end;
 end;
 
 
-function TIESCipher.DoFinal(input: TCryptoLibByteArray;
+function TIESCipher.DoFinal(const input: TCryptoLibByteArray;
   inputOffset, inputLen: Int32): TCryptoLibByteArray;
   inputOffset, inputLen: Int32): TCryptoLibByteArray;
 var
 var
   &in: TCryptoLibByteArray;
   &in: TCryptoLibByteArray;
@@ -204,13 +206,14 @@ begin
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
-function TIESCipher.DoFinal(input: TCryptoLibByteArray): TCryptoLibByteArray;
+function TIESCipher.DoFinal(const input: TCryptoLibByteArray)
+  : TCryptoLibByteArray;
 begin
 begin
   Result := DoFinal(input, 0, System.length(input));
   Result := DoFinal(input, 0, System.length(input));
 end;
 end;
 
 
-function TIESCipher.DoFinal(input: TCryptoLibByteArray;
-  inputOffset, inputLen: Int32; output: TCryptoLibByteArray;
+function TIESCipher.DoFinal(const input: TCryptoLibByteArray;
+  inputOffset, inputLen: Int32; const output: TCryptoLibByteArray;
   outputOffset: Int32): Int32;
   outputOffset: Int32): Int32;
 var
 var
   buf: TCryptoLibByteArray;
   buf: TCryptoLibByteArray;
@@ -286,12 +289,12 @@ begin
   FBuffer.SetSize(0);
   FBuffer.SetSize(0);
 end;
 end;
 
 
-procedure TIESCipher.ProcessBytes(input: TCryptoLibByteArray);
+procedure TIESCipher.ProcessBytes(const input: TCryptoLibByteArray);
 begin
 begin
   ProcessBytes(input, 0, System.length(input));
   ProcessBytes(input, 0, System.length(input));
 end;
 end;
 
 
-procedure TIESCipher.ProcessBytes(input: TCryptoLibByteArray;
+procedure TIESCipher.ProcessBytes(const input: TCryptoLibByteArray;
   inputOffset, inputLen: Int32);
   inputOffset, inputLen: Int32);
 begin
 begin
   FBuffer.Write(input[inputOffset], inputLen);
   FBuffer.Write(input[inputOffset], inputLen);

+ 6 - 4
CryptoLib/src/Crypto/Digests/ClpDigest.pas

@@ -78,7 +78,7 @@ type
     /// <param name="len">
     /// <param name="len">
     /// the length of the data.
     /// the length of the data.
     /// </param>
     /// </param>
-    procedure BlockUpdate(input: TCryptoLibByteArray; inOff, len: Int32);
+    procedure BlockUpdate(const input: TCryptoLibByteArray; inOff, len: Int32);
 
 
     /// <summary>
     /// <summary>
     /// Close the digest, producing the final digest value. The doFinal call
     /// Close the digest, producing the final digest value. The doFinal call
@@ -90,7 +90,7 @@ type
     /// <param name="outOff">
     /// <param name="outOff">
     /// the offset into the out array the digest is to start at.
     /// the offset into the out array the digest is to start at.
     /// </param>
     /// </param>
-    function DoFinal(output: TCryptoLibByteArray; outOff: Int32)
+    function DoFinal(const output: TCryptoLibByteArray; outOff: Int32)
       : Int32; overload;
       : Int32; overload;
 
 
     /// <summary>
     /// <summary>
@@ -134,7 +134,8 @@ begin
   FHash.Initialize;
   FHash.Initialize;
 end;
 end;
 
 
-procedure TDigest.BlockUpdate(input: TCryptoLibByteArray; inOff, len: Int32);
+procedure TDigest.BlockUpdate(const input: TCryptoLibByteArray;
+  inOff, len: Int32);
 begin
 begin
   FHash.TransformBytes(input, inOff, len);
   FHash.TransformBytes(input, inOff, len);
 end;
 end;
@@ -146,7 +147,8 @@ begin
   FHash.Initialize;
   FHash.Initialize;
 end;
 end;
 
 
-function TDigest.DoFinal(output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TDigest.DoFinal(const output: TCryptoLibByteArray;
+  outOff: Int32): Int32;
 var
 var
   buf: TCryptoLibByteArray;
   buf: TCryptoLibByteArray;
 begin
 begin

+ 14 - 14
CryptoLib/src/Crypto/Engines/ClpAesEngine.pas

@@ -104,15 +104,15 @@ type
     /// This code is written assuming those are the only possible values
     /// This code is written assuming those are the only possible values
     /// </para>
     /// </para>
     /// </summary>
     /// </summary>
-    function GenerateWorkingKey(key: TCryptoLibByteArray;
+    function GenerateWorkingKey(const key: TCryptoLibByteArray;
       forEncryption: Boolean): TCryptoLibMatrixUInt32Array;
       forEncryption: Boolean): TCryptoLibMatrixUInt32Array;
 
 
-    procedure UnPackBlock(bytes: TCryptoLibByteArray; off: Int32); inline;
-    procedure PackBlock(bytes: TCryptoLibByteArray; off: Int32); inline;
+    procedure UnPackBlock(const bytes: TCryptoLibByteArray; off: Int32); inline;
+    procedure PackBlock(const bytes: TCryptoLibByteArray; off: Int32); inline;
 
 
-    procedure EncryptBlock(KW: TCryptoLibMatrixUInt32Array);
+    procedure EncryptBlock(const KW: TCryptoLibMatrixUInt32Array);
 
 
-    procedure DecryptBlock(KW: TCryptoLibMatrixUInt32Array);
+    procedure DecryptBlock(const KW: TCryptoLibMatrixUInt32Array);
 
 
   class var
   class var
     Fs, FSi, Frcon: TCryptoLibByteArray;
     Fs, FSi, Frcon: TCryptoLibByteArray;
@@ -150,8 +150,8 @@ type
     procedure Init(forEncryption: Boolean;
     procedure Init(forEncryption: Boolean;
       const parameters: ICipherParameters); virtual;
       const parameters: ICipherParameters); virtual;
 
 
-    function ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32; virtual;
+    function ProcessBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const output: TCryptoLibByteArray; outOff: Int32): Int32; virtual;
 
 
     procedure Reset(); virtual;
     procedure Reset(); virtual;
 
 
@@ -307,7 +307,7 @@ begin
     (UInt32(Fs[(x shr 24) and 255]) shl 24);
     (UInt32(Fs[(x shr 24) and 255]) shl 24);
 end;
 end;
 
 
-procedure TAesEngine.DecryptBlock(KW: TCryptoLibMatrixUInt32Array);
+procedure TAesEngine.DecryptBlock(const KW: TCryptoLibMatrixUInt32Array);
 var
 var
   lkw: TCryptoLibUInt32Array;
   lkw: TCryptoLibUInt32Array;
   lt0, lt1, lt2, lr0, lr1, lr2, lr3: UInt32;
   lt0, lt1, lt2, lr0, lr1, lr2, lr3: UInt32;
@@ -384,7 +384,7 @@ begin
 
 
 end;
 end;
 
 
-procedure TAesEngine.EncryptBlock(KW: TCryptoLibMatrixUInt32Array);
+procedure TAesEngine.EncryptBlock(const KW: TCryptoLibMatrixUInt32Array);
 var
 var
   lkw: TCryptoLibUInt32Array;
   lkw: TCryptoLibUInt32Array;
   lt0, lt1, lt2, lr0, lr1, lr2, lr3: UInt32;
   lt0, lt1, lt2, lr0, lr1, lr2, lr3: UInt32;
@@ -489,7 +489,7 @@ begin
   result := t0;
   result := t0;
 end;
 end;
 
 
-function TAesEngine.GenerateWorkingKey(key: TCryptoLibByteArray;
+function TAesEngine.GenerateWorkingKey(const key: TCryptoLibByteArray;
   forEncryption: Boolean): TCryptoLibMatrixUInt32Array;
   forEncryption: Boolean): TCryptoLibMatrixUInt32Array;
 var
 var
   keyLen, KC, i, j: Int32;
   keyLen, KC, i, j: Int32;
@@ -741,7 +741,7 @@ begin
 
 
 end;
 end;
 
 
-procedure TAesEngine.PackBlock(bytes: TCryptoLibByteArray; off: Int32);
+procedure TAesEngine.PackBlock(const bytes: TCryptoLibByteArray; off: Int32);
 begin
 begin
   TConverters.ReadUInt32AsBytesLE(FC0, bytes, off);
   TConverters.ReadUInt32AsBytesLE(FC0, bytes, off);
   TConverters.ReadUInt32AsBytesLE(FC1, bytes, off + 4);
   TConverters.ReadUInt32AsBytesLE(FC1, bytes, off + 4);
@@ -749,7 +749,7 @@ begin
   TConverters.ReadUInt32AsBytesLE(FC3, bytes, off + 12);
   TConverters.ReadUInt32AsBytesLE(FC3, bytes, off + 12);
 end;
 end;
 
 
-procedure TAesEngine.UnPackBlock(bytes: TCryptoLibByteArray; off: Int32);
+procedure TAesEngine.UnPackBlock(const bytes: TCryptoLibByteArray; off: Int32);
 begin
 begin
   FC0 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off);
   FC0 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off);
   FC1 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off + 4);
   FC1 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off + 4);
@@ -757,8 +757,8 @@ begin
   FC3 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off + 12);
   FC3 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off + 12);
 end;
 end;
 
 
-function TAesEngine.ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TAesEngine.ProcessBlock(const input: TCryptoLibByteArray; inOff: Int32;
+  const output: TCryptoLibByteArray; outOff: Int32): Int32;
 begin
 begin
   if (FWorkingKey = Nil) then
   if (FWorkingKey = Nil) then
   begin
   begin

+ 16 - 14
CryptoLib/src/Crypto/Engines/ClpAesLightEngine.pas

@@ -103,15 +103,15 @@ type
     /// This code is written assuming those are the only possible values
     /// This code is written assuming those are the only possible values
     /// </para>
     /// </para>
     /// </summary>
     /// </summary>
-    function GenerateWorkingKey(key: TCryptoLibByteArray;
+    function GenerateWorkingKey(const key: TCryptoLibByteArray;
       forEncryption: Boolean): TCryptoLibMatrixUInt32Array;
       forEncryption: Boolean): TCryptoLibMatrixUInt32Array;
 
 
-    procedure UnPackBlock(bytes: TCryptoLibByteArray; off: Int32); inline;
-    procedure PackBlock(bytes: TCryptoLibByteArray; off: Int32); inline;
+    procedure UnPackBlock(const bytes: TCryptoLibByteArray; off: Int32); inline;
+    procedure PackBlock(const bytes: TCryptoLibByteArray; off: Int32); inline;
 
 
-    procedure EncryptBlock(KW: TCryptoLibMatrixUInt32Array);
+    procedure EncryptBlock(const KW: TCryptoLibMatrixUInt32Array);
 
 
-    procedure DecryptBlock(KW: TCryptoLibMatrixUInt32Array);
+    procedure DecryptBlock(const KW: TCryptoLibMatrixUInt32Array);
 
 
     class var
     class var
 
 
@@ -149,8 +149,8 @@ type
     procedure Init(forEncryption: Boolean;
     procedure Init(forEncryption: Boolean;
       const parameters: ICipherParameters); virtual;
       const parameters: ICipherParameters); virtual;
 
 
-    function ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32; virtual;
+    function ProcessBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const output: TCryptoLibByteArray; outOff: Int32): Int32; virtual;
 
 
     procedure Reset(); virtual;
     procedure Reset(); virtual;
 
 
@@ -263,7 +263,7 @@ begin
   result := t0;
   result := t0;
 end;
 end;
 
 
-procedure TAesLightEngine.EncryptBlock(KW: TCryptoLibMatrixUInt32Array);
+procedure TAesLightEngine.EncryptBlock(const KW: TCryptoLibMatrixUInt32Array);
 var
 var
   lkw: TCryptoLibUInt32Array;
   lkw: TCryptoLibUInt32Array;
   lt0, lt1, lt2, lr0, lr1, lr2, lr3: UInt32;
   lt0, lt1, lt2, lr0, lr1, lr2, lr3: UInt32;
@@ -341,7 +341,7 @@ begin
     xor ((UInt32(Fs[(lr2 shr 24) and 255])) shl 24) xor lkw[3];
     xor ((UInt32(Fs[(lr2 shr 24) and 255])) shl 24) xor lkw[3];
 end;
 end;
 
 
-procedure TAesLightEngine.DecryptBlock(KW: TCryptoLibMatrixUInt32Array);
+procedure TAesLightEngine.DecryptBlock(const KW: TCryptoLibMatrixUInt32Array);
 var
 var
   lkw: TCryptoLibUInt32Array;
   lkw: TCryptoLibUInt32Array;
   lt0, lt1, lt2, lr0, lr1, lr2, lr3: UInt32;
   lt0, lt1, lt2, lr0, lr1, lr2, lr3: UInt32;
@@ -430,7 +430,7 @@ begin
     xor ((UInt32(FSi[(lr0 shr 24) and 255])) shl 24) xor lkw[3];
     xor ((UInt32(FSi[(lr0 shr 24) and 255])) shl 24) xor lkw[3];
 end;
 end;
 
 
-function TAesLightEngine.GenerateWorkingKey(key: TCryptoLibByteArray;
+function TAesLightEngine.GenerateWorkingKey(const key: TCryptoLibByteArray;
   forEncryption: Boolean): TCryptoLibMatrixUInt32Array;
   forEncryption: Boolean): TCryptoLibMatrixUInt32Array;
 var
 var
   keyLen, KC, i, j: Int32;
   keyLen, KC, i, j: Int32;
@@ -673,7 +673,8 @@ begin
   FforEncryption := forEncryption;
   FforEncryption := forEncryption;
 end;
 end;
 
 
-procedure TAesLightEngine.PackBlock(bytes: TCryptoLibByteArray; off: Int32);
+procedure TAesLightEngine.PackBlock(const bytes: TCryptoLibByteArray;
+  off: Int32);
 begin
 begin
   TConverters.ReadUInt32AsBytesLE(FC0, bytes, off);
   TConverters.ReadUInt32AsBytesLE(FC0, bytes, off);
   TConverters.ReadUInt32AsBytesLE(FC1, bytes, off + 4);
   TConverters.ReadUInt32AsBytesLE(FC1, bytes, off + 4);
@@ -681,7 +682,8 @@ begin
   TConverters.ReadUInt32AsBytesLE(FC3, bytes, off + 12);
   TConverters.ReadUInt32AsBytesLE(FC3, bytes, off + 12);
 end;
 end;
 
 
-procedure TAesLightEngine.UnPackBlock(bytes: TCryptoLibByteArray; off: Int32);
+procedure TAesLightEngine.UnPackBlock(const bytes: TCryptoLibByteArray;
+  off: Int32);
 begin
 begin
   FC0 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off);
   FC0 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off);
   FC1 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off + 4);
   FC1 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off + 4);
@@ -689,8 +691,8 @@ begin
   FC3 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off + 12);
   FC3 := TConverters.ReadBytesAsUInt32LE(PByte(bytes), off + 12);
 end;
 end;
 
 
-function TAesLightEngine.ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TAesLightEngine.ProcessBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const output: TCryptoLibByteArray; outOff: Int32): Int32;
 begin
 begin
   if (FWorkingKey = Nil) then
   if (FWorkingKey = Nil) then
   begin
   begin

+ 17 - 15
CryptoLib/src/Crypto/Engines/ClpIESEngine.pas

@@ -67,7 +67,8 @@ type
   strict private
   strict private
 
 
     // as described in Shroup's paper( ch 10, pg 20) and P1363a
     // as described in Shroup's paper( ch 10, pg 20) and P1363a
-    function GetLengthTag(p2: TCryptoLibByteArray): TCryptoLibByteArray; inline;
+    function GetLengthTag(const p2: TCryptoLibByteArray)
+      : TCryptoLibByteArray; inline;
 
 
     procedure ExtractParams(const params: ICipherParameters); inline;
     procedure ExtractParams(const params: ICipherParameters); inline;
 
 
@@ -87,11 +88,11 @@ type
 
 
     function GetCipher: IBufferedBlockCipher; inline;
     function GetCipher: IBufferedBlockCipher; inline;
     function GetMac: IMac; inline;
     function GetMac: IMac; inline;
-    function EncryptBlock(&in: TCryptoLibByteArray; inOff, inLen: Int32)
+    function EncryptBlock(const &in: TCryptoLibByteArray; inOff, inLen: Int32)
       : TCryptoLibByteArray; virtual;
       : TCryptoLibByteArray; virtual;
 
 
-    function DecryptBlock(in_enc: TCryptoLibByteArray; inOff, inLen: Int32)
-      : TCryptoLibByteArray; virtual;
+    function DecryptBlock(const in_enc: TCryptoLibByteArray;
+      inOff, inLen: Int32): TCryptoLibByteArray; virtual;
 
 
   public
   public
 
 
@@ -148,8 +149,8 @@ type
     /// encoding and derivation parameters, may be wrapped to include an IV
     /// encoding and derivation parameters, may be wrapped to include an IV
     /// for an underlying block cipher.
     /// for an underlying block cipher.
     /// </param>
     /// </param>
-    procedure Init(forEncryption: Boolean;
-      privParam, pubParam, params: ICipherParameters); overload;
+    procedure Init(forEncryption: Boolean; const privParam, pubParam,
+      params: ICipherParameters); overload;
 
 
     /// <summary>
     /// <summary>
     /// Initialise the encryptor.
     /// Initialise the encryptor.
@@ -185,7 +186,7 @@ type
       const params: ICipherParameters;
       const params: ICipherParameters;
       const publicKeyParser: IKeyParser); overload;
       const publicKeyParser: IKeyParser); overload;
 
 
-    function ProcessBlock(&in: TCryptoLibByteArray; inOff, inLen: Int32)
+    function ProcessBlock(const &in: TCryptoLibByteArray; inOff, inLen: Int32)
       : TCryptoLibByteArray; virtual;
       : TCryptoLibByteArray; virtual;
 
 
     property cipher: IBufferedBlockCipher read GetCipher;
     property cipher: IBufferedBlockCipher read GetCipher;
@@ -197,7 +198,8 @@ implementation
 
 
 { TIESEngine }
 { TIESEngine }
 
 
-function TIESEngine.GetLengthTag(p2: TCryptoLibByteArray): TCryptoLibByteArray;
+function TIESEngine.GetLengthTag(const p2: TCryptoLibByteArray)
+  : TCryptoLibByteArray;
 begin
 begin
   System.SetLength(Result, 8);
   System.SetLength(Result, 8);
   if (p2 <> Nil) then
   if (p2 <> Nil) then
@@ -229,7 +231,7 @@ begin
   Fcipher := cipher;
   Fcipher := cipher;
 end;
 end;
 
 
-function TIESEngine.DecryptBlock(in_enc: TCryptoLibByteArray;
+function TIESEngine.DecryptBlock(const in_enc: TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
 var
 var
   M, K, K1, K2, p2, L2, T1, T2: TCryptoLibByteArray;
   M, K, K1, K2, p2, L2, T1, T2: TCryptoLibByteArray;
@@ -359,8 +361,8 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TIESEngine.EncryptBlock(&in: TCryptoLibByteArray; inOff, inLen: Int32)
-  : TCryptoLibByteArray;
+function TIESEngine.EncryptBlock(const &in: TCryptoLibByteArray;
+  inOff, inLen: Int32): TCryptoLibByteArray;
 var
 var
   C, K, K1, K2, p2, L2, T: TCryptoLibByteArray;
   C, K, K1, K2, p2, L2, T: TCryptoLibByteArray;
   len, i: Int32;
   len, i: Int32;
@@ -509,7 +511,7 @@ begin
 end;
 end;
 
 
 procedure TIESEngine.Init(forEncryption: Boolean;
 procedure TIESEngine.Init(forEncryption: Boolean;
-  privParam, pubParam, params: ICipherParameters);
+  const privParam, pubParam, params: ICipherParameters);
 begin
 begin
   FforEncryption := forEncryption;
   FforEncryption := forEncryption;
   FprivParam := privParam;
   FprivParam := privParam;
@@ -518,8 +520,8 @@ begin
   ExtractParams(params);
   ExtractParams(params);
 end;
 end;
 
 
-function TIESEngine.ProcessBlock(&in: TCryptoLibByteArray; inOff, inLen: Int32)
-  : TCryptoLibByteArray;
+function TIESEngine.ProcessBlock(const &in: TCryptoLibByteArray;
+  inOff, inLen: Int32): TCryptoLibByteArray;
 var
 var
   ephKeyPair: IEphemeralKeyPair;
   ephKeyPair: IEphemeralKeyPair;
   bIn: TBytesStream;
   bIn: TBytesStream;
@@ -549,7 +551,7 @@ begin
         bIn.Position := 0;
         bIn.Position := 0;
 
 
         try
         try
-          FpubParam := FkeyParser.readKey(bIn);
+          FpubParam := FkeyParser.ReadKey(bIn);
         except
         except
           on e: EIOCryptoLibException do
           on e: EIOCryptoLibException do
           begin
           begin

+ 10 - 9
CryptoLib/src/Crypto/Engines/ClpPascalCoinIESEngine.pas

@@ -79,15 +79,15 @@ type
 
 
   strict protected
   strict protected
 
 
-    function EncryptBlock(&in: TCryptoLibByteArray; inOff, inLen: Int32)
+    function EncryptBlock(const &in: TCryptoLibByteArray; inOff, inLen: Int32)
       : TCryptoLibByteArray; override;
       : TCryptoLibByteArray; override;
 
 
-    function DecryptBlock(in_enc: TCryptoLibByteArray; inOff, inLen: Int32)
-      : TCryptoLibByteArray; override;
+    function DecryptBlock(const in_enc: TCryptoLibByteArray;
+      inOff, inLen: Int32): TCryptoLibByteArray; override;
 
 
   public
   public
 
 
-    function ProcessBlock(&in: TCryptoLibByteArray; inOff, inLen: Int32)
+    function ProcessBlock(const &in: TCryptoLibByteArray; inOff, inLen: Int32)
       : TCryptoLibByteArray; override;
       : TCryptoLibByteArray; override;
 
 
   end;
   end;
@@ -96,7 +96,7 @@ implementation
 
 
 { TPascalCoinIESEngine }
 { TPascalCoinIESEngine }
 
 
-function TPascalCoinIESEngine.DecryptBlock(in_enc: TCryptoLibByteArray;
+function TPascalCoinIESEngine.DecryptBlock(const in_enc: TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
 var
 var
   K, K1, K2, T1, T2: TCryptoLibByteArray;
   K, K1, K2, T1, T2: TCryptoLibByteArray;
@@ -162,7 +162,7 @@ begin
   Exit;
   Exit;
 end;
 end;
 
 
-function TPascalCoinIESEngine.EncryptBlock(&in: TCryptoLibByteArray;
+function TPascalCoinIESEngine.EncryptBlock(const &in: TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
 var
 var
   C, K, K1, K2, T, tempHolder: TCryptoLibByteArray;
   C, K, K1, K2, T, tempHolder: TCryptoLibByteArray;
@@ -263,7 +263,7 @@ begin
 
 
 end;
 end;
 
 
-function TPascalCoinIESEngine.ProcessBlock(&in: TCryptoLibByteArray;
+function TPascalCoinIESEngine.ProcessBlock(const &in: TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
   inOff, inLen: Int32): TCryptoLibByteArray;
 var
 var
   ephKeyPair: IEphemeralKeyPair;
   ephKeyPair: IEphemeralKeyPair;
@@ -291,10 +291,11 @@ begin
       bIn := TBytesStream.Create(System.Copy(&in, inOff, inLen));
       bIn := TBytesStream.Create(System.Copy(&in, inOff, inLen));
 
 
       try
       try
-        bIn.Position := SECURE_HEAD_SIZE; // for compatiblity purposes
+        bIn.Position := SECURE_HEAD_SIZE;
+        // for existing PascalCoin compatiblity purposes
 
 
         try
         try
-          FpubParam := FkeyParser.readKey(bIn);
+          FpubParam := FkeyParser.ReadKey(bIn);
         except
         except
           on e: EIOCryptoLibException do
           on e: EIOCryptoLibException do
           begin
           begin

+ 8 - 7
CryptoLib/src/Crypto/Generators/ClpDsaParametersGenerator.pas

@@ -79,10 +79,11 @@ type
 
 
     class function GetDefaultN(L: Int32): Int32; static; inline;
     class function GetDefaultN(L: Int32): Int32; static; inline;
     class function GetMinimumIterations(L: Int32): Int32; static; inline;
     class function GetMinimumIterations(L: Int32): Int32; static; inline;
-    class procedure Hash(const d: IDigest; input, output: TCryptoLibByteArray;
-      outputPos: Int32); static; inline;
+    class procedure Hash(const d: IDigest;
+      const input, output: TCryptoLibByteArray; outputPos: Int32);
+      static; inline;
 
 
-    class procedure Inc(buf: TCryptoLibByteArray); static; inline;
+    class procedure Inc(const buf: TCryptoLibByteArray); static; inline;
 
 
     class function CalculateGenerator_FIPS186_2(const p, q: TBigInteger;
     class function CalculateGenerator_FIPS186_2(const p, q: TBigInteger;
       const r: ISecureRandom): TBigInteger; static; inline;
       const r: ISecureRandom): TBigInteger; static; inline;
@@ -91,7 +92,7 @@ type
       q: TBigInteger; const r: ISecureRandom): TBigInteger; static; inline;
       q: TBigInteger; const r: ISecureRandom): TBigInteger; static; inline;
 
 
     class function CalculateGenerator_FIPS186_3_Verifiable(const d: IDigest;
     class function CalculateGenerator_FIPS186_3_Verifiable(const d: IDigest;
-      const p, q: TBigInteger; seed: TCryptoLibByteArray; index: Int32)
+      const p, q: TBigInteger; const seed: TCryptoLibByteArray; index: Int32)
       : TBigInteger; static; inline;
       : TBigInteger; static; inline;
 
 
   public
   public
@@ -206,13 +207,13 @@ begin
 end;
 end;
 
 
 class procedure TDsaParametersGenerator.Hash(const d: IDigest;
 class procedure TDsaParametersGenerator.Hash(const d: IDigest;
-  input, output: TCryptoLibByteArray; outputPos: Int32);
+  const input, output: TCryptoLibByteArray; outputPos: Int32);
 begin
 begin
   d.BlockUpdate(input, 0, System.Length(input));
   d.BlockUpdate(input, 0, System.Length(input));
   d.DoFinal(output, outputPos);
   d.DoFinal(output, outputPos);
 end;
 end;
 
 
-class procedure TDsaParametersGenerator.Inc(buf: TCryptoLibByteArray);
+class procedure TDsaParametersGenerator.Inc(const buf: TCryptoLibByteArray);
 var
 var
   i: Int32;
   i: Int32;
   b: Byte;
   b: Byte;
@@ -264,7 +265,7 @@ begin
 end;
 end;
 
 
 class function TDsaParametersGenerator.CalculateGenerator_FIPS186_3_Verifiable
 class function TDsaParametersGenerator.CalculateGenerator_FIPS186_3_Verifiable
-  (const d: IDigest; const p, q: TBigInteger; seed: TCryptoLibByteArray;
+  (const d: IDigest; const p, q: TBigInteger; const seed: TCryptoLibByteArray;
   index: Int32): TBigInteger;
   index: Int32): TBigInteger;
 var
 var
   e, W, g: TBigInteger;
   e, W, g: TBigInteger;

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

@@ -74,7 +74,7 @@ type
     /// <returns>
     /// <returns>
     /// the PRK as KeyParameter
     /// the PRK as KeyParameter
     /// </returns>
     /// </returns>
-    function Extract(salt, ikm: TCryptoLibByteArray): IKeyParameter;
+    function Extract(const salt, ikm: TCryptoLibByteArray): IKeyParameter;
 
 
     /// <summary>
     /// <summary>
     /// Performs the expand part of the key derivation function, using
     /// Performs the expand part of the key derivation function, using
@@ -138,7 +138,7 @@ begin
   FhMacHash.DoFinal(FcurrentT, 0);
   FhMacHash.DoFinal(FcurrentT, 0);
 end;
 end;
 
 
-function THkdfBytesGenerator.Extract(salt, ikm: TCryptoLibByteArray)
+function THkdfBytesGenerator.Extract(const salt, ikm: TCryptoLibByteArray)
   : IKeyParameter;
   : IKeyParameter;
 var
 var
   temp, prk: TCryptoLibByteArray;
   temp, prk: TCryptoLibByteArray;

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

@@ -62,7 +62,7 @@ type
 
 
   public
   public
 
 
-    procedure Init(password, salt: TCryptoLibByteArray;
+    procedure Init(const password, salt: TCryptoLibByteArray;
       iterationCount: Int32); virtual;
       iterationCount: Int32); virtual;
 
 
     /// <value>
     /// <value>
@@ -148,8 +148,8 @@ begin
   result := System.Copy(FmSalt);
   result := System.Copy(FmSalt);
 end;
 end;
 
 
-procedure TPbeParametersGenerator.Init(password, salt: TCryptoLibByteArray;
-  iterationCount: Int32);
+procedure TPbeParametersGenerator.Init(const password,
+  salt: TCryptoLibByteArray; iterationCount: Int32);
 begin
 begin
 
 
   if (password = Nil) then
   if (password = Nil) then

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

@@ -66,7 +66,7 @@ type
     /// </param>
     /// </param>
     constructor Create(const digest: IDigest);
     constructor Create(const digest: IDigest);
 
 
-    procedure Init(password, salt: TCryptoLibByteArray;
+    procedure Init(const password, salt: TCryptoLibByteArray;
       iterationCount: Int32); override;
       iterationCount: Int32); override;
 
 
     /// <summary>
     /// <summary>
@@ -185,8 +185,8 @@ begin
   result := Fdigest;
   result := Fdigest;
 end;
 end;
 
 
-procedure TPkcs5S2ParametersGenerator.Init(password, salt: TCryptoLibByteArray;
-  iterationCount: Int32);
+procedure TPkcs5S2ParametersGenerator.Init(const password,
+  salt: TCryptoLibByteArray; iterationCount: Int32);
 begin
 begin
   inherited Init(password, salt, iterationCount);
   inherited Init(password, salt, iterationCount);
   FPBKDF2_HMAC := TKDF.TPBKDF2_HMAC.CreatePBKDF2_HMAC
   FPBKDF2_HMAC := TKDF.TPBKDF2_HMAC.CreatePBKDF2_HMAC

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

@@ -61,9 +61,9 @@ type
     function GetMacSize: Int32; inline;
     function GetMacSize: Int32; inline;
 
 
     procedure Update(input: Byte);
     procedure Update(input: Byte);
-    procedure BlockUpdate(input: TCryptoLibByteArray; inOff, len: Int32);
+    procedure BlockUpdate(const input: TCryptoLibByteArray; inOff, len: Int32);
     procedure Init(const parameters: ICipherParameters);
     procedure Init(const parameters: ICipherParameters);
-    function DoFinal(output: TCryptoLibByteArray; outOff: Int32)
+    function DoFinal(const output: TCryptoLibByteArray; outOff: Int32)
       : Int32; overload;
       : Int32; overload;
     function DoFinal: TCryptoLibByteArray; overload;
     function DoFinal: TCryptoLibByteArray; overload;
 
 
@@ -85,7 +85,8 @@ begin
   result := FHMAC.HashSize;
   result := FHMAC.HashSize;
 end;
 end;
 
 
-procedure THMac.BlockUpdate(input: TCryptoLibByteArray; inOff, len: Int32);
+procedure THMac.BlockUpdate(const input: TCryptoLibByteArray;
+  inOff, len: Int32);
 begin
 begin
   FHMAC.TransformBytes(input, inOff, len);
   FHMAC.TransformBytes(input, inOff, len);
 end;
 end;
@@ -97,7 +98,7 @@ begin
   FHMAC := THashFactory.THMac.CreateHMAC(FDigest.GetUnderlyingIHash);
   FHMAC := THashFactory.THMac.CreateHMAC(FDigest.GetUnderlyingIHash);
 end;
 end;
 
 
-function THMac.DoFinal(output: TCryptoLibByteArray; outOff: Int32): Int32;
+function THMac.DoFinal(const output: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   buf: TCryptoLibByteArray;
   buf: TCryptoLibByteArray;
 begin
 begin

+ 12 - 12
CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas

@@ -85,8 +85,8 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function EncryptBlock(input: TCryptoLibByteArray; inOff: Int32;
-      outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
+    function EncryptBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// Do the appropriate chaining step for CBC mode decryption.
     /// Do the appropriate chaining step for CBC mode decryption.
@@ -112,8 +112,8 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function DecryptBlock(input: TCryptoLibByteArray; inOff: Int32;
-      outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
+    function DecryptBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
   public
   public
 
 
@@ -183,8 +183,8 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32;
+    function ProcessBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const output: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// reset the chaining vector back to the IV and reset the underlying
     /// reset the chaining vector back to the IV and reset the underlying
@@ -219,8 +219,8 @@ begin
   System.SetLength(FcbcNextV, FblockSize);
   System.SetLength(FcbcNextV, FblockSize);
 end;
 end;
 
 
-function TCbcBlockCipher.DecryptBlock(input: TCryptoLibByteArray; inOff: Int32;
-  outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
+function TCbcBlockCipher.DecryptBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   length, I: Int32;
   length, I: Int32;
   tmp: TCryptoLibByteArray;
   tmp: TCryptoLibByteArray;
@@ -252,8 +252,8 @@ begin
   result := &length;
   result := &length;
 end;
 end;
 
 
-function TCbcBlockCipher.EncryptBlock(input: TCryptoLibByteArray; inOff: Int32;
-  outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
+function TCbcBlockCipher.EncryptBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   I, &length: Int32;
   I, &length: Int32;
 begin
 begin
@@ -349,8 +349,8 @@ begin
 
 
 end;
 end;
 
 
-function TCbcBlockCipher.ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TCbcBlockCipher.ProcessBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const output: TCryptoLibByteArray; outOff: Int32): Int32;
 begin
 begin
   if Fencrypting then
   if Fencrypting then
   begin
   begin

+ 12 - 12
CryptoLib/src/Crypto/Modes/ClpCfbBlockCipher.pas

@@ -83,8 +83,8 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function EncryptBlock(input: TCryptoLibByteArray; inOff: Int32;
-      outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
+    function EncryptBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// Do the appropriate chaining step for CBC mode decryption.
     /// Do the appropriate chaining step for CBC mode decryption.
@@ -110,8 +110,8 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function DecryptBlock(input: TCryptoLibByteArray; inOff: Int32;
-      outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
+    function DecryptBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
   public
   public
 
 
@@ -182,8 +182,8 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32;
+    function ProcessBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const output: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// reset the chaining vector back to the IV and reset the underlying
     /// reset the chaining vector back to the IV and reset the underlying
@@ -219,8 +219,8 @@ begin
   System.SetLength(FcfbOutV, Fcipher.GetBlockSize);
   System.SetLength(FcfbOutV, Fcipher.GetBlockSize);
 end;
 end;
 
 
-function TCfbBlockCipher.DecryptBlock(input: TCryptoLibByteArray; inOff: Int32;
-  outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
+function TCfbBlockCipher.DecryptBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   I: Int32;
   I: Int32;
 begin
 begin
@@ -255,8 +255,8 @@ begin
   result := FblockSize;
   result := FblockSize;
 end;
 end;
 
 
-function TCfbBlockCipher.EncryptBlock(input: TCryptoLibByteArray; inOff: Int32;
-  outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
+function TCfbBlockCipher.EncryptBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const outBytes: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   I: Int32;
   I: Int32;
 begin
 begin
@@ -351,8 +351,8 @@ begin
 
 
 end;
 end;
 
 
-function TCfbBlockCipher.ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TCfbBlockCipher.ProcessBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const output: TCryptoLibByteArray; outOff: Int32): Int32;
 begin
 begin
   if Fencrypting then
   if Fencrypting then
   begin
   begin

+ 4 - 4
CryptoLib/src/Crypto/Modes/ClpOfbBlockCipher.pas

@@ -129,8 +129,8 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32;
+    function ProcessBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const output: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// reset the chaining vector back to the IV and reset the underlying
     /// reset the chaining vector back to the IV and reset the underlying
@@ -240,8 +240,8 @@ begin
 
 
 end;
 end;
 
 
-function TOfbBlockCipher.ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TOfbBlockCipher.ProcessBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const output: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   I: Int32;
   I: Int32;
 begin
 begin

+ 4 - 4
CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas

@@ -132,8 +132,8 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32;
+    function ProcessBlock(const input: TCryptoLibByteArray; inOff: Int32;
+      const output: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// reset the chaining vector back to the IV and reset the underlying
     /// reset the chaining vector back to the IV and reset the underlying
@@ -246,8 +246,8 @@ begin
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
-function TSicBlockCipher.ProcessBlock(input: TCryptoLibByteArray; inOff: Int32;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TSicBlockCipher.ProcessBlock(const input: TCryptoLibByteArray;
+  inOff: Int32; const output: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   I, J: Int32;
   I, J: Int32;
 begin
 begin

+ 4 - 4
CryptoLib/src/Crypto/Paddings/ClpISO10126d2Padding.pas

@@ -75,7 +75,7 @@ type
     /// <returns>
     /// <returns>
     /// returns number of bytes added
     /// returns number of bytes added
     /// </returns>
     /// </returns>
-    function AddPadding(input: TCryptoLibByteArray; inOff: Int32): Int32;
+    function AddPadding(const input: TCryptoLibByteArray; inOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// return the number of pad bytes present in the block.
     /// return the number of pad bytes present in the block.
@@ -89,7 +89,7 @@ type
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// if the padding is badly formed or invalid.
     /// if the padding is badly formed or invalid.
     /// </exception>
     /// </exception>
-    function PadCount(input: TCryptoLibByteArray): Int32;
+    function PadCount(const input: TCryptoLibByteArray): Int32;
 
 
   end;
   end;
 
 
@@ -97,7 +97,7 @@ implementation
 
 
 { TISO10126d2Padding }
 { TISO10126d2Padding }
 
 
-function TISO10126d2Padding.AddPadding(input: TCryptoLibByteArray;
+function TISO10126d2Padding.AddPadding(const input: TCryptoLibByteArray;
   inOff: Int32): Int32;
   inOff: Int32): Int32;
 var
 var
   code: Byte;
   code: Byte;
@@ -132,7 +132,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TISO10126d2Padding.PadCount(input: TCryptoLibByteArray): Int32;
+function TISO10126d2Padding.PadCount(const input: TCryptoLibByteArray): Int32;
 var
 var
   count: Int32;
   count: Int32;
 begin
 begin

+ 4 - 4
CryptoLib/src/Crypto/Paddings/ClpISO7816d4Padding.pas

@@ -72,7 +72,7 @@ type
     /// <returns>
     /// <returns>
     /// returns number of bytes added
     /// returns number of bytes added
     /// </returns>
     /// </returns>
-    function AddPadding(input: TCryptoLibByteArray; inOff: Int32): Int32;
+    function AddPadding(const input: TCryptoLibByteArray; inOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// return the number of pad bytes present in the block.
     /// return the number of pad bytes present in the block.
@@ -86,7 +86,7 @@ type
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// if the padding is badly formed or invalid.
     /// if the padding is badly formed or invalid.
     /// </exception>
     /// </exception>
-    function PadCount(input: TCryptoLibByteArray): Int32;
+    function PadCount(const input: TCryptoLibByteArray): Int32;
 
 
   end;
   end;
 
 
@@ -94,7 +94,7 @@ implementation
 
 
 { TISO7816d4Padding }
 { TISO7816d4Padding }
 
 
-function TISO7816d4Padding.AddPadding(input: TCryptoLibByteArray;
+function TISO7816d4Padding.AddPadding(const input: TCryptoLibByteArray;
   inOff: Int32): Int32;
   inOff: Int32): Int32;
 var
 var
   added: Int32;
   added: Int32;
@@ -126,7 +126,7 @@ begin
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
-function TISO7816d4Padding.PadCount(input: TCryptoLibByteArray): Int32;
+function TISO7816d4Padding.PadCount(const input: TCryptoLibByteArray): Int32;
 var
 var
   count: Int32;
   count: Int32;
 begin
 begin

+ 10 - 8
CryptoLib/src/Crypto/Paddings/ClpPaddedBufferedBlockCipher.pas

@@ -146,7 +146,7 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function ProcessByte(input: Byte; output: TCryptoLibByteArray;
+    function ProcessByte(input: Byte; const output: TCryptoLibByteArray;
       outOff: Int32): Int32; override;
       outOff: Int32): Int32; override;
 
 
     /// <summary>
     /// <summary>
@@ -176,8 +176,9 @@ type
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// <exception cref="EInvalidOperationCryptoLibException">
     /// if the cipher isn't initialised.
     /// if the cipher isn't initialised.
     /// </exception>
     /// </exception>
-    function ProcessBytes(input: TCryptoLibByteArray; inOff, length: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32; override;
+    function ProcessBytes(const input: TCryptoLibByteArray;
+      inOff, length: Int32; const output: TCryptoLibByteArray; outOff: Int32)
+      : Int32; override;
 
 
     /// <summary>
     /// <summary>
     /// Process the last block in the buffer. If the buffer is currently full
     /// Process the last block in the buffer. If the buffer is currently full
@@ -203,7 +204,7 @@ type
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// if padding is expected and not found.
     /// if padding is expected and not found.
     /// </exception>
     /// </exception>
-    function DoFinal(output: TCryptoLibByteArray; outOff: Int32)
+    function DoFinal(const output: TCryptoLibByteArray; outOff: Int32)
       : Int32; override;
       : Int32; override;
 
 
   end;
   end;
@@ -228,7 +229,7 @@ begin
   Create(cipher, TPkcs7Padding.Create() as IPkcs7Padding);
   Create(cipher, TPkcs7Padding.Create() as IPkcs7Padding);
 end;
 end;
 
 
-function TPaddedBufferedBlockCipher.DoFinal(output: TCryptoLibByteArray;
+function TPaddedBufferedBlockCipher.DoFinal(const output: TCryptoLibByteArray;
   outOff: Int32): Int32;
   outOff: Int32): Int32;
 var
 var
   blockSize, resultLen: Int32;
   blockSize, resultLen: Int32;
@@ -349,7 +350,7 @@ begin
 end;
 end;
 
 
 function TPaddedBufferedBlockCipher.ProcessByte(input: Byte;
 function TPaddedBufferedBlockCipher.ProcessByte(input: Byte;
-  output: TCryptoLibByteArray; outOff: Int32): Int32;
+  const output: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   resultLen: Int32;
   resultLen: Int32;
 begin
 begin
@@ -367,8 +368,9 @@ begin
   result := resultLen;
   result := resultLen;
 end;
 end;
 
 
-function TPaddedBufferedBlockCipher.ProcessBytes(input: TCryptoLibByteArray;
-  inOff, length: Int32; output: TCryptoLibByteArray; outOff: Int32): Int32;
+function TPaddedBufferedBlockCipher.ProcessBytes(const input
+  : TCryptoLibByteArray; inOff, length: Int32;
+  const output: TCryptoLibByteArray; outOff: Int32): Int32;
 var
 var
   blockSize, outLength, resultLen, gapLen: Int32;
   blockSize, outLength, resultLen, gapLen: Int32;
 begin
 begin

+ 4 - 4
CryptoLib/src/Crypto/Paddings/ClpPkcs7Padding.pas

@@ -68,7 +68,7 @@ type
     /// <returns>
     /// <returns>
     /// returns number of bytes added
     /// returns number of bytes added
     /// </returns>
     /// </returns>
-    function AddPadding(input: TCryptoLibByteArray; inOff: Int32): Int32;
+    function AddPadding(const input: TCryptoLibByteArray; inOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// return the number of pad bytes present in the block.
     /// return the number of pad bytes present in the block.
@@ -82,7 +82,7 @@ type
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// if the padding is badly formed or invalid.
     /// if the padding is badly formed or invalid.
     /// </exception>
     /// </exception>
-    function PadCount(input: TCryptoLibByteArray): Int32;
+    function PadCount(const input: TCryptoLibByteArray): Int32;
 
 
   end;
   end;
 
 
@@ -90,7 +90,7 @@ implementation
 
 
 { TPkcs7Padding }
 { TPkcs7Padding }
 
 
-function TPkcs7Padding.AddPadding(input: TCryptoLibByteArray;
+function TPkcs7Padding.AddPadding(const input: TCryptoLibByteArray;
   inOff: Int32): Int32;
   inOff: Int32): Int32;
 var
 var
   code: Byte;
   code: Byte;
@@ -119,7 +119,7 @@ begin
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
-function TPkcs7Padding.PadCount(input: TCryptoLibByteArray): Int32;
+function TPkcs7Padding.PadCount(const input: TCryptoLibByteArray): Int32;
 var
 var
   countAsByte: Byte;
   countAsByte: Byte;
   count, i: Int32;
   count, i: Int32;

+ 4 - 4
CryptoLib/src/Crypto/Paddings/ClpTTBCPadding.pas

@@ -67,7 +67,7 @@ type
     /// should be the same as the last block of plain text.
     /// should be the same as the last block of plain text.
     /// </p>
     /// </p>
     /// </summary>
     /// </summary>
-    function AddPadding(input: TCryptoLibByteArray; inOff: Int32): Int32;
+    function AddPadding(const input: TCryptoLibByteArray; inOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// return the number of pad bytes present in the block.
     /// return the number of pad bytes present in the block.
@@ -78,7 +78,7 @@ type
     /// <returns>
     /// <returns>
     /// the number of pad bytes present in the block.
     /// the number of pad bytes present in the block.
     /// </returns>
     /// </returns>
-    function PadCount(input: TCryptoLibByteArray): Int32;
+    function PadCount(const input: TCryptoLibByteArray): Int32;
 
 
   end;
   end;
 
 
@@ -86,7 +86,7 @@ implementation
 
 
 { TTBCPadding }
 { TTBCPadding }
 
 
-function TTBCPadding.AddPadding(input: TCryptoLibByteArray;
+function TTBCPadding.AddPadding(const input: TCryptoLibByteArray;
   inOff: Int32): Int32;
   inOff: Int32): Int32;
 var
 var
   count: Int32;
   count: Int32;
@@ -142,7 +142,7 @@ begin
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
-function TTBCPadding.PadCount(input: TCryptoLibByteArray): Int32;
+function TTBCPadding.PadCount(const input: TCryptoLibByteArray): Int32;
 var
 var
   code: Byte;
   code: Byte;
   index: Int32;
   index: Int32;

+ 4 - 4
CryptoLib/src/Crypto/Paddings/ClpX923Padding.pas

@@ -76,7 +76,7 @@ type
     /// <returns>
     /// <returns>
     /// returns number of bytes added
     /// returns number of bytes added
     /// </returns>
     /// </returns>
-    function AddPadding(input: TCryptoLibByteArray; inOff: Int32): Int32;
+    function AddPadding(const input: TCryptoLibByteArray; inOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// return the number of pad bytes present in the block.
     /// return the number of pad bytes present in the block.
@@ -90,7 +90,7 @@ type
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// if the padding is badly formed or invalid.
     /// if the padding is badly formed or invalid.
     /// </exception>
     /// </exception>
-    function PadCount(input: TCryptoLibByteArray): Int32;
+    function PadCount(const input: TCryptoLibByteArray): Int32;
 
 
   end;
   end;
 
 
@@ -98,7 +98,7 @@ implementation
 
 
 { TX923Padding }
 { TX923Padding }
 
 
-function TX923Padding.AddPadding(input: TCryptoLibByteArray;
+function TX923Padding.AddPadding(const input: TCryptoLibByteArray;
   inOff: Int32): Int32;
   inOff: Int32): Int32;
 var
 var
   code: Byte;
   code: Byte;
@@ -132,7 +132,7 @@ begin
   FRandom := random;
   FRandom := random;
 end;
 end;
 
 
-function TX923Padding.PadCount(input: TCryptoLibByteArray): Int32;
+function TX923Padding.PadCount(const input: TCryptoLibByteArray): Int32;
 var
 var
   count: Int32;
   count: Int32;
 begin
 begin

+ 4 - 4
CryptoLib/src/Crypto/Paddings/ClpZeroBytePadding.pas

@@ -69,7 +69,7 @@ type
     /// <returns>
     /// <returns>
     /// returns number of bytes added
     /// returns number of bytes added
     /// </returns>
     /// </returns>
-    function AddPadding(input: TCryptoLibByteArray; inOff: Int32): Int32;
+    function AddPadding(const input: TCryptoLibByteArray; inOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// return the number of pad bytes present in the block.
     /// return the number of pad bytes present in the block.
@@ -80,7 +80,7 @@ type
     /// <returns>
     /// <returns>
     /// the number of pad bytes present in the block.
     /// the number of pad bytes present in the block.
     /// </returns>
     /// </returns>
-    function PadCount(input: TCryptoLibByteArray): Int32;
+    function PadCount(const input: TCryptoLibByteArray): Int32;
 
 
   end;
   end;
 
 
@@ -88,7 +88,7 @@ implementation
 
 
 { TZeroBytePadding }
 { TZeroBytePadding }
 
 
-function TZeroBytePadding.AddPadding(input: TCryptoLibByteArray;
+function TZeroBytePadding.AddPadding(const input: TCryptoLibByteArray;
   inOff: Int32): Int32;
   inOff: Int32): Int32;
 var
 var
   added: Int32;
   added: Int32;
@@ -117,7 +117,7 @@ begin
 end;
 end;
 {$ENDIF}
 {$ENDIF}
 
 
-function TZeroBytePadding.PadCount(input: TCryptoLibByteArray): Int32;
+function TZeroBytePadding.PadCount(const input: TCryptoLibByteArray): Int32;
 var
 var
   count: Int32;
   count: Int32;
 begin
 begin

+ 5 - 4
CryptoLib/src/Crypto/Parameters/ClpDsaValidationParameters.pas

@@ -41,8 +41,9 @@ type
     function GetSeed: TCryptoLibByteArray; virtual;
     function GetSeed: TCryptoLibByteArray; virtual;
 
 
   public
   public
-    constructor Create(seed: TCryptoLibByteArray; counter: Int32); overload;
-    constructor Create(seed: TCryptoLibByteArray;
+    constructor Create(const seed: TCryptoLibByteArray;
+      counter: Int32); overload;
+    constructor Create(const seed: TCryptoLibByteArray;
       counter, usageIndex: Int32); overload;
       counter, usageIndex: Int32); overload;
 
 
     function Equals(const other: IDsaValidationParameters): Boolean;
     function Equals(const other: IDsaValidationParameters): Boolean;
@@ -59,13 +60,13 @@ implementation
 
 
 { TDsaValidationParameters }
 { TDsaValidationParameters }
 
 
-constructor TDsaValidationParameters.Create(seed: TCryptoLibByteArray;
+constructor TDsaValidationParameters.Create(const seed: TCryptoLibByteArray;
   counter: Int32);
   counter: Int32);
 begin
 begin
   Create(seed, counter, -1);
   Create(seed, counter, -1);
 end;
 end;
 
 
-constructor TDsaValidationParameters.Create(seed: TCryptoLibByteArray;
+constructor TDsaValidationParameters.Create(const seed: TCryptoLibByteArray;
   counter, usageIndex: Int32);
   counter, usageIndex: Int32);
 begin
 begin
   Inherited Create();
   Inherited Create();

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

@@ -73,7 +73,7 @@ type
     constructor Create(const curve: IECCurve; const g: IECPoint;
     constructor Create(const curve: IECCurve; const g: IECPoint;
       const n, h: TBigInteger); overload;
       const n, h: TBigInteger); overload;
     constructor Create(const curve: IECCurve; const g: IECPoint;
     constructor Create(const curve: IECCurve; const g: IECPoint;
-      const n, h: TBigInteger; seed: TCryptoLibByteArray); overload;
+      const n, h: TBigInteger; const seed: TCryptoLibByteArray); overload;
 
 
     property curve: IECCurve read GetCurve;
     property curve: IECCurve read GetCurve;
     property g: IECPoint read GetG;
     property g: IECPoint read GetG;
@@ -159,7 +159,7 @@ begin
 end;
 end;
 
 
 constructor TECDomainParameters.Create(const curve: IECCurve; const g: IECPoint;
 constructor TECDomainParameters.Create(const curve: IECCurve; const g: IECPoint;
-  const n, h: TBigInteger; seed: TCryptoLibByteArray);
+  const n, h: TBigInteger; const seed: TCryptoLibByteArray);
 begin
 begin
   if (curve = Nil) then
   if (curve = Nil) then
     raise EArgumentNilCryptoLibException.CreateRes(@SCurveNil);
     raise EArgumentNilCryptoLibException.CreateRes(@SCurveNil);

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

@@ -42,8 +42,8 @@ type
     Fikm, Fsalt, Finfo: TCryptoLibByteArray;
     Fikm, Fsalt, Finfo: TCryptoLibByteArray;
     FskipExpand: Boolean;
     FskipExpand: Boolean;
 
 
-    constructor Create(ikm: TCryptoLibByteArray; skip: Boolean;
-      salt, info: TCryptoLibByteArray); overload;
+    constructor Create(const ikm: TCryptoLibByteArray; skip: Boolean;
+      const salt, info: TCryptoLibByteArray); overload;
 
 
   strict protected
   strict protected
 
 
@@ -70,7 +70,7 @@ type
     /// <param name="info">
     /// <param name="info">
     /// the info to use, may be null for an info field of zero bytes
     /// the info to use, may be null for an info field of zero bytes
     /// </param>
     /// </param>
-    constructor Create(ikm, salt, info: TCryptoLibByteArray); overload;
+    constructor Create(const ikm, salt, info: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// Returns the input keying material or seed.
     /// Returns the input keying material or seed.
@@ -119,11 +119,11 @@ type
     /// <returns>
     /// <returns>
     /// that makes the implementation skip step 1
     /// that makes the implementation skip step 1
     /// </returns>
     /// </returns>
-    class function SkipExtractParameters(ikm, info: TCryptoLibByteArray)
+    class function SkipExtractParameters(const ikm, info: TCryptoLibByteArray)
       : IHkdfParameters; static; inline;
       : IHkdfParameters; static; inline;
 
 
-    class function DefaultParameters(ikm: TCryptoLibByteArray): IHkdfParameters;
-      static; inline;
+    class function DefaultParameters(const ikm: TCryptoLibByteArray)
+      : IHkdfParameters; static; inline;
 
 
   end;
   end;
 
 
@@ -131,8 +131,8 @@ implementation
 
 
 { THkdfParameters }
 { THkdfParameters }
 
 
-constructor THkdfParameters.Create(ikm: TCryptoLibByteArray; skip: Boolean;
-  salt, info: TCryptoLibByteArray);
+constructor THkdfParameters.Create(const ikm: TCryptoLibByteArray;
+  skip: Boolean; const salt, info: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
 
 
@@ -163,12 +163,12 @@ begin
   end;
   end;
 end;
 end;
 
 
-constructor THkdfParameters.Create(ikm, salt, info: TCryptoLibByteArray);
+constructor THkdfParameters.Create(const ikm, salt, info: TCryptoLibByteArray);
 begin
 begin
   Create(ikm, false, salt, info);
   Create(ikm, false, salt, info);
 end;
 end;
 
 
-class function THkdfParameters.DefaultParameters(ikm: TCryptoLibByteArray)
+class function THkdfParameters.DefaultParameters(const ikm: TCryptoLibByteArray)
   : IHkdfParameters;
   : IHkdfParameters;
 begin
 begin
   result := THkdfParameters.Create(ikm, false, Nil, Nil);
   result := THkdfParameters.Create(ikm, false, Nil, Nil);
@@ -194,7 +194,7 @@ begin
   result := FskipExpand;
   result := FskipExpand;
 end;
 end;
 
 
-class function THkdfParameters.SkipExtractParameters(ikm,
+class function THkdfParameters.SkipExtractParameters(const ikm,
   info: TCryptoLibByteArray): IHkdfParameters;
   info: TCryptoLibByteArray): IHkdfParameters;
 begin
 begin
   result := THkdfParameters.Create(ikm, true, Nil, info);
   result := THkdfParameters.Create(ikm, true, Nil, info);

+ 3 - 3
CryptoLib/src/Crypto/Parameters/ClpIESParameters.pas

@@ -52,7 +52,7 @@ type
     /// <param name="MacKeySize">
     /// <param name="MacKeySize">
     /// the size of the MAC key (in bits).
     /// the size of the MAC key (in bits).
     /// </param>
     /// </param>
-    constructor Create(derivation, encoding: TCryptoLibByteArray;
+    constructor Create(const derivation, encoding: TCryptoLibByteArray;
       MacKeySize: Int32);
       MacKeySize: Int32);
   end;
   end;
 
 
@@ -60,8 +60,8 @@ implementation
 
 
 { TIESParameters }
 { TIESParameters }
 
 
-constructor TIESParameters.Create(derivation, encoding: TCryptoLibByteArray;
-  MacKeySize: Int32);
+constructor TIESParameters.Create(const derivation,
+  encoding: TCryptoLibByteArray; MacKeySize: Int32);
 begin
 begin
   Inherited Create();
   Inherited Create();
   Fderivation := derivation;
   Fderivation := derivation;

+ 11 - 10
CryptoLib/src/Crypto/Parameters/ClpIESWithCipherParameters.pas

@@ -58,7 +58,7 @@ type
     /// <param name="CipherKeySize">
     /// <param name="CipherKeySize">
     /// the key size (in bits) for the block cipher.
     /// the key size (in bits) for the block cipher.
     /// </param>
     /// </param>
-    constructor Create(derivation, encoding: TCryptoLibByteArray;
+    constructor Create(const derivation, encoding: TCryptoLibByteArray;
       macKeySize, CipherKeySize: Int32); overload;
       macKeySize, CipherKeySize: Int32); overload;
 
 
     /// <summary>
     /// <summary>
@@ -79,8 +79,9 @@ type
     /// <param name="nonce">
     /// <param name="nonce">
     /// an IV to use initialising the block cipher.
     /// an IV to use initialising the block cipher.
     /// </param>
     /// </param>
-    constructor Create(derivation, encoding: TCryptoLibByteArray;
-      macKeySize, CipherKeySize: Int32; nonce: TCryptoLibByteArray); overload;
+    constructor Create(const derivation, encoding: TCryptoLibByteArray;
+      macKeySize, CipherKeySize: Int32;
+      const nonce: TCryptoLibByteArray); overload;
 
 
     /// <summary>
     /// <summary>
     /// Set the IES engine parameters.
     /// Set the IES engine parameters.
@@ -103,8 +104,8 @@ type
     /// <param name="UsePointCompression">
     /// <param name="UsePointCompression">
     /// whether to use EC point compression or not (false by default)
     /// whether to use EC point compression or not (false by default)
     /// </param>
     /// </param>
-    constructor Create(derivation, encoding: TCryptoLibByteArray;
-      macKeySize, CipherKeySize: Int32; nonce: TCryptoLibByteArray;
+    constructor Create(const derivation, encoding: TCryptoLibByteArray;
+      macKeySize, CipherKeySize: Int32; const nonce: TCryptoLibByteArray;
       UsePointCompression: Boolean); overload;
       UsePointCompression: Boolean); overload;
 
 
     /// <summary>
     /// <summary>
@@ -151,22 +152,22 @@ begin
   Result := FusePointCompression;
   Result := FusePointCompression;
 end;
 end;
 
 
-constructor TIESWithCipherParameters.Create(derivation,
+constructor TIESWithCipherParameters.Create(const derivation,
   encoding: TCryptoLibByteArray; macKeySize, CipherKeySize: Int32);
   encoding: TCryptoLibByteArray; macKeySize, CipherKeySize: Int32);
 begin
 begin
   Create(derivation, encoding, macKeySize, CipherKeySize, Nil);
   Create(derivation, encoding, macKeySize, CipherKeySize, Nil);
 end;
 end;
 
 
-constructor TIESWithCipherParameters.Create(derivation,
+constructor TIESWithCipherParameters.Create(const derivation,
   encoding: TCryptoLibByteArray; macKeySize, CipherKeySize: Int32;
   encoding: TCryptoLibByteArray; macKeySize, CipherKeySize: Int32;
-  nonce: TCryptoLibByteArray);
+  const nonce: TCryptoLibByteArray);
 begin
 begin
   Create(derivation, encoding, macKeySize, CipherKeySize, nonce, false);
   Create(derivation, encoding, macKeySize, CipherKeySize, nonce, false);
 end;
 end;
 
 
-constructor TIESWithCipherParameters.Create(derivation,
+constructor TIESWithCipherParameters.Create(const derivation,
   encoding: TCryptoLibByteArray; macKeySize, CipherKeySize: Int32;
   encoding: TCryptoLibByteArray; macKeySize, CipherKeySize: Int32;
-  nonce: TCryptoLibByteArray; UsePointCompression: Boolean);
+  const nonce: TCryptoLibByteArray; UsePointCompression: Boolean);
 begin
 begin
   Inherited Create(derivation, encoding, macKeySize);
   Inherited Create(derivation, encoding, macKeySize);
 
 

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

@@ -40,14 +40,14 @@ type
   public
   public
     function GetSeed(): TCryptoLibByteArray; inline;
     function GetSeed(): TCryptoLibByteArray; inline;
 
 
-    constructor Create(seed: TCryptoLibByteArray);
+    constructor Create(const seed: TCryptoLibByteArray);
   end;
   end;
 
 
 implementation
 implementation
 
 
 { TIso18033KdfParameters }
 { TIso18033KdfParameters }
 
 
-constructor TIso18033KdfParameters.Create(seed: TCryptoLibByteArray);
+constructor TIso18033KdfParameters.Create(const seed: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   Fseed := seed;
   Fseed := seed;

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

@@ -41,14 +41,14 @@ type
     function GetSharedSecret(): TCryptoLibByteArray; inline;
     function GetSharedSecret(): TCryptoLibByteArray; inline;
     function GetIV(): TCryptoLibByteArray; inline;
     function GetIV(): TCryptoLibByteArray; inline;
 
 
-    constructor Create(shared, iv: TCryptoLibByteArray);
+    constructor Create(const shared, iv: TCryptoLibByteArray);
   end;
   end;
 
 
 implementation
 implementation
 
 
 { TKdfParameters }
 { TKdfParameters }
 
 
-constructor TKdfParameters.Create(shared, iv: TCryptoLibByteArray);
+constructor TKdfParameters.Create(const shared, iv: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   Fshared := shared;
   Fshared := shared;

+ 4 - 4
CryptoLib/src/Crypto/Parameters/ClpKeyParameter.pas

@@ -40,8 +40,8 @@ type
     Fkey: TCryptoLibByteArray;
     Fkey: TCryptoLibByteArray;
 
 
   public
   public
-    constructor Create(key: TCryptoLibByteArray); overload;
-    constructor Create(key: TCryptoLibByteArray;
+    constructor Create(const key: TCryptoLibByteArray); overload;
+    constructor Create(const key: TCryptoLibByteArray;
       keyOff, keyLen: Int32); overload;
       keyOff, keyLen: Int32); overload;
     function GetKey(): TCryptoLibByteArray; inline;
     function GetKey(): TCryptoLibByteArray; inline;
 
 
@@ -51,7 +51,7 @@ implementation
 
 
 { TKeyParameter }
 { TKeyParameter }
 
 
-constructor TKeyParameter.Create(key: TCryptoLibByteArray);
+constructor TKeyParameter.Create(const key: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
 
 
@@ -62,7 +62,7 @@ begin
   Fkey := System.Copy(key);
   Fkey := System.Copy(key);
 end;
 end;
 
 
-constructor TKeyParameter.Create(key: TCryptoLibByteArray;
+constructor TKeyParameter.Create(const key: TCryptoLibByteArray;
   keyOff, keyLen: Int32);
   keyOff, keyLen: Int32);
 begin
 begin
   Inherited Create();
   Inherited Create();

+ 4 - 4
CryptoLib/src/Crypto/Parameters/ClpParametersWithIV.pas

@@ -43,9 +43,9 @@ type
 
 
   public
   public
     constructor Create(const parameters: ICipherParameters;
     constructor Create(const parameters: ICipherParameters;
-      iv: TCryptoLibByteArray); overload;
+      const iv: TCryptoLibByteArray); overload;
     constructor Create(const parameters: ICipherParameters;
     constructor Create(const parameters: ICipherParameters;
-      iv: TCryptoLibByteArray; ivOff, ivLen: Int32); overload;
+      const iv: TCryptoLibByteArray; ivOff, ivLen: Int32); overload;
     function GetIV(): TCryptoLibByteArray; inline;
     function GetIV(): TCryptoLibByteArray; inline;
     property parameters: ICipherParameters read GetParameters;
     property parameters: ICipherParameters read GetParameters;
 
 
@@ -56,14 +56,14 @@ implementation
 { TParametersWithIV }
 { TParametersWithIV }
 
 
 constructor TParametersWithIV.Create(const parameters: ICipherParameters;
 constructor TParametersWithIV.Create(const parameters: ICipherParameters;
-  iv: TCryptoLibByteArray);
+  const iv: TCryptoLibByteArray);
 begin
 begin
   Inherited Create();
   Inherited Create();
   Create(parameters, iv, 0, System.Length(iv))
   Create(parameters, iv, 0, System.Length(iv))
 end;
 end;
 
 
 constructor TParametersWithIV.Create(const parameters: ICipherParameters;
 constructor TParametersWithIV.Create(const parameters: ICipherParameters;
-  iv: TCryptoLibByteArray; ivOff, ivLen: Int32);
+  const iv: TCryptoLibByteArray; ivOff, ivLen: Int32);
 begin
 begin
   Inherited Create();
   Inherited Create();
   // NOTE: 'parameters' may be null to imply key re-use
   // NOTE: 'parameters' may be null to imply key re-use

+ 2 - 2
CryptoLib/src/Crypto/Parsers/ClpECIESPublicKeyParser.pas

@@ -46,7 +46,7 @@ type
     FecParams: IECDomainParameters;
     FecParams: IECDomainParameters;
 
 
   public
   public
-    function ReadKey(Stream: TStream): IAsymmetricKeyParameter;
+    function ReadKey(const Stream: TStream): IAsymmetricKeyParameter;
     constructor Create(const ecParams: IECDomainParameters);
     constructor Create(const ecParams: IECDomainParameters);
 
 
   end;
   end;
@@ -61,7 +61,7 @@ begin
   FecParams := ecParams;
   FecParams := ecParams;
 end;
 end;
 
 
-function TECIESPublicKeyParser.ReadKey(Stream: TStream)
+function TECIESPublicKeyParser.ReadKey(const Stream: TStream)
   : IAsymmetricKeyParameter;
   : IAsymmetricKeyParameter;
 var
 var
   v: TCryptoLibByteArray;
   v: TCryptoLibByteArray;

+ 8 - 6
CryptoLib/src/Crypto/Prng/ClpCryptoApiRandomGenerator.pas

@@ -51,7 +51,8 @@ type
 
 
     /// <summary>Add more seed material to the generator.</summary>
     /// <summary>Add more seed material to the generator.</summary>
     /// <param name="seed">A byte array to be mixed into the generator's state.</param>
     /// <param name="seed">A byte array to be mixed into the generator's state.</param>
-    procedure AddSeedMaterial(seed: TCryptoLibByteArray); overload; virtual;
+    procedure AddSeedMaterial(const seed: TCryptoLibByteArray);
+      overload; virtual;
 
 
     /// <summary>Add more seed material to the generator.</summary>
     /// <summary>Add more seed material to the generator.</summary>
     /// <param name="seed">A long value to be mixed into the generator's state.</param>
     /// <param name="seed">A long value to be mixed into the generator's state.</param>
@@ -59,13 +60,13 @@ type
 
 
     /// <summary>Fill byte array with random values.</summary>
     /// <summary>Fill byte array with random values.</summary>
     /// <param name="bytes">Array to be filled.</param>
     /// <param name="bytes">Array to be filled.</param>
-    procedure NextBytes(bytes: TCryptoLibByteArray); overload; virtual;
+    procedure NextBytes(const bytes: TCryptoLibByteArray); overload; virtual;
 
 
     /// <summary>Fill byte array with random values.</summary>
     /// <summary>Fill byte array with random values.</summary>
     /// <param name="bytes">Array to receive bytes.</param>
     /// <param name="bytes">Array to receive bytes.</param>
     /// <param name="start">Index to start filling at.</param>
     /// <param name="start">Index to start filling at.</param>
     /// <param name="len">Length of segment to fill.</param>
     /// <param name="len">Length of segment to fill.</param>
-    procedure NextBytes(bytes: TCryptoLibByteArray; start, len: Int32);
+    procedure NextBytes(const bytes: TCryptoLibByteArray; start, len: Int32);
       overload; virtual;
       overload; virtual;
 
 
   end;
   end;
@@ -79,7 +80,8 @@ begin
   // We don't care about the seed
   // We don't care about the seed
 end;
 end;
 
 
-procedure TCryptoApiRandomGenerator.AddSeedMaterial(seed: TCryptoLibByteArray);
+procedure TCryptoApiRandomGenerator.AddSeedMaterial
+  (const seed: TCryptoLibByteArray);
 begin
 begin
   // We don't care about the seed
   // We don't care about the seed
 end;
 end;
@@ -95,12 +97,12 @@ begin
   Create(TRandomNumberGenerator.CreateRNG());
   Create(TRandomNumberGenerator.CreateRNG());
 end;
 end;
 
 
-procedure TCryptoApiRandomGenerator.NextBytes(bytes: TCryptoLibByteArray);
+procedure TCryptoApiRandomGenerator.NextBytes(const bytes: TCryptoLibByteArray);
 begin
 begin
   FrndProv.GetBytes(bytes);
   FrndProv.GetBytes(bytes);
 end;
 end;
 
 
-procedure TCryptoApiRandomGenerator.NextBytes(bytes: TCryptoLibByteArray;
+procedure TCryptoApiRandomGenerator.NextBytes(const bytes: TCryptoLibByteArray;
   start, len: Int32);
   start, len: Int32);
 var
 var
   tmpBuf: TCryptoLibByteArray;
   tmpBuf: TCryptoLibByteArray;

+ 15 - 11
CryptoLib/src/Crypto/Prng/ClpDigestRandomGenerator.pas

@@ -52,8 +52,8 @@ type
     procedure CycleSeed(); inline;
     procedure CycleSeed(); inline;
     procedure GenerateState(); inline;
     procedure GenerateState(); inline;
     procedure DigestAddCounter(seedVal: Int64); inline;
     procedure DigestAddCounter(seedVal: Int64); inline;
-    procedure DigestUpdate(inSeed: TCryptoLibByteArray); inline;
-    procedure DigestDoFinal(result: TCryptoLibByteArray); inline;
+    procedure DigestUpdate(const inSeed: TCryptoLibByteArray); inline;
+    procedure DigestDoFinal(const result: TCryptoLibByteArray); inline;
 
 
     class var
     class var
 
 
@@ -65,11 +65,12 @@ type
   public
   public
 
 
     constructor Create(const digest: IDigest);
     constructor Create(const digest: IDigest);
-    procedure AddSeedMaterial(inSeed: TCryptoLibByteArray); overload; inline;
+    procedure AddSeedMaterial(const inSeed: TCryptoLibByteArray);
+      overload; inline;
     procedure AddSeedMaterial(rSeed: Int64); overload; inline;
     procedure AddSeedMaterial(rSeed: Int64); overload; inline;
-    procedure NextBytes(bytes: TCryptoLibByteArray); overload; inline;
-    procedure NextBytes(bytes: TCryptoLibByteArray; start, len: Int32);
-      overload;
+    procedure NextBytes(const bytes: TCryptoLibByteArray); overload; inline;
+    procedure NextBytes(const bytes: TCryptoLibByteArray;
+      start, len: Int32); overload;
 
 
   end;
   end;
 
 
@@ -86,12 +87,14 @@ begin
   Fdigest.BlockUpdate(bytes, 0, System.Length(bytes));
   Fdigest.BlockUpdate(bytes, 0, System.Length(bytes));
 end;
 end;
 
 
-procedure TDigestRandomGenerator.DigestUpdate(inSeed: TCryptoLibByteArray);
+procedure TDigestRandomGenerator.DigestUpdate(const inSeed
+  : TCryptoLibByteArray);
 begin
 begin
   Fdigest.BlockUpdate(inSeed, 0, System.Length(inSeed));
   Fdigest.BlockUpdate(inSeed, 0, System.Length(inSeed));
 end;
 end;
 
 
-procedure TDigestRandomGenerator.DigestDoFinal(result: TCryptoLibByteArray);
+procedure TDigestRandomGenerator.DigestDoFinal(const result
+  : TCryptoLibByteArray);
 begin
 begin
   Fdigest.DoFinal(result, 0);
   Fdigest.DoFinal(result, 0);
 end;
 end;
@@ -108,7 +111,8 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TDigestRandomGenerator.AddSeedMaterial(inSeed: TCryptoLibByteArray);
+procedure TDigestRandomGenerator.AddSeedMaterial(const inSeed
+  : TCryptoLibByteArray);
 begin
 begin
   FLock.Acquire;
   FLock.Acquire;
   try
   try
@@ -162,12 +166,12 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TDigestRandomGenerator.NextBytes(bytes: TCryptoLibByteArray);
+procedure TDigestRandomGenerator.NextBytes(const bytes: TCryptoLibByteArray);
 begin
 begin
   NextBytes(bytes, 0, System.Length(bytes));
   NextBytes(bytes, 0, System.Length(bytes));
 end;
 end;
 
 
-procedure TDigestRandomGenerator.NextBytes(bytes: TCryptoLibByteArray;
+procedure TDigestRandomGenerator.NextBytes(const bytes: TCryptoLibByteArray;
   start, len: Int32);
   start, len: Int32);
 var
 var
   stateOff, endPoint: Int32;
   stateOff, endPoint: Int32;

+ 8 - 7
CryptoLib/src/Crypto/Signers/ClpDsaDigestSigner.pas

@@ -58,7 +58,7 @@ type
 
 
     function DerEncode(const r, s: TBigInteger): TCryptoLibByteArray; inline;
     function DerEncode(const r, s: TBigInteger): TCryptoLibByteArray; inline;
 
 
-    function DerDecode(encoding: TCryptoLibByteArray)
+    function DerDecode(const encoding: TCryptoLibByteArray)
       : TCryptoLibGenericArray<TBigInteger>; inline;
       : TCryptoLibGenericArray<TBigInteger>; inline;
 
 
   public
   public
@@ -78,7 +78,7 @@ type
     /// <summary>
     /// <summary>
     /// update the internal digest with the byte array in
     /// update the internal digest with the byte array in
     /// </summary>
     /// </summary>
-    procedure BlockUpdate(input: TCryptoLibByteArray;
+    procedure BlockUpdate(const input: TCryptoLibByteArray;
       inOff, length: Int32); virtual;
       inOff, length: Int32); virtual;
 
 
     /// <summary>
     /// <summary>
@@ -91,7 +91,8 @@ type
     /// true if the internal state represents the signature described in the
     /// true if the internal state represents the signature described in the
     /// passed in array.
     /// passed in array.
     /// </returns>
     /// </returns>
-    function VerifySignature(signature: TCryptoLibByteArray): Boolean; virtual;
+    function VerifySignature(const signature: TCryptoLibByteArray)
+      : Boolean; virtual;
 
 
     /// <summary>
     /// <summary>
     /// Reset the internal state
     /// Reset the internal state
@@ -104,7 +105,7 @@ implementation
 
 
 { TDsaDigestSigner }
 { TDsaDigestSigner }
 
 
-procedure TDsaDigestSigner.BlockUpdate(input: TCryptoLibByteArray;
+procedure TDsaDigestSigner.BlockUpdate(const input: TCryptoLibByteArray;
   inOff, length: Int32);
   inOff, length: Int32);
 begin
 begin
   Fdigest.BlockUpdate(input, inOff, length);
   Fdigest.BlockUpdate(input, inOff, length);
@@ -117,7 +118,7 @@ begin
   Fdigest := digest;
   Fdigest := digest;
 end;
 end;
 
 
-function TDsaDigestSigner.DerDecode(encoding: TCryptoLibByteArray)
+function TDsaDigestSigner.DerDecode(const encoding: TCryptoLibByteArray)
   : TCryptoLibGenericArray<TBigInteger>;
   : TCryptoLibGenericArray<TBigInteger>;
 var
 var
   s: IAsn1Sequence;
   s: IAsn1Sequence;
@@ -201,8 +202,8 @@ begin
   Fdigest.Update(input);
   Fdigest.Update(input);
 end;
 end;
 
 
-function TDsaDigestSigner.VerifySignature
-  (signature: TCryptoLibByteArray): Boolean;
+function TDsaDigestSigner.VerifySignature(const signature
+  : TCryptoLibByteArray): Boolean;
 var
 var
   hash: TCryptoLibByteArray;
   hash: TCryptoLibByteArray;
   sig: TCryptoLibGenericArray<TBigInteger>;
   sig: TCryptoLibGenericArray<TBigInteger>;

+ 7 - 7
CryptoLib/src/Crypto/Signers/ClpDsaSigner.pas

@@ -60,8 +60,8 @@ type
     Fkey: IDsaKeyParameters;
     Fkey: IDsaKeyParameters;
     Frandom: ISecureRandom;
     Frandom: ISecureRandom;
 
 
-    function CalculateE(const n: TBigInteger; &message: TCryptoLibByteArray)
-      : TBigInteger; virtual;
+    function CalculateE(const n: TBigInteger;
+      const &message: TCryptoLibByteArray): TBigInteger; virtual;
 
 
     function InitSecureRandom(needed: Boolean; const provided: ISecureRandom)
     function InitSecureRandom(needed: Boolean; const provided: ISecureRandom)
       : ISecureRandom; virtual;
       : ISecureRandom; virtual;
@@ -92,7 +92,7 @@ type
     /// <param name="&amp;message">
     /// <param name="&amp;message">
     /// the message that will be verified later.
     /// the message that will be verified later.
     /// </param>
     /// </param>
-    function GenerateSignature(&message: TCryptoLibByteArray)
+    function GenerateSignature(const &message: TCryptoLibByteArray)
       : TCryptoLibGenericArray<TBigInteger>; virtual;
       : TCryptoLibGenericArray<TBigInteger>; virtual;
 
 
     /// <summary>
     /// <summary>
@@ -100,7 +100,7 @@ type
     /// the passed in message for standard DSA the message should be a <br />
     /// the passed in message for standard DSA the message should be a <br />
     /// SHA-1 hash of the real message to be verified.
     /// SHA-1 hash of the real message to be verified.
     /// </summary>
     /// </summary>
-    function VerifySignature(&message: TCryptoLibByteArray;
+    function VerifySignature(const &message: TCryptoLibByteArray;
       const r, s: TBigInteger): Boolean; virtual;
       const r, s: TBigInteger): Boolean; virtual;
 
 
     property AlgorithmName: String read GetAlgorithmName;
     property AlgorithmName: String read GetAlgorithmName;
@@ -118,7 +118,7 @@ begin
 end;
 end;
 
 
 function TDsaSigner.CalculateE(const n: TBigInteger;
 function TDsaSigner.CalculateE(const n: TBigInteger;
-  &message: TCryptoLibByteArray): TBigInteger;
+  const &message: TCryptoLibByteArray): TBigInteger;
 var
 var
   length: Int32;
   length: Int32;
 begin
 begin
@@ -132,7 +132,7 @@ begin
   FkCalculator := kCalculator;
   FkCalculator := kCalculator;
 end;
 end;
 
 
-function TDsaSigner.GenerateSignature(&message: TCryptoLibByteArray)
+function TDsaSigner.GenerateSignature(const &message: TCryptoLibByteArray)
   : TCryptoLibGenericArray<TBigInteger>;
   : TCryptoLibGenericArray<TBigInteger>;
 var
 var
   parameters: IDsaParameters;
   parameters: IDsaParameters;
@@ -228,7 +228,7 @@ begin
 
 
 end;
 end;
 
 
-function TDsaSigner.VerifySignature(&message: TCryptoLibByteArray;
+function TDsaSigner.VerifySignature(const &message: TCryptoLibByteArray;
   const r, s: TBigInteger): Boolean;
   const r, s: TBigInteger): Boolean;
 var
 var
   parameters: IDsaParameters;
   parameters: IDsaParameters;

+ 7 - 7
CryptoLib/src/Crypto/Signers/ClpECDsaSigner.pas

@@ -73,8 +73,8 @@ type
     Fkey: IECKeyParameters;
     Fkey: IECKeyParameters;
     Frandom: ISecureRandom;
     Frandom: ISecureRandom;
 
 
-    function CalculateE(const n: TBigInteger; &message: TCryptoLibByteArray)
-      : TBigInteger; virtual;
+    function CalculateE(const n: TBigInteger;
+      const &message: TCryptoLibByteArray): TBigInteger; virtual;
 
 
     function CreateBasePointMultiplier(): IECMultiplier; virtual;
     function CreateBasePointMultiplier(): IECMultiplier; virtual;
 
 
@@ -112,7 +112,7 @@ type
     // * hash of the message of interest.
     // * hash of the message of interest.
     // *
     // *
     // * @param message the message that will be verified later.
     // * @param message the message that will be verified later.
-    function GenerateSignature(&message: TCryptoLibByteArray)
+    function GenerateSignature(const &message: TCryptoLibByteArray)
       : TCryptoLibGenericArray<TBigInteger>; virtual;
       : TCryptoLibGenericArray<TBigInteger>; virtual;
 
 
     // // 5.4 pg 29
     // // 5.4 pg 29
@@ -121,7 +121,7 @@ type
     // * the passed in message (for standard DSA the message should be
     // * the passed in message (for standard DSA the message should be
     // * a SHA-1 hash of the real message to be verified).
     // * a SHA-1 hash of the real message to be verified).
     // */
     // */
-    function VerifySignature(&message: TCryptoLibByteArray;
+    function VerifySignature(const &message: TCryptoLibByteArray;
       const r, s: TBigInteger): Boolean;
       const r, s: TBigInteger): Boolean;
 
 
   end;
   end;
@@ -137,7 +137,7 @@ begin
 end;
 end;
 
 
 function TECDsaSigner.CalculateE(const n: TBigInteger;
 function TECDsaSigner.CalculateE(const n: TBigInteger;
-  &message: TCryptoLibByteArray): TBigInteger;
+  const &message: TCryptoLibByteArray): TBigInteger;
 var
 var
   messageBitLength: Int32;
   messageBitLength: Int32;
   trunc: TBigInteger;
   trunc: TBigInteger;
@@ -170,7 +170,7 @@ begin
   FEight := TBigInteger.ValueOf(8);
   FEight := TBigInteger.ValueOf(8);
 end;
 end;
 
 
-function TECDsaSigner.GenerateSignature(&message: TCryptoLibByteArray)
+function TECDsaSigner.GenerateSignature(const &message: TCryptoLibByteArray)
   : TCryptoLibGenericArray<TBigInteger>;
   : TCryptoLibGenericArray<TBigInteger>;
 var
 var
   ec: IECDomainParameters;
   ec: IECDomainParameters;
@@ -305,7 +305,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TECDsaSigner.VerifySignature(&message: TCryptoLibByteArray;
+function TECDsaSigner.VerifySignature(const &message: TCryptoLibByteArray;
   const r, s: TBigInteger): Boolean;
   const r, s: TBigInteger): Boolean;
 var
 var
   n, e, c, u1, u2, cofactor, v, Smallr: TBigInteger;
   n, e, c, u1, u2, cofactor, v, Smallr: TBigInteger;

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

@@ -88,7 +88,7 @@ type
     /// <exception cref="EDataLengthCryptoLibException">
     /// <exception cref="EDataLengthCryptoLibException">
     /// if the digest is longer than the key allows
     /// if the digest is longer than the key allows
     /// </exception>
     /// </exception>
-    function GenerateSignature(&message: TCryptoLibByteArray)
+    function GenerateSignature(const &message: TCryptoLibByteArray)
       : TCryptoLibGenericArray<TBigInteger>; virtual;
       : TCryptoLibGenericArray<TBigInteger>; virtual;
 
 
     /// <summary>
     /// <summary>
@@ -116,7 +116,7 @@ type
     /// <exception cref="EDataLengthCryptoLibException">
     /// <exception cref="EDataLengthCryptoLibException">
     /// if the digest is longer than the key allows
     /// if the digest is longer than the key allows
     /// </exception>
     /// </exception>
-    function VerifySignature(&message: TCryptoLibByteArray;
+    function VerifySignature(const &message: TCryptoLibByteArray;
       const r, s: TBigInteger): Boolean;
       const r, s: TBigInteger): Boolean;
 
 
   end;
   end;
@@ -125,7 +125,7 @@ implementation
 
 
 { TECNRSigner }
 { TECNRSigner }
 
 
-function TECNRSigner.GenerateSignature(&message: TCryptoLibByteArray)
+function TECNRSigner.GenerateSignature(const &message: TCryptoLibByteArray)
   : TCryptoLibGenericArray<TBigInteger>;
   : TCryptoLibGenericArray<TBigInteger>;
 var
 var
   n, e, r, s, Vx, x, u: TBigInteger;
   n, e, r, s, Vx, x, u: TBigInteger;
@@ -225,7 +225,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TECNRSigner.VerifySignature(&message: TCryptoLibByteArray;
+function TECNRSigner.VerifySignature(const &message: TCryptoLibByteArray;
   const r, s: TBigInteger): Boolean;
   const r, s: TBigInteger): Boolean;
 var
 var
   pubKey: IECPublicKeyParameters;
   pubKey: IECPublicKeyParameters;

+ 10 - 9
CryptoLib/src/Crypto/Signers/ClpECSchnorrSigner.pas

@@ -70,12 +70,12 @@ type
       const k: TBigInteger): TCryptoLibByteArray;
       const k: TBigInteger): TCryptoLibByteArray;
 
 
     function Do_Verify(const pu_key: IECPublicKeyParameters;
     function Do_Verify(const pu_key: IECPublicKeyParameters;
-      sig: TCryptoLibByteArray): Boolean;
+      const sig: TCryptoLibByteArray): Boolean;
 
 
     class function Encode_Sig(const r, s: TBigInteger)
     class function Encode_Sig(const r, s: TBigInteger)
       : TCryptoLibByteArray; static;
       : TCryptoLibByteArray; static;
 
 
-    class function Decode_Sig(sig: TCryptoLibByteArray)
+    class function Decode_Sig(const sig: TCryptoLibByteArray)
       : TCryptoLibGenericArray<TBigInteger>; static;
       : TCryptoLibGenericArray<TBigInteger>; static;
 
 
 
 
@@ -175,7 +175,8 @@ type
     /// <summary>
     /// <summary>
     /// update the internal digest with the byte array in
     /// update the internal digest with the byte array in
     /// </summary>
     /// </summary>
-    procedure BlockUpdate(input: TCryptoLibByteArray; inOff, length: Int32);
+    procedure BlockUpdate(const input: TCryptoLibByteArray;
+      inOff, length: Int32);
 
 
     /// <summary>
     /// <summary>
     /// Generate a signature for the message we've been loaded with using the
     /// Generate a signature for the message we've been loaded with using the
@@ -187,7 +188,7 @@ type
     /// true if the internal state represents the signature described in the
     /// true if the internal state represents the signature described in the
     /// passed in array.
     /// passed in array.
     /// </returns>
     /// </returns>
-    function VerifySignature(signature: TCryptoLibByteArray): Boolean;
+    function VerifySignature(const signature: TCryptoLibByteArray): Boolean;
 
 
     /// <summary>
     /// <summary>
     /// Reset the internal state
     /// Reset the internal state
@@ -206,7 +207,7 @@ begin
     TDerInteger.Create(s) as IDerInteger]).GetDerEncoded();
     TDerInteger.Create(s) as IDerInteger]).GetDerEncoded();
 end;
 end;
 
 
-class function TECSchnorrSigner.Decode_Sig(sig: TCryptoLibByteArray)
+class function TECSchnorrSigner.Decode_Sig(const sig: TCryptoLibByteArray)
   : TCryptoLibGenericArray<TBigInteger>;
   : TCryptoLibGenericArray<TBigInteger>;
 var
 var
   s: IAsn1Sequence;
   s: IAsn1Sequence;
@@ -223,7 +224,7 @@ begin
   FBuffer.Read(Result[0], FBuffer.Size);
   FBuffer.Read(Result[0], FBuffer.Size);
 end;
 end;
 
 
-procedure TECSchnorrSigner.BlockUpdate(input: TCryptoLibByteArray;
+procedure TECSchnorrSigner.BlockUpdate(const input: TCryptoLibByteArray;
   inOff, length: Int32);
   inOff, length: Int32);
 begin
 begin
   FBuffer.Write(input[inOff], length);
   FBuffer.Write(input[inOff], length);
@@ -257,7 +258,7 @@ begin
 end;
 end;
 
 
 function TECSchnorrSigner.Do_Verify(const pu_key: IECPublicKeyParameters;
 function TECSchnorrSigner.Do_Verify(const pu_key: IECPublicKeyParameters;
-  sig: TCryptoLibByteArray): Boolean;
+  const sig: TCryptoLibByteArray): Boolean;
 begin
 begin
 
 
   if (pu_key.parameters.curve = Nil) then
   if (pu_key.parameters.curve = Nil) then
@@ -348,8 +349,8 @@ begin
   FBuffer.Write(TCryptoLibByteArray.Create(input)[0], 1);
   FBuffer.Write(TCryptoLibByteArray.Create(input)[0], 1);
 end;
 end;
 
 
-function TECSchnorrSigner.VerifySignature
-  (signature: TCryptoLibByteArray): Boolean;
+function TECSchnorrSigner.VerifySignature(const signature
+  : TCryptoLibByteArray): Boolean;
 var
 var
   pu_key_params: IECPublicKeyParameters;
   pu_key_params: IECPublicKeyParameters;
 begin
 begin

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

@@ -56,7 +56,7 @@ type
     FK, FV: TCryptoLibByteArray;
     FK, FV: TCryptoLibByteArray;
     Fn: TBigInteger;
     Fn: TBigInteger;
 
 
-    function BitsToInt(t: TCryptoLibByteArray): TBigInteger; inline;
+    function BitsToInt(const t: TCryptoLibByteArray): TBigInteger; inline;
 
 
     function GetIsDeterministic: Boolean; virtual;
     function GetIsDeterministic: Boolean; virtual;
 
 
@@ -74,7 +74,7 @@ type
       overload; virtual;
       overload; virtual;
 
 
     procedure Init(const n, d: TBigInteger;
     procedure Init(const n, d: TBigInteger;
-      &message: TCryptoLibByteArray); overload;
+      const &message: TCryptoLibByteArray); overload;
 
 
     function NextK(): TBigInteger; virtual;
     function NextK(): TBigInteger; virtual;
 
 
@@ -91,7 +91,8 @@ begin
   result := True;
   result := True;
 end;
 end;
 
 
-function THMacDsaKCalculator.BitsToInt(t: TCryptoLibByteArray): TBigInteger;
+function THMacDsaKCalculator.BitsToInt(const t: TCryptoLibByteArray)
+  : TBigInteger;
 begin
 begin
   result := TBigInteger.Create(1, t);
   result := TBigInteger.Create(1, t);
   if ((System.Length(t) * 8) > Fn.BitLength) then
   if ((System.Length(t) * 8) > Fn.BitLength) then
@@ -118,7 +119,7 @@ end;
 {$ENDIF}
 {$ENDIF}
 
 
 procedure THMacDsaKCalculator.Init(const n, d: TBigInteger;
 procedure THMacDsaKCalculator.Init(const n, d: TBigInteger;
-  &message: TCryptoLibByteArray);
+  const &message: TCryptoLibByteArray);
 var
 var
   x, dVal, m, mVal: TCryptoLibByteArray;
   x, dVal, m, mVal: TCryptoLibByteArray;
   mInt: TBigInteger;
   mInt: TBigInteger;

+ 3 - 3
CryptoLib/src/Crypto/Signers/ClpRandomDsaKCalculator.pas

@@ -48,8 +48,8 @@ type
     property IsDeterministic: Boolean read GetIsDeterministic;
     property IsDeterministic: Boolean read GetIsDeterministic;
     procedure Init(const n: TBigInteger; const random: ISecureRandom);
     procedure Init(const n: TBigInteger; const random: ISecureRandom);
       overload; virtual;
       overload; virtual;
-    procedure Init(const n, d: TBigInteger; &message: TCryptoLibByteArray);
-      overload; virtual;
+    procedure Init(const n, d: TBigInteger;
+      const &message: TCryptoLibByteArray); overload; virtual;
     function NextK(): TBigInteger; virtual;
     function NextK(): TBigInteger; virtual;
   end;
   end;
 
 
@@ -72,7 +72,7 @@ end;
 {$IFNDEF _FIXINSIGHT_}
 {$IFNDEF _FIXINSIGHT_}
 
 
 procedure TRandomDsaKCalculator.Init(const n, d: TBigInteger;
 procedure TRandomDsaKCalculator.Init(const n, d: TBigInteger;
-  &message: TCryptoLibByteArray);
+  const &message: TCryptoLibByteArray);
 begin
 begin
   raise EInvalidOperationCryptoLibException.CreateRes(@SUnSupportedOperation);
   raise EInvalidOperationCryptoLibException.CreateRes(@SUnSupportedOperation);
 end;
 end;

+ 2 - 2
CryptoLib/src/Interfaces/ClpIAsn1EncodableVector.pas

@@ -32,9 +32,9 @@ type
     function GetCount: Int32;
     function GetCount: Int32;
     function GetSelf(Index: Int32): IAsn1Encodable;
     function GetSelf(Index: Int32): IAsn1Encodable;
 
 
-    procedure Add(objs: array of IAsn1Encodable);
+    procedure Add(const objs: array of IAsn1Encodable);
 
 
-    procedure AddOptional(objs: array of IAsn1Encodable);
+    procedure AddOptional(const objs: array of IAsn1Encodable);
 
 
     property Self[Index: Int32]: IAsn1Encodable read GetSelf; default;
     property Self[Index: Int32]: IAsn1Encodable read GetSelf; default;
 
 

+ 2 - 2
CryptoLib/src/Interfaces/ClpIBlockCipher.pas

@@ -53,8 +53,8 @@ type
     /// <param name="outOff">The offset into <paramref>outBuf</paramref> to write the output block.</param>
     /// <param name="outOff">The offset into <paramref>outBuf</paramref> to write the output block.</param>
     /// <exception cref="DataLengthException">If input block is wrong size, or outBuf too small.</exception>
     /// <exception cref="DataLengthException">If input block is wrong size, or outBuf too small.</exception>
     /// <returns>The number of bytes processed and produced.</returns>
     /// <returns>The number of bytes processed and produced.</returns>
-    function ProcessBlock(inBuf: TCryptoLibByteArray; inOff: Int32;
-      outBuf: TCryptoLibByteArray; outOff: Int32): Int32;
+    function ProcessBlock(const inBuf: TCryptoLibByteArray; inOff: Int32;
+      const outBuf: TCryptoLibByteArray; outOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// Reset the cipher to the same state as it was after the last init (if there was one).
     /// Reset the cipher to the same state as it was after the last init (if there was one).

+ 2 - 2
CryptoLib/src/Interfaces/ClpIBlockCipherPadding.pas

@@ -61,7 +61,7 @@ type
     /// <returns>
     /// <returns>
     /// returns number of bytes added
     /// returns number of bytes added
     /// </returns>
     /// </returns>
-    function AddPadding(input: TCryptoLibByteArray; inOff: Int32): Int32;
+    function AddPadding(const input: TCryptoLibByteArray; inOff: Int32): Int32;
 
 
     /// <summary>
     /// <summary>
     /// return the number of pad bytes present in the block.
     /// return the number of pad bytes present in the block.
@@ -75,7 +75,7 @@ type
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// <exception cref="EInvalidCipherTextCryptoLibException">
     /// if the padding is badly formed or invalid.
     /// if the padding is badly formed or invalid.
     /// </exception>
     /// </exception>
-    function PadCount(input: TCryptoLibByteArray): Int32;
+    function PadCount(const input: TCryptoLibByteArray): Int32;
 
 
   end;
   end;
 
 

+ 15 - 13
CryptoLib/src/Interfaces/ClpIBufferedCipher.pas

@@ -46,28 +46,30 @@ type
     function GetUpdateOutputSize(inputLen: Int32): Int32;
     function GetUpdateOutputSize(inputLen: Int32): Int32;
 
 
     function ProcessByte(input: Byte): TCryptoLibByteArray; overload;
     function ProcessByte(input: Byte): TCryptoLibByteArray; overload;
-    function ProcessByte(input: Byte; output: TCryptoLibByteArray;
+    function ProcessByte(input: Byte; const output: TCryptoLibByteArray;
       outOff: Int32): Int32; overload;
       outOff: Int32): Int32; overload;
 
 
-    function ProcessBytes(input: TCryptoLibByteArray)
+    function ProcessBytes(const input: TCryptoLibByteArray)
       : TCryptoLibByteArray; overload;
       : TCryptoLibByteArray; overload;
-    function ProcessBytes(input: TCryptoLibByteArray; inOff, length: Int32)
-      : TCryptoLibByteArray; overload;
-    function ProcessBytes(input, output: TCryptoLibByteArray; outOff: Int32)
+    function ProcessBytes(const input: TCryptoLibByteArray;
+      inOff, length: Int32): TCryptoLibByteArray; overload;
+    function ProcessBytes(const input, output: TCryptoLibByteArray;
+      outOff: Int32): Int32; overload;
+    function ProcessBytes(const input: TCryptoLibByteArray;
+      inOff, length: Int32; const output: TCryptoLibByteArray; outOff: Int32)
       : Int32; overload;
       : Int32; overload;
-    function ProcessBytes(input: TCryptoLibByteArray; inOff, length: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32; overload;
 
 
     function DoFinal(): TCryptoLibByteArray; overload;
     function DoFinal(): TCryptoLibByteArray; overload;
-    function DoFinal(input: TCryptoLibByteArray): TCryptoLibByteArray; overload;
-    function DoFinal(input: TCryptoLibByteArray; inOff, length: Int32)
+    function DoFinal(const input: TCryptoLibByteArray)
+      : TCryptoLibByteArray; overload;
+    function DoFinal(const input: TCryptoLibByteArray; inOff, length: Int32)
       : TCryptoLibByteArray; overload;
       : TCryptoLibByteArray; overload;
-    function DoFinal(output: TCryptoLibByteArray; outOff: Int32)
+    function DoFinal(const output: TCryptoLibByteArray; outOff: Int32)
       : Int32; overload;
       : Int32; overload;
-    function DoFinal(input, output: TCryptoLibByteArray; outOff: Int32)
+    function DoFinal(const input, output: TCryptoLibByteArray; outOff: Int32)
       : Int32; overload;
       : Int32; overload;
-    function DoFinal(input: TCryptoLibByteArray; inOff, length: Int32;
-      output: TCryptoLibByteArray; outOff: Int32): Int32; overload;
+    function DoFinal(const input: TCryptoLibByteArray; inOff, length: Int32;
+      const output: TCryptoLibByteArray; outOff: Int32): Int32; overload;
 
 
     /// <summary>
     /// <summary>
     /// Reset the cipher. After resetting the cipher is in the same state
     /// Reset the cipher. After resetting the cipher is in the same state

+ 1 - 1
CryptoLib/src/Interfaces/ClpIDerApplicationSpecific.pas

@@ -30,7 +30,7 @@ type
     ['{87EE7482-8D8B-4593-85B7-B5B286B43195}']
     ['{87EE7482-8D8B-4593-85B7-B5B286B43195}']
 
 
     function GetApplicationTag: Int32;
     function GetApplicationTag: Int32;
-    function GetLengthOfHeader(data: TCryptoLibByteArray): Int32;
+    function GetLengthOfHeader(const data: TCryptoLibByteArray): Int32;
 
 
     function isConstructed(): Boolean;
     function isConstructed(): Boolean;
     function GetContents(): TCryptoLibByteArray;
     function GetContents(): TCryptoLibByteArray;

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