2 * COPYRIGHT (C) 1990 DIGITAL EQUIPMENT CORPORATION
5 * "Digital Equipment Corporation authorizes the reproduction,
6 * distribution and modification of this software subject to the following
9 * 1. Any partial or whole copy of this software, or any modification
10 * thereof, must include this copyright notice in its entirety.
12 * 2. This software is supplied "as is" with no warranty of any kind,
13 * expressed or implied, for any purpose, including any warranty of fitness
14 * or merchantibility. DIGITAL assumes no responsibility for the use or
15 * reliability of this software, nor promises to provide any form of
16 * support for it on any basis.
18 * 3. Distribution of this software is authorized only if no profit or
19 * remuneration of any kind is received in exchange for such distribution.
21 * 4. This software produces public key authentication certificates
22 * bearing an expiration date established by DIGITAL and RSA Data
23 * Security, Inc. It may cease to generate certificates after the expiration
24 * date. Any modification of this software that changes or defeats
25 * the expiration date or its effect is unauthorized.
27 * 5. Software that will renew or extend the expiration date of
28 * authentication certificates produced by this software may be obtained
29 * from RSA Data Security, Inc., 10 Twin Dolphin Drive, Redwood City, CA
30 * 94065, (415)595-8782, or from DIGITAL"
36 #include <sys/types.h>
39 #include "bigsignverify.h"
51 RSAKeyStorage public_key ;
52 RSAKeyStorage private_key ;
53 unsigned char bigbuf [2*DigitLim*sizeof(BigNumDigit)];
54 unsigned char testdata[]="Now is the time for all good men to come to the aid";
60 char usernameBuf [50], uidBuf [50], x500NameBuf[50], hashkey[50];
63 DESblock newkey1, newkey2;
65 time_t expires1, expires2;
70 printf("usage: %s name \n", argv[0]);
74 strcpy(usernameBuf, argv[1]);
76 memset(&keys,0,sizeof(keys));
78 if (read_privkey (usernameBuf, x500NameBuf, uidBuf, &uid_len, hashkey, &private_key)) {
79 printf("\nPrivate key read.");
80 PrintTestKey(&private_key);
83 printf("\nUnable to read private key for %s.\n", usernameBuf);
87 if (read_pubkey (usernameBuf, x500NameBuf, uidBuf, &uid_len, &public_key)){
88 printf("\nPublic key read.");
89 PrintTestKey(&public_key);
92 printf("\nUnable to read public key for %s.\n", usernameBuf);
96 if(!RSASign(testdata, sizeof(testdata), &private_key, bigbuf, &bigbuflen)) {
97 printf("\nError signing test data.\n");
101 printf("\nSigned Data:\n");
102 dumphex(bigbuf, bigbuflen);
104 if(!RSAVerify(testdata, sizeof(testdata), &public_key, bigbuf, bigbuflen)) {
105 printf("\nError verifying signature.\n");
108 printf("\nSignature verifies.\n");
111 printf("\nCurrent time: %s", ctime(&expires1));
112 expires1 += (time_t) 60; /* one minute */
114 InitAuthenticationKey ( &private_key, &public_key, &newkey1, bigbuf,
115 &bigbuflen, expires1);
117 printf("\nNew generated key:\n");
118 dumphex(&newkey1, sizeof(DESblock));
119 printf("\nExpires %s", ctime(&expires1));
120 printf("\nEncrypted key (length %d):\n", bigbuflen);
121 dumphex(bigbuf, bigbuflen);
123 if (AcceptAuthenticationKey (&private_key, &newkey2, bigbuf, bigbuflen, &expires2)) {
124 printf("\nRecovered key:\n");
125 dumphex(&newkey1, sizeof(DESblock));
126 printf("\nExpires %s", ctime(&expires2));
129 printf("\nRecovery of key failed.\n");