Log in

No account? Create an account
LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

New to community (problem solved) [Jul. 27th, 2006|02:50 pm]
LiveJournal Client Discussions


Hi, I've just started working on a client written in C# that will eventually have a gtk# frontend (codename: GerryGiraffe). I'm using the flat interface, as XML-RPC.NET seems to have a sketchy relationship with the mono compiler. Anyhow, I'm working on the login request at the moment. The getchallenge request/response seems to be working just fine. I get an "Invalid password" error message when I attempt to login (and yes, I checked to make sure I had the right password). I'm now wondering if I misunderstood the formula to calculate auth_response. If someone could take a look at my code and verify I'd be quite grateful :)

public static string GetAuthResponseString(string chlg, string pass)
using (System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider())
// Compute string lengths
int lenChlg = Encoding.UTF8.GetByteCount(chlg);
int lenPass = Encoding.UTF8.GetByteCount(pass);

// Allocate input buffer
byte[] input = new byte[lenChlg + System.Math.Max(16, lenPass)];

// Convert the password into the buffer
Encoding.UTF8.GetBytes(pass, 0, pass.Length, input, 0);

// Compute the MD5 hash of the password
md5.TransformFinalBlock(input, 0, lenPass);

// Copy the MD5 hash back into the input buffer
Array.Copy(md5.Hash, 0, input, lenChlg, md5.Hash.Length);

// Convert the challenge into the input buffer
Encoding.UTF8.GetBytes(chlg, 0, chlg.Length, input, 0);

// Length of input
int lenHalf = lenChlg + md5.Hash.Length;

// Compute the MD5 hash of the password
md5.TransformFinalBlock(input, 0, lenHalf);

return Convert.ToBase64String(md5.Hash);


[User Picture]From: trinbellwoods
2006-07-27 08:49 pm (UTC)


I realized that I should have converted my byte array output from ComputeHash into a 16-bit hex string rather than a regular base64 string. Whoops. I'm leaving this entry, however, since I meant to introduce myself anyhow :)
(Reply) (Thread)