4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (C) 2013, Trustees of Indiana University
24 * Author: Andrew Korty <ajk@iu.edu>
27 #define DEBUG_SUBSYSTEM S_SEC
29 #include <linux/init.h>
30 #include <linux/module.h>
31 #include <linux/slab.h>
32 #include <linux/crypto.h>
33 #include <linux/mutex.h>
35 #include <liblustre.h>
39 #include <obd_class.h>
40 #include <obd_support.h>
43 #include "gss_internal.h"
51 __u32 gss_import_sec_context_null(rawobj_t *inbuf, struct gss_ctx *gss_context)
53 struct null_ctx *null_context;
55 if (inbuf == NULL || inbuf->data == NULL)
58 OBD_ALLOC_PTR(null_context);
59 if (null_context == NULL)
62 gss_context->internal_ctx_id = null_context;
63 CDEBUG(D_SEC, "succesfully imported null context\n");
65 return GSS_S_COMPLETE;
69 __u32 gss_copy_reverse_context_null(struct gss_ctx *gss_context_old,
70 struct gss_ctx *gss_context_new)
72 struct null_ctx *null_context_old;
73 struct null_ctx *null_context_new;
75 OBD_ALLOC_PTR(null_context_new);
76 if (null_context_new == NULL)
79 null_context_old = gss_context_old->internal_ctx_id;
80 memcpy(null_context_new, null_context_old, sizeof(*null_context_new));
81 gss_context_new->internal_ctx_id = null_context_new;
82 CDEBUG(D_SEC, "succesfully copied reverse null context\n");
84 return GSS_S_COMPLETE;
88 __u32 gss_inquire_context_null(struct gss_ctx *gss_context,
89 unsigned long *endtime)
92 return GSS_S_COMPLETE;
96 __u32 gss_wrap_null(struct gss_ctx *gss_context, rawobj_t *gss_header,
97 rawobj_t *message, int message_buffer_length,
100 return GSS_S_COMPLETE;
104 __u32 gss_unwrap_null(struct gss_ctx *gss_context, rawobj_t *gss_header,
105 rawobj_t *token, rawobj_t *message)
107 return GSS_S_COMPLETE;
111 __u32 gss_prep_bulk_null(struct gss_ctx *gss_context,
112 struct ptlrpc_bulk_desc *desc)
114 return GSS_S_COMPLETE;
118 __u32 gss_wrap_bulk_null(struct gss_ctx *gss_context,
119 struct ptlrpc_bulk_desc *desc, rawobj_t *token,
122 return GSS_S_COMPLETE;
126 __u32 gss_unwrap_bulk_null(struct gss_ctx *gss_context,
127 struct ptlrpc_bulk_desc *desc,
128 rawobj_t *token, int adj_nob)
130 return GSS_S_COMPLETE;
134 void gss_delete_sec_context_null(void *internal_context)
136 struct null_ctx *null_context = internal_context;
138 OBD_FREE_PTR(null_context);
141 int gss_display_null(struct gss_ctx *gss_context, char *buf, int bufsize)
143 return snprintf(buf, bufsize, "null");
146 static struct gss_api_ops gss_null_ops = {
147 .gss_import_sec_context = gss_import_sec_context_null,
148 .gss_copy_reverse_context = gss_copy_reverse_context_null,
149 .gss_inquire_context = gss_inquire_context_null,
151 .gss_verify_mic = NULL,
152 .gss_wrap = gss_wrap_null,
153 .gss_unwrap = gss_unwrap_null,
154 .gss_prep_bulk = gss_prep_bulk_null,
155 .gss_wrap_bulk = gss_wrap_bulk_null,
156 .gss_unwrap_bulk = gss_unwrap_bulk_null,
157 .gss_delete_sec_context = gss_delete_sec_context_null,
158 .gss_display = gss_display_null,
161 static struct subflavor_desc gss_null_sfs[] = {
163 .sf_subflavor = SPTLRPC_SUBFLVR_GSSNULL,
165 .sf_service = SPTLRPC_SVC_NULL,
171 * currently we leave module owner NULL
173 static struct gss_api_mech gss_null_mech = {
174 .gm_owner = NULL, /*THIS_MODULE, */
175 .gm_name = "gssnull",
176 .gm_oid = (rawobj_t) {
178 "\053\006\001\004\001\311\146\215\126\001\000\000"
180 .gm_ops = &gss_null_ops,
182 .gm_sfs = gss_null_sfs,
185 int __init init_null_module(void)
189 status = lgss_mech_register(&gss_null_mech);
191 CERROR("Failed to register null gss mechanism!\n");
196 void cleanup_null_module(void)
198 lgss_mech_unregister(&gss_null_mech);