Yubico Forum

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

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu Mar 12, 2015 7:11 pm 
Offline

Joined: Tue Oct 21, 2014 7:53 pm
Posts: 13
?appId
"http://localhost:52701"

?Utils.ByteArrayToBase64String(U2F.Crypto.Hash(appId))
"ENIbQIWZ9ZHrY48rknvb_PjHS6RGN-wkcKM_n0gjCHw"


The results of Crypto.Hash are different between Java and .NET code. Here is the .NET code.

private readonly SHA256Managed _sha256Managed = new SHA256Managed();

public byte[] Hash(byte[] bytes)
{
try
{
return _sha256Managed.ComputeHash(bytes);
}
catch (Exception e)
{
throw new UnsupportedOperationException("Error when computing SHA-256", e);
}
}

public byte[] Hash(string str)
{
byte[] bytes = new byte[str.Length*sizeof (char)];
Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);

return Hash(bytes);
}


Top
 Profile  
Reply with quote  

Share On:

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

PostPosted: Thu Mar 12, 2015 7:40 pm 
Offline

Joined: Tue Oct 21, 2014 7:53 pm
Posts: 13
This code returned the correct results in VerifySignature!!! I applied the same changes to both the Register and Sign pages and both return the correct responses. I also checked that a false value is returned for VerifySignature() if the Signature array is reversed. Thank you so much for your help.

byte[] appIdHash = Encoding.ASCII.GetBytes(appId);
byte[] clientHash = Encoding.ASCII.GetBytes(clientData);

byte[] signedBytes = PackBytesToSign(
U2F.Crypto.Hash(appIdHash),
U2F.Crypto.Hash(clientHash),
KeyHandle,
UserPublicKey
);


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 13, 2015 8:07 am 
Offline
Yubico Team
Yubico Team

Joined: Wed Aug 06, 2014 2:40 pm
Posts: 38
Great! Glad I could help :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


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