Start
[exim.git] / src / src / auths / auth-spa.h
CommitLineData
0756eb3c
PH
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
16of the following types. I received a complaint about "int16" causing
17compilation problems. So I (PH) have renamed them all, to be on the safe side.
18
19typedef signed short int16;
20typedef unsigned short uint16;
21typedef unsigned uint32;
22typedef unsigned char uint8;
23*/
24
25typedef signed short int16x;
26typedef unsigned short uint16x;
27typedef unsigned uint32x;
28typedef unsigned char uint8x;
29
30typedef struct
31{
32 uint16x len;
33 uint16x maxlen;
34 uint32x offset;
35} SPAStrHeader;
36
37typedef 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
51typedef 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
62typedef 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
79void spa_bits_to_base64 (unsigned char *, const unsigned char *, int);
80int spa_base64_to_bits(char *, const char *);
81void spa_build_auth_response (SPAAuthChallenge *challenge,
82 SPAAuthResponse *response, char *user, char *password);
83void spa_build_auth_request (SPAAuthRequest *request, char *user,
84 char *domain);
85extern void spa_smb_encrypt (unsigned char * passwd, unsigned char * c8,
86 unsigned char * p24);
87extern void spa_smb_nt_encrypt (unsigned char * passwd, unsigned char * c8,
88 unsigned char * p24);
89extern char *unicodeToString(char *p, size_t len);
90extern void spa_build_auth_challenge(SPAAuthRequest *, SPAAuthChallenge *);
91