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"
46 int read_pubkey_messages = 0;
48 int read_pubkey_verbose (user,name,uid,uid_len,key)
54 int save = read_pubkey_messages, x;
55 read_pubkey_messages = 1;
56 x = read_pubkey (user,name,uid,uid_len,key);
57 read_pubkey_messages = save;
61 int read_pubkey (user,name,uid,uid_len,key)
68 static unsigned char buffer [MAX_KEY];
70 unsigned char *uptr = uid;
74 strcpy(tempname,user);
75 strcat(tempname,"_pubkey");
76 if((fp = fopen(tempname,"r")) == NULL) {
77 if (read_pubkey_messages)
78 printf("\n%s: can't open file %s.\n", __FILE__, tempname);
83 for(i=0,j=0;i<MAX_NAME;i++) {
84 if((c=getc(fp))==EOF) {
85 if (read_pubkey_messages)
86 printf("\nUnexpected end of file %s.\n",tempname);
89 switch (*ptr++ = (char)c){
91 case '}': j--; if (j==0) goto next; break;
92 case '\n': if(j==0){ptr--;goto next;} break;
97 if (read_pubkey_messages)
98 printf("\n%sIssuer name too long.\n", __FILE__);
104 printf("\n%s: name is %s",__FILE__,name);
108 for(i=0;i<MAX_UID;i++)
109 if(fscanf(fp,"%2x",&j)==1) *uptr++ =j; else break;
110 if(i==MAX_UID)return(0);
115 printf("\n%s: uid is ", __FILE__);
119 while(getc(fp)!=';');
120 for(i=0;i<MAX_KEY;i++)
121 if(fscanf(fp,"%2x",&j)==1) buffer[i]=j ;
124 if (read_pubkey_messages)
125 printf("\n%s: Length error reading public key buffer.\n",__FILE__);
129 printf("\n%s: Size of public key read is %d\n", __FILE__,i);
133 if(i=DecodePublic(buffer,key)) {
135 printf("\n%s: Recovered Key is\n",__FILE__);
141 if (read_pubkey_messages) printf("\n%s: Key decode failed.\n",__FILE__);