auth0 / node-jsonwebtoken

JsonWebToken implementation for node.js http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html
MIT License
17.71k stars 1.23k forks source link

ES256 and ES384 throwing length error. ES512 works. #242

Closed tylergoza closed 8 years ago

tylergoza commented 8 years ago

I didn't notice another issue on this so I thought I'd mention it. Could be that I've mucked something up, could be coming from a lib you're using, or could be coming from you guys. Not sure so I thought I'd start here.

I'm currently working on a prototype for work using node-jsonwebtoken and everything works fine if I generate a token using ES512 everything is fine, but if I try to use ES256 or ES384 I get a variation of this error: (this is from ES256)

.../node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js:60
 throw new Error('"r" specified length of "' + rLength + '", max of "' + maxEncodedParamLength + '" is acceptable');
                ^

Error: "r" specified length of "65", max of "33" is acceptable
    at Object.derToJose (.../node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js:60:9)
    at Object.sign (.../node_modules/jwa/index.js:75:29)
    at Object.jwsSign [as sign] (.../node_modules/jws/lib/sign-stream.js:23:24)
    at Object.module.exports [as sign] (.../node_modules/jsonwebtoken/sign.js:144:16)
    at .../createToken.js:24:17
    at Object.<anonymous> (.../createToken.js:48:3)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)

I've not got anything too important in the script as it's pretty generic so I can add it if someone wishes to take a look at my code that leads to this.

Thanks for the hard work!

tylergoza commented 8 years ago

Well someone from work pointed out that I was using a 512 key. So that makes sense. I'll close this issue for you. Thanks again!