1
0

auth.h 3.4 KB

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