PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/ALL-CODE-MOVED-TO-OKWS_SFSLITE/svc/sfsauth_prot.x

http://github.com/maxtaco/sfslite
Alex | 315 lines | 290 code | 25 blank | 0 comment | 0 complexity | 851330801c3d480e9a63047925332241 MD5 | raw file
Possible License(s): GPL-2.0
  1. /* $Id$ */
  2. /*
  3. * This file was written by David Mazieres. Its contents is
  4. * uncopyrighted and in the public domain. Of course, standards of
  5. * academic honesty nonetheless prevent anyone in research from
  6. * falsely claiming credit for this work.
  7. */
  8. %#include "sfs_prot.h"
  9. typedef string sfsauth_errmsg<>;
  10. const SPRIVK_HISTORY_LEN = 2;
  11. /*
  12. * sfs_authreq2 -- Contents of the login certificate in sfs_loginarg
  13. */
  14. struct sfs_authreq2 {
  15. sfs_msgtype type; /* = SFS_SIGNED_AUTHREQ(_NOCRED)? */
  16. sfs_hash authid; /* SHA-1 (sfs_authinfo) */
  17. sfs_seqno seqno; /* Counter, value unique per authid */
  18. sfs_idname user; /* User name, can be "" for sigauth */
  19. };
  20. struct sfs_sigauth {
  21. sfs_authreq2 req;
  22. sfs_pubkey2 key;
  23. sfs_sig2 sig;
  24. };
  25. struct sfs_unixpwauth {
  26. sfs_authreq2 req;
  27. string password<>;
  28. };
  29. struct sfs_unixpwauth_res { /* this struct is resmore for unixpw reply */
  30. string prompt<>;
  31. bool echo;
  32. };
  33. struct sfs_srpauth {
  34. sfs_authreq2 req;
  35. opaque msg<>;
  36. };
  37. union sfs_autharg2 switch (sfs_authtype type) {
  38. case SFS_NOAUTH:
  39. void;
  40. case SFS_AUTHREQ:
  41. sfs_authreq authreq1;
  42. case SFS_AUTHREQ2:
  43. sfs_sigauth sigauth;
  44. case SFS_UNIXPWAUTH:
  45. sfs_unixpwauth pwauth;
  46. case SFS_SRPAUTH:
  47. sfs_srpauth srpauth;
  48. };
  49. #if 0 /* from sfs_prot.x: */
  50. struct sfs_loginarg {
  51. sfs_seqno seqno;
  52. opaque certificate<>; /* marshalled sfs_autharg2 */
  53. };
  54. #endif
  55. struct sfsauth2_loginarg {
  56. sfs_loginarg arg;
  57. sfs_hash authid;
  58. string source<>; /* Source of request, for audit trail */
  59. };
  60. struct sfsauth2_loginokres {
  61. sfsauth_cred creds<>;
  62. opaque resmore<>; /* If necessary, for mutual authentication */
  63. string hello<>; /* To be printed on user's terminal */
  64. };
  65. union sfsauth2_loginres switch (sfs_loginstat status) {
  66. case SFSLOGIN_OK:
  67. sfsauth2_loginokres resok;
  68. case SFSLOGIN_MORE:
  69. opaque resmore<>;
  70. case SFSLOGIN_BAD:
  71. sfsauth_errmsg errmsg;
  72. default:
  73. void;
  74. };
  75. enum sfsauth_keyhalf_type {
  76. SFSAUTH_KEYHALF_NONE = 0,
  77. SFSAUTH_KEYHALF_PRIV = 1,
  78. SFSAUTH_KEYHALF_DELTA = 2,
  79. SFSAUTH_KEYHALF_FLAG = 3
  80. };
  81. union sfsauth_keyhalf switch (sfsauth_keyhalf_type type) {
  82. case SFSAUTH_KEYHALF_NONE:
  83. void;
  84. case SFSAUTH_KEYHALF_PRIV:
  85. sfs_2schnorr_priv_xdr priv<SPRIVK_HISTORY_LEN>;
  86. case SFSAUTH_KEYHALF_DELTA:
  87. bigint delta;
  88. case SFSAUTH_KEYHALF_FLAG:
  89. void;
  90. };
  91. /*
  92. * Auth server database types
  93. */
  94. typedef sfs_groupmember sfs_groupmembers<>;
  95. %const u_int32_t sfsauth_noid = 0xffffffff;
  96. struct sfsauth_userinfo {
  97. sfs_idname name;
  98. unsigned id;
  99. unsigned vers;
  100. unsigned gid;
  101. sfs_idname *owner;
  102. sfs_pubkey2 pubkey;
  103. string privs<>;
  104. string pwauth<>; /* Never returned, only set */
  105. sfs_privkey2 privkey; /* Only returned after SRP authentication */
  106. sfsauth_keyhalf srvprivkey; /* Never returned, only set */
  107. string audit<>;
  108. };
  109. struct sfsauth_groupinfo {
  110. sfs_idname name;
  111. unsigned id;
  112. unsigned vers;
  113. sfs_groupmembers owners;
  114. sfs_groupmembers members;
  115. string properties<>;
  116. string audit<>;
  117. };
  118. struct sfsauth_ids {
  119. sfs_idname user;
  120. unsigned uid;
  121. unsigned gid;
  122. unsigned gidlist<>;
  123. };
  124. struct sfsauth_srpparms {
  125. unsigned pwcost;
  126. string parms<>;
  127. };
  128. struct sfsauth_cacheentry {
  129. sfs_groupmember key;
  130. sfs_groupmembers values;
  131. unsigned vers;
  132. sfs_time refresh;
  133. sfs_time timeout;
  134. sfs_time last_update;
  135. };
  136. struct sfsauth_logentry {
  137. unsigned vers;
  138. sfs_groupmembers members;
  139. bool more;
  140. sfs_time refresh;
  141. sfs_time timeout;
  142. string audit<>;
  143. };
  144. struct sfsauth_revinfo {
  145. unsigned hyper dbrev;
  146. opaque dbid[16];
  147. };
  148. enum sfsauth_dbtype {
  149. SFSAUTH_ERROR = 0,
  150. SFSAUTH_USER = 1,
  151. SFSAUTH_GROUP = 2,
  152. SFSAUTH_IDS = 3,
  153. SFSAUTH_SRPPARMS = 5,
  154. SFSAUTH_CERTINFO = 6,
  155. SFSAUTH_CACHEENTRY = 7,
  156. SFSAUTH_EXPANDEDGROUP = 8,
  157. SFSAUTH_LOGENTRY = 9,
  158. SFSAUTH_REVINFO = 10,
  159. SFSAUTH_DELUSER = 11,
  160. SFSAUTH_DELGROUP = 12,
  161. SFSAUTH_NEXT = 13
  162. };
  163. union sfsauth_dbrec switch (sfsauth_dbtype type) {
  164. case SFSAUTH_ERROR:
  165. sfsauth_errmsg errmsg;
  166. case SFSAUTH_USER:
  167. sfsauth_userinfo userinfo;
  168. case SFSAUTH_GROUP:
  169. case SFSAUTH_EXPANDEDGROUP:
  170. sfsauth_groupinfo groupinfo;
  171. case SFSAUTH_IDS:
  172. sfsauth_ids ids;
  173. case SFSAUTH_SRPPARMS:
  174. sfsauth_srpparms srpparms;
  175. case SFSAUTH_CERTINFO:
  176. sfsauth_certinfores certinfo;
  177. case SFSAUTH_CACHEENTRY:
  178. sfsauth_cacheentry cacheentry;
  179. case SFSAUTH_LOGENTRY:
  180. sfsauth_logentry logentry;
  181. case SFSAUTH_REVINFO:
  182. sfsauth_revinfo revinfo;
  183. case SFSAUTH_DELUSER:
  184. case SFSAUTH_DELGROUP:
  185. sfs_idname deleted;
  186. };
  187. struct sfs_namevers {
  188. sfs_idname name;
  189. unsigned vers;
  190. };
  191. enum sfsauth_dbkeytype {
  192. SFSAUTH_DBKEY_NULL = 0,
  193. SFSAUTH_DBKEY_NAME = 1,
  194. SFSAUTH_DBKEY_ID = 2,
  195. SFSAUTH_DBKEY_PUBKEY = 3,
  196. SFSAUTH_DBKEY_NAMEVERS = 4,
  197. SFSAUTH_DBKEY_REVINFO = 5
  198. };
  199. union sfsauth_dbkey switch (sfsauth_dbkeytype type) {
  200. case SFSAUTH_DBKEY_NULL:
  201. void;
  202. case SFSAUTH_DBKEY_NAME:
  203. sfs_idname name;
  204. case SFSAUTH_DBKEY_ID:
  205. unsigned id;
  206. case SFSAUTH_DBKEY_PUBKEY:
  207. sfs_pubkey2 key;
  208. case SFSAUTH_DBKEY_NAMEVERS:
  209. sfs_namevers namevers;
  210. case SFSAUTH_DBKEY_REVINFO:
  211. sfsauth_revinfo revinfo;
  212. };
  213. /* arg must be accompanied by an authuint to retrieve certain fields. */
  214. struct sfsauth2_query_arg {
  215. sfsauth_dbtype type;
  216. sfsauth_dbkey key;
  217. };
  218. typedef sfsauth_dbrec sfsauth2_query_res;
  219. typedef unsigned hyper sfs_update_opts;
  220. /* SFS Update Options Bit mask values */
  221. const SFSUP_KPSRP = 0x1; /* Don't overwrite SRP information */
  222. const SFSUP_KPESK = 0x2; /* Don't overwrite secret key information */
  223. const SFSUP_KPPK = 0x4; /* Don't overwrite public key */
  224. const SFSUP_CLROKH = 0x8; /* Clear old server keyhalf */
  225. const SFSUP_CLRNKH = 0x10; /* Clear new server keyhalf */
  226. /*
  227. * Signed message required for an update
  228. */
  229. struct sfs_updatereq {
  230. sfs_msgtype type; /* = SFS_UPDATEREQ */
  231. sfs_hash authid; /* SHA-1 (sfs_authinfo) */
  232. sfsauth_dbrec rec; /* USER or GROUP only */
  233. sfs_update_opts opts; /* Bit Mask with Update Options */
  234. };
  235. /* Arg must be accompanied by authuint. */
  236. struct sfsauth2_update_arg {
  237. sfs_updatereq req;
  238. sfs_sig2 *newsig; /* sig by req.rec.userinfo->pubkey if
  239. * non admin user updating key. */
  240. sfs_sig2 *authsig; /* Signature for key corresponding to
  241. * authuint. Can be empty when
  242. * registering. */
  243. };
  244. union sfsauth2_update_res switch (bool ok) {
  245. case false:
  246. sfsauth_errmsg errmsg;
  247. case true:
  248. void;
  249. };
  250. union sfsauth2_presig switch (sfs_keytype type) {
  251. case SFS_2SCHNORR:
  252. sfs_2schnorr_presig schnorr;
  253. default:
  254. void;
  255. };
  256. union sfsauth2_sigreq switch (sfs_msgtype type) {
  257. case SFS_NULL:
  258. sfs_hash rnd;
  259. case SFS_SIGNED_AUTHREQ:
  260. sfs_authreq2 authreq;
  261. case SFS_UPDATEREQ:
  262. sfs_updatereq updatereq;
  263. };
  264. struct sfsauth2_sign_arg {
  265. sfsauth2_sigreq req;
  266. sfs_authinfo authinfo;
  267. sfsauth2_presig presig; /* used to pass a partial signature */
  268. sfs_idname user; /* if no authno, look up user name */
  269. sfs_hash pubkeyhash; /* hash of the pubkey client signed with */
  270. };
  271. union sfsauth2_sign_res switch (bool ok) {
  272. case false:
  273. sfsauth_errmsg errmsg;
  274. case true:
  275. sfs_sig2 sig;
  276. };
  277. program SFSAUTH_PROG {
  278. version SFSAUTH_V2 {
  279. void
  280. SFSAUTH2_NULL (void) = 0;
  281. sfsauth2_loginres
  282. SFSAUTH2_LOGIN (sfsauth2_loginarg) = 1;
  283. sfsauth2_query_res
  284. SFSAUTH2_QUERY (sfsauth2_query_arg) = 2;
  285. sfsauth2_update_res
  286. SFSAUTH2_UPDATE (sfsauth2_update_arg) = 3;
  287. sfsauth2_sign_res
  288. SFSAUTH2_SIGN (sfsauth2_sign_arg) = 4;
  289. } = 2;
  290. } = 344442;