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