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) 2015, Trustees of Indiana University
25 * Author: Jeremy Filizetti <jfilizet@iu.edu>
30 #include "lgss_utils.h"
32 static int lgss_null_prepare_cred(struct lgss_cred *cred)
36 cred->lc_mech_token.value = malloc(sizeof(uint64_t));
37 if (!cred->lc_mech_token.value)
39 cred->lc_mech_token.length = sizeof(uint64_t);
41 /* random token so it's not cached by the other side */
45 /* Sec part flags needed on the other end */
46 tmp |= cred->lc_root_flags;
48 /* big-endian for the wire */
50 memcpy(cred->lc_mech_token.value, &tmp, cred->lc_mech_token.length);
55 static void lgss_null_release_cred(struct lgss_cred *cred)
57 free(cred->lc_mech_token.value);
60 static int lgss_null_validate_cred(struct lgss_cred *cred,
61 gss_buffer_desc *token,
62 gss_buffer_desc *ctx_token)
64 if (token->length <= 0)
67 ctx_token->length = token->length;
68 ctx_token->value = malloc(ctx_token->length);
69 memcpy(ctx_token->value, token->value, ctx_token->length);
73 struct lgss_mech_type lgss_mech_null = {
74 .lmt_name = "gssnull",
75 .lmt_mech_n = LGSS_MECH_NULL,
76 .lmt_prepare_cred = lgss_null_prepare_cred,
77 .lmt_release_cred = lgss_null_release_cred,
78 .lmt_validate_cred = lgss_null_validate_cred,