gss_api.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * linux/include/linux/sunrpc/gss_api.h
  3. *
  4. * Somewhat simplified version of the gss api.
  5. *
  6. * Dug Song <dugsong@monkey.org>
  7. * Andy Adamson <andros@umich.edu>
  8. * Bruce Fields <bfields@umich.edu>
  9. * Copyright (c) 2000 The Regents of the University of Michigan
  10. */
  11. #ifndef _LINUX_SUNRPC_GSS_API_H
  12. #define _LINUX_SUNRPC_GSS_API_H
  13. #ifdef __KERNEL__
  14. #include <linux/sunrpc/xdr.h>
  15. #include <linux/sunrpc/msg_prot.h>
  16. #include <linux/uio.h>
  17. /* The mechanism-independent gss-api context: */
  18. struct gss_ctx {
  19. struct gss_api_mech *mech_type;
  20. void *internal_ctx_id;
  21. };
  22. #define GSS_C_NO_BUFFER ((struct xdr_netobj) 0)
  23. #define GSS_C_NO_CONTEXT ((struct gss_ctx *) 0)
  24. #define GSS_C_QOP_DEFAULT (0)
  25. /*XXX arbitrary length - is this set somewhere? */
  26. #define GSS_OID_MAX_LEN 32
  27. struct rpcsec_gss_oid {
  28. unsigned int len;
  29. u8 data[GSS_OID_MAX_LEN];
  30. };
  31. /* From RFC 3530 */
  32. struct rpcsec_gss_info {
  33. struct rpcsec_gss_oid oid;
  34. u32 qop;
  35. u32 service;
  36. };
  37. /* gss-api prototypes; note that these are somewhat simplified versions of
  38. * the prototypes specified in RFC 2744. */
  39. int gss_import_sec_context(
  40. const void* input_token,
  41. size_t bufsize,
  42. struct gss_api_mech *mech,
  43. struct gss_ctx **ctx_id,
  44. time_t *endtime,
  45. gfp_t gfp_mask);
  46. u32 gss_get_mic(
  47. struct gss_ctx *ctx_id,
  48. struct xdr_buf *message,
  49. struct xdr_netobj *mic_token);
  50. u32 gss_verify_mic(
  51. struct gss_ctx *ctx_id,
  52. struct xdr_buf *message,
  53. struct xdr_netobj *mic_token);
  54. u32 gss_wrap(
  55. struct gss_ctx *ctx_id,
  56. int offset,
  57. struct xdr_buf *outbuf,
  58. struct page **inpages);
  59. u32 gss_unwrap(
  60. struct gss_ctx *ctx_id,
  61. int offset,
  62. struct xdr_buf *inbuf);
  63. u32 gss_delete_sec_context(
  64. struct gss_ctx **ctx_id);
  65. rpc_authflavor_t gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 qop,
  66. u32 service);
  67. u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor);
  68. char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
  69. struct pf_desc {
  70. u32 pseudoflavor;
  71. u32 qop;
  72. u32 service;
  73. char *name;
  74. char *auth_domain_name;
  75. };
  76. /* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and
  77. * mechanisms may be dynamically registered or unregistered by modules. */
  78. /* Each mechanism is described by the following struct: */
  79. struct gss_api_mech {
  80. struct list_head gm_list;
  81. struct module *gm_owner;
  82. struct rpcsec_gss_oid gm_oid;
  83. char *gm_name;
  84. const struct gss_api_ops *gm_ops;
  85. /* pseudoflavors supported by this mechanism: */
  86. int gm_pf_num;
  87. struct pf_desc * gm_pfs;
  88. /* Should the following be a callback operation instead? */
  89. const char *gm_upcall_enctypes;
  90. };
  91. /* and must provide the following operations: */
  92. struct gss_api_ops {
  93. int (*gss_import_sec_context)(
  94. const void *input_token,
  95. size_t bufsize,
  96. struct gss_ctx *ctx_id,
  97. time_t *endtime,
  98. gfp_t gfp_mask);
  99. u32 (*gss_get_mic)(
  100. struct gss_ctx *ctx_id,
  101. struct xdr_buf *message,
  102. struct xdr_netobj *mic_token);
  103. u32 (*gss_verify_mic)(
  104. struct gss_ctx *ctx_id,
  105. struct xdr_buf *message,
  106. struct xdr_netobj *mic_token);
  107. u32 (*gss_wrap)(
  108. struct gss_ctx *ctx_id,
  109. int offset,
  110. struct xdr_buf *outbuf,
  111. struct page **inpages);
  112. u32 (*gss_unwrap)(
  113. struct gss_ctx *ctx_id,
  114. int offset,
  115. struct xdr_buf *buf);
  116. void (*gss_delete_sec_context)(
  117. void *internal_ctx_id);
  118. };
  119. int gss_mech_register(struct gss_api_mech *);
  120. void gss_mech_unregister(struct gss_api_mech *);
  121. /* returns a mechanism descriptor given an OID, and increments the mechanism's
  122. * reference count. */
  123. struct gss_api_mech * gss_mech_get_by_OID(struct rpcsec_gss_oid *);
  124. /* Given a GSS security tuple, look up a pseudoflavor */
  125. rpc_authflavor_t gss_mech_info2flavor(struct rpcsec_gss_info *);
  126. /* Given a pseudoflavor, look up a GSS security tuple */
  127. int gss_mech_flavor2info(rpc_authflavor_t, struct rpcsec_gss_info *);
  128. /* Returns a reference to a mechanism, given a name like "krb5" etc. */
  129. struct gss_api_mech *gss_mech_get_by_name(const char *);
  130. /* Similar, but get by pseudoflavor. */
  131. struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
  132. /* Fill in an array with a list of supported pseudoflavors */
  133. int gss_mech_list_pseudoflavors(rpc_authflavor_t *, int);
  134. struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
  135. /* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
  136. * corresponding call to gss_mech_put. */
  137. void gss_mech_put(struct gss_api_mech *);
  138. #endif /* __KERNEL__ */
  139. #endif /* _LINUX_SUNRPC_GSS_API_H */