EC JWK 'x' and 'y' param leading zero padding bug

Issue #77 resolved
Vladimir Dzhuvinov created an issue

Reported by email:


From: Anders Rundgren Subject: EC JWK Bug in NimbusDS Date: Tue, 21 Jan 2014 13:28:24 +0100 (01/21/2014 02:28:24 PM)

Hi Vladimir, I may have accidentally found a bug in NimbusDS.

http://www.ietf.org/mail-archive/web/jose/current/msg03901.html

Cheers, Anders

Comments (5)

  1. Vladimir Dzhuvinov reporter

    Further comments and suggestions from Anders:


    My fix to the problem was using a table:

    https://code.google.com/p/openkeystore/source/browse/javascript/trunk/src/crypto/KeySerializing.js

    I.e. if you know the curve you can from a table find how long a coordinate is supposed to be and then pad it to the proper length.


    Hi Vladimir, I enclosed a bunch of such from my tests. Note that the JSON keys are not following JWK but the line below is a genuine SPKI.

    I think the fix is finding the fieldsize : ((ECPublicKey)public_key).getParams ().getCurve ().getField ().getFieldSize ())

    The number of bytes to output is: (fieldsize + 7)/8

    Good luck!

    Anders

  2. Log in to comment