Skip to content

Commit 4fb625c

Browse files
committed
Worked on some ToDo comments
1 parent ef39da3 commit 4fb625c

File tree

2 files changed

+161
-171
lines changed

2 files changed

+161
-171
lines changed

Source/DECCipherModesGCM.pas

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ TGCM = class(TObject)
334334

335335
implementation
336336

337+
type
338+
T16ByteArray = array[0..15] of Byte;
339+
P16ByteArray = ^T16ByteArray;
340+
337341
function TGCM.XOR_T128(const x, y : T128): T128;
338342
begin
339343
Result[0] := x[0] xor y[0];
@@ -405,11 +409,11 @@ procedure TGCM.GenerateTableM8Bit(const H : T128);
405409
var
406410
hbit, hbyte, i, j : integer;
407411
HP : T128;
408-
{ TODO : change to a pointer to HP[0], to get rid of the absolute? }
409-
bHP : array[0..15] of byte absolute HP[0];
412+
bHP : P16ByteArray;
410413
mask : byte;
411414
begin
412415
HP := H;
416+
bHP := @HP[0];
413417
for hbyte := 0 to 15 do
414418
begin
415419
mask := 128;
@@ -464,9 +468,10 @@ procedure TGCM.SetAuthenticationTagLength(const Value: UInt32);
464468

465469
procedure TGCM.INCR(var Y : T128);
466470
var
467-
{ TODO : change to a pointer to Y[0], to get rid of the absolute? }
468-
bY : array[0..15] of byte absolute Y[0];
471+
bY : P16ByteArray;
469472
begin
473+
bY := @Y[0];
474+
470475
{$IFOPT Q+}{$DEFINE RESTORE_OVERFLOWCHECKS}{$Q-}{$ENDIF}
471476
{$Q-}
472477
inc(bY[15]);
@@ -541,15 +546,10 @@ function TGCM.CalcGaloisHash(AuthenticatedData, Ciphertext : TBytes): T128;
541546
div_d := len_d div 16;
542547
if div_d > 0 then
543548
begin
544-
{ TODO : When 6.5 is started the while should be replaced by the for loop again }
545-
// for i := 0 to div_d-1 do
546-
i := 0;
547-
while (i <= div_d-1) do
549+
for i := 0 to div_d-1 do
548550
begin
549551
x := poly_mult_H(XOR_PointerWithT128(@data[n], x ));
550552
inc(n, 16);
551-
{ TODO : Remove the inc when 6.5 implementation starts }
552-
inc(i);
553553
end;
554554
end;
555555

@@ -580,16 +580,11 @@ procedure TGCM.DecodeGCM(Source, Dest: TBytes; Size: Integer);
580580
i := 0;
581581
BlockCount := Size div 16;
582582

583-
{ TODO : When 6.5 is started the while should be replaced by the for loop again }
584-
// for j := 1 to BlockCount do
585-
j := 1;
586-
while (j <= BlockCount) do
583+
for j := 1 to BlockCount do
587584
begin
588585
INCR(FY);
589586
P128(@Dest[i])^ := XOR_PointerWithT128(@Source[i], EncodeT128(FY));
590587
inc(i, 16);
591-
{ TODO : Remove the inc when 6.5 implementation starts }
592-
inc(j);
593588
end;
594589

595590
if i < Size then
@@ -622,18 +617,13 @@ procedure TGCM.EncodeGCM(Source, Dest: TBytes; Size: Integer);
622617
i := 0;
623618
div_len_plain := Size div 16;
624619

625-
{ TODO : When 6.5 is started the while should be replaced by the for loop again }
626-
// for j := 1 to div_len_plain do
627-
j := 1;
628-
while (j <= div_len_plain) do
620+
for j := 1 to div_len_plain do
629621
begin
630622
INCR(FY);
631623

632624
P128(@Dest[i])^ := XOR_PointerWithT128(@Source[i], EncodeT128(FY));
633625

634626
inc(i,16);
635-
{ TODO : Remove the inc when 6.5 implementation starts }
636-
inc(j);
637627
end;
638628

639629
if i < Size then

0 commit comments

Comments
 (0)