1-- This program is free software; you can redistribute it and/or 2-- modify it under the terms of the GNU General Public License as 3-- published by the Free Software Foundation; either version 2 of the 4-- License, or (at your option) any later version. 5 6-- This program is distributed in the hope that it will be useful, 7-- but WITHOUT ANY WARRANTY; without even the implied warranty of 8-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 9-- General Public License for more details. 10 11-- You should have received a copy of the GNU General Public License 12-- along with this program; if not, write to the Free Software 13-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 14-- 02111-1307, USA. 15 16-- As a special exception, if other files instantiate generics from 17-- this unit, or you link this unit with other files to produce an 18-- executable, this unit does not by itself cause the resulting 19-- executable to be covered by the GNU General Public License. This 20-- exception does not however invalidate any other reasons why the 21-- executable file might be covered by the GNU Public License. 22 23with Crypto.Types; use Crypto.Types; 24with Crypto.Symmetric.Blockcipher_TripleDES; 25with Crypto.Symmetric.Mode.CBC; 26with Crypto.Symmetric.Mode.OFB; 27with Crypto.Symmetric.Mode.CFB; 28with Crypto.Symmetric.Mode.CTR; 29 30with Ada.Text_IO; use Ada.Text_IO; 31 32procedure E is 33 34 package DIO is new Ada.Text_Io.Modular_IO (DWord); 35 36 package TDES renames Crypto.Symmetric.Blockcipher_TripleDES; 37 package TDES_CBC is new Crypto.Symmetric.Mode.CBC(TDES); 38 package TDES_OFB is new Crypto.Symmetric.Mode.OFB(TDES); 39 package TDES_CFB is new Crypto.Symmetric.Mode.CFB(TDES); 40 package TDES_CTR is new Crypto.Symmetric.Mode.CTR(TDES); 41 42 use TDES_CBC; 43 44 TDES_KEY : B_Block192 := (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 45 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 46 16#00#, 16#00#, 16#00#, 16#00#, 16#A0#, 16#23#, 47 16#15#, 16#67#, 16#89#, 16#ab#, 16#ad#, 16#ef#); 48 49 IV_TDES : B_Block64 := 50 (16#12#, 16#34#, 16#56#, 16#78#, 16#90#, 16#ab#, 16#cd#, 16#ef#); 51 52 P_TDES_String : String :="All your base are belong to us!"; 53 P_TDES : array (1..3) of B_Block64 := 54 ((To_Bytes(P_TDES_String(1..8))), 55 (To_Bytes(P_TDES_String(9..16))), 56 (To_Bytes(P_TDES_String(17..24)))); 57 58 C_TDES : array (0..3) of B_Block64; 59 60begin 61 62 --Initialisierung 63 Init(TDES_KEY, IV_TDES); 64 65 -- 1. Chiffreblock = Startwert. 66 C_TDES(0) := IV_TDES; 67 68 --Verschluesselung 69 for I in P_TDES'Range loop 70 Encrypt(P_TDES(I), C_TDES(I)); 71 end loop; 72 73 -- Fuer die Entschluesselung wird die Chiffre mit dem 74 -- gleichen Startwert wie bei der Entschluesselung reinitalisiert 75 Set_IV(C_TDES(0)); 76 77 for I in P_TDES'Range loop 78 P_TDES(I) := (others => 0); 79 Decrypt(C_TDES(I), P_TDES(I)); 80 Put(To_String(P_TDES(I))); 81 end loop; 82end E; 83