Yubico Forum

...visit our web-store at store.yubico.com
It is currently Tue Jan 30, 2018 3:38 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Jun 25, 2008 2:00 pm 
Offline

Joined: Wed Jun 25, 2008 1:56 pm
Posts: 6
I am having problems implementing the signature checking in C#. I have used the Microsoft MSDN hmac SHA1 example to encode the parameters with no luck. All I get is the dreaded BAD_SIGNATURE.

Any ideas?

_authid and otp was populated correctly and without the &h... it works STATUS=OK
Code:
            String sParams = "id=" + _authId + "&otp=" + otp;
            String sAPIKeyUtf8 = base64Decode(APIKEY);
            String shmac;

            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = Encoding.ASCII.GetBytes(sAPIKeyUtf8);
            byte[] dataBuffer = System.Text.Encoding.ASCII.GetBytes(sParams);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            shmac = Convert.ToBase64String(hashBytes);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(YUBICO_AUTH_SRV_URL + _authId + "&otp=" + otp + "&h=" + shmac);


Top
 Profile  
Reply with quote  

Share On:

Share on Facebook FacebookShare on Twitter TwitterShare on Tumblr TumblrShare on Google+ Google+

PostPosted: Wed Jun 25, 2008 6:36 pm 
Offline

Joined: Wed Jun 25, 2008 1:56 pm
Posts: 6
Got this working now ... why are (almost) all the most infuriating problems the easiest solutions :oops: :

Code:
byte[] dataBuffer = System.Text.Encoding.ASCII.GetBytes(sParams);


should read:

Code:
byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(sParams);



8-)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group