File: ntlm_auth.h

package info (click to toggle)
pavuk 0.9.32-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,696 kB
  • ctags: 3,858
  • sloc: ansic: 51,667; sh: 3,381; makefile: 364
file content (123 lines) | stat: -rw-r--r-- 5,864 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/***************************************************************************/
/*    This code is part of WWW grabber called pavuk                        */
/*    Copyright (c) 1997 - 2001 Stefan Ondrejicka                          */
/*    Distributed under GPL 2 or later                                     */
/***************************************************************************/

#ifndef _ntlm_auth_h_
#define _ntlm_auth_h_

/****************************************************************/
/* based on document "NTLM Athentication Scheme for HTTP"       */
/* http://www.innovation.ch/java/ntlm.html                      */
/* by Ronald Tschaler <ronald@innovation.ch>                    */
/****************************************************************/

typedef unsigned char byte_t;

#ifdef __GNUC__
#define _PACKED         __attribute__((packed))
#else
#define _PACKED
#endif

#define NTLM_MSG1_SIZE 32+128
#define NTLM_MSG2_SIZE 40
#define NTLM_MSG3_SIZE 64+512

typedef struct
{
  byte_t protocol[8];           /* "NTLMSSP\0"                          */
  byte_t type;                  /* 0x01                                 */
  byte_t zero[3];               /* \0\0\0                               */
  unsigned short flags;         /* 0xb203                               */
  byte_t zero2[2];              /* \0\0                                 */

  short dom_len;                /* length of domainname                 */
  short dom_len2;               /* length of domainname                 */
  short dom_off;                /* offset of domainname in structure    */
  byte_t zero3[2];              /* \0\0                                 */

  short host_len;               /* length of hostname                   */
  short host_len2;              /* length of hostname                   */
  short host_off;               /* offset of hostname in structure      */
  byte_t zero4[2];              /* \0\0                                 */

  byte_t padding[128];          /* space for hostname and domainname    */
#if 0
  byte_t host[*];               /* hostname                             */
  byte_t dom[*];                /* domainname                           */
#endif
} _PACKED ntlm_type_1_msg_t;

typedef struct
{
  byte_t protocol[8];           /* "NTLMSSP\0"                          */
  byte_t type;                  /* 0x02                                 */
  byte_t zero[7];               /* \0\0\0\0\0\0\0                       */
  short msg_len;                /* 0x28                                 */
  byte_t zero2[2];              /* \0\0                                 */
  unsigned short flags;         /* 0x8201                               */
  byte_t zero3[2];              /* \0\0                                 */
  byte_t nonce[8];              /* server nonce                         */
  byte_t zero4[8];              /* \0\0\0\0\0\0\0\0                     */
} _PACKED ntlm_type_2_msg_t;

typedef struct
{
  byte_t protocol[8];           /* "NTLMSSP\0"                          */
  byte_t type;                  /* 0x03                                 */
  byte_t zero[3];               /* \0\0\0                               */

  short lm_resp_len;            /* LM response length (0x18)            */
  short lm_resp_len2;           /* LM response length (0x18)            */
  short lm_resp_off;            /* offset of LM response in structure   */
  byte_t zero2[2];              /* \0\0                                 */

  short nt_resp_len;            /* NT response length (0x18)            */
  short nt_resp_len2;           /* NT response length (0x18)            */
  short nt_resp_off;            /* offset of NT response in structure   */
  byte_t zero3[2];              /* \0\0                                 */

  short dom_len;                /* length of domainname                 */
  short dom_len2;               /* length of domainname                 */
  short dom_off;                /* offset of domainname in structure    */
  byte_t zero4[2];              /* \0\0                                 */

  short user_len;               /* length of username                   */
  short user_len2;              /* length of username                   */
  short user_off;               /* offset of username in structure      */
  byte_t zero5[2];              /* \0\0                                 */

  short host_len;               /* length of hostname                   */
  short host_len2;              /* length of hostname                   */
  short host_off;               /* offset of hostname in structure      */
  byte_t zero6[6];              /* \0\0\0\0\0\0                         */

  short msg_len;                /* message length                       */
  byte_t zero7[2];              /* \0\0                                 */

  unsigned short flags;         /* 0x8201                               */
  byte_t zero8[2];              /* \0\0                                 */

  byte_t padding[512];          /* space for hostname and domainname    */
#if 0
  byte_t host[*];               /* hostname                             */
  byte_t user[*];               /* username                             */
  byte_t dom[*];                /* domainname                           */
  byte_t lm_resp[*];            /* LM response                          */
  byte_t nt_resp[*];            /* NT response                          */
#endif
} _PACKED ntlm_type_3_msg_t;

extern char *ntlm_get_t1msg_str(char *, char *);
extern char *ntlm_get_nonce(char *, unsigned short *);
extern char *ntlm_get_t3msg_str(char *, char *, char *, char *, char *,
  unsigned short);

#ifndef ____ACCONFIG_TEST___
extern int ntlm_negotiate_connection(doc *, char *);
extern int ntlm_negotiate_proxy_connection(doc *, char *);
#endif

#endif