52394e57038f68e7932e5e10e1a301e599fa20da
[exim.git] / src / src / auths / auth-spa.h
1 /* $Cambridge: exim/src/src/auths/auth-spa.h,v 1.1 2004/10/07 13:10:00 ph10 Exp $ */
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 */
14
15 /* It seems that some systems have existing but different definitions of some
16 of the following types. I received a complaint about "int16" causing
17 compilation problems. So I (PH) have renamed them all, to be on the safe side.
18
19 typedef signed short int16;
20 typedef unsigned short uint16;
21 typedef unsigned uint32;
22 typedef unsigned char uint8;
23 */
24
25 typedef signed short int16x;
26 typedef unsigned short uint16x;
27 typedef unsigned uint32x;
28 typedef unsigned char uint8x;
29
30 typedef struct
31 {
32 uint16x len;
33 uint16x maxlen;
34 uint32x offset;
35 } SPAStrHeader;
36
37 typedef struct
38 {
39 char ident[8];
40 uint32x msgType;
41 SPAStrHeader uDomain;
42 uint32x flags;
43 uint8x challengeData[8];
44 uint8x reserved[8];
45 SPAStrHeader emptyString;
46 uint8x buffer[1024];
47 uint32x bufIndex;
48 } SPAAuthChallenge;
49
50
51 typedef struct
52 {
53 char ident[8];
54 uint32x msgType;
55 uint32x flags;
56 SPAStrHeader user;
57 SPAStrHeader domain;
58 uint8x buffer[1024];
59 uint32x bufIndex;
60 } SPAAuthRequest;
61
62 typedef struct
63 {
64 char ident[8];
65 uint32x msgType;
66 SPAStrHeader lmResponse;
67 SPAStrHeader ntResponse;
68 SPAStrHeader uDomain;
69 SPAStrHeader uUser;
70 SPAStrHeader uWks;
71 SPAStrHeader sessionKey;
72 uint32x flags;
73 uint8x buffer[1024];
74 uint32x bufIndex;
75 } SPAAuthResponse;
76
77 #define spa_request_length(ptr) (((ptr)->buffer - (uint8x*)(ptr)) + (ptr)->bufIndex)
78
79 void spa_bits_to_base64 (unsigned char *, const unsigned char *, int);
80 int spa_base64_to_bits(char *, const char *);
81 void spa_build_auth_response (SPAAuthChallenge *challenge,
82 SPAAuthResponse *response, char *user, char *password);
83 void spa_build_auth_request (SPAAuthRequest *request, char *user,
84 char *domain);
85 extern void spa_smb_encrypt (unsigned char * passwd, unsigned char * c8,
86 unsigned char * p24);
87 extern void spa_smb_nt_encrypt (unsigned char * passwd, unsigned char * c8,
88 unsigned char * p24);
89 extern char *unicodeToString(char *p, size_t len);
90 extern void spa_build_auth_challenge(SPAAuthRequest *, SPAAuthChallenge *);
91