auth.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. typedef struct Ticket Ticket;
  2. typedef struct Ticketreq Ticketreq;
  3. typedef struct Authenticator Authenticator;
  4. typedef struct Nvrsafe Nvrsafe;
  5. typedef struct Passwordreq Passwordreq;
  6. typedef struct Chalstate Chalstate;
  7. enum
  8. {
  9. DOMLEN= 48, /* length of an authentication domain name */
  10. DESKEYLEN= 7, /* length of a des key for encrypt/decrypt */
  11. CHALLEN= 8, /* length of a challenge */
  12. NETCHLEN= 16, /* max network challenge length */
  13. CONFIGLEN= 14,
  14. KEYDBLEN= NAMELEN+DESKEYLEN+4+2
  15. };
  16. /* encryption numberings (anti-replay) */
  17. enum
  18. {
  19. AuthTreq=1, /* ticket request */
  20. AuthChal=2, /* challenge box request */
  21. AuthPass=3, /* change password */
  22. AuthMod=6, /* modify user */
  23. AuthOK=4, /* reply follows */
  24. AuthErr=5, /* error follows */
  25. AuthTs=64, /* ticket encrypted with server's key */
  26. AuthTc, /* ticket encrypted with client's key */
  27. AuthAs, /* server generated authenticator */
  28. AuthAc /* client generated authenticator */
  29. };
  30. struct Ticketreq
  31. {
  32. char type;
  33. char authid[NAMELEN]; /* server's encryption id */
  34. char authdom[DOMLEN]; /* server's authentication domain */
  35. char chal[CHALLEN]; /* challenge from server */
  36. char hostid[NAMELEN]; /* host's encryption id */
  37. char uid[NAMELEN]; /* uid of requesting user on host */
  38. };
  39. #define TICKREQLEN (3*NAMELEN+CHALLEN+DOMLEN+1)
  40. struct Ticket
  41. {
  42. char num; /* replay protection */
  43. char chal[CHALLEN]; /* server challenge */
  44. char cuid[NAMELEN]; /* uid on client */
  45. char suid[NAMELEN]; /* uid on server */
  46. char key[DESKEYLEN]; /* nonce DES key */
  47. };
  48. #define TICKETLEN (CHALLEN+2*NAMELEN+DESKEYLEN+1)
  49. struct Authenticator
  50. {
  51. char num; /* replay protection */
  52. char chal[CHALLEN];
  53. ulong id; /* authenticator id, ++'d with each auth */
  54. };
  55. #define AUTHENTLEN (CHALLEN+4+1)
  56. struct Passwordreq
  57. {
  58. char num;
  59. char old[NAMELEN];
  60. char new[NAMELEN];
  61. };
  62. #define PASSREQLEN (2*NAMELEN+1)
  63. struct Nvrsafe
  64. {
  65. char machkey[DESKEYLEN];
  66. uchar machsum;
  67. char authkey[DESKEYLEN];
  68. uchar authsum;
  69. char config[CONFIGLEN];
  70. uchar configsum;
  71. char authid[NAMELEN];
  72. uchar authidsum;
  73. char authdom[DOMLEN];
  74. uchar authdomsum;
  75. };
  76. struct Chalstate
  77. {
  78. int afd; /* /dev/authenticate */
  79. int asfd; /* authdial() */
  80. char chal[NETCHLEN]; /* challenge/response */
  81. };
  82. extern int convT2M(Ticket*, char*, char*);
  83. extern void convM2T(char*, Ticket*, char*);
  84. extern int convA2M(Authenticator*, char*, char*);
  85. extern void convM2A(char*, Authenticator*, char*);
  86. extern int convTR2M(Ticketreq*, char*);
  87. extern void convM2TR(char*, Ticketreq*);
  88. extern int convPR2M(Passwordreq*, char*, char*);
  89. extern void convM2PR(char*, Passwordreq*, char*);
  90. extern uchar nvcsum(void*, int);
  91. extern int opasstokey(void*, char*);
  92. extern int passtokey(void*, char*);
  93. extern int authenticate(int, int);
  94. extern int newns(char*, char*);
  95. extern int authdial(void);
  96. extern int auth(int, uchar*);
  97. extern int srvauth(int, char*);
  98. extern int getchal(Chalstate*, char*);
  99. extern int chalreply(Chalstate*, char*);
  100. extern int amount(int, char*, int, char*);