wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
ms_funcs.c File Reference

WPA Supplicant / shared MSCHAPV2 helper functions / RFC 2433 / RFC 2759. More...

#include "includes.h"
#include "common.h"
#include "sha1.h"
#include "ms_funcs.h"
#include "crypto.h"

Macros

#define PWBLOCK_LEN   516
 

Functions

int challenge_hash (const u8 *peer_challenge, const u8 *auth_challenge, const u8 *username, size_t username_len, u8 *challenge)
 ChallengeHash() - RFC 2759, Sect. 8.2. More...
 
int nt_password_hash (const u8 *password, size_t password_len, u8 *password_hash)
 NtPasswordHash() - RFC 2759, Sect. 8.3. More...
 
int hash_nt_password_hash (const u8 *password_hash, u8 *password_hash_hash)
 HashNtPasswordHash() - RFC 2759, Sect. 8.4. More...
 
void challenge_response (const u8 *challenge, const u8 *password_hash, u8 *response)
 ChallengeResponse() - RFC 2759, Sect. 8.5. More...
 
int generate_nt_response (const u8 *auth_challenge, const u8 *peer_challenge, const u8 *username, size_t username_len, const u8 *password, size_t password_len, u8 *response)
 GenerateNTResponse() - RFC 2759, Sect. 8.1. More...
 
int generate_nt_response_pwhash (const u8 *auth_challenge, const u8 *peer_challenge, const u8 *username, size_t username_len, const u8 *password_hash, u8 *response)
 GenerateNTResponse() - RFC 2759, Sect. 8.1. More...
 
int generate_authenticator_response_pwhash (const u8 *password_hash, const u8 *peer_challenge, const u8 *auth_challenge, const u8 *username, size_t username_len, const u8 *nt_response, u8 *response)
 GenerateAuthenticatorResponse() - RFC 2759, Sect. 8.7. More...
 
int generate_authenticator_response (const u8 *password, size_t password_len, const u8 *peer_challenge, const u8 *auth_challenge, const u8 *username, size_t username_len, const u8 *nt_response, u8 *response)
 GenerateAuthenticatorResponse() - RFC 2759, Sect. 8.7. More...
 
int nt_challenge_response (const u8 *challenge, const u8 *password, size_t password_len, u8 *response)
 NtChallengeResponse() - RFC 2433, Sect. A.5. More...
 
int get_master_key (const u8 *password_hash_hash, const u8 *nt_response, u8 *master_key)
 GetMasterKey() - RFC 3079, Sect. 3.4. More...
 
int get_asymetric_start_key (const u8 *master_key, u8 *session_key, size_t session_key_len, int is_send, int is_server)
 GetAsymetricStartKey() - RFC 3079, Sect. 3.4. More...
 
int encrypt_pw_block_with_password_hash (const u8 *password, size_t password_len, const u8 *password_hash, u8 *pw_block)
 EncryptPwBlockWithPasswordHash() - RFC 2759, Sect. 8.10. More...
 
int new_password_encrypted_with_old_nt_password_hash (const u8 *new_password, size_t new_password_len, const u8 *old_password, size_t old_password_len, u8 *encrypted_pw_block)
 NewPasswordEncryptedWithOldNtPasswordHash() - RFC 2759, Sect. 8.9. More...
 
void nt_password_hash_encrypted_with_block (const u8 *password_hash, const u8 *block, u8 *cypher)
 NtPasswordHashEncryptedWithBlock() - RFC 2759, Sect 8.13. More...
 
int old_nt_password_hash_encrypted_with_new_nt_password_hash (const u8 *new_password, size_t new_password_len, const u8 *old_password, size_t old_password_len, u8 *encrypted_password_hash)
 OldNtPasswordHashEncryptedWithNewNtPasswordHash() - RFC 2759, Sect. 8.12. More...
 

Detailed Description

WPA Supplicant / shared MSCHAPV2 helper functions / RFC 2433 / RFC 2759.

Function Documentation

