OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/WINNT/afsd/krb.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 /*
00011  * Excerpted from krb.sed
00012  */
00013 
00014 /*
00015  * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
00016  *
00017  * For copying and distribution information, please see the file
00018  * <mit-copyright.h>.
00019  *
00020  * Include file for the Kerberos library.
00021  */
00022 
00023 /* Only one time, please */
00024 #ifndef KRB_DEFS
00025 #define KRB_DEFS
00026 
00027 /* Need some defs from des.h     */
00028 #include <hcrypto/des.h>
00029 
00030 /* General definitions */
00031 #define         KSUCCESS        0
00032 #define         KFAILURE        255
00033 
00034 /* The maximum sizes for aname, realm, sname, and instance +1 */
00035 #define         ANAME_SZ        40
00036 #define         REALM_SZ        40
00037 #define         SNAME_SZ        40
00038 #define         INST_SZ         40
00039 /* include space for '.' and '@' */
00040 #define         MAX_K_NAME_SZ   (ANAME_SZ + INST_SZ + REALM_SZ + 2)
00041 #define         KKEY_SZ         100
00042 #define         VERSION_SZ      1
00043 #define         MSG_TYPE_SZ     1
00044 #define         DATE_SZ         26      /* RTI date output */
00045 
00046 #define         MAX_HSTNM       100
00047 
00048 #ifndef DEFAULT_TKT_LIFE                /* allow compile-time override */
00049 #define         DEFAULT_TKT_LIFE        120 /* default lifetime 10 hrs */
00050 #endif
00051 
00052 /* Definition of text structure used to pass text around */
00053 #define         MAX_KTXT_LEN    1250
00054 
00055 struct ktext {
00056     unsigned int     length;            /* Length of the text */
00057     unsigned char dat[MAX_KTXT_LEN];    /* The data itself */
00058     unsigned long mbz;          /* zero to catch runaway strings */
00059 };
00060 
00061 typedef struct ktext *KTEXT;
00062 typedef struct ktext KTEXT_ST;
00063 
00064 
00065 /* Definitions for send_to_kdc */
00066 #define CLIENT_KRB_TIMEOUT      4       /* time between retries */
00067 #define CLIENT_KRB_RETRY        5       /* retry this many times */
00068 #define CLIENT_KRB_BUFLEN       512     /* max unfragmented packet */
00069 
00070 /* Parameters for rd_ap_req */
00071 /* Maximum alloable clock skew in seconds */
00072 #define         CLOCK_SKEW      5*60
00073 
00074 /* Error codes returned from the KDC */
00075 #define         KDC_OK          0       /* Request OK */
00076 #define         KDC_NAME_EXP    1       /* Principal expired */
00077 #define         KDC_SERVICE_EXP 2       /* Service expired */
00078 #define         KDC_AUTH_EXP    3       /* Auth expired */
00079 #define         KDC_PKT_VER     4       /* Protocol version unknown */
00080 #define         KDC_P_MKEY_VER  5       /* Wrong master key version */
00081 #define         KDC_S_MKEY_VER  6       /* Wrong master key version */
00082 #define         KDC_BYTE_ORDER  7       /* Byte order unknown */
00083 #define         KDC_PR_UNKNOWN  8       /* Principal unknown */
00084 #define         KDC_PR_N_UNIQUE 9       /* Principal not unique */
00085 #define         KDC_NULL_KEY   10       /* Principal has null key */
00086 #define         KDC_GEN_ERR    20       /* Generic error from KDC */
00087 
00088 
00089 /* Values returned by get_credentials */
00090 #define         GC_OK           0       /* Retrieve OK */
00091 #define         RET_OK          0       /* Retrieve OK */
00092 #define         GC_TKFIL       21       /* Can't read ticket file */
00093 #define         RET_TKFIL      21       /* Can't read ticket file */
00094 #define         GC_NOTKT       22       /* Can't find ticket or TGT */
00095 #define         RET_NOTKT      22       /* Can't find ticket or TGT */
00096 
00097 
00098 /* Values returned by mk_ap_req  */
00099 #define         MK_AP_OK        0       /* Success */
00100 #define         MK_AP_TGTEXP   26       /* TGT Expired */
00101 
00102 /* Values returned by rd_ap_req */
00103 #define         RD_AP_OK        0       /* Request authentic */
00104 #define         RD_AP_UNDEC    31       /* Can't decode authenticator */
00105 #define         RD_AP_EXP      32       /* Ticket expired */
00106 #define         RD_AP_NYV      33       /* Ticket not yet valid */
00107 #define         RD_AP_REPEAT   34       /* Repeated request */
00108 #define         RD_AP_NOT_US   35       /* The ticket isn't for us */
00109 #define         RD_AP_INCON    36       /* Request is inconsistent */
00110 #define         RD_AP_TIME     37       /* delta_t too big */
00111 #define         RD_AP_BADD     38       /* Incorrect net address */
00112 #define         RD_AP_VERSION  39       /* protocol version mismatch */
00113 #define         RD_AP_MSG_TYPE 40       /* invalid msg type */
00114 #define         RD_AP_MODIFIED 41       /* message stream modified */
00115 #define         RD_AP_ORDER    42       /* message out of order */
00116 #define         RD_AP_UNAUTHOR 43       /* unauthorized request */
00117 
00118 /* Values returned by get_pw_tkt */
00119 #define         GT_PW_OK        0       /* Got password changing tkt */
00120 #define         GT_PW_NULL     51       /* Current PW is null */
00121 #define         GT_PW_BADPW    52       /* Incorrect current password */
00122 #define         GT_PW_PROT     53       /* Protocol Error */
00123 #define         GT_PW_KDCERR   54       /* Error returned by KDC */
00124 #define         GT_PW_NULLTKT  55       /* Null tkt returned by KDC */
00125 
00126 
00127 /* Values returned by send_to_kdc */
00128 #define         SKDC_OK         0       /* Response received */
00129 #define         SKDC_RETRY     56       /* Retry count exceeded */
00130 #define         SKDC_CANT      57       /* Can't send request */
00131 
00132 /*
00133  * Values returned by get_intkt
00134  * (can also return SKDC_* and KDC errors)
00135  */
00136 
00137 #define         INTK_OK         0       /* Ticket obtained */
00138 #define         INTK_W_NOTALL  61       /* Not ALL tickets returned */
00139 #define         INTK_BADPW     62       /* Incorrect password */
00140 #define         INTK_PROT      63       /* Protocol Error */
00141 #define         INTK_ERR       70       /* Other error */
00142 
00143 /* Values returned by get_adtkt */
00144 #define         AD_OK           0       /* Ticket Obtained */
00145 #define         AD_NOTGT       71       /* Don't have tgt */
00146 
00147 /* Error codes returned by ticket file utilities */
00148 #define         NO_TKT_FIL      76      /* No ticket file found */
00149 #define         TKT_FIL_ACC     77      /* Couldn't access tkt file */
00150 #define         TKT_FIL_LCK     78      /* Couldn't lock ticket file */
00151 #define         TKT_FIL_FMT     79      /* Bad ticket file format */
00152 #define         TKT_FIL_INI     80      /* tf_init not called first */
00153 
00154 /* Error code returned by kparse_name */
00155 #define         KNAME_FMT       81      /* Bad Kerberos name format */
00156 
00157 /* Error code returned by krb_mk_safe */
00158 #define         SAFE_PRIV_ERROR -1      /* syscall error */
00159 
00160 #if 0
00161 /*
00162  * macros for byte swapping; also scratch space
00163  * u_quad  0-->7, 1-->6, 2-->5, 3-->4, 4-->3, 5-->2, 6-->1, 7-->0
00164  * u_long  0-->3, 1-->2, 2-->1, 3-->0
00165  * u_short 0-->1, 1-->0
00166  */
00167 
00168 #define     swap_u_16(x) {\
00169  unsigned long   _krb_swap_tmp[4];\
00170  swab(((char *) x) +0, ((char *)  _krb_swap_tmp) +14 ,2); \
00171  swab(((char *) x) +2, ((char *)  _krb_swap_tmp) +12 ,2); \
00172  swab(((char *) x) +4, ((char *)  _krb_swap_tmp) +10 ,2); \
00173  swab(((char *) x) +6, ((char *)  _krb_swap_tmp) +8  ,2); \
00174  swab(((char *) x) +8, ((char *)  _krb_swap_tmp) +6 ,2); \
00175  swab(((char *) x) +10,((char *)  _krb_swap_tmp) +4 ,2); \
00176  swab(((char *) x) +12,((char *)  _krb_swap_tmp) +2 ,2); \
00177  swab(((char *) x) +14,((char *)  _krb_swap_tmp) +0 ,2); \
00178  memcpy((char *)x, (char *)_krb_swap_tmp, 16);\
00179                             }
00180 
00181 #define     swap_u_12(x) {\
00182  unsigned long   _krb_swap_tmp[4];\
00183  swab(( char *) x,     ((char *)  _krb_swap_tmp) +10 ,2); \
00184  swab(((char *) x) +2, ((char *)  _krb_swap_tmp) +8 ,2); \
00185  swab(((char *) x) +4, ((char *)  _krb_swap_tmp) +6 ,2); \
00186  swab(((char *) x) +6, ((char *)  _krb_swap_tmp) +4 ,2); \
00187  swab(((char *) x) +8, ((char *)  _krb_swap_tmp) +2 ,2); \
00188  swab(((char *) x) +10,((char *)  _krb_swap_tmp) +0 ,2); \
00189  memcpy((char *)x, (char *)_krb_swap_tmp, 12);\
00190                             }
00191 
00192 #define     swap_C_Block(x) {\
00193  unsigned long   _krb_swap_tmp[4];\
00194  swab(( char *) x,    ((char *)  _krb_swap_tmp) +6 ,2); \
00195  swab(((char *) x) +2,((char *)  _krb_swap_tmp) +4 ,2); \
00196  swab(((char *) x) +4,((char *)  _krb_swap_tmp) +2 ,2); \
00197  swab(((char *) x) +6,((char *)  _krb_swap_tmp)    ,2); \
00198  memcpy((char *)x, (char *)_krb_swap_tmp, 8);\
00199                             }
00200 #define     swap_u_quad(x) {\
00201  unsigned long   _krb_swap_tmp[4];\
00202  swab(( char *) &x,    ((char *)  _krb_swap_tmp) +6 ,2); \
00203  swab(((char *) &x) +2,((char *)  _krb_swap_tmp) +4 ,2); \
00204  swab(((char *) &x) +4,((char *)  _krb_swap_tmp) +2 ,2); \
00205  swab(((char *) &x) +6,((char *)  _krb_swap_tmp)    ,2); \
00206  memcpy((char *)&x, (char *)_krb_swap_tmp, 8);\
00207                             }
00208 
00209 #define     swap_u_long(x) {\
00210  unsigned long   _krb_swap_tmp[4];\
00211  swab((char *)  &x,    ((char *)  _krb_swap_tmp) +2 ,2); \
00212  swab(((char *) &x) +2,((char *)  _krb_swap_tmp),2); \
00213  x = _krb_swap_tmp[0];   \
00214                            }
00215 
00216 #define     swap_u_short(x) {\
00217  unsigned short _krb_swap_sh_tmp; \
00218  swab((char *)  &x,    ( &_krb_swap_sh_tmp) ,2); \
00219  x = (unsigned short) _krb_swap_sh_tmp; \
00220                             }
00221 #endif /* 0 */
00222 
00223 #include "krb_prot.h"
00224 
00225 static send_to_kdc(
00226     KTEXT pkt,
00227     KTEXT rpkt);
00228 
00229 #endif  /* KRB_DEFS */
 All Data Structures Files Functions Variables