Conversation
Contributor
Author
|
@panva is this the fix you expected? Seems like jwt.io still isn't verifying... hmmph |
Member
Yes.
It is for me. 🤔 |
Contributor
Author
|
This is what I'm trying. Yours both work, but PS256 still fails for jws/jwa 'use strict';
const { generateKeyPair } = require('crypto');
const { promisify } = require('util');
const base64url = require('base64url');
const { JWK, JWS } = require('@panva/jose');
const jws = require('.');
const ALGS = ['RS256', 'PS256'];
const PAYLOAD = JSON.stringify({ foo: 'bar' });
promisify(generateKeyPair)('rsa', {
modulusLength: 2048
}).then(async keys => {
process._rawDebug('pubkey\n', keys.publicKey.export({ type: 'spki', format: 'pem' }));
for (const alg of ALGS) {
process._rawDebug(`${alg} signature (jwa)\n`, jws.sign({
header: { alg },
payload: PAYLOAD,
privateKey: keys.privateKey
}));
process._rawDebug(`${alg} signature (@panva/jose)\n`, JWS.sign(PAYLOAD, JWK.importKey(keys.privateKey), { alg }));
}
}); |
Contributor
Author
|
Oh. derp |
Member
|
What is it? :-) |
Contributor
Author
diff --git a/index.js b/index.js
index 8def0ec..e71e6d1 100644
--- a/index.js
+++ b/index.js
@@ -173,7 +173,7 @@ function createPSSKeySigner(bits) {
var sig = (signer.update(thing), signer.sign({
key: privateKey,
padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
- salt: crypto.constants.RSA_PSS_SALTLEN_DIGEST
+ saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST
}, 'base64'));
return fromBase64(sig);
}
@@ -189,7 +189,7 @@ function createPSSKeyVerifier(bits) {
return verifier.verify({
key: publicKey,
padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
- salt: crypto.constants.RSA_PSS_SALTLEN_DIGEST
+ saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST
}, signature, 'base64');
} |
omsmith
added a commit
that referenced
this pull request
Mar 16, 2019
https://tools.ietf.org/html/rfc7518#section-3.5 describes "The size of the salt value is the same size as the hash function output.". Fixes: auth0/node-jws#85 PR-URL: #34
https://tools.ietf.org/html/rfc7518#section-3.5 describes "The size of the salt value is the same size as the hash function output.". Fixes: auth0/node-jws#85 PR-URL: #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://tools.ietf.org/html/rfc7518#section-3.5 describes "The size of the salt value is the same size as
the hash function output.".
Fixes: auth0/node-jws#85
PR-URL: #34