# 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.
# Basic responses
Simply MD5 hash the challenge 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 challenge 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
temp
variable should be set to the part of the array created in the fifth step indexed by the iterator. - Multiply and set
temp
by0x0E79A9C1
. - Modulo (not bitwise AND) and set
temp
by0x7FFFFFFF
. - Add and set
temp
by the contents ofhigh
. - Multiply and set
temp
by 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
temp
by0x7FFFFFFF
. - Set
high
to the part of the array created in the fifth step indexed by the iterator plus 1. - Add and set
high
to the value oftemp
. - Modulo
high
by0x7FFFFFFF
. - Multiply and set
high
by the third part of the array made in step 2. - Add and set
high
by the value of the fourth part of the array made in step 2. - Modulo and set
high
by0x7FFFFFFF
. - Add and set
low
to the result ofhigh
andtemp
being added together.
- The
- We have now finished the loop.
- Add and set
high
by the value of the second part of the array made in step 2. - Modulo
high
by0x7FFFFFFF
. - Swap the endianness of the 32-bit segment of
high
. - Add and set
low
by the value of the fourth part of the array made in step 2. - Modulo
low
by0x7FFFFFFF
. - 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
high
shifted 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
resultHigh
to the first 64 bits of the value created in step 1. - Set
resultLow
to the last 64 bits of the value created in step 1. - Bitwise XOR and set
resultHigh
by the value ofkey
. - Bitwise XOR and set
resultLow
by the value ofkey
. - Concatenate the values of
resultHigh
andresultLow
as 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
S: CHL 12345678901234567890
C: QRY 1 msmsgs@msnmsgr.com 32
8ba1bb9d6dbf624fee31a2053af5fdd0
S: QRY 1
# Failed challenge
NOTE: This happens as-is in MSNP11, since it isn't using the new method.
S: CHL 12345678901234567890
C: QRY 2 msmsgs@msnmsgr.com 32
8ba1bb9d6dbf624fee31a2053af5fdd0
S: 540 2
Server disconnects client.
# Known changes
- MSNP11: Changed challenge response generation algorithm drastically.