Browse Source

consistency fix.

Ugochukwu Mmaduekwe 7 years ago
parent
commit
aa846390db

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

@@ -36,8 +36,8 @@ type
   public
 
     const
-    Der = 'DER';
-    Ber = 'BER';
+    Der: String = 'DER';
+    Ber: String = 'BER';
 
     function GetEncoded(): TCryptoLibByteArray; overload;
     function GetEncoded(const encoding: String): TCryptoLibByteArray; overload;

+ 1 - 1
CryptoLib/src/Asn1/CryptoPro/ClpCryptoProObjectIdentifiers.pas

@@ -94,7 +94,7 @@ type
     const
     // GOST Algorithms OBJECT IDENTIFIERS :
     // { iso(1) member-body(2) ru(643) rans(2) cryptopro(2)}
-    GostID = '1.2.643.2.2';
+    GostID: String = '1.2.643.2.2';
 
     class property GostR3411: IDerObjectIdentifier read GetGostR3411;
     class property GostR3411Hmac: IDerObjectIdentifier read GetGostR3411Hmac;

+ 1 - 1
CryptoLib/src/Asn1/Pkcs/ClpPkcsObjectIdentifiers.pas

@@ -34,7 +34,7 @@ type
     //
     // object identifiers for digests
     //
-    DigestAlgorithm = '1.2.840.113549.2';
+    DigestAlgorithm: String = '1.2.840.113549.2';
 
     class var
 

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

@@ -37,7 +37,7 @@ type
     //
   const
 
-    AnsiX962 = '1.2.840.10045';
+    AnsiX962: String = '1.2.840.10045';
 
     class var
 

+ 2 - 1
CryptoLib/src/Math/EC/ClpLongArray.pas

@@ -433,7 +433,8 @@ type
       Int64($0102040810204081));
 
     // For toString(); must have length 64
-    ZEROES = '0000000000000000000000000000000000000000000000000000000000000000';
+    ZEROES: String =
+      '0000000000000000000000000000000000000000000000000000000000000000';
 
 {$ENDREGION}
 

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

@@ -34,7 +34,7 @@ type
   TFixedPointUtilities = class sealed(TObject)
   strict private
   const
-    PRECOMP_NAME = 'bc_fixed_point';
+    PRECOMP_NAME: String = 'bc_fixed_point';
 
   public
     class function GetCombSize(const c: IECCurve): Int32; static; inline;

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

@@ -64,7 +64,7 @@ type
   public
 
     const
-    PRECOMP_NAME = 'bc_wnaf';
+    PRECOMP_NAME: String = 'bc_wnaf';
 
     class function GenerateCompactNaf(const k: TBigInteger)
       : TCryptoLibInt32Array; static;

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

@@ -48,7 +48,7 @@ type
   strict private
     // TODO Create WTauNafUtilities class and move various functionality into it
   const
-    PRECOMP_NAME = 'bc_wtnaf';
+    PRECOMP_NAME: String = 'bc_wtnaf';
 
     // /**
     // * Multiplies an AbstractF2mPoint

+ 13 - 7
CryptoLib/src/Utils/ClpConverters.pas

@@ -35,6 +35,9 @@ uses
   ClpBits,
   ClpBitConverter;
 
+resourcestring
+  SEncodingInstanceNil = 'Encoding Instance Cannot Be Nil';
+
 type
   TConverters = class sealed(TObject)
 
@@ -110,10 +113,8 @@ type
     class procedure ReadUInt64AsBytesBE(a_in: UInt64;
       a_out: TCryptoLibByteArray; a_index: Int32); overload; static; inline;
 
-    class function ConvertStringToBytes(const a_in:
-{$IFDEF FPC}UnicodeString{$ELSE} String
-{$ENDIF FPC}; a_encoding: TEncoding): TCryptoLibByteArray; overload;
-      static; inline;
+    class function ConvertStringToBytes(const a_in: String;
+      a_encoding: TEncoding): TCryptoLibByteArray; overload; static; inline;
 
     class function ConvertHexStringToBytes(a_in: String): TCryptoLibByteArray;
       static; inline;
@@ -468,10 +469,15 @@ begin
 
 end;
 
-class function TConverters.ConvertStringToBytes(const a_in:
-{$IFDEF FPC}UnicodeString{$ELSE} String
-{$ENDIF FPC}; a_encoding: TEncoding): TCryptoLibByteArray;
+class function TConverters.ConvertStringToBytes(const a_in: String;
+  a_encoding: TEncoding): TCryptoLibByteArray;
 begin
+
+  if a_encoding = Nil then
+  begin
+    raise EArgumentNilCryptoLibException.CreateRes(@SEncodingInstanceNil);
+  end;
+
   result := a_encoding.GetBytes(a_in);
 end;
 

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

@@ -206,4 +206,14 @@ type
 
 implementation
 
+{$IFDEF FPC}
+
+initialization
+
+// Set UTF-8 in AnsiStrings, just like Lazarus
+SetMultiByteConversionCodePage(CP_UTF8);
+// SetMultiByteFileSystemCodePage(CP_UTF8); not needed, this is the default under Windows
+SetMultiByteRTLFileSystemCodePage(CP_UTF8);
+{$ENDIF FPC}
+
 end.