Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / ptlrpc / gss / gss_krb5.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Modifications for Lustre
5  * Copyright 2004 - 2006, Cluster File Systems, Inc.
6  * All rights reserved
7  * Author: Eric Mei <ericm@clusterfs.com>
8  */
9
10 /*
11  *  linux/include/linux/sunrpc/gss_krb5_types.h
12  *
13  *  Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h,
14  *  lib/gssapi/krb5/gssapiP_krb5.h, and others
15  *
16  *  Copyright (c) 2000 The Regents of the University of Michigan.
17  *  All rights reserved.
18  *
19  *  Andy Adamson   <andros@umich.edu>
20  *  Bruce Fields   <bfields@umich.edu>
21  */
22
23 /*
24  * Copyright 1995 by the Massachusetts Institute of Technology.
25  * All Rights Reserved.
26  *
27  * Export of this software from the United States of America may
28  *   require a specific license from the United States Government.
29  *   It is the responsibility of any person or organization contemplating
30  *   export to obtain such a license before exporting.
31  *
32  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
33  * distribute this software and its documentation for any purpose and
34  * without fee is hereby granted, provided that the above copyright
35  * notice appear in all copies and that both that copyright notice and
36  * this permission notice appear in supporting documentation, and that
37  * the name of M.I.T. not be used in advertising or publicity pertaining
38  * to distribution of the software without specific, written prior
39  * permission.  Furthermore if you modify this software you must label
40  * your software as modified software and not distribute it in such a
41  * fashion that it might be confused with the original M.I.T. software.
42  * M.I.T. makes no representations about the suitability of
43  * this software for any purpose.  It is provided "as is" without express
44  * or implied warranty.
45  *
46  */
47
48 #ifndef PTLRPC_GSS_KRB5_H
49 #define PTLRPC_GSS_KRB5_H
50
51 extern spinlock_t krb5_seq_lock;
52
53 /*
54  * RFC 4142
55  */
56
57 #define KG_USAGE_ACCEPTOR_SEAL          22
58 #define KG_USAGE_ACCEPTOR_SIGN          23
59 #define KG_USAGE_INITIATOR_SEAL         24
60 #define KG_USAGE_INITIATOR_SIGN         25
61
62 #define KG_TOK_MIC_MSG                  0x0404
63 #define KG_TOK_WRAP_MSG                 0x0504
64
65 #define FLAG_SENDER_IS_ACCEPTOR         0x01
66 #define FLAG_WRAP_CONFIDENTIAL          0x02
67 #define FLAG_ACCEPTOR_SUBKEY            0x04
68
69 struct krb5_header {
70         __u16           kh_tok_id;      /* token id */
71         __u8            kh_flags;       /* acceptor flags */
72         __u8            kh_filler;      /* 0xff */
73         __u16           kh_ec;          /* extra count */
74         __u16           kh_rrc;         /* right rotation count */
75         __u64           kh_seq;         /* sequence number */
76         __u8            kh_cksum[0];    /* checksum */
77 };
78
79 struct krb5_keyblock {
80         rawobj_t                 kb_key;
81         struct ll_crypto_cipher *kb_tfm;
82 };
83
84 struct krb5_ctx {
85         unsigned int            kc_initiate:1,
86                                 kc_cfx:1,
87                                 kc_seed_init:1,
88                                 kc_have_acceptor_subkey:1;
89         __s32                   kc_endtime;
90         __u8                    kc_seed[16];
91         __u64                   kc_seq_send;
92         __u64                   kc_seq_recv;
93         __u32                   kc_enctype;
94         struct krb5_keyblock    kc_keye;        /* encryption */
95         struct krb5_keyblock    kc_keyi;        /* integrity */
96         struct krb5_keyblock    kc_keyc;        /* checksum */
97         rawobj_t                kc_mech_used;
98 };
99
100 enum sgn_alg {
101         SGN_ALG_DES_MAC_MD5           = 0x0000,
102         SGN_ALG_MD2_5                 = 0x0001,
103         SGN_ALG_DES_MAC               = 0x0002,
104         SGN_ALG_3                     = 0x0003, /* not published */
105         SGN_ALG_HMAC_MD5              = 0x0011, /* microsoft w2k; no support */
106         SGN_ALG_HMAC_SHA1_DES3_KD     = 0x0004
107 };
108
109 enum seal_alg {
110         SEAL_ALG_NONE                 = 0xffff,
111         SEAL_ALG_DES                  = 0x0000,
112         SEAL_ALG_1                    = 0x0001, /* not published */
113         SEAL_ALG_MICROSOFT_RC4        = 0x0010, /* microsoft w2k; no support */
114         SEAL_ALG_DES3KD               = 0x0002
115 };
116
117 #define CKSUMTYPE_CRC32                 0x0001
118 #define CKSUMTYPE_RSA_MD4               0x0002
119 #define CKSUMTYPE_RSA_MD4_DES           0x0003
120 #define CKSUMTYPE_DESCBC                0x0004
121 /* des-mac-k */
122 /* rsa-md4-des-k */
123 #define CKSUMTYPE_RSA_MD5               0x0007
124 #define CKSUMTYPE_RSA_MD5_DES           0x0008
125 #define CKSUMTYPE_NIST_SHA              0x0009
126 #define CKSUMTYPE_HMAC_SHA1_DES3        0x000c
127 #define CKSUMTYPE_HMAC_SHA1_96_AES128   0x000f
128 #define CKSUMTYPE_HMAC_SHA1_96_AES256   0x0010
129 #define CKSUMTYPE_HMAC_MD5_ARCFOUR      -138
130
131 /* from gssapi_err_krb5.h */
132 #define KG_CCACHE_NOMATCH                        (39756032L)
133 #define KG_KEYTAB_NOMATCH                        (39756033L)
134 #define KG_TGT_MISSING                           (39756034L)
135 #define KG_NO_SUBKEY                             (39756035L)
136 #define KG_CONTEXT_ESTABLISHED                   (39756036L)
137 #define KG_BAD_SIGN_TYPE                         (39756037L)
138 #define KG_BAD_LENGTH                            (39756038L)
139 #define KG_CTX_INCOMPLETE                        (39756039L)
140 #define KG_CONTEXT                               (39756040L)
141 #define KG_CRED                                  (39756041L)
142 #define KG_ENC_DESC                              (39756042L)
143 #define KG_BAD_SEQ                               (39756043L)
144 #define KG_EMPTY_CCACHE                          (39756044L)
145 #define KG_NO_CTYPES                             (39756045L)
146
147 /* per Kerberos v5 protocol spec crypto types from the wire. 
148  * these get mapped to linux kernel crypto routines.  
149  */
150 #define ENCTYPE_NULL            0x0000
151 #define ENCTYPE_DES_CBC_CRC     0x0001        /* DES cbc mode with CRC-32 */
152 #define ENCTYPE_DES_CBC_MD4     0x0002        /* DES cbc mode with RSA-MD4 */
153 #define ENCTYPE_DES_CBC_MD5     0x0003        /* DES cbc mode with RSA-MD5 */
154 #define ENCTYPE_DES_CBC_RAW     0x0004        /* DES cbc mode raw */
155 /* XXX deprecated? */
156 #define ENCTYPE_DES3_CBC_SHA    0x0005        /* DES-3 cbc mode with NIST-SHA */
157 #define ENCTYPE_DES3_CBC_RAW    0x0006        /* DES-3 cbc mode raw */
158 #define ENCTYPE_DES_HMAC_SHA1   0x0008
159 #define ENCTYPE_DES3_CBC_SHA1   0x0010
160 #define ENCTYPE_AES128_CTS_HMAC_SHA1_96 0x0011
161 #define ENCTYPE_AES256_CTS_HMAC_SHA1_96 0x0012
162 #define ENCTYPE_ARCFOUR_HMAC    0x0017
163 #define ENCTYPE_ARCFOUR_HMAC_EXP 0x0018
164 #define ENCTYPE_UNKNOWN         0x01ff
165
166 #endif /* PTLRPC_GSS_KRB5_H */