habe es nun wie folgt:
Delphi-Quellcode:
type
Tkey128 = Array [1 .. 176] Of Byte;
Function Taes.Expandkey(Var Key: Tinput; Var Expandedkey: Tkey128): Byte;
//expands given key (128,192,256 bit, determined by bitlen variable) to (176,208,240 bytes)
//blocksize=16=>keysize 128 bit
//result:= the number of rounds (10,12,14) determined by new keylength
//SRC= http://www.samiam.org/key-schedule.html
//http://cboard.cprogramming.com/c-programming/87805-%5Btutorial%5D-implementing-advanced-encryption-standard.html
Var
I, Rconiterator, A, C: Integer;
Temp: Tword;
Begin
I := 1;
While I <= Length(Key) Do
Begin
Expandedkey[I] := Key[I];
Inc(I);
End;
Rconiterator := 1;
C := 17;
While C <= 176 Do
Begin
{ Copy the temporary variable over from the last 4-byte- block }
A := 1;
While A <= 4 Do
Begin
//showmessage(inttostr(a)+';'+inttostr(c));
Temp[A] := Expandedkey[A + C - 4];
Inc(A);
End;
//Every four blocks (of four bytes) run keyschedule_core
If C Mod 16 = 0 Then
Begin
Keyschedule_core(Temp, Rconiterator, 0);
Inc(Rconiterator);
End;
A := 1;
While A <= 4 Do
Begin
Expandedkey[C] := Expandedkey[C - 16] Xor Temp[A];
Inc(C);
Inc(A);
End;
End;
Result := 11; //number of rounds for 128 bit keys
End;
hier von diesem code generierte output (expanded key) für input
00 00 00 00
00 00 00 00
00 00 00 00
00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 58 00 00 58 00 00 58 00 58 58 00 58 0E
00 58 0E C2 58 0E 9A 0E 0E C2 0E 53 9A 0E 0B 7A
0E 53 74 C7 0B 7A 5D 0E 74 9F 00 53 05 0E 58 2A
00 0B 5E C7 00 24 9A B6 50 05 B6 53 00 B8 0B 0A
B8 00 54
CC 00 70 56 B6 20 53 00 EB 53 B8 E0 F4
00 E0 A0
CC E0 D0 9A B6 F0 C9 B6 13 9A 0E F3 B4
0E 13 14 98 F3 C4 02 96 34 CB 20 65 51 2E 96 B4
20 85 A0 98 76 64 9A 96 50 51 B6 D5 00 98 43 7E
B8 C6 DE 28 B0 BA B2 96 EA E3 20 D5 E3 B8 96 B4
00 50 6A 98 E0 D0 2A F2 3A C9 D2 F5 2A 6A 63 8C
laut
http://www.samiam.org/key-schedule.html sollte der key allerdings lauten (ich hoffe das stimmt)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
62 63 63 63 62 63 63 63 62 63 63 63 62 63 63 63
9b 98 98 c9 f9
fb fb aa 9b 98 98 c9 f9
fb fb aa
90 97 34 50 69 6c cf fa f2 f4 57 33 0b 0f ac 99
ee 06 da 7b 87 6a 15 81 75 9e 42 b2 7e 91 ee 2b
7f 2e 2b 88 f8 44 3e 09 8d da 7c bb f3 4b 92 90
ec 61 4b 85 14 25 75 8c 99 ff 09 37 6a b4 9b a7
21 75 17 87 35 50 62 0b ac af 6b 3c c6 1b f0 9b
0e f9 03 33 3b a9 61 38 97 06 0a 04 51 1d fa 9f
b1 d4 d8 e2 8a 7d b9 da 1d 7b b3 de 4c 66 49 41
b4 ef 5b cb 3e 92 e2 11 23 e9 51 cf 6f 8f 18 8e