DOC

RFC2759

By Erica Reed,2014-05-21 08:52
7 views 0
RFC2759

    RFC2759 - Microsoft PPP CHAP Extensions, Version 2 Network Working Group G. Zorn

    Request for Comments: 2759 Microsoft Corporation

    Category: Informational January 2000

    Microsoft PPP CHAP Extensions, Version 2

    Status of this Memo

    This memo provides information for the Internet community. It does not specify an Internet standard of any kind. Distribution of this memo is unlimited.

    Copyright Notice ;Copyright (C) The Internet Society (2000). All Rights Reserved.

    Abstract

    The Point-to-Point Protocol (PPP) [1] provides a standard method for transporting multi-protocol datagrams over point-to-point links. PPP defines an extensible Link Control Protocol and a family of Network Control Protocols (NCPs) for establishing and configuring different network-layer protocols.

    This document describes version two of Microsoft's PPP CHAP dialect (MS-CHAP-V2). MS-CHAP-V2 is similar to, but incompatible with, MS- CHAP version one (MS-CHAP-V1, described in [9]). In particular,certain protocol fields have been deleted or reused but with different semantics. In addition, MS-CHAP-V2 features mutual authentication.The algorithms used in the generation of various MS-CHAP-V2 protocol fields are described in section 8. Negotiation and hash generation examples are provided in section 9.

    Specification of Requirements

    In this document, the key words "MAY", "MUST, "MUST NOT", "optional", "recommended", "SHOULD", and "SHOULD NOT" are to be interpreted as described in [3].

    1. Introduction

    Where possible, MS-CHAP-V2 is consistent with both MS-CHAP-V1 and standard CHAP. Briefly, the differences between MS-CHAP-V2 and MS-CHAP-V1 are:

    * MS-CHAP-V2 is enabled by negotiating CHAP Algorithm 0x81 in LCP option 3, Authentication Protocol.

    * MS-CHAP-V2 provides mutual authentication between peers by piggybacking a peer challenge on the Response packet and an authenticator response on the Success packet. * The calculation of the "Windows NT compatible challenge response"sub-field in the Response packet has been changed to include the peer challenge and the user name.

    * In MS-CHAP-V1, the "LAN Manager compatible challenge response" sub-field was always sent in the Response packet. This field has been replaced in MS-CHAP-V2 by the Peer-Challenge field. * The format of the Message field in the Failure packet has been changed.

    * The Change Password (version 1) and Change Password (version 2) packets are no longer supported. They have been replaced with a single Change-Password packet.

    2. LCP Configuration

    The LCP configuration for MS-CHAP-V2 is identical to that for standard CHAP, except that the Algorithm field has value 0x81, rather than the MD5 value 0x05. PPP implementations which do not support MS-CHAP-V2, but correctly implement LCP Config-Rej, should have no problem dealing with this non-standard option.

    3. Challenge Packet

    The MS-CHAP-V2 Challenge packet is identical in format to the standard CHAP Challenge packet. MS-CHAP-V2 authenticators send an 16-octet challenge Value field.Peers need not duplicate Microsoft's algorithm for selecting the 16-octet value, but the standard guidelines on randomness [1,2,7] SHOULD be observed.

    Microsoft authenticators do not currently provide information in the Name field. This may change in the future.

    4. Response Packet

    The MS-CHAP-V2 Response packet is identical in format to the standard CHAP Response packet. However, the Value field is sub-formatted differently as follows:

    16 octets: Peer-Challenge

    8 octets: Reserved, must be zero

    24 octets: NT-Response

    1 octet : Flags

    The Peer-Challenge field is a 16-octet random number. As the name implies, it is generated by the peer and is used in the calculation of the NT-Response field, below. Peers need not duplicate Microsoft's algorithm for selecting the 16-octet value, but the standard guidelines on randomness [1,2,7] SHOULD be observed.

    The NT-Response field is an encoded function of the password, the user name, the contents of the Peer-Challenge field and the received challenge as output by the routine GenerateNTResponse() (see section8.1, below). The Windows NT password is a string of 0 to (theoretically) 256 case-sensitive Unicode [8] characters. Current versions of Windows NT limit passwords to 14 characters, mainly for compatibility reasons; this may change in the future. When computing the NT-Response field contents, only the user name is used, without any associated Windows NT domain name. This is true regardless of whether a Windows NT domain name is present in the Name field (see below).

    The Flag field is reserved for future use and MUST be zero.

    The Name field is a string of 0 to (theoretically) 256 case-sensitive ASCII characters which identifies the peer's user account name. The Windows NT domain name may prefix the user's account name (e.g."BIGCO\johndoe" where "BIGCO" is a Windows NT domain containing the user account "johndoe"). If a domain is not provided, the backslash should also be omitted, (e.g. "johndoe").

    5. Success Packet

    The Success packet is identical in format to the standard CHAP Success packet. However, the Message field contains a 42-octet authenticator response string and a printable message. The format of the message field is illustrated below.

