Parcourir la source

clean up some unneeded comments.

- add Clear() method for KeyParameter and ParameterWithIV
Ugochukwu Mmaduekwe il y a 6 ans
Parent
commit
b587292f8f

+ 1 - 1
CryptoLib/src/Crypto/Engines/ClpRijndaelEngine.pas

@@ -905,7 +905,7 @@ end;
 
 procedure TRijndaelEngine.Reset;
 begin
-
+  // nothing to do.
 end;
 
 end.

+ 0 - 1
CryptoLib/src/Crypto/Paddings/ClpPaddedBufferedBlockCipher.pas

@@ -322,7 +322,6 @@ begin
 
   if (leftOver = 0) then
   begin
-    // result := total - System.length(Fbuf);
     result := Max(0, total - System.length(Fbuf));
     Exit;
   end;

+ 0 - 17
CryptoLib/src/Crypto/Paddings/ClpPaddingModes.pas

@@ -532,23 +532,6 @@ var
   count, i: Int32;
   failed: Boolean;
 begin
-  // countAsByte := input[System.Length(input) - 1];
-  // count := countAsByte;
-  //
-  // if ((count < 1) or (count > System.Length(input))) then
-  // begin
-  // raise EInvalidCipherTextCryptoLibException.CreateRes(@SCorruptedPadBlock);
-  // end;
-  //
-  // for i := 2 to count do
-  // begin
-  // if (input[System.Length(input) - i] <> countAsByte) then
-  // begin
-  // raise EInvalidCipherTextCryptoLibException.CreateRes(@SCorruptedPadBlock);
-  // end;
-  // end;
-  //
-  // result := count;
 
   count := input[System.Length(input) - 1] and $FF;
   countAsByte := Byte(count);

+ 7 - 1
CryptoLib/src/Crypto/Parameters/ClpKeyParameter.pas

@@ -46,6 +46,7 @@ type
       keyOff, keyLen: Int32); overload;
     destructor Destroy; override;
     function GetKey(): TCryptoLibByteArray; inline;
+    procedure Clear(); inline;
 
   end;
 
@@ -64,6 +65,11 @@ begin
   Fkey := System.Copy(key);
 end;
 
+procedure TKeyParameter.Clear;
+begin
+  TArrayUtils.Fill(Fkey, 0, System.Length(Fkey), Byte(0));
+end;
+
 constructor TKeyParameter.Create(const key: TCryptoLibByteArray;
   keyOff, keyLen: Int32);
 begin
@@ -91,7 +97,7 @@ end;
 
 destructor TKeyParameter.Destroy;
 begin
-  TArrayUtils.Fill(Fkey, 0, System.Length(Fkey), Byte(0));
+  Clear();
   inherited Destroy;
 end;
 

+ 7 - 1
CryptoLib/src/Crypto/Parameters/ClpParametersWithIV.pas

@@ -49,6 +49,7 @@ type
     destructor Destroy; override;
     function GetIV(): TCryptoLibByteArray; inline;
     property parameters: ICipherParameters read GetParameters;
+    procedure Clear(); inline;
 
   end;
 
@@ -63,6 +64,11 @@ begin
   Create(parameters, iv, 0, System.Length(iv))
 end;
 
+procedure TParametersWithIV.Clear;
+begin
+  TArrayUtils.Fill(Fiv, 0, System.Length(Fiv), Byte(0));
+end;
+
 constructor TParametersWithIV.Create(const parameters: ICipherParameters;
   const iv: TCryptoLibByteArray; ivOff, ivLen: Int32);
 begin
@@ -79,7 +85,7 @@ end;
 
 destructor TParametersWithIV.Destroy;
 begin
-  TArrayUtils.Fill(Fiv, 0, System.Length(Fiv), Byte(0));
+  Clear();
   inherited Destroy;
 end;
 

+ 0 - 1
CryptoLib/src/Crypto/Signers/ClpECNRSigner.pas

@@ -167,7 +167,6 @@ begin
 
     tempPair := keyGen.GenerateKeyPair();
 
-    // BigInteger Vx := tempPair.getPublic().getW().getAffineX();
     V := tempPair.Public as IECPublicKeyParameters; // get temp's public key
     Vx := V.Q.AffineXCoord.ToBigInteger(); // get the point's x coordinate
 

+ 1 - 0
CryptoLib/src/Interfaces/ClpIKeyParameter.pas

@@ -31,6 +31,7 @@ type
     ['{92E7D4F7-40E5-4DC1-8058-23BE60848CC3}']
 
     function GetKey(): TCryptoLibByteArray;
+    procedure Clear();
 
   end;
 

+ 1 - 0
CryptoLib/src/Interfaces/ClpIParametersWithIV.pas

@@ -32,6 +32,7 @@ type
     function GetIV(): TCryptoLibByteArray;
     function GetParameters: ICipherParameters;
     property Parameters: ICipherParameters read GetParameters;
+    procedure Clear();
 
   end;