]> andersk Git - moira.git/blob - util/gdss/gdss_test.c
Remove incorrect krb_get_lrealm() prototype.
[moira.git] / util / gdss / gdss_test.c
1 /*
2  * Test program for GDSS.
3  *
4  */
5
6 #include <krb.h>
7 #include <gdss.h>
8
9 char TestMessage[] = "This is a test message. This is only a test.";
10
11 unsigned char OldSig[] = { 0x44, 0x6a, 0x69, 0x73, 0x20, 0x21, 0x20,
12 0x21, 0x41, 0x54, 0x48, 0x45, 0x4e, 0x41, 0x2e, 0x4d, 0x49, 0x54,
13 0x2e, 0x45, 0x44, 0x55, 0x20, 0x21, 0x2a, 0x13, 0x28, 0x97, 0x2b,
14 0x47, 0xad, 0xcc, 0xb0, 0xe1, 0x11, 0x71, 0xc1, 0x48, 0xa5, 0xd1,
15 0x1e, 0xa6, 0x20, 0x20, 0x97, 0x3d, 0xcb, 0x73, 0xf3, 0x63, 0x52,
16 0x3b, 0x2c, 0x7f, 0x05, 0x30, 0xe0, 0x03, 0x75, 0x9e, 0x0c, 0xa7,
17 0xdc, 0xf2, 0x41, 0x89, 0x95, 0xb1, 0x4e, 0xe1, 0x11, 0xba, 0x05,
18 0x39, 0xd1, 0xf1, 0x74, 0x96, 0x7f, 0xa2, 0xaf, 0x40, 0xc3, 0x70,
19 0x5a, 0x39, 0xa0, 0xce, 0x8a, 0xfd, 0x1c, 0xed, 0xcc, 0x00 };
20
21 main(argc, argv)
22 int argc;
23 char **argv;
24 {
25   char Signature[1000];
26   int status;
27   SigInfo aSigInfo;
28
29   printf("Performing Test Signature....");
30   status = GDSS_Sign(TestMessage, strlen(TestMessage), Signature);
31   if (status != GDSS_SUCCESS) {
32     printf("FAILED\n");
33     if (status == GDSS_E_TIMEDOUT)
34       printf("Signature Server Request timed out (is it running?)!\n");
35     else printf("GDSS_Sign Error number: %d\n", status);
36     exit (1);
37   } else {
38     printf("SUCCESS\n");
39   }
40
41   memset(&aSigInfo, 0, sizeof(aSigInfo));
42
43   printf("Attempting to Verify signature...");
44   status = GDSS_Verify(TestMessage, strlen(TestMessage), Signature,
45                        &aSigInfo);
46   if (status != GDSS_SUCCESS) {
47     printf("FAILED\n");
48     printf("GDSS_Verify Error number: %d\n", status);
49     exit (1);
50   } else {
51     printf("SUCCESS\n");
52     printf("Signature by: %s.%s@%s at %s\n",
53            aSigInfo.pname, aSigInfo.pinst, aSigInfo.prealm,
54            ctime(&aSigInfo.timestamp));
55   }
56
57   printf("Purposely damaging data...test: ");
58
59   TestMessage[0] = 'S';
60
61   status = GDSS_Verify(TestMessage, strlen(TestMessage), Signature,
62                        &aSigInfo);
63   if (status == GDSS_SUCCESS) {
64     printf("FAILED\n");
65     printf("Signature succeeded when it should *not* have!\n");
66     exit (1);
67   } else if (status != GDSS_E_BADSIG) {
68     printf("FAILED\n");
69     printf("Signature failed, but returned error code %d\n", status);
70     exit (1);
71   } else {
72     printf("PASSED\n");
73   }
74
75   printf("Fixing data...\n");
76
77   TestMessage[0] = 'T';
78
79   printf("Attempting to Verify signature...");
80   status = GDSS_Verify(TestMessage, strlen(TestMessage), Signature,
81                        &aSigInfo);
82   if (status != GDSS_SUCCESS) {
83     printf("FAILED\n");
84     printf("GDSS_Verify Error number: %d\n", status);
85     exit (1);
86   } else {
87     printf("SUCCESS\n");
88     printf("Signature by: %s.%s@%s at %s\n",
89            aSigInfo.pname, aSigInfo.pinst, aSigInfo.prealm,
90            ctime(&aSigInfo.timestamp));
91   }
92
93   printf("Testing Builtin Signature...\n");
94
95   printf("Attempting to Verify signature...");
96
97   status = GDSS_Verify(TestMessage, strlen(TestMessage), OldSig,
98                        &aSigInfo);
99   if (status != GDSS_SUCCESS) {
100     printf("FAILED\n");
101     printf("GDSS_Verify Error number: %d\n", status);
102     exit (1);
103   } else {
104     printf("SUCCESS\n");
105     printf("Signature by: %s.%s@%s at %s\n",
106            aSigInfo.pname, aSigInfo.pinst, aSigInfo.prealm,
107            ctime(&aSigInfo.timestamp));
108   }
109
110   printf("All Test Passed.\n");
111   exit (0);
112 }
113
114
115
116
117
118
This page took 0.04348 seconds and 5 git commands to generate.