1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Modifications for Lustre
5 * Copyright 2004, Cluster File Systems, Inc.
7 * Author: Eric Mei <ericm@clusterfs.com>
11 * linux/net/sunrpc/gss_krb5_seqnum.c
13 * Adapted from MIT Kerberos 5-1.2.1 lib/gssapi/krb5/util_seqnum.c
15 * Copyright (c) 2000 The Regents of the University of Michigan.
16 * All rights reserved.
18 * Andy Adamson <andros@umich.edu>
22 * Copyright 1993 by OpenVision Technologies, Inc.
24 * Permission to use, copy, modify, distribute, and sell this software
25 * and its documentation for any purpose is hereby granted without fee,
26 * provided that the above copyright notice appears in all copies and
27 * that both that copyright notice and this permission notice appear in
28 * supporting documentation, and that the name of OpenVision not be used
29 * in advertising or publicity pertaining to distribution of the software
30 * without specific, written prior permission. OpenVision makes no
31 * representations about the suitability of this software for any
32 * purpose. It is provided "as is" without express or implied warranty.
34 * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
35 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
36 * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
37 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
38 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
39 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
40 * PERFORMANCE OF THIS SOFTWARE.
44 # define EXPORT_SYMTAB
46 #define DEBUG_SUBSYSTEM S_SEC
48 #include <linux/init.h>
49 #include <linux/module.h>
50 #include <linux/slab.h>
51 #include <linux/crypto.h>
53 #include <liblustre.h>
54 //#include "../kcrypto/libcrypto.h"
57 #include <libcfs/kp30.h>
58 #include <linux/obd.h>
59 #include <linux/obd_class.h>
60 #include <linux/obd_support.h>
61 #include <linux/lustre_idl.h>
62 #include <linux/lustre_net.h>
63 #include <linux/lustre_import.h>
64 #include <linux/lustre_sec.h>
67 #include "gss_internal.h"
72 krb5_make_seq_num(struct crypto_tfm *key,
78 unsigned char plain[8];
80 plain[0] = (unsigned char) (seqnum & 0xff);
81 plain[1] = (unsigned char) ((seqnum >> 8) & 0xff);
82 plain[2] = (unsigned char) ((seqnum >> 16) & 0xff);
83 plain[3] = (unsigned char) ((seqnum >> 24) & 0xff);
90 return krb5_encrypt(key, cksum, plain, buf, 8);
94 krb5_get_seq_num(struct crypto_tfm *key,
101 unsigned char plain[8];
103 if ((code = krb5_decrypt(key, cksum, buf, plain, 8)))
106 if ((plain[4] != plain[5]) || (plain[4] != plain[6])
107 || (plain[4] != plain[7]))
108 return (__s32)KG_BAD_SEQ;
110 *direction = plain[4];
112 *seqnum = ((plain[0]) |
113 (plain[1] << 8) | (plain[2] << 16) | (plain[3] << 24));