raw
eucrypt_ch11_serpent    1 -------------------------------------------------------------------------------
eucrypt_ch11_serpent 2 -- S.MG, 2018; with added automated tests
eucrypt_ch11_serpent 3 --
eucrypt_ch11_serpent 4 -- Serpent Blockcipher
eucrypt_ch11_serpent 5 --
eucrypt_ch11_serpent 6 -- Copyright (c) 1998 Markus G. Kuhn <mkuhn@acm.org>. All rights reserved.
eucrypt_ch11_serpent 7 --
eucrypt_ch11_serpent 8 -- $Id: serpent.ads,v 1.2 1998-06-10 14:22:16+00 mgk25 Exp $
eucrypt_ch11_serpent 9 --
eucrypt_ch11_serpent 10 -------------------------------------------------------------------------------
eucrypt_ch11_serpent 11 --
eucrypt_ch11_serpent 12 -- This is the Ada95 reference implementation of the Serpent cipher
eucrypt_ch11_serpent 13 -- submitted by Ross Anderson, Eli Biham and Lars Knudson in June 1998 to
eucrypt_ch11_serpent 14 -- the NIST Advanced Encryption Standard (AES) contest. Please note that
eucrypt_ch11_serpent 15 -- this is a revised algorithm that is not identical to the old version
eucrypt_ch11_serpent 16 -- presented at the 1998 Fast Software Encryption Workshop.
eucrypt_ch11_serpent 17 -- <http://www.cs.technion.ac.il/~biham/Reports/Serpent/>
eucrypt_ch11_serpent 18 --
eucrypt_ch11_serpent 19 -- Compiled with GNAT 3.10p under Linux, this implementation encrypts and
eucrypt_ch11_serpent 20 -- decrypts with 20.8 Mbit/s on a 300 MHz Pentium II.
eucrypt_ch11_serpent 21 --
eucrypt_ch11_serpent 22 -------------------------------------------------------------------------------
eucrypt_ch11_serpent 23
eucrypt_ch11_serpent 24 with Interfaces; use Interfaces;
eucrypt_ch11_serpent 25
eucrypt_ch11_serpent 26 package SMG_Serpent is
eucrypt_ch11_serpent 27
eucrypt_ch11_serpent 28 pragma Pure(SMG_Serpent);
eucrypt_ch11_serpent 29
eucrypt_ch11_serpent 30 type Bytes is array (Integer range <>) of Unsigned_8;
eucrypt_ch11_serpent 31 type Words is array (Integer range <>) of Unsigned_32;
eucrypt_ch11_serpent 32 subtype Block is Bytes (0 .. 15);
eucrypt_ch11_serpent 33 subtype Key is Bytes (0 .. 31);
eucrypt_ch11_serpent 34 subtype Key_Schedule is Words (-8 .. 131);
eucrypt_ch11_serpent 35
eucrypt_ch11_serpent 36 procedure Prepare_Key (K : in Key; W : out Key_Schedule);
eucrypt_ch11_serpent 37
eucrypt_ch11_serpent 38 procedure Encrypt (W : in Key_Schedule; Plaintext : in Block;
eucrypt_ch11_serpent 39 Ciphertext : out Block);
eucrypt_ch11_serpent 40
eucrypt_ch11_serpent 41 procedure Decrypt (W : in Key_Schedule; Ciphertext : in Block;
eucrypt_ch11_serpent 42 Plaintext : out Block);
eucrypt_ch11_serpent 43
eucrypt_ch11_serpent 44 procedure Selftest;
eucrypt_ch11_serpent 45
eucrypt_ch11_serpent 46 Implementation_Error : exception; -- raised if Selftest failed
eucrypt_ch11_serpent 47
eucrypt_ch11_serpent 48 end SMG_Serpent;