This morning, I have been turning over the SyncML 1.1 protocol of OMA, Which is stuck in the user verification area. The expected results cannot be calculated based on the Protocol example.
Based on the Protocol text, the MD5 verification algorithm is very simple. It is represented by Pseudo Code as follows:
Result = base64 (MD5 (base64 (MD5 (username + ":" + password) + ":" + nonce ));
Written in PHP:
Function computehash ($ username, $ password, $ nonce ){
Return base64_encode (pack ('H * ', MD5 (base64_encode (pack ('H *', MD5 ("$ username: $ password "))). ": $ nonce ")));
}
However, use the parameters specified in the Protocol:
Username = "bruce1", password = "ohbehave", Nonce = "nonce"
In any case, the value "zz6eivr3yeaaencrn6lpaq =" is not included in the Protocol, but "+ meikfrf8qdou2b1h2ymxw ="
I wrote one with. net, and the results are the same.
Code
/// <Summary>
/// Generate MD5 Digest for SyncML Authentication
/// </Summary>
/// <Param name = "user"> </param>
/// <Param name = "password"> </param>
/// <Param name = "nonce"> </param>
/// <Returns> </returns>
Public static string generatesyncmlmd5 (string user, string password, string nonce)
{
System. Security. cryptography. MD5 MD5 = system. Security. cryptography. md5.create ();
Md5.computehash (encoding. ASCII. getbytes (User + ":" + password ));
String S = convert. tobase64string (md5.hash) + ":" + nonce;
Md5.computehash (encoding. ASCII. getbytes (s ));
Return convert. tobase64string (md5.hash );
}
After searching by multiple parties, I finally found the cause: the Protocol was written incorrectly. The correct parameters should be:
Username = "bruce2", password = "ohbehave", Nonce = "nonce"
I faint...