Path: blob/main/crypto/krb5/src/include/gssrpc/auth.h
34907 views
/* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */1/*2* Copyright (c) 2010, Oracle America, Inc.3*4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions are met:8*9* * Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* * Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in14* the documentation and/or other materials provided with the15* distribution.16*17* * Neither the name of the "Oracle America, Inc." nor the names of18* its contributors may be used to endorse or promote products19* derived from this software without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS22* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED23* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A24* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT25* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,26* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED27* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR28* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF29* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING30* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS31* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.32*/3334/*35* auth.h, Authentication interface.36*37* The data structures are completely opaque to the client. The client38* is required to pass a AUTH * to routines that create rpc39* "sessions".40*/41#ifndef GSSRPC_AUTH_H42#define GSSRPC_AUTH_H4344#include <gssrpc/xdr.h>4546GSSRPC__BEGIN_DECLS4748#define MAX_AUTH_BYTES 40049#define MAXNETNAMELEN 255 /* maximum length of network user's name */5051/*52* Status returned from authentication check53*/54enum auth_stat {55AUTH_OK=0,56/*57* failed at remote end58*/59AUTH_BADCRED=1, /* bogus credentials (seal broken) */60AUTH_REJECTEDCRED=2, /* client should begin new session */61AUTH_BADVERF=3, /* bogus verifier (seal broken) */62AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */63AUTH_TOOWEAK=5, /* rejected due to security reasons */64/*65* failed locally66*/67AUTH_INVALIDRESP=6, /* bogus response verifier */68AUTH_FAILED=7, /* some unknown reason */69/*70* RPCSEC_GSS errors71*/72RPCSEC_GSS_CREDPROBLEM = 13,73RPCSEC_GSS_CTXPROBLEM = 1474};7576union des_block {77char c[8];78};79typedef union des_block des_block;80extern bool_t xdr_des_block(XDR *, des_block *);8182/*83* Authentication info. Opaque to client.84*/85struct opaque_auth {86enum_t oa_flavor; /* flavor of auth */87caddr_t oa_base; /* address of more auth stuff */88u_int oa_length; /* not to exceed MAX_AUTH_BYTES */89};909192/*93* Auth handle, interface to client side authenticators.94*/95struct rpc_msg;9697typedef struct AUTH {98struct opaque_auth ah_cred;99struct opaque_auth ah_verf;100union des_block ah_key;101struct auth_ops {102void (*ah_nextverf)(struct AUTH *);103/* nextverf & serialize */104int (*ah_marshal)(struct AUTH *, XDR *);105/* validate varifier */106int (*ah_validate)(struct AUTH *,107struct opaque_auth *);108/* refresh credentials */109int (*ah_refresh)(struct AUTH *, struct rpc_msg *);110/* destroy this structure */111void (*ah_destroy)(struct AUTH *);112/* encode data for wire */113int (*ah_wrap)(struct AUTH *, XDR *,114xdrproc_t, caddr_t);115/* decode data from wire */116int (*ah_unwrap)(struct AUTH *, XDR *,117xdrproc_t, caddr_t);118} *ah_ops;119void *ah_private;120} AUTH;121122123/*124* Authentication ops.125* The ops and the auth handle provide the interface to the authenticators.126*127* AUTH *auth;128* XDR *xdrs;129* struct opaque_auth verf;130*/131#define AUTH_NEXTVERF(auth) \132((*((auth)->ah_ops->ah_nextverf))(auth))133#define auth_nextverf(auth) \134((*((auth)->ah_ops->ah_nextverf))(auth))135136#define AUTH_MARSHALL(auth, xdrs) \137((*((auth)->ah_ops->ah_marshal))(auth, xdrs))138#define auth_marshall(auth, xdrs) \139((*((auth)->ah_ops->ah_marshal))(auth, xdrs))140141#define AUTH_VALIDATE(auth, verfp) \142((*((auth)->ah_ops->ah_validate))((auth), verfp))143#define auth_validate(auth, verfp) \144((*((auth)->ah_ops->ah_validate))((auth), verfp))145146#define AUTH_REFRESH(auth, msg) \147((*((auth)->ah_ops->ah_refresh))(auth, msg))148#define auth_refresh(auth, msg) \149((*((auth)->ah_ops->ah_refresh))(auth, msg))150151#define AUTH_WRAP(auth, xdrs, xfunc, xwhere) \152((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \153xfunc, xwhere))154#define auth_wrap(auth, xdrs, xfunc, xwhere) \155((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \156xfunc, xwhere))157#define AUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \158((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \159xfunc, xwhere))160#define auth_unwrap(auth, xdrs, xfunc, xwhere) \161((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \162xfunc, xwhere))163164#define AUTH_DESTROY(auth) \165((*((auth)->ah_ops->ah_destroy))(auth))166#define auth_destroy(auth) \167((*((auth)->ah_ops->ah_destroy))(auth))168169170#ifdef GSSRPC__IMPL171/* RENAMED: should be _null_auth if we can use reserved namespace. */172extern struct opaque_auth gssrpc__null_auth;173#endif174175/*176* These are the various implementations of client side authenticators.177*/178179/*180* Unix style authentication181* AUTH *authunix_create(machname, uid, gid, len, aup_gids)182* char *machname;183* int uid;184* int gid;185* int len;186* int *aup_gids;187*/188extern AUTH *authunix_create(char *machname, int uid, int gid, int len,189int *aup_gids);190extern AUTH *authunix_create_default(void); /* takes no parameters */191extern AUTH *authnone_create(void); /* takes no parameters */192extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *);193194#define AUTH_NONE 0 /* no authentication */195#define AUTH_NULL 0 /* backward compatibility */196#define AUTH_UNIX 1 /* unix style (uid, gids) */197#define AUTH_SHORT 2 /* short hand unix style */198#define AUTH_DES 3 /* des style (encrypted timestamps) */199#define AUTH_GSSAPI 300001 /* GSS-API style */200#define RPCSEC_GSS 6 /* RPCSEC_GSS */201202GSSRPC__END_DECLS203204#endif /* !defined(GSSRPC_AUTH_H) */205206207