# Table of contents:
# Introduction
QRY is a command introduced with MSNP6.
It is a Notification Server command, WITH a request payload but without a response payload.
Responds to a challenge request (CHL command).
# Client/Request
QRY TrID public-key length
payload
Where public-key is your client's Public Key.
For a list of valid Public Keys, read the Challenge Key Pairs article.
Where length is the size (in bytes) of the payload.
Where payload is the challenge response.
# Challenge responses
Calculating the challenge response depends on the version of the protocol you are using.
For a list of valid Private Keys, read the Challenge Key Pairs article.
For the challenge input, use the last CHL received.
THe server can accept a response for the previous challenge given to the client, so long as it's valid with the specified key pair.
# Basic responses
Simply MD5 hash the latest challenge received and your client's Private Key concatenated together as a string.
For an implementation of this, review SolveMSNP6Challenge in msnp_challenges.cs.
The output should be 32 bytes and lowercase hexadecimal.
# Advanced responses
Since MSNP11.
- MD5 hash the latest challenge received and your client's Private Key concatenated together as a string.
- Create an 32-bit integer array with the size of 4, with the contents being each part of the first step put through a bitwise AND of
0x7FFFFFFF. - Concatenate the challenge and Public Key together and save as a new string.
- Pad the string to the right if it's length can not be divided by 8.
- Create a new 32-bit integer array with the size of the padded string's length divided by 4, with the contents being 4 bytes of the fourth step put through a bitwise AND of
0x7FFFFFFF. - Initialize three 64-bit variables, one called
temp, another calledhigh, and the last calledlow. - In a loop, iterate the array made in step 5, and increase the iterator by 2 every pass.
- The
tempvariable should be set to the part of the array created in the fifth step indexed by the iterator. - Multiply and set
tempby0x0E79A9C1. - Modulo (not bitwise AND) and set
tempby0x7FFFFFFF. - Add and set
tempby the contents ofhigh. - Multiply and set
tempby the first part of the array made in step 2. - Add the value of the second part of the array made in step 2 to
temp. - Modulo and set
tempby0x7FFFFFFF. - Set
highto the part of the array created in the fifth step indexed by the iterator plus 1. - Add and set
highto the value oftemp. - Modulo
highby0x7FFFFFFF. - Multiply and set
highby the third part of the array made in step 2. - Add and set
highby the value of the fourth part of the array made in step 2. - Modulo and set
highby0x7FFFFFFF. - Add and set
lowto the result ofhighandtempbeing added together.
- The
- We have now finished the loop.
- Add and set
highby the value of the second part of the array made in step 2. - Modulo
highby0x7FFFFFFF. - Swap the endianness of the 32-bit segment of
high. - Add and set
lowby the value of the fourth part of the array made in step 2. - Modulo
lowby0x7FFFFFFF. - Swap the endianness of the 32-bit segment of
low. - Create a new 64-bit variable named key.
- Set the value of key to the value of
highshifted 32 bits to the left, and the value oflow. - Swap the endianness of the entire 64-bit segment of
key. - Create two new 64-bit variables, one
resultHigh, and the otherresultLow. - Set
resultHighto the first 64 bits of the value created in step 1. - Set
resultLowto the last 64 bits of the value created in step 1. - Bitwise XOR and set
resultHighby the value ofkey. - Bitwise XOR and set
resultLowby the value ofkey. - Concatenate the values of
resultHighandresultLowas a set of bytes. - Convert the concatenated values into a hex stream.
For an implementation of this, review SolveMSNP11Challenge in msnp_challenges.cs.
The output should be 32 bytes and lowercase hexadecimal.
# Server/Response
QRY TrID
# Examples
# Successful response to asynchronous challenge
S: CHL 0 12345678901234567890
C: QRY 1 msmsgs@msnmsgr.com 32
8ba1bb9d6dbf624fee31a2053af5fdd0
S: QRY 1
# Multiple successful responses to requested challenge
NOTE: This usually happens when threedegrees is installed.
C: CHL 2
S: CHL 2 12345678901234567890
C: QRY 3 PROD0038W!61ZTF9 32
c64fe621f55832479b97b7f50829d5c1
S: QRY 3
C: QRY 4 PROD0045YI56T?TX 32
2063564d38ea46776a45326c4c638fa1
S: QRY 4
# Failed challenge
NOTE: This happens as-is in MSNP11, since it isn't using the new method.
S: CHL 0 12345678901234567890
C: QRY 5 msmsgs@msnmsgr.com 32
8ba1bb9d6dbf624fee31a2053af5fdd0
S: 540 5
Server disconnects client.
# Known changes
- MSNP11: Changed challenge response generation algorithm drastically.