18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/* 28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * WPA Supplicant / shared MSCHAPV2 helper functions / RFC 2433 / RFC 2759 38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi> 48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * 5c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * This software may be distributed under the terms of the BSD license. 6c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * See README for more details. 78d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */ 88d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef MS_FUNCS_H 108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define MS_FUNCS_H 118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint generate_nt_response(const u8 *auth_challenge, const u8 *peer_challenge, 138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *username, size_t username_len, 148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *password, size_t password_len, 158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *response); 168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint generate_nt_response_pwhash(const u8 *auth_challenge, 178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *peer_challenge, 188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *username, size_t username_len, 198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *password_hash, 208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *response); 218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint generate_authenticator_response(const u8 *password, size_t password_len, 228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *peer_challenge, 238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *auth_challenge, 248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *username, size_t username_len, 258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *nt_response, u8 *response); 268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint generate_authenticator_response_pwhash( 278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *password_hash, 288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *peer_challenge, const u8 *auth_challenge, 298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *username, size_t username_len, 308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *nt_response, u8 *response); 318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint nt_challenge_response(const u8 *challenge, const u8 *password, 328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t password_len, u8 *response); 338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid challenge_response(const u8 *challenge, const u8 *password_hash, 358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *response); 368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint nt_password_hash(const u8 *password, size_t password_len, 378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *password_hash); 388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint hash_nt_password_hash(const u8 *password_hash, u8 *password_hash_hash); 398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint get_master_key(const u8 *password_hash_hash, const u8 *nt_response, 408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *master_key); 418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint get_asymetric_start_key(const u8 *master_key, u8 *session_key, 428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt size_t session_key_len, int is_send, 438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt int is_server); 448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint __must_check encrypt_pw_block_with_password_hash( 458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *password, size_t password_len, 468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *password_hash, u8 *pw_block); 478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint __must_check new_password_encrypted_with_old_nt_password_hash( 488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *new_password, size_t new_password_len, 498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *old_password, size_t old_password_len, 508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *encrypted_pw_block); 518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtvoid nt_password_hash_encrypted_with_block(const u8 *password_hash, 528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *block, u8 *cypher); 538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint old_nt_password_hash_encrypted_with_new_nt_password_hash( 548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *new_password, size_t new_password_len, 558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt const u8 *old_password, size_t old_password_len, 568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt u8 *encrypted_password_hash); 578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif /* MS_FUNCS_H */ 59