1/* Copyright (C) 1996-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _RPC_AUTH_DES_H
19#define _RPC_AUTH_DES_H 1
20
21#include <sys/cdefs.h>
22#include <rpc/auth.h>
23
24__BEGIN_DECLS
25
26/* There are two kinds of "names": fullnames and nicknames */
27enum authdes_namekind
28 {
29 ADN_FULLNAME,
30 ADN_NICKNAME
31 };
32
33/* A fullname contains the network name of the client,
34 a conversation key and the window */
35struct authdes_fullname
36 {
37 char *name; /* network name of client, up to MAXNETNAMELEN */
38 des_block key; /* conversation key */
39 uint32_t window; /* associated window */
40 };
41
42/* A credential */
43struct authdes_cred
44 {
45 enum authdes_namekind adc_namekind;
46 struct authdes_fullname adc_fullname;
47 uint32_t adc_nickname;
48 };
49
50/* A timeval replacement for !32bit platforms */
51struct rpc_timeval
52 {
53 uint32_t tv_sec; /* Seconds. */
54 uint32_t tv_usec; /* Microseconds. */
55 };
56
57/* A des authentication verifier */
58struct authdes_verf
59 {
60 union
61 {
62 struct rpc_timeval adv_ctime; /* clear time */
63 des_block adv_xtime; /* crypt time */
64 }
65 adv_time_u;
66 uint32_t adv_int_u;
67 };
68
69/* des authentication verifier: client variety
70
71 adv_timestamp is the current time.
72 adv_winverf is the credential window + 1.
73 Both are encrypted using the conversation key. */
74#define adv_timestamp adv_time_u.adv_ctime
75#define adv_xtimestamp adv_time_u.adv_xtime
76#define adv_winverf adv_int_u
77
78/* des authentication verifier: server variety
79
80 adv_timeverf is the client's timestamp + client's window
81 adv_nickname is the server's nickname for the client.
82 adv_timeverf is encrypted using the conversation key. */
83#define adv_timeverf adv_time_u.adv_ctime
84#define adv_xtimeverf adv_time_u.adv_xtime
85#define adv_nickname adv_int_u
86
87/* Map a des credential into a unix cred. */
88extern int authdes_getucred (const struct authdes_cred * __adc,
89 uid_t * __uid, gid_t * __gid,
90 short *__grouplen, gid_t * __groups) __THROW;
91
92/* Get the public key for NAME and place it in KEY. NAME can only be
93 up to MAXNETNAMELEN bytes long and the destination buffer KEY should
94 have HEXKEYBYTES + 1 bytes long to fit all characters from the key. */
95extern int getpublickey (const char *__name, char *__key) __THROW;
96
97/* Get the secret key for NAME and place it in KEY. PASSWD is used to
98 decrypt the encrypted key stored in the database. NAME can only be
99 up to MAXNETNAMELEN bytes long and the destination buffer KEY
100 should have HEXKEYBYTES + 1 bytes long to fit all characters from
101 the key. */
102extern int getsecretkey (const char *__name, char *__key,
103 const char *__passwd) __THROW;
104
105extern int rtime (struct sockaddr_in *__addrp, struct rpc_timeval *__timep,
106 struct rpc_timeval *__timeout) __THROW;
107
108__END_DECLS
109
110
111#endif /* rpc/auth_des.h */
112