Yubico Forum

...visit our web-store at store.yubico.com
It is currently Tue Jan 30, 2018 10:37 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Sep 29, 2015 2:41 pm 
Offline

Joined: Fri Nov 22, 2013 1:03 am
Posts: 14
Location: Germany
Hi,
I am implementing U2F in python.

I registered a u2f device, send a challenge and I am getting the response.

I run my unittest against the values from
https://fidoalliance.org/specs/fido-u2f ... on-example
which works out fine.

They give an example signature like:

"304402204b5f0cd17534cedd8c34ee09570ef542a353df4436030ce43d406de870b847780220267bb998fac9b7266eb60e7cb0b5eabdfd5ba9614f53c7b22272ec10047a923f"

To my understanding this is DER encoded.
which is very well explained here
http://crypto.stackexchange.com/questio ... e-to-asn-1

So after the first byte 0x32 I get 0x44, which is 68 (minus the 4 bytes markes and length) I get a raw signature length of 64 bytes.

I am using python-edcsa. Putting this into my code

Code:
    vkey = ecdsa.VerifyingKey.from_string(user_pub_key_bin,
                                          curve=ecdsa.NIST256p,
                                          hashfunc=sha256)
    vkey.verify(signature_bin_asn, input_data)


works out just fine.
Great. Now going live. I registered the blue yubikey u2f and am now doing a challenge request.
The response gives me this signature:

'3046022100ff57770dfcdf1bcb80f303459215a23577b3fcffcf48ce70c589cd5620b3524c022100daa4ed2727477b95a91185fc30aa7488a47370cf4a3551c208e6709b445bc2a4'

The second byte gives me a remaining length of 70 bytes and I end up with a raw signature length of 66 bytes.
Is this really correct?

Feeding this into python-edcsa gives me an assertion, since it expects a signature length of 64.

Thanks for any insight.

Kind regards
Cornelius


Top
 Profile  
Reply with quote  

Share On:

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

PostPosted: Tue Sep 29, 2015 3:02 pm 
Offline

Joined: Fri Nov 22, 2013 1:03 am
Posts: 14
Location: Germany
Bummer.

I realized, that sometimes the two values vr and vs are 33/32 or 32/33 bytes.
Sometimes 32/32 and then the signature worked.

Reading a bit deeper I realized, that it is due to the DER encoding, that a 33byte length value starts with a \0x00, which needs to bedropped, when verifying the signature.

Now everything works fine.

(if I new how to mark this thing as solved)


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 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