hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sunrpc/rpc/auth.h

Packit 6c4009
/*
Packit 6c4009
 * auth.h, Authentication interface.
Packit 6c4009
 *
Packit 6c4009
 * Copyright (c) 2010, Oracle America, Inc.
Packit 6c4009
 *
Packit 6c4009
 * Redistribution and use in source and binary forms, with or without
Packit 6c4009
 * modification, are permitted provided that the following conditions are
Packit 6c4009
 * met:
Packit 6c4009
 *
Packit 6c4009
 *     * Redistributions of source code must retain the above copyright
Packit 6c4009
 *       notice, this list of conditions and the following disclaimer.
Packit 6c4009
 *     * Redistributions in binary form must reproduce the above
Packit 6c4009
 *       copyright notice, this list of conditions and the following
Packit 6c4009
 *       disclaimer in the documentation and/or other materials
Packit 6c4009
 *       provided with the distribution.
Packit 6c4009
 *     * Neither the name of the "Oracle America, Inc." nor the names of its
Packit 6c4009
 *       contributors may be used to endorse or promote products derived
Packit 6c4009
 *       from this software without specific prior written permission.
Packit 6c4009
 *
Packit 6c4009
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 6c4009
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 6c4009
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Packit 6c4009
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
Packit 6c4009
 *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
Packit 6c4009
 *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 6c4009
 *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Packit 6c4009
 *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit 6c4009
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
Packit 6c4009
 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit 6c4009
 *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 6c4009
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 6c4009
 *
Packit 6c4009
 * The data structures are completely opaque to the client.  The client
Packit 6c4009
 * is required to pass a AUTH * to routines that create rpc
Packit 6c4009
 * "sessions".
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#ifndef _RPC_AUTH_H
Packit 6c4009
Packit 6c4009
#define _RPC_AUTH_H	1
Packit 6c4009
#include <features.h>
Packit 6c4009
#include <rpc/xdr.h>
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
#define MAX_AUTH_BYTES	400
Packit 6c4009
#define MAXNETNAMELEN	255	/* maximum length of network user's name */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Status returned from authentication check
Packit 6c4009
 */
