From d4aebbb92b23ccd896b05126f30a577894930ff6 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 1 Apr 2021 22:06:39 +0200 Subject: [PATCH] crypto: use correct webcrypto RSASSA-PKCS1-v1_5 algorithm name --- lib/internal/crypto/rsa.js | 2 +- lib/internal/crypto/webcrypto.js | 12 ++++++------ test/parallel/test-webcrypto-export-import-rsa.js | 2 +- test/parallel/test-webcrypto-keygen.js | 4 ++-- test/parallel/test-webcrypto-sign-verify.js | 8 ++++---- test/parallel/test-webcrypto-wrap-unwrap.js | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/internal/crypto/rsa.js b/lib/internal/crypto/rsa.js index 06a9e802717c54..25e9f2e4c226f9 100644 --- a/lib/internal/crypto/rsa.js +++ b/lib/internal/crypto/rsa.js @@ -66,7 +66,7 @@ const { } = require('internal/crypto/keygen'); const kRsaVariants = { - 'RSASSA-PKCS1-V1_5': kKeyVariantRSA_SSA_PKCS1_V1_5, + 'RSASSA-PKCS1-v1_5': kKeyVariantRSA_SSA_PKCS1_V1_5, 'RSA-PSS': kKeyVariantRSA_PSS, 'RSA-OAEP': kKeyVariantRSA_OAEP, }; diff --git a/lib/internal/crypto/webcrypto.js b/lib/internal/crypto/webcrypto.js index 57e3ee3af11eb2..47c34b9ca0d665 100644 --- a/lib/internal/crypto/webcrypto.js +++ b/lib/internal/crypto/webcrypto.js @@ -71,7 +71,7 @@ async function generateKey( validateBoolean(extractable, 'extractable'); validateArray(keyUsages, 'keyUsages'); switch (algorithm.name) { - case 'RSASSA-PKCS1-V1_5': + case 'RSASSA-PKCS1-v1_5': // Fall through case 'RSA-PSS': // Fall through @@ -199,7 +199,7 @@ async function deriveKey( async function exportKeySpki(key) { switch (key.algorithm.name) { - case 'RSASSA-PKCS1-V1_5': + case 'RSASSA-PKCS1-v1_5': // Fall through case 'RSA-PSS': // Fall through @@ -242,7 +242,7 @@ async function exportKeySpki(key) { async function exportKeyPkcs8(key) { switch (key.algorithm.name) { - case 'RSASSA-PKCS1-V1_5': + case 'RSASSA-PKCS1-v1_5': // Fall through case 'RSA-PSS': // Fall through @@ -321,7 +321,7 @@ async function exportKeyJWK(key) { ext: key.extractable, }); switch (key.algorithm.name) { - case 'RSASSA-PKCS1-V1_5': + case 'RSASSA-PKCS1-v1_5': jwk.alg = normalizeHashName( key.algorithm.hash.name, normalizeHashName.kContextJwkRsa); @@ -461,7 +461,7 @@ async function importKey( validateBoolean(extractable, 'extractable'); validateArray(keyUsages, 'keyUsages'); switch (algorithm.name) { - case 'RSASSA-PKCS1-V1_5': + case 'RSASSA-PKCS1-v1_5': // Fall through case 'RSA-PSS': // Fall through @@ -588,7 +588,7 @@ function signVerify(algorithm, key, data, signature) { switch (algorithm.name) { case 'RSA-PSS': // Fall through - case 'RSASSA-PKCS1-V1_5': + case 'RSASSA-PKCS1-v1_5': return lazyRequire('internal/crypto/rsa') .rsaSignVerify(key, data, algorithm, signature); case 'NODE-ED25519': diff --git a/test/parallel/test-webcrypto-export-import-rsa.js b/test/parallel/test-webcrypto-export-import-rsa.js index 1caf60f156c945..5deff132cb383a 100644 --- a/test/parallel/test-webcrypto-export-import-rsa.js +++ b/test/parallel/test-webcrypto-export-import-rsa.js @@ -457,7 +457,7 @@ const testVectors = [ publicUsages: ['verify'] }, { - name: 'RSASSA-PKCS1-V1_5', + name: 'RSASSA-PKCS1-v1_5', privateUsages: ['sign'], publicUsages: ['verify'] } diff --git a/test/parallel/test-webcrypto-keygen.js b/test/parallel/test-webcrypto-keygen.js index 4aa3cc4cf28401..9e18c871a169dd 100644 --- a/test/parallel/test-webcrypto-keygen.js +++ b/test/parallel/test-webcrypto-keygen.js @@ -65,7 +65,7 @@ const vectors = { ], mandatoryUsages: [] }, - 'RSASSA-PKCS1-V1_5': { + 'RSASSA-PKCS1-v1_5': { algorithm: { modulusLength: 1024, publicExponent: new Uint8Array([1, 0, 1]), @@ -317,7 +317,7 @@ const vectors = { const kTests = [ [ - 'RSASSA-PKCS1-V1_5', + 'RSASSA-PKCS1-v1_5', 1024, Buffer.from([1, 0, 1]), 'SHA-256', diff --git a/test/parallel/test-webcrypto-sign-verify.js b/test/parallel/test-webcrypto-sign-verify.js index 93fcdc17815f3e..71e357fedb7fc0 100644 --- a/test/parallel/test-webcrypto-sign-verify.js +++ b/test/parallel/test-webcrypto-sign-verify.js @@ -11,23 +11,23 @@ const { subtle } = require('crypto').webcrypto; // This is only a partial test. The WebCrypto Web Platform Tests // will provide much greater coverage. -// Test Sign/Verify RSASSA-PKCS1-V1_5 +// Test Sign/Verify RSASSA-PKCS1-v1_5 { async function test(data) { const ec = new TextEncoder(); const { publicKey, privateKey } = await subtle.generateKey({ - name: 'RSASSA-PKCS1-V1_5', + name: 'RSASSA-PKCS1-v1_5', modulusLength: 1024, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256' }, true, ['sign', 'verify']); const signature = await subtle.sign({ - name: 'RSASSA-PKCS1-V1_5' + name: 'RSASSA-PKCS1-v1_5' }, privateKey, ec.encode(data)); assert(await subtle.verify({ - name: 'RSASSA-PKCS1-V1_5' + name: 'RSASSA-PKCS1-v1_5' }, publicKey, signature, ec.encode(data))); } diff --git a/test/parallel/test-webcrypto-wrap-unwrap.js b/test/parallel/test-webcrypto-wrap-unwrap.js index d0c46737797a29..a28829b646f598 100644 --- a/test/parallel/test-webcrypto-wrap-unwrap.js +++ b/test/parallel/test-webcrypto-wrap-unwrap.js @@ -64,7 +64,7 @@ async function generateKeysToWrap() { const parameters = [ { algorithm: { - name: 'RSASSA-PKCS1-V1_5', + name: 'RSASSA-PKCS1-v1_5', modulusLength: 1024, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256'