1189251Ssam/*
2189251Ssam * WPA Supplicant / shared MSCHAPV2 helper functions / RFC 2433 / RFC 2759
3214734Srpaulo * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
4189251Ssam *
5189251Ssam * This program is free software; you can redistribute it and/or modify
6189251Ssam * it under the terms of the GNU General Public License version 2 as
7189251Ssam * published by the Free Software Foundation.
8189251Ssam *
9189251Ssam * Alternatively, this software may be distributed under the terms of BSD
10189251Ssam * license.
11189251Ssam *
12189251Ssam * See README and COPYING for more details.
13189251Ssam */
14189251Ssam
15189251Ssam#ifndef MS_FUNCS_H
16189251Ssam#define MS_FUNCS_H
17189251Ssam
18214734Srpauloint generate_nt_response(const u8 *auth_challenge, const u8 *peer_challenge,
19214734Srpaulo			 const u8 *username, size_t username_len,
20214734Srpaulo			 const u8 *password, size_t password_len,
21214734Srpaulo			 u8 *response);
22214734Srpauloint generate_nt_response_pwhash(const u8 *auth_challenge,
23214734Srpaulo				const u8 *peer_challenge,
24214734Srpaulo				const u8 *username, size_t username_len,
25214734Srpaulo				const u8 *password_hash,
26214734Srpaulo				u8 *response);
27214734Srpauloint generate_authenticator_response(const u8 *password, size_t password_len,
28214734Srpaulo				    const u8 *peer_challenge,
29214734Srpaulo				    const u8 *auth_challenge,
30214734Srpaulo				    const u8 *username, size_t username_len,
31214734Srpaulo				    const u8 *nt_response, u8 *response);
32214734Srpauloint generate_authenticator_response_pwhash(
33189251Ssam	const u8 *password_hash,
34189251Ssam	const u8 *peer_challenge, const u8 *auth_challenge,
35189251Ssam	const u8 *username, size_t username_len,
36189251Ssam	const u8 *nt_response, u8 *response);
37214734Srpauloint nt_challenge_response(const u8 *challenge, const u8 *password,
38214734Srpaulo			  size_t password_len, u8 *response);
39189251Ssam
40189251Ssamvoid challenge_response(const u8 *challenge, const u8 *password_hash,
41189251Ssam			u8 *response);
42214734Srpauloint nt_password_hash(const u8 *password, size_t password_len,
43214734Srpaulo		     u8 *password_hash);
44214734Srpauloint hash_nt_password_hash(const u8 *password_hash, u8 *password_hash_hash);
45214734Srpauloint get_master_key(const u8 *password_hash_hash, const u8 *nt_response,
46214734Srpaulo		   u8 *master_key);
47214734Srpauloint get_asymetric_start_key(const u8 *master_key, u8 *session_key,
48214734Srpaulo			    size_t session_key_len, int is_send,
49214734Srpaulo			    int is_server);
50189251Ssamint __must_check encrypt_pw_block_with_password_hash(
51189251Ssam	const u8 *password, size_t password_len,
52189251Ssam	const u8 *password_hash, u8 *pw_block);
53189251Ssamint __must_check new_password_encrypted_with_old_nt_password_hash(
54189251Ssam	const u8 *new_password, size_t new_password_len,
55189251Ssam	const u8 *old_password, size_t old_password_len,
56189251Ssam	u8 *encrypted_pw_block);
57189251Ssamvoid nt_password_hash_encrypted_with_block(const u8 *password_hash,
58189251Ssam					   const u8 *block, u8 *cypher);
59214734Srpauloint old_nt_password_hash_encrypted_with_new_nt_password_hash(
60189251Ssam	const u8 *new_password, size_t new_password_len,
61189251Ssam	const u8 *old_password, size_t old_password_len,
62189251Ssam	u8 *encrypted_password_hash);
63189251Ssam
64189251Ssam#endif /* MS_FUNCS_H */
65