For an application I want to be able to login to MSN Messenger Service with
MSNP18 protocol with requires SSO authentication.

I found some examples in VB and C# and tried to translate them to Delphi
(2010).

With some testvalues I found on the internet I didn't get the result I
should have

 

unit testMsgr;

 

interface

 

uses

    Windows, Classes, SysUtils, OverbyteIcsSha1; (etc);

 

type

   ...

 function DeriveKey(const key, magic: array of byte;

              const Mlen: integer; var des: array of byte): boolean;

  ...

end;

 

implementation

...

..

function TForm1.DeriveKey(const key, Magic: array of byte;

          const Mlen: integer; var des: array of byte): boolean;

var

   h1, h2, h3, h4: Sha1Digest;

  I: integer;

  hm1, hm2: array of byte;

begin

  Result := true;

  SetLength(hm1, 20 + MLen);

  SetLength(hm2, 20 + MLen);

  for I := 0 to SizeOf(Magic) - 1 do

    mb2[I] := Magic[I];

  HMac_Sha1(Magic, SizeOf(Magic), Key, SizeOf(Key), h1);

  for I := 0 to 19 do

    hm1[I] := ord(h1[I]);

  for I := 0 to LenM - 1 do

    hm1[I + 20] := Magic[I];

  HMac_Sha1(hm1, 20 + Mlen, key, SizeOf(key), h2);

  HMac_Sha1(h1, SizeOf(h1), Key, SizeOf(Key), h3);

  for I := 0 to 19 do

    hm2[I] := ord(h3[I]);

  for I := 0 to LenM - 1 do

    hm2[I + 20] := Magic[I];

  HMac_Sha1(hm2, 20 + Mlen, key, SizeOf(key), h4);

  //.

end;

 

h1 and h3 have the expected result but h2 and h4 don't and when I call the
function again they have a different result.

I've tried a couple other methods but no difference.

Is there some stupid error in my code?

 

Tia, Ger

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to