Skip to content

PS*: fix PS* signatures#34

Merged
omsmith merged 1 commit intomasterfrom
fix-pss
Mar 16, 2019
Merged

PS*: fix PS* signatures#34
omsmith merged 1 commit intomasterfrom
fix-pss

Conversation

@omsmith
Copy link
Copy Markdown
Contributor

@omsmith omsmith commented 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

@omsmith
Copy link
Copy Markdown
Contributor Author

omsmith commented Mar 16, 2019

@panva is this the fix you expected? Seems like jwt.io still isn't verifying... hmmph

@panva
Copy link
Copy Markdown
Member

panva commented Mar 16, 2019

is this the fix?

Yes.

Seems like jwt.io still isn't verifying

It is for me.

🤔

@omsmith
Copy link
Copy Markdown
Contributor Author

omsmith commented Mar 16, 2019

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 }));
	}
});

@omsmith
Copy link
Copy Markdown
Contributor Author

omsmith commented Mar 16, 2019

Oh. derp

@panva
Copy link
Copy Markdown
Member

panva commented Mar 16, 2019

What is it? :-)

@omsmith
Copy link
Copy Markdown
Contributor Author

omsmith commented Mar 16, 2019

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants