Commit | Line | Data |
---|---|---|
384152a6 | 1 | /* $Cambridge: exim/src/src/auths/auth-spa.h,v 1.4 2005/05/24 08:15:02 tom Exp $ */ |
0756eb3c PH |
2 | |
3 | /************************************************* | |
4 | * Exim - an Internet mail transport agent * | |
5 | *************************************************/ | |
6 | ||
7 | /* | |
8 | * This file provides the necessary methods for authenticating with | |
9 | * Microsoft's Secure Password Authentication. | |
10 | ||
11 | * All the code used here was torn by Marc Prud'hommeaux out of the | |
12 | * Samba project (by Andrew Tridgell, Jeremy Allison, and others). | |
13 | */ | |
8e669ac1 PH |
14 | |
15 | /* December 2004: The spa_base64_to_bits() function has no length checking in | |
16 | it. I have added a check. PH */ | |
0756eb3c PH |
17 | |
18 | /* It seems that some systems have existing but different definitions of some | |
19 | of the following types. I received a complaint about "int16" causing | |
20 | compilation problems. So I (PH) have renamed them all, to be on the safe side. | |
21 | ||
22 | typedef signed short int16; | |
23 | typedef unsigned short uint16; | |
24 | typedef unsigned uint32; | |
25 | typedef unsigned char uint8; | |
26 | */ | |
27 | ||
28 | typedef signed short int16x; | |
29 | typedef unsigned short uint16x; | |
30 | typedef unsigned uint32x; | |
31 | typedef unsigned char uint8x; | |
32 | ||
33 | typedef struct | |
34 | { | |
384152a6 TK |
35 | uint16x len; |
36 | uint16x maxlen; | |
37 | uint32x offset; | |
0756eb3c PH |
38 | } SPAStrHeader; |
39 | ||
40 | typedef struct | |
41 | { | |
384152a6 TK |
42 | char ident[8]; |
43 | uint32x msgType; | |
0756eb3c | 44 | SPAStrHeader uDomain; |
384152a6 TK |
45 | uint32x flags; |
46 | uint8x challengeData[8]; | |
47 | uint8x reserved[8]; | |
0756eb3c | 48 | SPAStrHeader emptyString; |
384152a6 TK |
49 | uint8x buffer[1024]; |
50 | uint32x bufIndex; | |
0756eb3c PH |
51 | } SPAAuthChallenge; |
52 | ||
53 | ||
54 | typedef struct | |
55 | { | |
384152a6 TK |
56 | char ident[8]; |
57 | uint32x msgType; | |
58 | uint32x flags; | |
0756eb3c PH |
59 | SPAStrHeader user; |
60 | SPAStrHeader domain; | |
384152a6 TK |
61 | uint8x buffer[1024]; |
62 | uint32x bufIndex; | |
0756eb3c PH |
63 | } SPAAuthRequest; |
64 | ||
65 | typedef struct | |
66 | { | |
384152a6 TK |
67 | char ident[8]; |
68 | uint32x msgType; | |
0756eb3c PH |
69 | SPAStrHeader lmResponse; |
70 | SPAStrHeader ntResponse; | |
71 | SPAStrHeader uDomain; | |
72 | SPAStrHeader uUser; | |
73 | SPAStrHeader uWks; | |
74 | SPAStrHeader sessionKey; | |
384152a6 TK |
75 | uint32x flags; |
76 | uint8x buffer[1024]; | |
77 | uint32x bufIndex; | |
0756eb3c PH |
78 | } SPAAuthResponse; |
79 | ||
80 | #define spa_request_length(ptr) (((ptr)->buffer - (uint8x*)(ptr)) + (ptr)->bufIndex) | |
81 | ||
82 | void spa_bits_to_base64 (unsigned char *, const unsigned char *, int); | |
85b87bc2 | 83 | int spa_base64_to_bits(char *, int, const char *); |
0756eb3c PH |
84 | void spa_build_auth_response (SPAAuthChallenge *challenge, |
85 | SPAAuthResponse *response, char *user, char *password); | |
86 | void spa_build_auth_request (SPAAuthRequest *request, char *user, | |
87 | char *domain); | |
88 | extern void spa_smb_encrypt (unsigned char * passwd, unsigned char * c8, | |
89 | unsigned char * p24); | |
90 | extern void spa_smb_nt_encrypt (unsigned char * passwd, unsigned char * c8, | |
91 | unsigned char * p24); | |
92 | extern char *unicodeToString(char *p, size_t len); | |
93 | extern void spa_build_auth_challenge(SPAAuthRequest *, SPAAuthChallenge *); | |
94 |