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