Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Uwe Zeisberger | f30c226 | 2006-10-03 23:01:26 +0200 | [diff] [blame] | 2 | * linux/include/linux/sunrpc/gss_api.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #ifndef _LINUX_SUNRPC_GSS_API_H |
| 13 | #define _LINUX_SUNRPC_GSS_API_H |
| 14 | |
| 15 | #ifdef __KERNEL__ |
| 16 | #include <linux/sunrpc/xdr.h> |
| 17 | #include <linux/uio.h> |
| 18 | |
| 19 | /* The mechanism-independent gss-api context: */ |
| 20 | struct gss_ctx { |
| 21 | struct gss_api_mech *mech_type; |
| 22 | void *internal_ctx_id; |
| 23 | }; |
| 24 | |
| 25 | #define GSS_C_NO_BUFFER ((struct xdr_netobj) 0) |
| 26 | #define GSS_C_NO_CONTEXT ((struct gss_ctx *) 0) |
| 27 | #define GSS_C_NULL_OID ((struct xdr_netobj) 0) |
| 28 | |
| 29 | /*XXX arbitrary length - is this set somewhere? */ |
| 30 | #define GSS_OID_MAX_LEN 32 |
| 31 | |
| 32 | /* gss-api prototypes; note that these are somewhat simplified versions of |
| 33 | * the prototypes specified in RFC 2744. */ |
| 34 | int gss_import_sec_context( |
| 35 | const void* input_token, |
| 36 | size_t bufsize, |
| 37 | struct gss_api_mech *mech, |
Trond Myklebust | 1f4c86c | 2010-05-13 12:51:02 -0400 | [diff] [blame] | 38 | struct gss_ctx **ctx_id, |
| 39 | gfp_t gfp_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | u32 gss_get_mic( |
| 41 | struct gss_ctx *ctx_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | struct xdr_buf *message, |
| 43 | struct xdr_netobj *mic_token); |
| 44 | u32 gss_verify_mic( |
| 45 | struct gss_ctx *ctx_id, |
| 46 | struct xdr_buf *message, |
J. Bruce Fields | 00fd6e1 | 2005-10-13 16:55:18 -0400 | [diff] [blame] | 47 | struct xdr_netobj *mic_token); |
J. Bruce Fields | 293f1eb | 2005-10-13 16:54:37 -0400 | [diff] [blame] | 48 | u32 gss_wrap( |
| 49 | struct gss_ctx *ctx_id, |
J. Bruce Fields | 293f1eb | 2005-10-13 16:54:37 -0400 | [diff] [blame] | 50 | int offset, |
| 51 | struct xdr_buf *outbuf, |
| 52 | struct page **inpages); |
| 53 | u32 gss_unwrap( |
| 54 | struct gss_ctx *ctx_id, |
J. Bruce Fields | 293f1eb | 2005-10-13 16:54:37 -0400 | [diff] [blame] | 55 | int offset, |
| 56 | struct xdr_buf *inbuf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | u32 gss_delete_sec_context( |
| 58 | struct gss_ctx **ctx_id); |
| 59 | |
Andy Adamson | c417058 | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 60 | u32 gss_svc_to_pseudoflavor(struct gss_api_mech *, u32 service); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | u32 gss_pseudoflavor_to_service(struct gss_api_mech *, u32 pseudoflavor); |
| 62 | char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service); |
| 63 | |
| 64 | struct pf_desc { |
| 65 | u32 pseudoflavor; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | u32 service; |
| 67 | char *name; |
| 68 | char *auth_domain_name; |
| 69 | }; |
| 70 | |
| 71 | /* Different mechanisms (e.g., krb5 or spkm3) may implement gss-api, and |
| 72 | * mechanisms may be dynamically registered or unregistered by modules. */ |
| 73 | |
| 74 | /* Each mechanism is described by the following struct: */ |
| 75 | struct gss_api_mech { |
| 76 | struct list_head gm_list; |
| 77 | struct module *gm_owner; |
| 78 | struct xdr_netobj gm_oid; |
| 79 | char *gm_name; |
Trond Myklebust | f1c0a86 | 2007-06-23 20:17:58 -0400 | [diff] [blame] | 80 | const struct gss_api_ops *gm_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | /* pseudoflavors supported by this mechanism: */ |
| 82 | int gm_pf_num; |
| 83 | struct pf_desc * gm_pfs; |
Trond Myklebust | 683ac66 | 2010-04-08 14:09:58 -0400 | [diff] [blame] | 84 | /* Should the following be a callback operation instead? */ |
| 85 | const char *gm_upcall_enctypes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | /* and must provide the following operations: */ |
| 89 | struct gss_api_ops { |
| 90 | int (*gss_import_sec_context)( |
| 91 | const void *input_token, |
| 92 | size_t bufsize, |
Trond Myklebust | 1f4c86c | 2010-05-13 12:51:02 -0400 | [diff] [blame] | 93 | struct gss_ctx *ctx_id, |
| 94 | gfp_t gfp_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | u32 (*gss_get_mic)( |
| 96 | struct gss_ctx *ctx_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | struct xdr_buf *message, |
| 98 | struct xdr_netobj *mic_token); |
| 99 | u32 (*gss_verify_mic)( |
| 100 | struct gss_ctx *ctx_id, |
| 101 | struct xdr_buf *message, |
J. Bruce Fields | 00fd6e1 | 2005-10-13 16:55:18 -0400 | [diff] [blame] | 102 | struct xdr_netobj *mic_token); |
J. Bruce Fields | 293f1eb | 2005-10-13 16:54:37 -0400 | [diff] [blame] | 103 | u32 (*gss_wrap)( |
| 104 | struct gss_ctx *ctx_id, |
J. Bruce Fields | 293f1eb | 2005-10-13 16:54:37 -0400 | [diff] [blame] | 105 | int offset, |
| 106 | struct xdr_buf *outbuf, |
| 107 | struct page **inpages); |
| 108 | u32 (*gss_unwrap)( |
| 109 | struct gss_ctx *ctx_id, |
J. Bruce Fields | 293f1eb | 2005-10-13 16:54:37 -0400 | [diff] [blame] | 110 | int offset, |
| 111 | struct xdr_buf *buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | void (*gss_delete_sec_context)( |
| 113 | void *internal_ctx_id); |
| 114 | }; |
| 115 | |
| 116 | int gss_mech_register(struct gss_api_mech *); |
| 117 | void gss_mech_unregister(struct gss_api_mech *); |
| 118 | |
| 119 | /* returns a mechanism descriptor given an OID, and increments the mechanism's |
| 120 | * reference count. */ |
| 121 | struct gss_api_mech * gss_mech_get_by_OID(struct xdr_netobj *); |
| 122 | |
| 123 | /* Returns a reference to a mechanism, given a name like "krb5" etc. */ |
| 124 | struct gss_api_mech *gss_mech_get_by_name(const char *); |
| 125 | |
| 126 | /* Similar, but get by pseudoflavor. */ |
| 127 | struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32); |
| 128 | |
Bryan Schumaker | 8f70e95 | 2011-03-24 17:12:31 +0000 | [diff] [blame] | 129 | /* Fill in an array with a list of supported pseudoflavors */ |
| 130 | int gss_mech_list_pseudoflavors(u32 *); |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | /* Just increments the mechanism's reference count and returns its input: */ |
| 133 | struct gss_api_mech * gss_mech_get(struct gss_api_mech *); |
| 134 | |
Andreas Mohr | d6e05ed | 2006-06-26 18:35:02 +0200 | [diff] [blame] | 135 | /* For every successful gss_mech_get or gss_mech_get_by_* call there must be a |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | * corresponding call to gss_mech_put. */ |
| 137 | void gss_mech_put(struct gss_api_mech *); |
| 138 | |
| 139 | #endif /* __KERNEL__ */ |
| 140 | #endif /* _LINUX_SUNRPC_GSS_API_H */ |
| 141 | |