1with AUnit.Assertions;
2with Crypto.Asymmetric.ECDSA;
3
4pragma Elaborate_All (Crypto.Asymmetric.ECDSA);
5
6package body Test.ECDSA is
7
8   --------------------------------------------------------------------------
9   -------------------------- Type - Declaration ----------------------------
10   --------------------------------------------------------------------------
11
12   package ECDSA is new  Crypto.Asymmetric.ECDSA(544);
13   use ECDSA;
14
15    Public_Key  : Public_Key_ECDSA;
16    Private_Key : Private_Key_ECDSA;
17    Signature   : Signature_ECDSA;
18
19
20    -------------------------------------------------------------------------
21    ------------------------ Register ECDSA Test 1 --------------------------
22    -------------------------------------------------------------------------
23
24
25	procedure Register_Tests(T : in out ECDSA_Test) is
26	   use Test_Cases.Registration;
27	begin
28	   Register_Routine(T, ECDSA_Test1'Access,"ECDSA_Test1.");
29	   Register_Routine(T, ECDSA_Test2'Access,"ECDSA_Test2.");
30	end Register_Tests;
31
32
33	-----------------------------------------------------------------------------
34	------------------------------ Name ECDSA Test ------------------------------
35	-----------------------------------------------------------------------------
36	-----------------------------------------------------------------------------
37
38	function Name(T : ECDSA_Test) return Test_String is
39	begin
40	   return new String'("ECDSA Test");
41	end Name;
42
43------------------------------------------------------------------------------------
44------------------------------------------------------------------------------------
45------------------------------------ Start Tests -----------------------------------
46------------------------------------------------------------------------------------
47-------------------------------------- Test 1 --------------------------------------
48------------------------------------------------------------------------------------
49
50   procedure ECDSA_Test1(T : in out Test_Cases.Test_Case'Class) is
51      use AUnit.Assertions;
52   begin
53      Gen_Public_Key(Public_Key, 192);
54      Gen_Private_Key(Public_Key, Private_Key);
55      Sign_File("hash_message2.txt", Public_Key, Private_Key, Signature);
56
57      Assert(Verify_File("hash_message2.txt", Public_Key, Signature), "Verifying File with ECDSA failed.");
58      Assert(Verify_Key_Pair(Private_Key, Public_Key), "Verifying Key Pair with ECDSA failed.");
59
60   end ECDSA_Test1;
61
62------------------------------------------------------------------------------------
63-------------------------------------- Test 2 --------------------------------------
64------------------------------------------------------------------------------------
65
66   procedure ECDSA_Test2(T : in out Test_Cases.Test_Case'Class) is
67      use AUnit.Assertions;
68   begin
69      Gen_Public_Key(Public_Key, 192);
70      Gen_Private_Key(Public_Key, Private_Key);
71
72      Sign_File("hash_message5.txt", Public_Key, Private_Key, Signature);
73
74      Assert(Verify_File("hash_message5.txt", Public_Key, Signature), "Verifying File with ECDSA failed.");
75      Assert(Verify_Key_Pair(Private_Key, Public_Key), "Verifying Key Pair with ECDSA failed.");
76
77   end ECDSA_Test2;
78
79------------------------------------------------------------------------------------
80
81end Test.ECDSA;
82