int challenge_hash ( const u8 *  peer_challenge,
const u8 *  auth_challenge,
const u8 *  username,
size_t  username_len,
u8 *  challenge 
)

ChallengeHash() - RFC 2759, Sect. 8.2.

Parameters
peer_challenge16-octet PeerChallenge (IN)
auth_challenge16-octet AuthenticatorChallenge (IN)
username0-to-256-char UserName (IN)
username_lenLength of username
challenge8-octet Challenge (OUT)
Returns
0 on success, -1 on failure
void challenge_response ( const u8 *  challenge,
const u8 *  password_hash,
u8 *  response 
)

ChallengeResponse() - RFC 2759, Sect. 8.5.

Parameters
challenge8-octet Challenge (IN)
password_hash16-octet PasswordHash (IN)
response24-octet Response (OUT)
int encrypt_pw_block_with_password_hash ( const u8 *  password,
size_t  password_len,
const u8 *  password_hash,
u8 *  pw_block 
)

EncryptPwBlockWithPasswordHash() - RFC 2759, Sect. 8.10.

Parameters
password0-to-256-unicode-char Password (IN; UTF-8)
password_lenLength of password
password_hash16-octet PasswordHash (IN)
pw_block516-byte PwBlock (OUT)
Returns
0 on success, -1 on failure
int generate_authenticator_response ( const u8 *  password,
size_t  password_len,
const u8 *  peer_challenge,
const u8 *  auth_challenge,
const u8 *  username,
size_t  username_len,
const u8 *  nt_response,
u8 *  response 
)

GenerateAuthenticatorResponse() - RFC 2759, Sect. 8.7.

