Skip to content

Commit

Permalink
crypto: use correct webcrypto RSASSA-PKCS1-v1_5 algorithm name
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 1, 2021
1 parent 98ff5ac commit d4aebbb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/internal/crypto/rsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
12 changes: 6 additions & 6 deletions lib/internal/crypto/webcrypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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':
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-webcrypto-export-import-rsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ const testVectors = [
publicUsages: ['verify']
},
{
name: 'RSASSA-PKCS1-V1_5',
name: 'RSASSA-PKCS1-v1_5',
privateUsages: ['sign'],
publicUsages: ['verify']
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-webcrypto-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const vectors = {
],
mandatoryUsages: []
},
'RSASSA-PKCS1-V1_5': {
'RSASSA-PKCS1-v1_5': {
algorithm: {
modulusLength: 1024,
publicExponent: new Uint8Array([1, 0, 1]),
Expand Down Expand Up @@ -317,7 +317,7 @@ const vectors = {

const kTests = [
[
'RSASSA-PKCS1-V1_5',
'RSASSA-PKCS1-v1_5',
1024,
Buffer.from([1, 0, 1]),
'SHA-256',
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-webcrypto-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-webcrypto-wrap-unwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit d4aebbb

Please sign in to comment.