Browse Source

fix overflow bug in test.

Ugochukwu Mmaduekwe 7 years ago
parent
commit
b3216c0c36
1 changed files with 3 additions and 4 deletions
  1. 3 4
      CryptoLib.Tests/src/Security/SecureRandomTests.pas

+ 3 - 4
CryptoLib.Tests/src/Security/SecureRandomTests.pas

@@ -82,8 +82,7 @@ function TTestSecureRandom.MeasureChiSquared(const random: ISecureRandom;
 var
 var
   opts, bs: TCryptoLibByteArray;
   opts, bs: TCryptoLibByteArray;
   counts: TCryptoLibInt32Array;
   counts: TCryptoLibInt32Array;
-  I, b, total, k: Integer;
-  mask, shift: Byte;
+  I, b, total, k, mask, shift: Int32;
   chi2, diff, diff2, temp: Double;
   chi2, diff, diff2, temp: Double;
 begin
 begin
   opts := random.GenerateSeed(2);
   opts := random.GenerateSeed(2);
@@ -115,7 +114,7 @@ begin
     for b := 0 to System.Pred(256) do
     for b := 0 to System.Pred(256) do
     begin
     begin
 
 
-      counts[bs[b] xor mask] := counts[bs[b] xor mask] + 1;
+      counts[bs[b] xor Byte(mask)] := counts[bs[b] xor Byte(mask)] + 1;
 
 
     end;
     end;
     System.Inc(mask);
     System.Inc(mask);
@@ -132,7 +131,7 @@ begin
     for b := 0 to System.Pred(256) do
     for b := 0 to System.Pred(256) do
     begin
     begin
 
 
-      counts[Byte(bs[b] + shift)] := counts[Byte(bs[b] + shift)] + 1;
+      counts[Byte(bs[b] + Byte(shift))] := counts[Byte(bs[b] + Byte(shift))] + 1;
 
 
     end;
     end;
     System.Inc(shift);
     System.Inc(shift);