Browse Source

minor code cleanup

Ugochukwu Mmaduekwe 6 years ago
parent
commit
0abdb0dbcc

+ 1 - 7
src/libraries/cryptolib4pascal/ClpIESCipher.pas

@@ -92,8 +92,7 @@ type
       inputOffset, inputLen: Int32; const output: TCryptoLibByteArray;
       outputOffset: Int32): Int32; overload;
 
-    constructor Create(const Engine: IIESEngine); overload;
-    constructor Create(const Engine: IIESEngine; ivLength: Int32); overload;
+    constructor Create(const Engine: IIESEngine; ivLength: Int32 = 0);
     destructor Destroy(); override;
 
   end;
@@ -109,11 +108,6 @@ begin
   FBuffer.Read(Result[0], FBuffer.Size);
 end;
 
-constructor TIESCipher.Create(const Engine: IIESEngine);
-begin
-  Create(Engine, 0);
-end;
-
 constructor TIESCipher.Create(const Engine: IIESEngine; ivLength: Int32);
 begin
   Inherited Create();

+ 6 - 6
src/libraries/cryptolib4pascal/ClpIESEngine.pas

@@ -65,6 +65,8 @@ type
   TIESEngine = class(TInterfacedObject, IIESEngine)
 
   strict private
+  var
+    Fparam: IIESParameters;
 
     // as described in Shroup's paper( ch 10, pg 20) and P1363a
     function GetLengthTag(const p2: TCryptoLibByteArray)
@@ -82,20 +84,20 @@ type
     Fkdf: IDerivationFunction;
     Fmac: IMac;
     Fcipher: IBufferedBlockCipher;
-    FmacBuf, FV, FIV: TCryptoLibByteArray;
+    FV, FIV: TCryptoLibByteArray;
     FforEncryption: Boolean;
     FprivParam, FpubParam: ICipherParameters;
-    Fparam: IIESParameters;
     FkeyPairGenerator: IEphemeralKeyPairGenerator;
     FkeyParser: IKeyParser;
 
     function GetCipher: IBufferedBlockCipher; inline;
     function GetMac: IMac; inline;
+    procedure SetupBlockCipherAndMacKeyBytes(out K1,
+      K2: TCryptoLibByteArray); inline;
+
     function EncryptBlock(const &in: TCryptoLibByteArray; inOff, inLen: Int32)
       : TCryptoLibByteArray; virtual;
 
-    procedure SetupBlockCipherAndMacKeyBytes(out K1,
-      K2: TCryptoLibByteArray); inline;
     function DecryptBlock(const in_enc: TCryptoLibByteArray;
       inOff, inLen: Int32): TCryptoLibByteArray; virtual;
 
@@ -251,7 +253,6 @@ begin
   Fagree := agree;
   Fkdf := kdf;
   Fmac := mac;
-  System.SetLength(FmacBuf, mac.GetMacSize);
   Fcipher := Nil;
 end;
 
@@ -263,7 +264,6 @@ begin
   Fagree := agree;
   Fkdf := kdf;
   Fmac := mac;
-  System.SetLength(FmacBuf, mac.GetMacSize);
   Fcipher := cipher;
 end;
 

+ 1 - 1
src/libraries/cryptolib4pascal/ClpPascalCoinIESEngine.pas

@@ -208,7 +208,7 @@ begin
   // [1] := Convert Byte(Length(T)) to a ByteArray,
   // [2] and [3] := Convert UInt16(MessageToEncryptSize) to a ByteArray,
   // [4] and [5] := Convert UInt16(MessageToEncryptSize + MessageToEncryptPadSize) to a ByteArray,
-  // V := Ephermeral Public Key
+  // V := Ephemeral Public Key
   // T := Authentication Message (MAC)
   // C := Encrypted Payload