AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Algorithmen, Datenstrukturen und Klassendesign Advanced Encryption Standard 128 bit Eigenimplementierung - key schedule
Thema durchsuchen
Ansicht
Themen-Optionen

Advanced Encryption Standard 128 bit Eigenimplementierung - key schedule

Ein Thema von qwertz543221 · begonnen am 27. Dez 2012 · letzter Beitrag vom 7. Feb 2013
 
qwertz543221
(Gast)

n/a Beiträge
 
#5

AW: Advanced Encryption Standard 128 bit Eigenimplementierung - key schedule

  Alt 29. Dez 2012, 00:06
Habe es hinbekommen:

Delphi-Quellcode:
Function Taes.Expandkey(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;
  { inc(i);
    while i<=length(expandedkey) do
    begin
    expandedkey[i]:=0;
    inc(i);
    end; }


  Rconiterator := 1;

  C := Length(Key) + 1; //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 - 5]; //ok
      Inc(A);
    End;
    //Every four blocks (of four bytes) do a complex calculation
    If ((C - 1) Mod 16 = 0) Then
    Begin
      Keyschedule_core(Temp, Rconiterator, 0);
      Inc(Rconiterator);
    End;
    A := 1;
    While A <= 4 Do
    Begin
      //Expandedkey[C+1] := Expandedkey[C - 16] Xor Temp[A];
      Expandedkey[C] := Expandedkey[C - 16] Xor Temp[A];
      Inc(C);
      Inc(A);
    End;

  End;

  Result := 11; //number of rounds for 128 bit keys
End;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:53 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz