# Table of contents:
# Introduction
SSO (Single Sign On) is a authentication scheme available since MSNP15.
Like its predecessor TWN, it authenticates using a Passport Compact Token. However, the original query parameter-based policies have been replaced with encryption-based challenges. Additionally, the token domain has been changed.
# Procedure
# Initial USR Exchange
The client sends the initial USR request, and the notification server provides a policy and a base64 nonce:
C: USR TrID SSO I user-handle
S: USR TrID SSO S policy nonce
Where user-handle is the handle (e-mail address) the client is authenticating with.
Where policy is the authentication policy, usually MBI_KEY_OLD or MBI_KEY.
Where nonce is the cryptographic nonce used when calculating the client challenge. Encoded in base64.
# Passport Authentication
The client now authenticates with passport and completes the policy challenge using the provided nonce. This process is documented at Passport SOAP (RST).
The token must be requested for messengerclear.live.com.
Note that SSO no longer supports the use of Passport SSI 1.4 due to the use of policy challenges.
# Challenge generation
You will need to generate a response if the authentication policy is MBI_KEY or MBI_KEY_OLD:
- Using the challenge nonce (provided by the
USR SSO S's fourth parameter, 64 characters.) - Using the binary secret (provided by the Passport SOAP (RST) response for
messengerclear.live.com, 32 characters.) - Generating an IV (8 bytes, 12 characters).
- First, the binary secret should be base64 decoded into a buffer of 24 bytes.
NOTE: Do not decode the challenge nonce. It is treated as 64 bytes already.
NOTE: If replaying a generation, the IV is required to be extracted from the challenge response. - Instance a HMAC-SHA1 hash function with the 24-byte binary secret as the parameter. Call this
hashProvider. - Then compute hashes using the decoded binary secret (
key1):- Using
hashProvider, generate a hash with the constantWS-SecureConversationSESSION KEY HASH. Save this ashash1.
- Using
- Concatenate
hash1with the constantWS-SecureConversationSESSION KEY HASH. Save this ashash1constant. - Using
hashProvider, generate a hash ofhash1constant. Save this ashash2, and keep forkey2. - Using
hashProvider, generate a hash ofhash1. Save this ashash3. - Concatenate
hash3with the constantWS-SecureConversationSESSION KEY HASH. Save this ashash3constant. - Using
hashProvider, generate a hash ofhash1constant. Save this ashash4, and keep forkey2. - To create
key2, create a 24 byte buffer.
The first 20 bytes should be the entirity ofhash2, and the remaining 4 bytes should be the first 4 bytes ofhash4. - Then compute more hashes using the decoded binary secret (
key1).
Use the constantWS-SecureConversationSESSION KEY ENCRYPTIONinstead.
This should providehash5,hash6,hash7andhash8. - To create
key3, create a 24 byte buffer.
The first 20 bytes should be the entirity ofhash6. the remaining 4 bytes should be the first 4 bytes ofhash8. - Instance a HMAC-SHA1 hash function for
key2. - Use the
key2HMAC-SHA1 to compute the hash for the challenge nonce. Save this ashash9. - Create a 72-byte buffer called
inputBuffer. The last 8 bytes should be all the value8. - Copy the whole nonce (64 bytes) into the first 64 bytes of
inputBuffer. - Using 3DES-CBC, encrypt the first 64 bytes of
inputBufferwith your IV. Call thistdesBlock. - Create a 128-byte buffer called
result.
The first 28 bytes should be:28,0,0,0,1,0,0,0,3,102,0,0,4,128,0,0,8,0,0,0,20,0,0,0,72,0,0, and finally0. - The next 8 bytes of
resultshould be your IV. - The next 20 bytes of
resultshould behash9. - The next 72 bytes of
resultshould betdesBlock. - Encode
resultin base64. This is your challenge response.
An example of doing this is provided as SolveSSOChallenge in msnp_challenges.cs.
# Subsequent USR Exchange
The client completes the authentication flow by sending the Passport Compact Token and the completed policy challenge to the Notification Server (NS):
C: USR TrID SSO S compact-token challenge
S: USR TrID OK (...)