xref: /freebsd/contrib/wpa/src/crypto/ms_funcs.h (revision 29332c0dcee1e80c9fb871e06c3160bd5deb1b44)
1 /*
2  * WPA Supplicant / shared MSCHAPV2 helper functions / RFC 2433 / RFC 2759
3  * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef MS_FUNCS_H
10 #define MS_FUNCS_H
11 
12 int generate_nt_response(const u8 *auth_challenge, const u8 *peer_challenge,
13 			 const u8 *username, size_t username_len,
14 			 const u8 *password, size_t password_len,
15 			 u8 *response);
16 int generate_nt_response_pwhash(const u8 *auth_challenge,
17 				const u8 *peer_challenge,
18 				const u8 *username, size_t username_len,
19 				const u8 *password_hash,
20 				u8 *response);
21 int generate_authenticator_response(const u8 *password, size_t password_len,
22 				    const u8 *peer_challenge,
23 				    const u8 *auth_challenge,
24 				    const u8 *username, size_t username_len,
25 				    const u8 *nt_response, u8 *response);
26 int generate_authenticator_response_pwhash(
27 	const u8 *password_hash,
28 	const u8 *peer_challenge, const u8 *auth_challenge,
29 	const u8 *username, size_t username_len,
30 	const u8 *nt_response, u8 *response);
31 int nt_challenge_response(const u8 *challenge, const u8 *password,
32 			  size_t password_len, u8 *response);
33 
34 int challenge_response(const u8 *challenge, const u8 *password_hash,
35 		       u8 *response);
36 int challenge_hash(const u8 *peer_challenge, const u8 *auth_challenge,
37 		   const u8 *username, size_t username_len, u8 *challenge);
38 int nt_password_hash(const u8 *password, size_t password_len,
39 		     u8 *password_hash);
40 int hash_nt_password_hash(const u8 *password_hash, u8 *password_hash_hash);
41 int get_master_key(const u8 *password_hash_hash, const u8 *nt_response,
42 		   u8 *master_key);
43 int get_asymetric_start_key(const u8 *master_key, u8 *session_key,
44 			    size_t session_key_len, int is_send,
45 			    int is_server);
46 int __must_check encrypt_pw_block_with_password_hash(
47 	const u8 *password, size_t password_len,
48 	const u8 *password_hash, u8 *pw_block);
49 int __must_check new_password_encrypted_with_old_nt_password_hash(
50 	const u8 *new_password, size_t new_password_len,
51 	const u8 *old_password, size_t old_password_len,
52 	u8 *encrypted_pw_block);
53 int nt_password_hash_encrypted_with_block(const u8 *password_hash,
54 					  const u8 *block, u8 *cypher);
55 int old_nt_password_hash_encrypted_with_new_nt_password_hash(
56 	const u8 *new_password, size_t new_password_len,
57 	const u8 *old_password, size_t old_password_len,
58 	u8 *encrypted_password_hash);
59 
60 #endif /* MS_FUNCS_H */
61