]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/rpc/auth_kerb.h
Remove spurious newline
[FreeBSD/FreeBSD.git] / include / rpc / auth_kerb.h
1 /*      $FreeBSD$ */
2 /*-
3  * SPDX-License-Identifier: BSD-3-Clause
4  *
5  * Copyright (c) 2009, Sun Microsystems, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  * - Redistributions of source code must retain the above copyright notice,
11  *   this list of conditions and the following disclaimer.
12  * - Redistributions in binary form must reproduce the above copyright notice,
13  *   this list of conditions and the following disclaimer in the documentation
14  *   and/or other materials provided with the distribution.
15  * - Neither the name of Sun Microsystems, Inc. nor the names of its
16  *   contributors may be used to endorse or promote products derived
17  *   from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 /*
32  * auth_kerb.h, Protocol for Kerberos style authentication for RPC
33  *
34  * Copyright (C) 1986, Sun Microsystems, Inc.
35  */
36
37 #ifndef _RPC_AUTH_KERB_H
38 #define _RPC_AUTH_KERB_H
39
40 #ifdef KERBEROS
41
42 #include <kerberos/krb.h>
43 #include <sys/socket.h>
44 #include <sys/t_kuser.h>
45 #include <netinet/in.h>
46 #include <rpc/svc.h>
47
48 /*
49  * There are two kinds of "names": fullnames and nicknames
50  */
51 enum authkerb_namekind {
52         AKN_FULLNAME,
53         AKN_NICKNAME
54 };
55 /*
56  * A fullname contains the ticket and the window
57  */
58 struct authkerb_fullname {
59         KTEXT_ST ticket;
60         u_long window;          /* associated window */
61 };
62
63 /*
64  *  cooked credential stored in rq_clntcred
65  */
66 struct authkerb_clnt_cred {
67         /* start of AUTH_DAT */
68         unsigned char k_flags;  /* Flags from ticket */
69         char    pname[ANAME_SZ]; /* Principal's name */
70         char    pinst[INST_SZ]; /* His Instance */
71         char    prealm[REALM_SZ]; /* His Realm */
72         unsigned long checksum; /* Data checksum (opt) */
73         C_Block session;        /* Session Key */
74         int     life;           /* Life of ticket */
75         unsigned long time_sec; /* Time ticket issued */
76         unsigned long address;  /* Address in ticket */
77         /* KTEXT_ST reply;      Auth reply (opt) */
78         /* end of AUTH_DAT */
79         unsigned long expiry;   /* time the ticket is expiring */
80         u_long nickname;        /* Nickname into cache */
81         u_long window;          /* associated window */
82 };
83
84 typedef struct authkerb_clnt_cred authkerb_clnt_cred;
85
86 /*
87  * A credential
88  */
89 struct authkerb_cred {
90         enum authkerb_namekind akc_namekind;
91         struct authkerb_fullname akc_fullname;
92         u_long akc_nickname;
93 };
94
95 /*
96  * A kerb authentication verifier
97  */
98 struct authkerb_verf {
99         union {
100                 struct timeval akv_ctime;       /* clear time */
101                 des_block akv_xtime;            /* crypt time */
102         } akv_time_u;
103         u_long akv_int_u;
104 };
105
106 /*
107  * des authentication verifier: client variety
108  *
109  * akv_timestamp is the current time.
110  * akv_winverf is the credential window + 1.
111  * Both are encrypted using the conversation key.
112  */
113 #ifndef akv_timestamp
114 #define akv_timestamp   akv_time_u.akv_ctime
115 #define akv_xtimestamp  akv_time_u.akv_xtime
116 #define akv_winverf     akv_int_u
117 #endif
118 /*
119  * des authentication verifier: server variety
120  *
121  * akv_timeverf is the client's timestamp + client's window
122  * akv_nickname is the server's nickname for the client.
123  * akv_timeverf is encrypted using the conversation key.
124  */
125 #ifndef akv_timeverf
126 #define akv_timeverf    akv_time_u.akv_ctime
127 #define akv_xtimeverf   akv_time_u.akv_xtime
128 #define akv_nickname    akv_int_u
129 #endif
130
131 /*
132  * Register the service name, instance and realm.
133  */
134 extern int      authkerb_create(char *, char *, char *, u_int,
135                         struct netbuf *, int *, dev_t, int, AUTH **);
136 extern bool_t   xdr_authkerb_cred(XDR *, struct authkerb_cred *);
137 extern bool_t   xdr_authkerb_verf(XDR *, struct authkerb_verf *);
138 extern int      svc_kerb_reg(SVCXPRT *, char *, char *, char *);
139 extern enum auth_stat _svcauth_kerb(struct svc_req *, struct rpc_msg *);
140
141 #endif  /* KERBEROS */
142 #endif  /* !_RPC_AUTH_KERB_H */