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