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