Andreas Software - Source Code - LEA256Test.DPR

A simple test for my implementation of the block cipher LEA-256 for Embarcadero Delphi

program LEA256Test;

{
  A simple test for my implementation of the block cipher LEA-256 for Embarcadero Delphi.

  Original Author: Andreas Jonsson. (www.andreas-software.com)

  NOTICE: YOU MAY USE AND MODIFY THIS SOURCE CODE FREELY, THE ONLY REQUIREMENT IS THAT THE COMMENT ABOUT THE ORIGINAL AUTHOR AND THIS NOTICE REMAINS IN THE SOURCE CODE.
}

{$APPTYPE CONSOLE}

uses
  System.SysUtils, System.Variants, System.Classes,
  LEA256;

procedure Main();
var Keys: TLEA256Keys;
var Block: TLEA256Block;
var Context: TLEA256Context;
begin
  Keys[0] := $3C2D1E0F;
  Keys[1] := $78695A4B;
  Keys[2] := $B4A59687;
  Keys[3] := $F0E1D2C3;
  Keys[4] := $C3D2E1F0;
  Keys[5] := $8796A5B4;
  Keys[6] := $4B5A6978;
  Keys[7] := $0F1E2D3C;
  Block[0] := $33323130;
  Block[1] := $37363534;
  Block[2] := $3B3A3938;
  Block[3] := $3F3E3D3C;
  LEA256_Initialize(Context, Keys);
  LEA256_Encrypt(Context, Block);
  if (Block[0] = $F6AF51D6) and (Block[1] = $C189B147) and (Block[2] = $CA00893A) and (Block[3] = $97E1F927) then begin
    WriteLn('Encrypt = OK.');
  end
  else begin
    WriteLn('Encrypt = N/A.');
  end;
  LEA256_Decrypt(Context, Block);
  if (Block[0] = $33323130) and (Block[1] = $37363534) and (Block[2] = $3B3A3938) and (Block[3] = $3F3E3D3C) then begin
    WriteLn('Decrypt = OK.');
  end
  else begin
    WriteLn('Decrypt = N/A.');
  end;
  LEA256_Burn(Context);
end;

begin
  Main;
end.

⎙ Print LEA256Test.DPR

You can also view the source code as plain text, LEA256Test.DPR.TXT.

The source code is related to LEA256.PAS, LEA256CTR.PAS and LEA256CTRSpeedTest.DPR.

www.andreas-software.com

Copyright © 1998-2021, Andreas Jönsson. All rights reserved.

In Swedish?
View this page in Swedish