6 * Copyright (C) 2008 Novell, Inc.
7 * Copyright (C) 2005, Thomas Butter <butter@uni-mannheim.de>
8 * Modify 2007, Anibal Avelar <avelar@gmail.com>
10 * Implemented with reference to the follow documentation:
11 * - http://davenport.sourceforge.net/ntlm.html
12 * - MS-NLMP: http://msdn.microsoft.com/en-us/library/cc207842.aspx
13 * - MS-SIP : http://msdn.microsoft.com/en-us/library/cc246115.aspx
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #ifndef _PURPLE_NTLM_SIPE_H
31 #define _PURPLE_NTLM_SIPE_H
33 /* Negotiate flag required in connectionless NTLM
34 * 0x00000001 = NTLMSSP_NEGOTIATE_UNICODE (A)
35 * 0x00000010 = NTLMSSP_NEGOTIATE_SIGN (D)
36 * 0x00000040 = NTLMSSP_NEGOTIATE_DATAGRAM (F)
37 * 0x00000200 = NTLMSSP_NEGOTIATE_NTLM (H)
38 * 0x00008000 = NTLMSSP_NEGOTIATE_ALWAYS_SIGN (M)
39 * 0x40000000 = NTLMSSP_NEGOTIATE_KEY_EXCH (W)
41 #define NEGOTIATE_FLAGS 0x40008251
43 #define NTLMSSP_NT_OR_LM_KEY_LEN 24
44 #define NTLMSSP_SESSION_KEY_LEN 16
45 #define MD4_DIGEST_LEN 16
47 static char SIPE_DEFAULT_CODESET
[] = "ANSI_X3.4-1968";
50 * Parses the ntlm type 2 message
52 * @param challenge String containing the base64 encoded challenge message
53 * @return The nonce for use in message authenticate
55 gchar
*purple_ntlm_parse_challenge(gchar
*challenge
, guint32
*flags
);
58 * Generates a authenticate message
60 * @param username The username
61 * @param passw The password
62 * @param hostname The hostname
63 * @param domain The domain to authenticate against
64 * @param nonce The nonce returned by purple_ntlm_parse_challenge
65 * @param flags Pointer to the flags returned by purple_ntlm_parse_challenge
66 * @return A base64 encoded authenticate message
68 gchar
*purple_ntlm_gen_authenticate(const gchar
**ntlm_key
, const gchar
*username
, const gchar
*passw
, const gchar
*hostname
, const gchar
*domain
, const guint8
*nonce
, guint32
*flags
);
70 gchar
* purple_ntlm_sipe_signature_make (char * msg
, char * signing_key
);
72 gchar
* purple_ntlm_gen_signature (char * buf
, char * signing_key
, guint32 random_pad
, long sequence
, int key_len
);
75 gboolean
purple_ntlm_verify_signature (char * a
, char * b
);
77 #endif /* _PURPLE_NTLM_SIPE_H */