1189251Ssam/*
2189251Ssam * WPA Supplicant / shared MSCHAPV2 helper functions / RFC 2433 / RFC 2759
3214734Srpaulo * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
4189251Ssam *
5252726Srpaulo * This software may be distributed under the terms of the BSD license.
6252726Srpaulo * See README for more details.
7189251Ssam */
8189251Ssam
9189251Ssam#ifndef MS_FUNCS_H
10189251Ssam#define MS_FUNCS_H
11189251Ssam
12214734Srpauloint generate_nt_response(const u8 *auth_challenge, const u8 *peer_challenge,
13214734Srpaulo			 const u8 *username, size_t username_len,
14214734Srpaulo			 const u8 *password, size_t password_len,
15214734Srpaulo			 u8 *response);
16214734Srpauloint generate_nt_response_pwhash(const u8 *auth_challenge,
17214734Srpaulo				const u8 *peer_challenge,
18214734Srpaulo				const u8 *username, size_t username_len,
19214734Srpaulo				const u8 *password_hash,
20214734Srpaulo				u8 *response);
21214734Srpauloint generate_authenticator_response(const u8 *password, size_t password_len,
22214734Srpaulo				    const u8 *peer_challenge,
23214734Srpaulo				    const u8 *auth_challenge,
24214734Srpaulo				    const u8 *username, size_t username_len,
25214734Srpaulo				    const u8 *nt_response, u8 *response);
26214734Srpauloint generate_authenticator_response_pwhash(
27189251Ssam	const u8 *password_hash,
28189251Ssam	const u8 *peer_challenge, const u8 *auth_challenge,
29189251Ssam	const u8 *username, size_t username_len,
30189251Ssam	const u8 *nt_response, u8 *response);
31214734Srpauloint nt_challenge_response(const u8 *challenge, const u8 *password,
32214734Srpaulo			  size_t password_len, u8 *response);
33189251Ssam
34189251Ssamvoid challenge_response(const u8 *challenge, const u8 *password_hash,
35189251Ssam			u8 *response);
36214734Srpauloint nt_password_hash(const u8 *password, size_t password_len,
37214734Srpaulo		     u8 *password_hash);
38214734Srpauloint hash_nt_password_hash(const u8 *password_hash, u8 *password_hash_hash);
39214734Srpauloint get_master_key(const u8 *password_hash_hash, const u8 *nt_response,
40214734Srpaulo		   u8 *master_key);
41214734Srpauloint get_asymetric_start_key(const u8 *master_key, u8 *session_key,
42214734Srpaulo			    size_t session_key_len, int is_send,
43214734Srpaulo			    int is_server);
44189251Ssamint __must_check encrypt_pw_block_with_password_hash(
45189251Ssam	const u8 *password, size_t password_len,
46189251Ssam	const u8 *password_hash, u8 *pw_block);
47189251Ssamint __must_check new_password_encrypted_with_old_nt_password_hash(
48189251Ssam	const u8 *new_password, size_t new_password_len,
49189251Ssam	const u8 *old_password, size_t old_password_len,
50189251Ssam	u8 *encrypted_pw_block);
51189251Ssamvoid nt_password_hash_encrypted_with_block(const u8 *password_hash,
52189251Ssam					   const u8 *block, u8 *cypher);
53214734Srpauloint old_nt_password_hash_encrypted_with_new_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_password_hash);
57189251Ssam
58189251Ssam#endif /* MS_FUNCS_H */
59