1 #pragma lib "libauth.a" 2 3 typedef struct Ticket Ticket; 4 typedef struct Ticketreq Ticketreq; 5 typedef struct Authenticator Authenticator; 6 typedef struct Nvrsafe Nvrsafe; 7 typedef struct Passwordreq Passwordreq; 8 typedef struct Chalstate Chalstate; 9 10 enum 11 { 12 DOMLEN= 48, /* length of an authentication domain name */ 13 DESKEYLEN= 7, /* length of a des key for encrypt/decrypt */ 14 CHALLEN= 8, /* length of a challenge */ 15 NETCHLEN= 16, /* max network challenge length */ 16 CONFIGLEN= 14, 17 18 KEYDBLEN= NAMELEN+DESKEYLEN+4+2 19 }; 20 21 /* encryption numberings (anti-replay) */ 22 enum 23 { 24 AuthTreq=1, /* ticket request */ 25 AuthChal=2, /* challenge box request */ 26 AuthPass=3, /* change password */ 27 AuthMod=6, /* modify user */ 28 29 AuthOK=4, /* reply follows */ 30 AuthErr=5, /* error follows */ 31 32 AuthTs=64, /* ticket encrypted with server's key */ 33 AuthTc, /* ticket encrypted with client's key */ 34 AuthAs, /* server generated authenticator */ 35 AuthAc, /* client generated authenticator */ 36 }; 37 38 struct Ticketreq 39 { 40 char type; 41 char authid[NAMELEN]; /* server's encryption id */ 42 char authdom[DOMLEN]; /* server's authentication domain */ 43 char chal[CHALLEN]; /* challenge from server */ 44 char hostid[NAMELEN]; /* host's encryption id */ 45 char uid[NAMELEN]; /* uid of requesting user on host */ 46 }; 47 #define TICKREQLEN (3*NAMELEN+CHALLEN+DOMLEN+1) 48 49 struct Ticket 50 { 51 char num; /* replay protection */ 52 char chal[CHALLEN]; /* server challenge */ 53 char cuid[NAMELEN]; /* uid on client */ 54 char suid[NAMELEN]; /* uid on server */ 55 char key[DESKEYLEN]; /* nonce DES key */ 56 }; 57 #define TICKETLEN (CHALLEN+2*NAMELEN+DESKEYLEN+1) 58 59 struct Authenticator 60 { 61 char num; /* replay protection */ 62 char chal[CHALLEN]; 63 ulong id; /* authenticator id, ++'d with each auth */ 64 }; 65 #define AUTHENTLEN (CHALLEN+4+1) 66 67 struct Passwordreq 68 { 69 char num; 70 char old[NAMELEN]; 71 char new[NAMELEN]; 72 }; 73 #define PASSREQLEN (2*NAMELEN+1) 74 75 struct Nvrsafe 76 { 77 char machkey[DESKEYLEN]; 78 uchar machsum; 79 char authkey[DESKEYLEN]; 80 uchar authsum; 81 char config[CONFIGLEN]; 82 uchar configsum; 83 char authid[NAMELEN]; 84 uchar authidsum; 85 char authdom[DOMLEN]; 86 uchar authdomsum; 87 }; 88 89 struct Chalstate 90 { 91 int afd; /* /dev/authenticate */ 92 int asfd; /* authdial() */ 93 char chal[NETCHLEN]; /* challenge/response */ 94 }; 95 96 extern int convT2M(Ticket*, char*, char*); 97 extern void convM2T(char*, Ticket*, char*); 98 extern int convA2M(Authenticator*, char*, char*); 99 extern void convM2A(char*, Authenticator*, char*); 100 extern int convTR2M(Ticketreq*, char*); 101 extern void convM2TR(char*, Ticketreq*); 102 extern int convPR2M(Passwordreq*, char*, char*); 103 extern void convM2PR(char*, Passwordreq*, char*); 104 extern uchar nvcsum(void*, int); 105 extern int opasstokey(void*, char*); 106 extern int passtokey(void*, char*); 107 extern int authenticate(int, int); 108 extern int newns(char*, char*); 109 extern int authdial(void); 110 extern int auth(int); 111 extern int srvauth(int, char*); 112 extern int getchal(Chalstate*, char*); 113 extern int chalreply(Chalstate*, char*); 114 extern int amount(int, char*, int, char*); 115