Packit 6c4009
enum auth_stat {
Packit 6c4009
	AUTH_OK=0,
Packit 6c4009
	/*
Packit 6c4009
	 * failed at remote end
Packit 6c4009
	 */
Packit 6c4009
	AUTH_BADCRED=1,			/* bogus credentials (seal broken) */
Packit 6c4009
	AUTH_REJECTEDCRED=2,		/* client should begin new session */
Packit 6c4009
	AUTH_BADVERF=3,			/* bogus verifier (seal broken) */
Packit 6c4009
	AUTH_REJECTEDVERF=4,		/* verifier expired or was replayed */
Packit 6c4009
	AUTH_TOOWEAK=5,			/* rejected due to security reasons */
Packit 6c4009
	/*
Packit 6c4009
	 * failed locally
Packit 6c4009
	*/
Packit 6c4009
	AUTH_INVALIDRESP=6,		/* bogus response verifier */
Packit 6c4009
	AUTH_FAILED=7			/* some unknown reason */
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
union des_block {
Packit 6c4009
	struct {
Packit 6c4009
		uint32_t high;
Packit 6c4009
		uint32_t low;
Packit 6c4009
	} key;
Packit 6c4009
	char c[8];
Packit 6c4009
};
Packit 6c4009
typedef union des_block des_block;
Packit 6c4009
extern bool_t xdr_des_block (XDR *__xdrs, des_block *__blkp) __THROW;
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Authentication info.  Opaque to client.
Packit 6c4009
 */
Packit 6c4009
struct opaque_auth {
Packit 6c4009
	enum_t	oa_flavor;		/* flavor of auth */
Packit 6c4009
	caddr_t	oa_base;		/* address of more auth stuff */
Packit 6c4009
	u_int	oa_length;		/* not to exceed MAX_AUTH_BYTES */
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Auth handle, interface to client side authenticators.
Packit 6c4009
 */
Packit 6c4009
typedef struct AUTH AUTH;
Packit 6c4009
struct AUTH {
Packit 6c4009
  struct opaque_auth ah_cred;
Packit 6c4009
  struct opaque_auth ah_verf;
Packit 6c4009
  union des_block ah_key;
Packit 6c4009
  struct auth_ops {
Packit 6c4009
    void (*ah_nextverf) (AUTH *);
Packit 6c4009
    int  (*ah_marshal) (AUTH *, XDR *);		/* nextverf & serialize */
Packit 6c4009
    int  (*ah_validate) (AUTH *, struct opaque_auth *);
Packit 6c4009
						/* validate verifier */
Packit 6c4009
    int  (*ah_refresh) (AUTH *);		/* refresh credentials */
Packit 6c4009
    void (*ah_destroy) (AUTH *); 	    	/* destroy this structure */
Packit 6c4009
  } *ah_ops;
Packit 6c4009
  caddr_t ah_private;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Authentication ops.
Packit 6c4009
 * The ops and the auth handle provide the interface to the authenticators.
Packit 6c4009
 *
Packit 6c4009
 * AUTH	*auth;
Packit 6c4009
 * XDR	*xdrs;
Packit 6c4009
 * struct opaque_auth verf;
Packit 6c4009
 */
Packit 6c4009
#define AUTH_NEXTVERF(auth)		\
Packit 6c4009
		((*((auth)->ah_ops->ah_nextverf))(auth))
Packit 6c4009
#define auth_nextverf(auth)		\
Packit 6c4009
		((*((auth)->ah_ops->ah_nextverf))(auth))
Packit 6c4009
Packit 6c4009
#define AUTH_MARSHALL(auth, xdrs)	\
Packit 6c4009
		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
Packit 6c4009
#define auth_marshall(auth, xdrs)	\
Packit 6c4009
		((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
Packit 6c4009
Packit 6c4009
#define AUTH_VALIDATE(auth, verfp)	\
Packit 6c4009
		((*((auth)->ah_ops->ah_validate))((auth), verfp))
Packit 6c4009
#define auth_validate(auth, verfp)	\
Packit 6c4009
		((*((auth)->ah_ops->ah_validate))((auth), verfp))
Packit 6c4009
Packit 6c4009
#define AUTH_REFRESH(auth)		\
Packit 6c4009
		((*((auth)->ah_ops->ah_refresh))(auth))
Packit 6c4009
#define auth_refresh(auth)		\
Packit 6c4009
		((*((auth)->ah_ops->ah_refresh))(auth))
Packit 6c4009
Packit 6c4009
#define AUTH_DESTROY(auth)		\
Packit 6c4009
		((*((auth)->ah_ops->ah_destroy))(auth))
Packit 6c4009
#define auth_destroy(auth)		\
Packit 6c4009
		((*((auth)->ah_ops->ah_destroy))(auth))
Packit 6c4009
Packit 6c4009
Packit 6c4009
extern struct opaque_auth _null_auth;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * These are the various implementations of client side authenticators.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Unix style authentication
Packit 6c4009
 * AUTH *authunix_create(machname, uid, gid, len, aup_gids)
Packit 6c4009
 *	char *machname;
Packit 6c4009
 *	int uid;
Packit 6c4009
 *	int gid;
Packit 6c4009
 *	int len;
Packit 6c4009
 *	int *aup_gids;
Packit 6c4009
 */
Packit 6c4009
extern AUTH *authunix_create (char *__machname, __uid_t __uid, __gid_t __gid,
Packit 6c4009
			      int __len, __gid_t *__aup_gids);
Packit 6c4009
extern AUTH *authunix_create_default (void);
Packit 6c4009
extern AUTH *authnone_create (void) __THROW;
Packit 6c4009
extern AUTH *authdes_create (const char *__servername, u_int __window,
Packit 6c4009
			     struct sockaddr *__syncaddr, des_block *__ckey)
Packit 6c4009
     __THROW;
Packit 6c4009
extern AUTH *authdes_pk_create (const char *, netobj *, u_int,
Packit 6c4009
				struct sockaddr *, des_block *) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
#define AUTH_NONE	0		/* no authentication */
Packit 6c4009
#define	AUTH_NULL	0		/* backward compatibility */
Packit 6c4009
#define	AUTH_SYS	1		/* unix style (uid, gids) */
Packit 6c4009
#define	AUTH_UNIX	AUTH_SYS
Packit 6c4009
#define	AUTH_SHORT	2		/* short hand unix style */
Packit 6c4009
#define AUTH_DES	3		/* des style (encrypted timestamps) */
Packit 6c4009
#define AUTH_DH		AUTH_DES	/* Diffie-Hellman (this is DES) */
Packit 6c4009
#define AUTH_KERB       4               /* kerberos style */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 *  Netname manipulating functions
Packit 6c4009
 *
Packit 6c4009
 */
Packit 6c4009
extern int getnetname (char *) __THROW;
Packit 6c4009
extern int host2netname (char *, const char *, const char *) __THROW;
Packit 6c4009
extern int user2netname (char *, const uid_t, const char *) __THROW;
Packit 6c4009
extern int netname2user (const char *, uid_t *, gid_t *, int *, gid_t *)
Packit 6c4009
     __THROW;
Packit 6c4009
extern int netname2host (const char *, char *, const int) __THROW;
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 *
Packit 6c4009
 * These routines interface to the keyserv daemon
Packit 6c4009
 *
Packit 6c4009
 */
Packit 6c4009
extern int key_decryptsession (char *, des_block *);
Packit 6c4009
extern int key_decryptsession_pk (char *, netobj *, des_block *);
Packit 6c4009
extern int key_encryptsession (char *, des_block *);
Packit 6c4009
extern int key_encryptsession_pk (char *, netobj *, des_block *);
Packit 6c4009
extern int key_gendes (des_block *);
Packit 6c4009
extern int key_setsecret (char *);
Packit 6c4009
extern int key_secretkey_is_set (void);
Packit 6c4009
extern int key_get_conv (char *, des_block *);
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * XDR an opaque authentication struct.
Packit 6c4009
 */
Packit 6c4009
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *) __THROW;
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* rpc/auth.h */