Parameters
password0-to-256-unicode-char Password (IN; UTF-8)
password_lenLength of password
nt_response24-octet NT-Response (IN)
peer_challenge16-octet PeerChallenge (IN)
auth_challenge16-octet AuthenticatorChallenge (IN)
username0-to-256-char UserName (IN)
username_lenLength of username
response20-octet AuthenticatorResponse (OUT) (note: this value is usually encoded as a 42-octet ASCII string (S=hexdump_of_response)
Returns
0 on success, -1 on failure
int generate_authenticator_response_pwhash ( const u8 *  password_hash,
const u8 *  peer_challenge,
const u8 *  auth_challenge,
const u8 *  username,
size_t  username_len,
const u8 *  nt_response,
u8 *  response 
)

GenerateAuthenticatorResponse() - RFC 2759, Sect. 8.7.

Parameters
password_hash16-octet PasswordHash (IN)
nt_response24-octet NT-Response (IN)
peer_challenge16-octet PeerChallenge (IN)
auth_challenge16-octet AuthenticatorChallenge (IN)
username0-to-256-char UserName (IN)
username_lenLength of username
response20-octet AuthenticatorResponse (OUT) (note: this value is usually encoded as a 42-octet ASCII string (S=hexdump_of_response)
Returns
0 on success, -1 on failure
int generate_nt_response ( const u8 *  auth_challenge,
const u8 *  peer_challenge,
const u8 *  username,
size_t  username_len,
const u8 *  password,
size_t  password_len,
u8 *  response 
)

GenerateNTResponse() - RFC 2759, Sect. 8.1.

Parameters
auth_challenge16-octet AuthenticatorChallenge (IN)
peer_challenge16-octet PeerChallenge (IN)
username0-to-256-char UserName (IN)
username_lenLength of username
password0-to-256-unicode-char Password (IN; UTF-8)
password_lenLength of password
response24-octet Response (OUT)
Returns
0 on success, -1 on failure
int generate_nt_response_pwhash ( const u8 *  auth_challenge,
const u8 *  peer_challenge,
const u8 *  username,
size_t  username_len,
const u8 *  password_hash,
u8 *  response 
)

GenerateNTResponse() - RFC 2759, Sect. 8.1.

Parameters
auth_challenge16-octet AuthenticatorChallenge (IN)
peer_challenge16-octet PeerChallenge (IN)
username0-to-256-char UserName (IN)
username_lenLength of username
password_hash16-octet PasswordHash (IN)
response24-octet Response (OUT)
Returns
0 on success, -1 on failure
int get_asymetric_start_key ( const u8 *  master_key,
u8 *  session_key,
size_t  session_key_len,
int  is_send,
int  is_server 
)

GetAsymetricStartKey() - RFC 3079, Sect. 3.4.

Parameters
master_key16-octet MasterKey (IN)
session_key8-to-16 octet SessionKey (OUT)
session_key_lenSessionKeyLength (Length of session_key) (IN)
is_sendIsSend (IN, BOOLEAN)
is_serverIsServer (IN, BOOLEAN)
Returns
0 on success, -1 on failure
int get_master_key ( const u8 *  password_hash_hash,
const u8 *  nt_response,
u8 *  master_key 
)

GetMasterKey() - RFC 3079, Sect. 3.4.

Parameters
password_hash_hash16-octet PasswordHashHash (IN)
nt_response24-octet NTResponse (IN)
master_key16-octet MasterKey (OUT)
Returns
0 on success, -1 on failure
int hash_nt_password_hash ( const u8 *  password_hash,
u8 *  password_hash_hash 
)

HashNtPasswordHash() - RFC 2759, Sect. 8.4.

Parameters
password_hash16-octet PasswordHash (IN)
password_hash_hash16-octet PasswordHashHash (OUT)
Returns
0 on success, -1 on failure
int new_password_encrypted_with_old_nt_password_hash ( const u8 *  new_password,
size_t  new_password_len,
const u8 *  old_password,
size_t  old_password_len,
u8 *  encrypted_pw_block 
)

NewPasswordEncryptedWithOldNtPasswordHash() - RFC 2759, Sect. 8.9.

Parameters
new_password0-to-256-unicode-char NewPassword (IN; UTF-8)
new_password_lenLength of new_password
old_password0-to-256-unicode-char OldPassword (IN; UTF-8)
old_password_lenLength of old_password
encrypted_pw_block516-octet EncryptedPwBlock (OUT)
Returns
0 on success, -1 on failure
int nt_challenge_response ( const u8 *  challenge,
const u8 *  password,
size_t  password_len,
u8 *  response 
)

NtChallengeResponse() - RFC 2433, Sect. A.5.

Parameters
challenge8-octet Challenge (IN)
password0-to-256-unicode-char Password (IN; UTF-8)
password_lenLength of password
response24-octet Response (OUT)
Returns
0 on success, -1 on failure
int nt_password_hash ( const u8 *  password,
size_t  password_len,
u8 *  password_hash 
)

NtPasswordHash() - RFC 2759, Sect. 8.3.

Parameters
password0-to-256-unicode-char Password (IN; UTF-8)
password_lenLength of password
password_hash16-octet PasswordHash (OUT)
Returns
0 on success, -1 on failure
void nt_password_hash_encrypted_with_block ( const u8 *  password_hash,
const u8 *  block,
u8 *  cypher 
)

NtPasswordHashEncryptedWithBlock() - RFC 2759, Sect 8.13.

Parameters
password_hash16-octer PasswordHash (IN)
block16-octet Block (IN)
cypher16-octer Cypher (OUT)
int old_nt_password_hash_encrypted_with_new_nt_password_hash ( const u8 *  new_password,
size_t  new_password_len,
const u8 *  old_password,
size_t  old_password_len,
u8 *  encrypted_password_hash 
)

OldNtPasswordHashEncryptedWithNewNtPasswordHash() - RFC 2759, Sect. 8.12.

Parameters
new_password0-to-256-unicode-char NewPassword (IN; UTF-8)
new_password_lenLength of new_password
old_password0-to-256-unicode-char OldPassword (IN; UTF-8)
old_password_lenLength of old_password
encrypted_password_hash16-octet EncryptedPasswordHash (OUT)
Returns
0 on success, -1 on failure