home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Telnet 2.7b5 / source / parse / tnae.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-21  |  4.0 KB  |  138 lines  |  [TEXT/CWIE]

  1. #define authType 'TNae'                    /* auth/encrypt module resource type */
  2. #define moduleType 'TNae'                /* auth/encrypt module file type */
  3.  
  4. #define NTMPAIRS    10                    /* max type/modifier pairs */
  5.  
  6. #define    IAC    255
  7. #define    SB    250
  8. #define    SE    240
  9.  
  10. #define BOGUS 0x50015001
  11.  
  12. /*
  13.  * Kerberos, encryption
  14.  */
  15. #define OPT_AUTHENTICATION 37
  16. #define OPT_ENCRYPT 38
  17.  
  18. #define KRB_REJECT        1        /* Rejected (reason might follow) */
  19. #define KRB_AUTH        0        /* Authentication data follows */
  20. #define KRB_ACCEPT        2        /* Accepted */
  21. #define KRB_CHALLENGE    3        /* Challenge for mutual auth */
  22. #define KRB_RESPONSE    4        /* Response for mutual auth */
  23.  
  24. #define TNQ_IS            0        /* Option is ... */
  25. #define TNQ_SEND        1        /* send option */
  26. #define TNQ_REPLY        2        /* suboption reply */
  27. #define TNQ_NAME        3        /* suboption name */
  28.  
  29. /*
  30. * AUTHENTICATION option types
  31. */
  32. #define AUTH_NULL        0      /* no authentication */
  33. #define AUTH_KERBEROS_V4 1      /* Kerberos version 4 */
  34. #define AUTH_KERBEROS_V5 2      /* Kerberos version 5 */
  35.  
  36. /*
  37. * AUTHENTICATION option modifiers
  38. */
  39. #define AUTH_WHO_MASK         1
  40. #define AUTH_CLIENT_TO_SERVER 0
  41. #define AUTH_SERVER_TO_CLIENT 1
  42. #define AUTH_HOW_MASK         2
  43. #define AUTH_HOW_ONE_WAY      0
  44. #define AUTH_HOW_MUTUAL       2
  45.  
  46. /*
  47.  * suboption buffer offsets 
  48.  */
  49. #define SB_OPTION    0            /* option byte */
  50. #define SB_SUBOPTION 1          /* is, send, reply, name */
  51. #define SB_TYPE      2          /* authentication type */
  52. #define SB_MODIFIER  3          /* type modifier */
  53. #define SB_DATATYPE  4          /* type of data */
  54. #define SB_DATA      5          /* offset to first data byte */
  55.  
  56. /*
  57.  * ENCRYPTION suboptions
  58.  */
  59. #define    ENCRYPT_IS            0    /* I pick encryption type ... */
  60. #define    ENCRYPT_SUPPORT        1    /* I support encryption types ... */
  61. #define    ENCRYPT_REPLY        2    /* Initial setup response */
  62. #define    ENCRYPT_START        3    /* Am starting to send encrypted */
  63. #define    ENCRYPT_END            4    /* Am ending encrypted */
  64. #define    ENCRYPT_REQSTART    5    /* Request you start encrypting */
  65. #define    ENCRYPT_REQEND        6    /* Request you send encrypting */
  66. #define    ENCRYPT_ENC_KEYID    7
  67. #define    ENCRYPT_DEC_KEYID    8
  68. #define    ENCRYPT_CNT            9
  69.  
  70. #define    ENCTYPE_ANY            0
  71. #define    ENCTYPE_DES_CFB64    1
  72. #define    ENCTYPE_DES_OFB64    2
  73. #define    ENCTYPE_CNT            3
  74.  
  75. /* 
  76.  * authentication or encryption module entry point 
  77.  */
  78. typedef long (*module)(long func, void *parameters);
  79.  
  80. /*
  81.  * TNAE functions.
  82.  */
  83. enum {
  84.     TNFUNC_INIT_SESSION_AUTH = 1,        /* init auth session data */
  85.     TNFUNC_INIT_SESSION_ENCRYPT,        /* init encrypt session data */
  86.     TNFUNC_QUERY_ENCRYPT,                /* query encryption capability */
  87.     TNFUNC_INIT_CODE,                    /* init code module */
  88.     TNFUNC_AUTH_SEND,                    /* process auth send sub-option */
  89.     TNFUNC_AUTH_REPLY,                    /* process auth reply sub-option */
  90.     TNFUNC_ENCRYPT_SB,                    /* process encryption sub-options */
  91.     TNFUNC_DECRYPT,                        /* decrypt data */
  92.     TNFUNC_ENCRYPT                        /* encrypt data */
  93. };
  94.  
  95.  
  96. /*
  97.  * TN code module return codes
  98.  */
  99. enum {
  100.     TNREP_OK = 0,                        /* no error */
  101.     TNREP_START_DECRYPT,                /* start decrypting (not an error) */
  102.     TNREP_AUTH_OK,                        /* authentication ok */
  103.     TNREP_AUTH_ERR,                        /* authentication rejected */
  104.     TNREP_ERROR,                        /* generic error */
  105.     TNREP_NOMEM                            /* no memory */
  106. };
  107.  
  108.  
  109. /*
  110.  * Parameters
  111.  */
  112. typedef struct tnParams_ {
  113.     void *authdata;                        /* auth data */
  114.     void *encryptdata;                    /* encrypt data */
  115.  
  116.     /* parameters for auth/encrypt_suboption */
  117.     unsigned char *subbuffer;            /* sub options buffer */
  118.     unsigned long sublength;
  119.     unsigned char *sendbuffer;            /* buffer to return option data */
  120.     unsigned long *sendlength;            /* length of return buffer */
  121.     Boolean hisencrypt;                    /* his encrypt option state */
  122.     Boolean myencrypt;                    /* my encrypt option state */
  123.     char *cname;                        /* pointer to cannonical hostname */
  124.  
  125.     /* used by authencrypt.c */
  126.     module entry;                        /* auth/encrypt code module entry point */
  127.  
  128.     /* data and flags for client */
  129.     Boolean encrypting;                    /* we are encrypting */
  130.     Boolean startencrypting;            /* time to start encrypting */
  131.     Boolean decrypting;                    /* we are decrypting */
  132.     long data;                            /* for encrypt/decrypt */
  133.     unsigned char *ebuf;                /* encrypt buf */
  134. } tnParams;
  135.  
  136.  
  137.  
  138.