| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent afc6ab2 commit ac69b95
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ const { | |||
| 16 | 16 | kCryptoJobAsync, | |
| 17 | 17 | kCryptoJobSync, | |
| 18 | 18 | kKeyVariantRSA_PSS, | |
| 19 | - kKeyVariantRSA_SSA_PKCS1_V1_5, | ||
| 19 | + kKeyVariantRSA_SSA_PKCS1_v1_5, | ||
| 20 | 20 | EVP_PKEY_ED25519, | |
| 21 | 21 | EVP_PKEY_ED448, | |
| 22 | 22 | EVP_PKEY_X25519, | |
@@ -183,7 +183,7 @@ function createJob(mode, type, options) { | |||
| 183 | 183 | if (type === 'rsa') { | |
| 184 | 184 | return new RsaKeyPairGenJob( | |
| 185 | 185 | mode, | |
| 186 | - kKeyVariantRSA_SSA_PKCS1_V1_5, // Used also for RSA-OAEP | ||
| 186 | + kKeyVariantRSA_SSA_PKCS1_v1_5, // Used also for RSA-OAEP | ||
| 187 | 187 | modulusLength, | |
| 188 | 188 | publicExponent, | |
| 189 | 189 | ...encoding); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ const { | |||
| 14 | 14 | kCryptoJobAsync, | |
| 15 | 15 | kSignJobModeSign, | |
| 16 | 16 | kSignJobModeVerify, | |
| 17 | - kKeyVariantRSA_SSA_PKCS1_V1_5, | ||
| 17 | + kKeyVariantRSA_SSA_PKCS1_v1_5, | ||
| 18 | 18 | kKeyVariantRSA_PSS, | |
| 19 | 19 | kKeyVariantRSA_OAEP, | |
| 20 | 20 | kKeyTypePrivate, | |
@@ -66,7 +66,7 @@ const { | |||
| 66 | 66 | } = require('internal/crypto/keygen'); | |
| 67 | 67 | ||
| 68 | 68 | const kRsaVariants = { | |
| 69 | - 'RSASSA-PKCS1-V1_5': kKeyVariantRSA_SSA_PKCS1_V1_5, | ||
| 69 | + 'RSASSA-PKCS1-v1_5': kKeyVariantRSA_SSA_PKCS1_v1_5, | ||
| 70 | 70 | 'RSA-PSS': kKeyVariantRSA_PSS, | |
| 71 | 71 | 'RSA-OAEP': kKeyVariantRSA_OAEP, | |
| 72 | 72 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,9 +6,9 @@ const { | |||
| 6 | 6 | BigInt, | |
| 7 | 7 | FunctionPrototypeBind, | |
| 8 | 8 | Number, | |
| 9 | + ObjectKeys, | ||
| 9 | 10 | Promise, | |
| 10 | 11 | StringPrototypeToLowerCase, | |
| 11 | - StringPrototypeToUpperCase, | ||
| 12 | 12 | Symbol, | |
| 13 | 13 | } = primordials; | |
| 14 | 14 | ||
@@ -159,31 +159,32 @@ const kAesKeyLengths = [128, 192, 256]; | |||
| 159 | 159 | ||
| 160 | 160 | // These are the only algorithms we currently support | |
| 161 | 161 | // via the Web Crypto API | |
| 162 | - const kAlgorithms = [ | ||
| 163 | - 'rsassa-pkcs1-v1_5', | ||
| 164 | - 'rsa-pss', | ||
| 165 | - 'rsa-oaep', | ||
| 166 | - 'ecdsa', | ||
| 167 | - 'ecdh', | ||
| 168 | - 'aes-ctr', | ||
| 169 | - 'aes-cbc', | ||
| 170 | - 'aes-gcm', | ||
| 171 | - 'aes-kw', | ||
| 172 | - 'hmac', | ||
| 173 | - 'sha-1', | ||
| 174 | - 'sha-256', | ||
| 175 | - 'sha-384', | ||
| 176 | - 'sha-512', | ||
| 177 | - 'hkdf', | ||
| 178 | - 'pbkdf2', | ||
| 162 | + const kAlgorithms = { | ||
| 163 | + 'rsassa-pkcs1-v1_5': 'RSASSA-PKCS1-v1_5', | ||
| 164 | + 'rsa-pss': 'RSA-PSS', | ||
| 165 | + 'rsa-oaep': 'RSA-OAEP', | ||
| 166 | + 'ecdsa': 'ECDSA', | ||
| 167 | + 'ecdh': 'ECDH', | ||
| 168 | + 'aes-ctr': 'AES-CTR', | ||
| 169 | + 'aes-cbc': 'AES-CBC', | ||
| 170 | + 'aes-gcm': 'AES-GCM', | ||
| 171 | + 'aes-kw': 'AES-KW', | ||
| 172 | + 'hmac': 'HMAC', | ||
| 173 | + 'sha-1': 'SHA-1', | ||
| 174 | + 'sha-256': 'SHA-256', | ||
| 175 | + 'sha-384': 'SHA-384', | ||
| 176 | + 'sha-512': 'SHA-512', | ||
| 177 | + 'hkdf': 'HKDF', | ||
| 178 | + 'pbkdf2': 'PBKDF2', | ||
| 179 | 179 | // Following here are Node.js specific extensions. All | |
| 180 | 180 | // should be prefixed with 'node-' | |
| 181 | - 'node-dsa', | ||
| 182 | - 'node-dh', | ||
| 183 | - 'node-scrypt', | ||
| 184 | - 'node-ed25519', | ||
| 185 | - 'node-ed448', | ||
| 186 | - ]; | ||
| 181 | + 'node-dsa': 'NODE-DSA', | ||
| 182 | + 'node-dh': 'NODE-DH', | ||
| 183 | + 'node-scrypt': 'NODE-SCRYPT', | ||
| 184 | + 'node-ed25519': 'NODE-ED25519', | ||
| 185 | + 'node-ed448': 'NODE-ED448', | ||
| 186 | + }; | ||
| 187 | + const kAlgorithmsKeys = ObjectKeys(kAlgorithms); | ||
| 187 | 188 | ||
| 188 | 189 | // These are the only export and import formats we currently | |
| 189 | 190 | // support via the Web Crypto API | |
@@ -221,7 +222,7 @@ function normalizeAlgorithm(algorithm, label = 'algorithm') { | |||
| 221 | 222 | let hash; | |
| 222 | 223 | if (typeof name !== 'string' || | |
| 223 | 224 | !ArrayPrototypeIncludes( | |
| 224 | - kAlgorithms, | ||
| 225 | + kAlgorithmsKeys, | ||
| 225 | 226 | StringPrototypeToLowerCase(name))) { | |
| 226 | 227 | throw lazyDOMException('Unrecognized name.', 'NotSupportedError'); | |
| 227 | 228 | } | |
@@ -230,7 +231,11 @@ function normalizeAlgorithm(algorithm, label = 'algorithm') { | |||
| 230 | 231 | if (!ArrayPrototypeIncludes(kHashTypes, hash.name)) | |
| 231 | 232 | throw lazyDOMException('Unrecognized name.', 'NotSupportedError'); | |
| 232 | 233 | } | |
| 233 | - return { ...algorithm, name: StringPrototypeToUpperCase(name), hash }; | ||
| 234 | + return { | ||
| 235 | + ...algorithm, | ||
| 236 | + name: kAlgorithms[StringPrototypeToLowerCase(name)], | ||
| 237 | + hash, | ||
| 238 | + }; | ||
| 234 | 239 | } | |
| 235 | 240 | } | |
| 236 | 241 | throw lazyDOMException('Unrecognized name.', 'NotSupportedError'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,7 +71,7 @@ async function generateKey( | |||
| 71 | 71 | validateBoolean(extractable, 'extractable'); | |
| 72 | 72 | validateArray(keyUsages, 'keyUsages'); | |
| 73 | 73 | switch (algorithm.name) { | |
| 74 | - case 'RSASSA-PKCS1-V1_5': | ||
| 74 | + case 'RSASSA-PKCS1-v1_5': | ||
| 75 | 75 | // Fall through | |
| 76 | 76 | case 'RSA-PSS': | |
| 77 | 77 | // Fall through | |
@@ -199,7 +199,7 @@ async function deriveKey( | |||
| 199 | 199 | ||
| 200 | 200 | async function exportKeySpki(key) { | |
| 201 | 201 | switch (key.algorithm.name) { | |
| 202 | - case 'RSASSA-PKCS1-V1_5': | ||
| 202 | + case 'RSASSA-PKCS1-v1_5': | ||
| 203 | 203 | // Fall through | |
| 204 | 204 | case 'RSA-PSS': | |
| 205 | 205 | // Fall through | |
@@ -242,7 +242,7 @@ async function exportKeySpki(key) { | |||
| 242 | 242 | ||
| 243 | 243 | async function exportKeyPkcs8(key) { | |
| 244 | 244 | switch (key.algorithm.name) { | |
| 245 | - case 'RSASSA-PKCS1-V1_5': | ||
| 245 | + case 'RSASSA-PKCS1-v1_5': | ||
| 246 | 246 | // Fall through | |
| 247 | 247 | case 'RSA-PSS': | |
| 248 | 248 | // Fall through | |
@@ -321,7 +321,7 @@ async function exportKeyJWK(key) { | |||
| 321 | 321 | ext: key.extractable, | |
| 322 | 322 | }); | |
| 323 | 323 | switch (key.algorithm.name) { | |
| 324 | - case 'RSASSA-PKCS1-V1_5': | ||
| 324 | + case 'RSASSA-PKCS1-v1_5': | ||
| 325 | 325 | jwk.alg = normalizeHashName( | |
| 326 | 326 | key.algorithm.hash.name, | |
| 327 | 327 | normalizeHashName.kContextJwkRsa); | |
@@ -461,7 +461,7 @@ async function importKey( | |||
| 461 | 461 | validateBoolean(extractable, 'extractable'); | |
| 462 | 462 | validateArray(keyUsages, 'keyUsages'); | |
| 463 | 463 | switch (algorithm.name) { | |
| 464 | - case 'RSASSA-PKCS1-V1_5': | ||
| 464 | + case 'RSASSA-PKCS1-v1_5': | ||
| 465 | 465 | // Fall through | |
| 466 | 466 | case 'RSA-PSS': | |
| 467 | 467 | // Fall through | |
@@ -588,7 +588,7 @@ function signVerify(algorithm, key, data, signature) { | |||
| 588 | 588 | switch (algorithm.name) { | |
| 589 | 589 | case 'RSA-PSS': | |
| 590 | 590 | // Fall through | |
| 591 | - case 'RSASSA-PKCS1-V1_5': | ||
| 591 | + case 'RSASSA-PKCS1-v1_5': | ||
| 592 | 592 | return lazyRequire('internal/crypto/rsa') | |
| 593 | 593 | .rsaSignVerify(key, data, algorithm, signature); | |
| 594 | 594 | case 'NODE-ED25519': | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -559,7 +559,7 @@ void Initialize(Environment* env, Local<Object> target) { | |||
| 559 | 559 | RSAKeyExportJob::Initialize(env, target); | |
| 560 | 560 | RSACipherJob::Initialize(env, target); | |
| 561 | 561 | ||
| 562 | - NODE_DEFINE_CONSTANT(target, kKeyVariantRSA_SSA_PKCS1_V1_5); | ||
| 562 | + NODE_DEFINE_CONSTANT(target, kKeyVariantRSA_SSA_PKCS1_v1_5); | ||
| 563 | 563 | NODE_DEFINE_CONSTANT(target, kKeyVariantRSA_PSS); | |
| 564 | 564 | NODE_DEFINE_CONSTANT(target, kKeyVariantRSA_OAEP); | |
| 565 | 565 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ | |||
| 15 | 15 | namespace node { | |
| 16 | 16 | namespace crypto { | |
| 17 | 17 | enum RSAKeyVariant { | |
| 18 | - kKeyVariantRSA_SSA_PKCS1_V1_5, | ||
| 18 | + kKeyVariantRSA_SSA_PKCS1_v1_5, | ||
| 19 | 19 | kKeyVariantRSA_PSS, | |
| 20 | 20 | kKeyVariantRSA_OAEP | |
| 21 | 21 | }; | |
@@ -53,7 +53,7 @@ struct RsaKeyGenTraits final { | |||
| 53 | 53 | using RSAKeyPairGenJob = KeyGenJob<KeyPairGenTraits<RsaKeyGenTraits>>; | |
| 54 | 54 | ||
| 55 | 55 | struct RSAKeyExportConfig final : public MemoryRetainer { | |
| 56 | - RSAKeyVariant variant = kKeyVariantRSA_SSA_PKCS1_V1_5; | ||
| 56 | + RSAKeyVariant variant = kKeyVariantRSA_SSA_PKCS1_v1_5; | ||
| 57 | 57 | SET_NO_MEMORY_INFO() | |
| 58 | 58 | SET_MEMORY_INFO_NAME(RSAKeyExportConfig) | |
| 59 | 59 | SET_SELF_SIZE(RSAKeyExportConfig) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -457,7 +457,7 @@ const testVectors = [ | |||
| 457 | 457 | publicUsages: ['verify'] | |
| 458 | 458 | }, | |
| 459 | 459 | { | |
| 460 | - name: 'RSASSA-PKCS1-V1_5', | ||
| 460 | + name: 'RSASSA-PKCS1-v1_5', | ||
| 461 | 461 | privateUsages: ['sign'], | |
| 462 | 462 | publicUsages: ['verify'] | |
| 463 | 463 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,7 +65,7 @@ const vectors = { | |||
| 65 | 65 | ], | |
| 66 | 66 | mandatoryUsages: [] | |
| 67 | 67 | }, | |
| 68 | - 'RSASSA-PKCS1-V1_5': { | ||
| 68 | + 'RSASSA-PKCS1-v1_5': { | ||
| 69 | 69 | algorithm: { | |
| 70 | 70 | modulusLength: 1024, | |
| 71 | 71 | publicExponent: new Uint8Array([1, 0, 1]), | |
@@ -317,7 +317,7 @@ const vectors = { | |||
| 317 | 317 | ||
| 318 | 318 | const kTests = [ | |
| 319 | 319 | [ | |
| 320 | - 'RSASSA-PKCS1-V1_5', | ||
| 320 | + 'RSASSA-PKCS1-v1_5', | ||
| 321 | 321 | 1024, | |
| 322 | 322 | Buffer.from([1, 0, 1]), | |
| 323 | 323 | 'SHA-256', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,23 +11,23 @@ const { subtle } = require('crypto').webcrypto; | |||
| 11 | 11 | // This is only a partial test. The WebCrypto Web Platform Tests | |
| 12 | 12 | // will provide much greater coverage. | |
| 13 | 13 | ||
| 14 | - // Test Sign/Verify RSASSA-PKCS1-V1_5 | ||
| 14 | + // Test Sign/Verify RSASSA-PKCS1-v1_5 | ||
| 15 | 15 | { | |
| 16 | 16 | async function test(data) { | |
| 17 | 17 | const ec = new TextEncoder(); | |
| 18 | 18 | const { publicKey, privateKey } = await subtle.generateKey({ | |
| 19 | - name: 'RSASSA-PKCS1-V1_5', | ||
| 19 | + name: 'RSASSA-PKCS1-v1_5', | ||
| 20 | 20 | modulusLength: 1024, | |
| 21 | 21 | publicExponent: new Uint8Array([1, 0, 1]), | |
| 22 | 22 | hash: 'SHA-256' | |
| 23 | 23 | }, true, ['sign', 'verify']); | |
| 24 | 24 | ||
| 25 | 25 | const signature = await subtle.sign({ | |
| 26 | - name: 'RSASSA-PKCS1-V1_5' | ||
| 26 | + name: 'RSASSA-PKCS1-v1_5' | ||
| 27 | 27 | }, privateKey, ec.encode(data)); | |
| 28 | 28 | ||
| 29 | 29 | assert(await subtle.verify({ | |
| 30 | - name: 'RSASSA-PKCS1-V1_5' | ||
| 30 | + name: 'RSASSA-PKCS1-v1_5' | ||
| 31 | 31 | }, publicKey, signature, ec.encode(data))); | |
| 32 | 32 | } | |
| 33 | 33 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,7 +64,7 @@ async function generateKeysToWrap() { | |||
| 64 | 64 | const parameters = [ | |
| 65 | 65 | { | |
| 66 | 66 | algorithm: { | |
| 67 | - name: 'RSASSA-PKCS1-V1_5', | ||
| 67 | + name: 'RSASSA-PKCS1-v1_5', | ||
| 68 | 68 | modulusLength: 1024, | |
| 69 | 69 | publicExponent: new Uint8Array([1, 0, 1]), | |
| 70 | 70 | hash: 'SHA-256' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments