1 #pragma src "/sys/src/libauth" 2 #pragma lib "libauth.a" 3 4 /* 5 * Interface for typical callers. 6 */ 7 8 typedef struct AuthInfo AuthInfo; 9 typedef struct Chalstate Chalstate; 10 typedef struct Chapreply Chapreply; 11 typedef struct MSchapreply MSchapreply; 12 typedef struct UserPasswd UserPasswd; 13 typedef struct AuthRpc AuthRpc; 14 15 enum 16 { 17 MAXCHLEN= 256, /* max challenge length */ 18 MAXNAMELEN= 256, /* maximum name length */ 19 MD5LEN= 16, 20 21 ARok = 0, /* rpc return values */ 22 ARdone, 23 ARerror, 24 ARneedkey, 25 ARbadkey, 26 ARwritenext, 27 ARtoosmall, 28 ARtoobig, 29 ARrpcfailure, 30 ARphase, 31 32 AuthRpcMax = 4096, 33 }; 34 35 struct AuthRpc 36 { 37 int afd; 38 char ibuf[AuthRpcMax+1]; /* +1 for NUL in auth_rpc.c */ 39 char obuf[AuthRpcMax]; 40 char *arg; 41 uint narg; 42 }; 43 44 struct AuthInfo 45 { 46 char *cuid; /* caller id */ 47 char *suid; /* server id */ 48 char *cap; /* capability (only valid on server side) */ 49 int nsecret; /* length of secret */ 50 uchar *secret; /* secret */ 51 }; 52 53 struct Chalstate 54 { 55 char *user; 56 char chal[MAXCHLEN]; 57 int nchal; 58 void *resp; 59 int nresp; 60 61 /* for implementation only */ 62 int afd; /* to factotum */ 63 AuthRpc *rpc; /* to factotum */ 64 char userbuf[MAXNAMELEN]; /* temp space if needed */ 65 int userinchal; /* user was sent to obtain challenge */ 66 }; 67 68 struct Chapreply /* for protocol "chap" */ 69 { 70 uchar id; 71 char resp[MD5LEN]; 72 }; 73 74 struct MSchapreply /* for protocol "mschap" */ 75 { 76 char LMresp[24]; /* Lan Manager response */ 77 char NTresp[24]; /* NT response */ 78 }; 79 80 struct UserPasswd 81 { 82 char *user; 83 char *passwd; 84 }; 85 86 extern int newns(char*, char*); 87 extern int addns(char*, char*); 88 89 extern int noworld(char*); 90 extern int amount(int, char*, int, char*); 91 92 /* these two may get generalized away -rsc */ 93 extern int login(char*, char*, char*); 94 extern int httpauth(char*, char*); 95 96 typedef struct Attr Attr; 97 enum { 98 AttrNameval, /* name=val -- when matching, must have name=val */ 99 AttrQuery, /* name? -- when matching, must be present */ 100 AttrDefault, /* name:=val -- when matching, if present must match INTERNAL */ 101 }; 102 struct Attr 103 { 104 int type; 105 Attr *next; 106 char *name; 107 char *val; 108 }; 109 110 typedef int AuthGetkey(char*); 111 112 int _attrfmt(Fmt*); 113 Attr *_copyattr(Attr*); 114 Attr *_delattr(Attr*, char*); 115 Attr *_findattr(Attr*, char*); 116 void _freeattr(Attr*); 117 Attr *_mkattr(int, char*, char*, Attr*); 118 Attr *_parseattr(char*); 119 char *_strfindattr(Attr*, char*); 120 #pragma varargck type "A" Attr* 121 122 extern AuthInfo* fauth_proxy(int, AuthRpc *rpc, AuthGetkey *getkey, char *params); 123 extern AuthInfo* auth_proxy(int fd, AuthGetkey *getkey, char *fmt, ...); 124 extern int auth_getkey(char*); 125 extern int (*amount_getkey)(char*); 126 extern void auth_freeAI(AuthInfo *ai); 127 extern int auth_chuid(AuthInfo *ai, char *ns); 128 extern Chalstate *auth_challenge(char*, ...); 129 extern AuthInfo* auth_response(Chalstate*); 130 extern int auth_respond(void*, uint, char*, uint, void*, uint, AuthGetkey *getkey, char*, ...); 131 extern void auth_freechal(Chalstate*); 132 extern AuthInfo* auth_userpasswd(char *user, char *passwd); 133 extern UserPasswd* auth_getuserpasswd(AuthGetkey *getkey, char*, ...); 134 extern AuthInfo* auth_getinfo(AuthRpc *rpc); 135 extern AuthRpc* auth_allocrpc(int afd); 136 extern Attr* auth_attr(AuthRpc *rpc); 137 extern void auth_freerpc(AuthRpc *rpc); 138 extern uint auth_rpc(AuthRpc *rpc, char *verb, void *a, int n); 139 extern int auth_wep(char*, char*, ...); 140 #pragma varargck argpos auth_proxy 3 141 #pragma varargck argpos auth_challenge 1 142 #pragma varargck argpos auth_respond 8 143 #pragma varargck argpos auth_getuserpasswd 2 144