@@ -38,6 +38,15 @@ interface
3838 // / </summary>
3939 P128 = ^T128;
4040
41+ // / <summary>
42+ // / Array of 16 bytes
43+ // / </summary>
44+ T16ByteArray = array [0 ..15 ] of Byte;
45+ // / <summary>
46+ // / Pointer to an array of 16 bytes
47+ // / </summary>
48+ P16ByteArray = ^T16ByteArray;
49+
4150 // / <summary>
4251 // / A methopd of this type needs to be supplied for encrypting or decrypting
4352 // / a block via this GCM algorithm. The method is implemented as a parameter,
@@ -334,10 +343,6 @@ TGCM = class(TObject)
334343
335344implementation
336345
337- type
338- T16ByteArray = array [0 ..15 ] of Byte;
339- P16ByteArray = ^T16ByteArray;
340-
341346function TGCM.XOR_T128 (const x, y : T128): T128;
342347begin
343348 Result[0 ] := x[0 ] xor y[0 ];
@@ -353,9 +358,9 @@ function TGCM.XOR_PointerWithT128(const x : Pointer; y : T128): T128;
353358procedure TGCM.XOR_ArrayWithT128 (const x: TBytes; XIndex, Count: UInt64; y: T128; var Result: TBytes);
354359var
355360 i : integer;
356- { TODO : change to a pointer to y[0], to get rid of the absolute? }
357- by : array [0 ..15 ] of byte absolute y[0 ];
361+ by : P16ByteArray;
358362begin
363+ by := @y[0 ];
359364 for i := 0 to Count-1 do
360365 begin
361366 Result[XIndex] := x[XIndex] xor by[i];
@@ -366,9 +371,9 @@ procedure TGCM.XOR_ArrayWithT128(const x: TBytes; XIndex, Count: UInt64; y: T128
366371function TGCM.poly_mult_H (const hx : T128): T128;
367372var
368373 i : integer;
369- { TODO : change to a pointer to hx[0], to get rid of the absolute? }
370- x : array [0 ..15 ] of byte absolute hx[0 ];
374+ x : P16ByteArray;
371375begin
376+ x := @hx[0 ];
372377 Result := FM[0 , x[0 ]];
373378
374379 for i := 1 to 15 do
@@ -382,9 +387,9 @@ procedure TGCM.SetAuthenticationCipherLength(var x : T128;
382387 AuthDataLength, CipherTextLength : UInt64);
383388var
384389 i : integer;
385- { TODO : change to a pointer to x[0], to get rid of the absolute? }
386- hx : array [0 ..15 ] of byte absolute x[0 ];
390+ hx : P16ByteArray;
387391begin
392+ hx := @x[0 ];
388393 // al:
389394 x := nullbytes;
390395 i := 7 ;
@@ -450,10 +455,11 @@ procedure TGCM.GenerateTableM8Bit(const H : T128);
450455
451456procedure TGCM.ShiftRight (var rx : T128);
452457var
453- { TODO : change to a pointer to rx[0], to get rid of the absolute? }
454- x : array [0 ..15 ] of byte absolute rx[0 ];
458+ x : P16ByteArray;
455459 i : integer;
456460begin
461+ x := @rx[0 ];
462+
457463 for i := 15 downto 1 do
458464 x[i] := (x[i] shr 1 ) or ((x[i-1 ] and 1 ) shl 7 );
459465
@@ -648,16 +654,11 @@ function TGCM.GetAuthenticationTagBitLength: UInt32;
648654end ;
649655
650656function TGCM.GetStandardAuthenticationTagBitLengths : TStandardBitLengths;
651- const
652- BitLengths : array [0 ..4 ] of Uint16 = (96 , 104 , 112 , 120 , 128 );
653657var
654658 i : integer;
655659begin
656660 SetLength(Result, 5 );
657- { TODO: When 6.5 is started the array can be assigned directly again }
658- // Result := [96, 104, 112, 120, 128];
659- for i := 0 to high(BitLengths) do
660- result[i] := BitLengths[i];
661+ Result := [96 , 104 , 112 , 120 , 128 ];
661662end ;
662663
663664//
0 commit comments