gss_rpc_xdr.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /*
  2. * GSS Proxy upcall module
  3. *
  4. * Copyright (C) 2012 Simo Sorce <simo@redhat.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #ifndef _LINUX_GSS_RPC_XDR_H
  21. #define _LINUX_GSS_RPC_XDR_H
  22. #include <linux/sunrpc/xdr.h>
  23. #include <linux/sunrpc/clnt.h>
  24. #include <linux/sunrpc/xprtsock.h>
  25. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  26. # define RPCDBG_FACILITY RPCDBG_AUTH
  27. #endif
  28. #define LUCID_OPTION "exported_context_type"
  29. #define LUCID_VALUE "linux_lucid_v1"
  30. #define CREDS_OPTION "exported_creds_type"
  31. #define CREDS_VALUE "linux_creds_v1"
  32. typedef struct xdr_netobj gssx_buffer;
  33. typedef struct xdr_netobj utf8string;
  34. typedef struct xdr_netobj gssx_OID;
  35. enum gssx_cred_usage {
  36. GSSX_C_INITIATE = 1,
  37. GSSX_C_ACCEPT = 2,
  38. GSSX_C_BOTH = 3,
  39. };
  40. struct gssx_option {
  41. gssx_buffer option;
  42. gssx_buffer value;
  43. };
  44. struct gssx_option_array {
  45. u32 count;
  46. struct gssx_option *data;
  47. };
  48. struct gssx_status {
  49. u64 major_status;
  50. gssx_OID mech;
  51. u64 minor_status;
  52. utf8string major_status_string;
  53. utf8string minor_status_string;
  54. gssx_buffer server_ctx;
  55. struct gssx_option_array options;
  56. };
  57. struct gssx_call_ctx {
  58. utf8string locale;
  59. gssx_buffer server_ctx;
  60. struct gssx_option_array options;
  61. };
  62. struct gssx_name_attr {
  63. gssx_buffer attr;
  64. gssx_buffer value;
  65. struct gssx_option_array extensions;
  66. };
  67. struct gssx_name_attr_array {
  68. u32 count;
  69. struct gssx_name_attr *data;
  70. };
  71. struct gssx_name {
  72. gssx_buffer display_name;
  73. };
  74. typedef struct gssx_name gssx_name;
  75. struct gssx_cred_element {
  76. gssx_name MN;
  77. gssx_OID mech;
  78. u32 cred_usage;
  79. u64 initiator_time_rec;
  80. u64 acceptor_time_rec;
  81. struct gssx_option_array options;
  82. };
  83. struct gssx_cred_element_array {
  84. u32 count;
  85. struct gssx_cred_element *data;
  86. };
  87. struct gssx_cred {
  88. gssx_name desired_name;
  89. struct gssx_cred_element_array elements;
  90. gssx_buffer cred_handle_reference;
  91. u32 needs_release;
  92. };
  93. struct gssx_ctx {
  94. gssx_buffer exported_context_token;
  95. gssx_buffer state;
  96. u32 need_release;
  97. gssx_OID mech;
  98. gssx_name src_name;
  99. gssx_name targ_name;
  100. u64 lifetime;
  101. u64 ctx_flags;
  102. u32 locally_initiated;
  103. u32 open;
  104. struct gssx_option_array options;
  105. };
  106. struct gssx_cb {
  107. u64 initiator_addrtype;
  108. gssx_buffer initiator_address;
  109. u64 acceptor_addrtype;
  110. gssx_buffer acceptor_address;
  111. gssx_buffer application_data;
  112. };
  113. /* This structure is not defined in the protocol.
  114. * It is used in the kernel to carry around a big buffer
  115. * as a set of pages */
  116. struct gssp_in_token {
  117. struct page **pages; /* Array of contiguous pages */
  118. unsigned int page_base; /* Start of page data */
  119. unsigned int page_len; /* Length of page data */
  120. };
  121. struct gssx_arg_accept_sec_context {
  122. struct gssx_call_ctx call_ctx;
  123. struct gssx_ctx *context_handle;
  124. struct gssx_cred *cred_handle;
  125. struct gssp_in_token input_token;
  126. struct gssx_cb *input_cb;
  127. u32 ret_deleg_cred;
  128. struct gssx_option_array options;
  129. struct page **pages;
  130. unsigned int npages;
  131. };
  132. struct gssx_res_accept_sec_context {
  133. struct gssx_status status;
  134. struct gssx_ctx *context_handle;
  135. gssx_buffer *output_token;
  136. /* struct gssx_cred *delegated_cred_handle; not used in kernel */
  137. struct gssx_option_array options;
  138. };
  139. #define gssx_enc_indicate_mechs NULL
  140. #define gssx_dec_indicate_mechs NULL
  141. #define gssx_enc_get_call_context NULL
  142. #define gssx_dec_get_call_context NULL
  143. #define gssx_enc_import_and_canon_name NULL
  144. #define gssx_dec_import_and_canon_name NULL
  145. #define gssx_enc_export_cred NULL
  146. #define gssx_dec_export_cred NULL
  147. #define gssx_enc_import_cred NULL
  148. #define gssx_dec_import_cred NULL
  149. #define gssx_enc_acquire_cred NULL
  150. #define gssx_dec_acquire_cred NULL
  151. #define gssx_enc_store_cred NULL
  152. #define gssx_dec_store_cred NULL
  153. #define gssx_enc_init_sec_context NULL
  154. #define gssx_dec_init_sec_context NULL
  155. void gssx_enc_accept_sec_context(struct rpc_rqst *req,
  156. struct xdr_stream *xdr,
  157. struct gssx_arg_accept_sec_context *args);
  158. int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp,
  159. struct xdr_stream *xdr,
  160. struct gssx_res_accept_sec_context *res);
  161. #define gssx_enc_release_handle NULL
  162. #define gssx_dec_release_handle NULL
  163. #define gssx_enc_get_mic NULL
  164. #define gssx_dec_get_mic NULL
  165. #define gssx_enc_verify NULL
  166. #define gssx_dec_verify NULL
  167. #define gssx_enc_wrap NULL
  168. #define gssx_dec_wrap NULL
  169. #define gssx_enc_unwrap NULL
  170. #define gssx_dec_unwrap NULL
  171. #define gssx_enc_wrap_size_limit NULL
  172. #define gssx_dec_wrap_size_limit NULL
  173. /* non implemented calls are set to 0 size */
  174. #define GSSX_ARG_indicate_mechs_sz 0
  175. #define GSSX_RES_indicate_mechs_sz 0
  176. #define GSSX_ARG_get_call_context_sz 0
  177. #define GSSX_RES_get_call_context_sz 0
  178. #define GSSX_ARG_import_and_canon_name_sz 0
  179. #define GSSX_RES_import_and_canon_name_sz 0
  180. #define GSSX_ARG_export_cred_sz 0
  181. #define GSSX_RES_export_cred_sz 0
  182. #define GSSX_ARG_import_cred_sz 0
  183. #define GSSX_RES_import_cred_sz 0
  184. #define GSSX_ARG_acquire_cred_sz 0
  185. #define GSSX_RES_acquire_cred_sz 0
  186. #define GSSX_ARG_store_cred_sz 0
  187. #define GSSX_RES_store_cred_sz 0
  188. #define GSSX_ARG_init_sec_context_sz 0
  189. #define GSSX_RES_init_sec_context_sz 0
  190. #define GSSX_default_in_call_ctx_sz (4 + 4 + 4 + \
  191. 8 + sizeof(LUCID_OPTION) + sizeof(LUCID_VALUE) + \
  192. 8 + sizeof(CREDS_OPTION) + sizeof(CREDS_VALUE))
  193. #define GSSX_default_in_ctx_hndl_sz (4 + 4+8 + 4 + 4 + 6*4 + 6*4 + 8 + 8 + \
  194. 4 + 4 + 4)
  195. #define GSSX_default_in_cred_sz 4 /* we send in no cred_handle */
  196. #define GSSX_default_in_token_sz 4 /* does *not* include token data */
  197. #define GSSX_default_in_cb_sz 4 /* we do not use channel bindings */
  198. #define GSSX_ARG_accept_sec_context_sz (GSSX_default_in_call_ctx_sz + \
  199. GSSX_default_in_ctx_hndl_sz + \
  200. GSSX_default_in_cred_sz + \
  201. GSSX_default_in_token_sz + \
  202. GSSX_default_in_cb_sz + \
  203. 4 /* no deleg creds boolean */ + \
  204. 4) /* empty options */
  205. /* somewhat arbitrary numbers but large enough (we ignore some of the data
  206. * sent down, but it is part of the protocol so we need enough space to take
  207. * it in) */
  208. #define GSSX_default_status_sz 8 + 24 + 8 + 256 + 256 + 16 + 4
  209. #define GSSX_max_output_handle_sz 128
  210. #define GSSX_max_oid_sz 16
  211. #define GSSX_max_princ_sz 256
  212. #define GSSX_default_ctx_sz (GSSX_max_output_handle_sz + \
  213. 16 + 4 + GSSX_max_oid_sz + \
  214. 2 * GSSX_max_princ_sz + \
  215. 8 + 8 + 4 + 4 + 4)
  216. #define GSSX_max_output_token_sz 1024
  217. /* grouplist not included; we allocate separate pages for that: */
  218. #define GSSX_max_creds_sz (4 + 4 + 4 /* + NGROUPS_MAX*4 */)
  219. #define GSSX_RES_accept_sec_context_sz (GSSX_default_status_sz + \
  220. GSSX_default_ctx_sz + \
  221. GSSX_max_output_token_sz + \
  222. 4 + GSSX_max_creds_sz)
  223. #define GSSX_ARG_release_handle_sz 0
  224. #define GSSX_RES_release_handle_sz 0
  225. #define GSSX_ARG_get_mic_sz 0
  226. #define GSSX_RES_get_mic_sz 0
  227. #define GSSX_ARG_verify_sz 0
  228. #define GSSX_RES_verify_sz 0
  229. #define GSSX_ARG_wrap_sz 0
  230. #define GSSX_RES_wrap_sz 0
  231. #define GSSX_ARG_unwrap_sz 0
  232. #define GSSX_RES_unwrap_sz 0
  233. #define GSSX_ARG_wrap_size_limit_sz 0
  234. #define GSSX_RES_wrap_size_limit_sz 0
  235. #endif /* _LINUX_GSS_RPC_XDR_H */