"S=<auth_string> M=<message>"

    The <auth_string> quantity is a 20 octet number encoded in ASCII as 40 hexadecimal digits. The hexadecimal digits A-F (if present) MUST be uppercase. This number is derived from the challenge from the Challenge packet, the Peer-Challenge and NT-Response fields from the Response packet, and the peer password as output by the routine Generate

    AuthenticatorResponse() (see section 8.7, below). The authenticating peer MUST verify the authenticator response when a Success packet is received. The method for verifying the authenticator is described in section 8.8, below. If the authenticator response is either missing or incorrect, the peer MUST end the session.

    The <message> quantity is human-readable text in the appropriate charset and language [12]. 6. Failure Packet

    The Failure packet is identical in format to the standard CHAP Failure packet. There is, however, formatted text stored in the Message field which, contrary to the standard CHAP rules, does affect the operation of the protocol. The Message field format is:

    "E=eeeeeeeeee R=r C=cccccccccccccccccccccccccccccccc V=vvvvvvvvvv

    M=<msg>"

    where

    The "eeeeeeeeee" is the ASCII representation of a decimal error code (need not be 10 digits) corresponding to one of those listed below, though implementations should deal with codes not on this list gracefully.

    646 ERROR_RESTRICTED_LOGON_HOURS

    647 ERROR_ACCT_DISABLED

    648 ERROR_PASSWD_EXPIRED

    649 ERROR_NO_DIALIN_PERMISSION

    691 ERROR_AUTHENTICATION_FAILURE

    709 ERROR_CHANGING_PASSWORD

    The "r" is an ASCII flag set to '1' if a retry is allowed, and '0' if not. When the authenticator sets this flag to '1' it disables short timeouts, expecting the peer to prompt the user for new credentials and resubmit the response.

    The "cccccccccccccccccccccccccccccccc" is the ASCII representation of a hexadecimal challenge value. This field MUST be exactly 32 octets long and MUST be present.

    The "vvvvvvvvvv" is the ASCII representation of a decimal version code (need not be 10 digits) indicating the password changing protocol version supported on the server. For MS-CHAP-V2, this value SHOULD always be 3.

    <msg> is human-readable text in the appropriate charset and language [12].

    7. Change-Password Packet

    The Change-Password packet does not appear in either standard CHAP or MS-CHAP-V1. It allows the peer to change the password on the account specified in the preceding Response packet. The Change-Password packet should be sent only if the authenticator reports

    ERROR_PASSWD_EXPIRED (E=648) in the Message field of the Failure packet.

    This packet type is supported by recent versions of Windows NT 4.0, Windows 95 and Windows 98. It is not supported by Windows NT 3.5, Windows NT 3.51, or early versions of Windows NT

4.0, Windows 95 and Windows 98.

    The format of this packet is as follows:

    1 octet : Code

    1 octet : Identifier

    2 octets : Length

    516 octets : Encrypted-Password

    16 octets : Encrypted-Hash

    16 octets : Peer-Challenge

    8 octets : Reserved

    24 octets : NT-Response

    2-octet : Flags

    Code

    7

    Identifier

    The Identifier field is one octet and aids in matching requests and replies. The value is the Identifier of the received Failure packet to which this packet responds plus 1. Length

    586

    Encrypted-Password

    This field contains the PWBLOCK form of the new Windows NT password encrypted with the old Windows NT password hash, as output by the NewPasswordEncryptedWithOldNtPasswordHash() routine see section 8.9, below).

    Encrypted-Hash

    This field contains the old Windows NT password hash encrypted with the new Windows NT password hash, as output by the OldNtPasswordHashEncryptedWithNewNtPasswordHash() routine (seesection 8.12, below).

    Peer-Challenge

    A 16-octet random quantity, as described in the Response packet description. Reserved

    8 octets, must be zero.

    NT-Response

    The NT-Response field (as described in the Response packet description), but calculated on the new password and the challenge received in the Failure packet.

    Flags

    This field is two octets in length. It is a bit field of option flags where 0 is the least significant bit

    of the 16-bit quantity.The format of this field is illustrated in the following diagram: 1

    5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

    | |

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Bits 0-15

    Reserved, always clear (0).

8. Pseudocode

    The routines mentioned in the text above are described in pseudocode

    in the following sections.

    8.1. GenerateNTResponse()

GenerateNTResponse(

    IN 16-octet AuthenticatorChallenge,

    IN 16-octet PeerChallenge,

IN 0-to-256-char UserName,

IN 0-to-256-unicode-char Password,

    OUT 24-octet Response )

    {

    8-octet Challenge

    16-octet PasswordHash

ChallengeHash( PeerChallenge, AuthenticatorChallenge, UserName,giving Challenge)

    NtPasswordHash( Password, giving PasswordHash ) ChallengeResponse( Challenge, PasswordHash, giving Response ) }

    8.2. ChallengeHash()

    ChallengeHash(

    IN 16-octet PeerChallenge,

    IN 16-octet AuthenticatorChallenge,

    IN 0-to-256-char UserName,

    OUT 8-octet Challenge

    {

/*

    * SHAInit(), SHAUpdate() and SHAFinal() functions are an * implementation of Secure Hash Algorithm (SHA-1) [11]. These are

    * available in public domain or can be licensed from * RSA Data Security, Inc.

    */

SHAInit(Context)

    SHAUpdate(Context, PeerChallenge, 16)

    SHAUpdate(Context, AuthenticatorChallenge, 16)

/*

    * Only the user name (as presented by the peer and

    * excluding any prepended domain name) * is used as input to SHAUpdate(). */

SHAUpdate(Context, UserName, strlen(Username))

    SHAFinal(Context, Digest)

    memcpy(Challenge, Digest, 8)

    }

    8.3. NtPasswordHash()

    NtPasswordHash(

    IN 0-to-256-unicode-char Password, OUT 16-octet PasswordHash )

    {

    /*

    * Use the MD4 algorithm [5] to irreversibly hash Password

    * into PasswordHash. Only the password is hashed without

    * including any terminating 0.

    */

    }

    8.4. HashNtPasswordHash()

    HashNtPasswordHash(

    IN 16-octet PasswordHash,

    OUT 16-octet PasswordHashHash ) {

    /*

    * Use the MD4 algorithm [5] to irreversibly hash

    * PasswordHash into PasswordHashHash. */

    }

    8.5. ChallengeResponse()

    ChallengeResponse(

    IN 8-octet Challenge,

    IN 16-octet PasswordHash,

    OUT 24-octet Response )

    {

    Set ZPasswordHash to PasswordHash zero-padded to 21 octets

DesEncrypt( Challenge,

    1st 7-octets of ZPasswordHash,

giving 1st 8-octets of Response )

DesEncrypt( Challenge,

    2nd 7-octets of ZPasswordHash,

    giving 2nd 8-octets of Response )

DesEncrypt( Challenge,

    3rd 7-octets of ZPasswordHash,

    giving 3rd 8-octets of Response )

    }

    8.6. DesEncrypt()

    DesEncrypt(

    IN 8-octet Clear,

    IN 7-octet Key,

    OUT 8-octet Cypher )

    {

    /*

    * Use the DES encryption algorithm [4] in ECB mode [10] * to encrypt Clear into Cypher such that Cypher can * only be decrypted back to Clear by providing Key. * Note that the DES algorithm takes as input a 64-bit * stream where the 8th, 16th, 24th, etc. bits are * parity bits ignored by the encrypting algorithm. * Unless you write your own DES to accept 56-bit input * without parity, you will need to insert the parity bits * yourself.

    */

    }

    8.7. GenerateAuthenticatorResponse()

    GenerateAuthenticatorResponse(

    IN 0-to-256-unicode-char Password,

    IN 24-octet NT-Response,

    IN 16-octet PeerChallenge,

    IN 16-octet AuthenticatorChallenge,

    IN 0-to-256-char UserName,

    OUT 42-octet AuthenticatorResponse )

    {

    16-octet PasswordHash

    16-octet PasswordHashHash

    8-octet Challenge

/*

* "Magic" constants used in response generation

*/

Magic1[39] =

    {0x4D, 0x61, 0x67, 0x69, 0x63, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x74, 0x6F, 0x20, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x20, 0x73, 0x69, 0x67, 0x6E, 0x69, 0x6E, 0x67, 0x20, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x74};

Magic2[41] =

    {0x50, 0x61, 0x64, 0x20, 0x74, 0x6F, 0x20, 0x6D, 0x61, 0x6B, 0x65, 0x20, 0x69, 0x74, 0x20, 0x64, 0x6F, 0x20, 0x6D, 0x6F, 0x72, 0x65, 0x20, 0x74, 0x68, 0x61, 0x6E, 0x20, 0x6F, 0x6E, 0x65, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E};

/*

    * Hash the password with MD4

    */

NtPasswordHash( Password, giving PasswordHash )

/*

    * Now hash the hash

    */

    HashNtPasswordHash( PasswordHash, giving PasswordHashHash)

SHAInit(Context)

    SHAUpdate(Context, PasswordHashHash, 16)

    SHAUpdate(Context, NTResponse, 24)

    SHAUpdate(Context, Magic1, 39)

    SHAFinal(Context, Digest)

    ChallengeHash( PeerChallenge, AuthenticatorChallenge, UserName, giving Challenge)

SHAInit(Context)

    SHAUpdate(Context, Digest, 20)

    SHAUpdate(Context, Challenge, 8)

    SHAUpdate(Context, Magic2, 41)

    SHAFinal(Context, Digest)

/*

    * Encode the value of 'Digest' as "S=" followed by * 40 ASCII hexadecimal digits and return it in * AuthenticatorResponse.

    * For example,

    * "S=0123456789ABCDEF0123456789ABCDEF01234567" */

}

    8.8. CheckAuthenticatorResponse()

    CheckAuthenticatorResponse(

    IN 0-to-256-unicode-char Password,

    IN 24-octet NtResponse,

    IN 16-octet PeerChallenge,

    IN 16-octet AuthenticatorChallenge, IN 0-to-256-char UserName,

    IN 42-octet ReceivedResponse,

    OUT Boolean ResponseOK )

    {

20-octet MyResponse

set ResponseOK = FALSE

    GenerateAuthenticatorResponse( Password, NtResponse, PeerChallenge,

    AuthenticatorChallenge, UserName,

    giving MyResponse)

if (MyResponse = ReceivedResponse) then set ResponseOK = TRUE

    return ResponseOK

    }

    8.9. NewPasswordEncryptedWithOldNtPasswordHash() datatype-PWBLOCK

    {

    256-unicode-char Password

    4-octets PasswordLength

    }

    NewPasswordEncryptedWithOldNtPasswordHash( IN 0-to-256-unicode-char NewPassword, IN 0-to-256-unicode-char OldPassword, OUT datatype-PWBLOCK EncryptedPwBlock ) {

    NtPasswordHash( OldPassword, giving PasswordHash )

    EncryptPwBlockWithPasswordHash( NewPassword, PasswordHash,

    giving EncryptedPwBlock )

    }

    8.10. EncryptPwBlockWithPasswordHash()

    EncryptPwBlockWithPasswordHash(

    IN 0-to-256-unicode-char Password,

    IN 16-octet PasswordHash,

    OUT datatype-PWBLOCK PwBlock )

    {

    Fill ClearPwBlock with random octet values

    PwSize = lstrlenW( Password ) * sizeof( unicode-char ) PwOffset = sizeof( ClearPwBlock.Password ) - PwSize Move PwSize octets to (ClearPwBlock.Password + PwOffset ) from

    Password

    ClearPwBlock.PasswordLength = PwSize

    Rc4Encrypt( ClearPwBlock,

    sizeof( ClearPwBlock ),

    PasswordHash,

    sizeof( PasswordHash ),

    giving PwBlock )

    }

    8.11. Rc4Encrypt()

    Rc4Encrypt(

    IN x-octet Clear,

    IN integer ClearLength,

    IN y-octet Key,

    IN integer KeyLength,

    OUT x-octet Cypher )

    {

    /*

    * Use the RC4 encryption algorithm [6] to encrypt Clear of * length ClearLength octets into a Cypher of the same length * such that the Cypher can only be decrypted back to Clear * by providing a Key of length KeyLength octets. */

    }

    8.12. OldNtPasswordHashEncryptedWithNewNtPasswordHash()

Report this document

For any questions or suggestions please email
cust-service@docsford.com