| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9b272ae commit 53c0f2f
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | - ArrayFrom, | ||
| 5 | 4 | ArrayPrototypeSlice, | |
| 6 | 5 | ObjectDefineProperties, | |
| 7 | 6 | ObjectDefineProperty, | |
@@ -781,7 +780,7 @@ class CryptoKey { | |||
| 781 | 780 | get usages() { | |
| 782 | 781 | if (!(this instanceof CryptoKey)) | |
| 783 | 782 | throw new ERR_INVALID_THIS('CryptoKey'); | |
| 784 | - return ArrayFrom(this[kKeyUsages]); | ||
| 783 | + return this[kKeyUsages]; | ||
| 785 | 784 | } | |
| 786 | 785 | } | |
| 787 | 786 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -115,6 +115,8 @@ async function testImportSpki({ name, publicUsages }, extractable) { | |||
| 115 | 115 | assert.strictEqual(key.extractable, extractable); | |
| 116 | 116 | assert.deepStrictEqual(key.usages, publicUsages); | |
| 117 | 117 | assert.deepStrictEqual(key.algorithm.name, name); | |
| 118 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 119 | + assert.strictEqual(key.usages, key.usages); | ||
| 118 | 120 | ||
| 119 | 121 | if (extractable) { | |
| 120 | 122 | // Test the roundtrip | |
@@ -151,6 +153,8 @@ async function testImportPkcs8({ name, privateUsages }, extractable) { | |||
| 151 | 153 | assert.strictEqual(key.extractable, extractable); | |
| 152 | 154 | assert.deepStrictEqual(key.usages, privateUsages); | |
| 153 | 155 | assert.deepStrictEqual(key.algorithm.name, name); | |
| 156 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 157 | + assert.strictEqual(key.usages, key.usages); | ||
| 154 | 158 | ||
| 155 | 159 | if (extractable) { | |
| 156 | 160 | // Test the roundtrip | |
@@ -227,6 +231,10 @@ async function testImportJwk({ name, publicUsages, privateUsages }, extractable) | |||
| 227 | 231 | assert.deepStrictEqual(privateKey.usages, privateUsages); | |
| 228 | 232 | assert.strictEqual(publicKey.algorithm.name, name); | |
| 229 | 233 | assert.strictEqual(privateKey.algorithm.name, name); | |
| 234 | + assert.strictEqual(privateKey.algorithm, privateKey.algorithm); | ||
| 235 | + assert.strictEqual(privateKey.usages, privateKey.usages); | ||
| 236 | + assert.strictEqual(publicKey.algorithm, publicKey.algorithm); | ||
| 237 | + assert.strictEqual(publicKey.usages, publicKey.usages); | ||
| 230 | 238 | ||
| 231 | 239 | if (extractable) { | |
| 232 | 240 | // Test the round trip | |
@@ -345,6 +353,8 @@ async function testImportRaw({ name, publicUsages }) { | |||
| 345 | 353 | assert.strictEqual(publicKey.type, 'public'); | |
| 346 | 354 | assert.deepStrictEqual(publicKey.usages, publicUsages); | |
| 347 | 355 | assert.strictEqual(publicKey.algorithm.name, name); | |
| 356 | + assert.strictEqual(publicKey.algorithm, publicKey.algorithm); | ||
| 357 | + assert.strictEqual(publicKey.usages, publicKey.usages); | ||
| 348 | 358 | } | |
| 349 | 359 | ||
| 350 | 360 | (async function() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,6 +111,8 @@ async function testImportSpki({ name, publicUsages }, namedCurve, extractable) { | |||
| 111 | 111 | assert.deepStrictEqual(key.usages, publicUsages); | |
| 112 | 112 | assert.deepStrictEqual(key.algorithm.name, name); | |
| 113 | 113 | assert.deepStrictEqual(key.algorithm.namedCurve, namedCurve); | |
| 114 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 115 | + assert.strictEqual(key.usages, key.usages); | ||
| 114 | 116 | ||
| 115 | 117 | if (extractable) { | |
| 116 | 118 | // Test the roundtrip | |
@@ -151,6 +153,8 @@ async function testImportPkcs8( | |||
| 151 | 153 | assert.deepStrictEqual(key.usages, privateUsages); | |
| 152 | 154 | assert.deepStrictEqual(key.algorithm.name, name); | |
| 153 | 155 | assert.deepStrictEqual(key.algorithm.namedCurve, namedCurve); | |
| 156 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 157 | + assert.strictEqual(key.usages, key.usages); | ||
| 154 | 158 | ||
| 155 | 159 | if (extractable) { | |
| 156 | 160 | // Test the roundtrip | |
@@ -234,6 +238,10 @@ async function testImportJwk( | |||
| 234 | 238 | assert.strictEqual(privateKey.algorithm.name, name); | |
| 235 | 239 | assert.strictEqual(publicKey.algorithm.namedCurve, namedCurve); | |
| 236 | 240 | assert.strictEqual(privateKey.algorithm.namedCurve, namedCurve); | |
| 241 | + assert.strictEqual(privateKey.algorithm, privateKey.algorithm); | ||
| 242 | + assert.strictEqual(privateKey.usages, privateKey.usages); | ||
| 243 | + assert.strictEqual(publicKey.algorithm, publicKey.algorithm); | ||
| 244 | + assert.strictEqual(publicKey.usages, publicKey.usages); | ||
| 237 | 245 | ||
| 238 | 246 | if (extractable) { | |
| 239 | 247 | // Test the round trip | |
@@ -368,6 +376,8 @@ async function testImportRaw({ name, publicUsages }, namedCurve) { | |||
| 368 | 376 | assert.deepStrictEqual(publicKey.usages, publicUsages); | |
| 369 | 377 | assert.strictEqual(publicKey.algorithm.name, name); | |
| 370 | 378 | assert.strictEqual(publicKey.algorithm.namedCurve, namedCurve); | |
| 379 | + assert.strictEqual(publicKey.algorithm, publicKey.algorithm); | ||
| 380 | + assert.strictEqual(publicKey.usages, publicKey.usages); | ||
| 371 | 381 | } | |
| 372 | 382 | ||
| 373 | 383 | (async function() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -315,6 +315,8 @@ async function testImportSpki({ name, publicUsages }, size, hash, extractable) { | |||
| 315 | 315 | assert.deepStrictEqual(key.algorithm.publicExponent, | |
| 316 | 316 | new Uint8Array([1, 0, 1])); | |
| 317 | 317 | assert.strictEqual(key.algorithm.hash.name, hash); | |
| 318 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 319 | + assert.strictEqual(key.usages, key.usages); | ||
| 318 | 320 | ||
| 319 | 321 | if (extractable) { | |
| 320 | 322 | const spki = await subtle.exportKey('spki', key); | |
@@ -349,6 +351,8 @@ async function testImportPkcs8( | |||
| 349 | 351 | assert.deepStrictEqual(key.algorithm.publicExponent, | |
| 350 | 352 | new Uint8Array([1, 0, 1])); | |
| 351 | 353 | assert.strictEqual(key.algorithm.hash.name, hash); | |
| 354 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 355 | + assert.strictEqual(key.usages, key.usages); | ||
| 352 | 356 | ||
| 353 | 357 | if (extractable) { | |
| 354 | 358 | const pkcs8 = await subtle.exportKey('pkcs8', key); | |
@@ -415,6 +419,10 @@ async function testImportJwk( | |||
| 415 | 419 | new Uint8Array([1, 0, 1])); | |
| 416 | 420 | assert.deepStrictEqual(publicKey.algorithm.publicExponent, | |
| 417 | 421 | privateKey.algorithm.publicExponent); | |
| 422 | + assert.strictEqual(privateKey.algorithm, privateKey.algorithm); | ||
| 423 | + assert.strictEqual(privateKey.usages, privateKey.usages); | ||
| 424 | + assert.strictEqual(publicKey.algorithm, publicKey.algorithm); | ||
| 425 | + assert.strictEqual(publicKey.usages, publicKey.usages); | ||
| 418 | 426 | ||
| 419 | 427 | if (extractable) { | |
| 420 | 428 | const [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,6 +86,10 @@ const { subtle } = globalThis.crypto; | |||
| 86 | 86 | hash: 'SHA-256' | |
| 87 | 87 | }, true, ['sign', 'verify']); | |
| 88 | 88 | ||
| 89 | + | ||
| 90 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 91 | + assert.strictEqual(key.usages, key.usages); | ||
| 92 | + | ||
| 89 | 93 | const raw = await subtle.exportKey('raw', key); | |
| 90 | 94 | ||
| 91 | 95 | assert.deepStrictEqual( | |
@@ -127,6 +131,8 @@ const { subtle } = globalThis.crypto; | |||
| 127 | 131 | name: 'AES-CTR', | |
| 128 | 132 | length: 256, | |
| 129 | 133 | }, true, ['encrypt', 'decrypt']); | |
| 134 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 135 | + assert.strictEqual(key.usages, key.usages); | ||
| 130 | 136 | ||
| 131 | 137 | const raw = await subtle.exportKey('raw', key); | |
| 132 | 138 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -298,6 +298,10 @@ const vectors = { | |||
| 298 | 298 | KeyObject.from(privateKey).asymmetricKeyDetails.publicExponent, | |
| 299 | 299 | bigIntArrayToUnsignedBigInt(publicExponent)); | |
| 300 | 300 | assert.strictEqual(privateKey.algorithm.hash.name, hash); | |
| 301 | + assert.strictEqual(privateKey.algorithm, privateKey.algorithm); | ||
| 302 | + assert.strictEqual(privateKey.usages, privateKey.usages); | ||
| 303 | + assert.strictEqual(publicKey.algorithm, publicKey.algorithm); | ||
| 304 | + assert.strictEqual(publicKey.usages, publicKey.usages); | ||
| 301 | 305 | ||
| 302 | 306 | // Missing parameters | |
| 303 | 307 | await assert.rejects( | |
@@ -442,6 +446,10 @@ const vectors = { | |||
| 442 | 446 | assert.strictEqual(privateKey.algorithm.name, name); | |
| 443 | 447 | assert.strictEqual(publicKey.algorithm.namedCurve, namedCurve); | |
| 444 | 448 | assert.strictEqual(privateKey.algorithm.namedCurve, namedCurve); | |
| 449 | + assert.strictEqual(privateKey.algorithm, privateKey.algorithm); | ||
| 450 | + assert.strictEqual(privateKey.usages, privateKey.usages); | ||
| 451 | + assert.strictEqual(publicKey.algorithm, publicKey.algorithm); | ||
| 452 | + assert.strictEqual(publicKey.usages, publicKey.usages); | ||
| 445 | 453 | ||
| 446 | 454 | // Invalid parameters | |
| 447 | 455 | [1, true, {}, [], null].forEach(async (namedCurve) => { | |
@@ -508,6 +516,8 @@ const vectors = { | |||
| 508 | 516 | assert.deepStrictEqual(key.usages, usages); | |
| 509 | 517 | assert.strictEqual(key.algorithm.name, name); | |
| 510 | 518 | assert.strictEqual(key.algorithm.length, length); | |
| 519 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 520 | + assert.strictEqual(key.usages, key.usages); | ||
| 511 | 521 | ||
| 512 | 522 | // Invalid parameters | |
| 513 | 523 | [1, 100, 257, '', false, null].forEach(async (length) => { | |
@@ -568,6 +578,8 @@ const vectors = { | |||
| 568 | 578 | assert.strictEqual(key.algorithm.name, 'HMAC'); | |
| 569 | 579 | assert.strictEqual(key.algorithm.length, length); | |
| 570 | 580 | assert.strictEqual(key.algorithm.hash.name, hash); | |
| 581 | + assert.strictEqual(key.algorithm, key.algorithm); | ||
| 582 | + assert.strictEqual(key.usages, key.usages); | ||
| 571 | 583 | ||
| 572 | 584 | [1, false, null].forEach(async (hash) => { | |
| 573 | 585 | await assert.rejects( | |
@@ -632,6 +644,10 @@ assert.throws(() => new CryptoKey(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' }); | |||
| 632 | 644 | assert.deepStrictEqual(privateKey.usages, privateUsages); | |
| 633 | 645 | assert.strictEqual(publicKey.algorithm.name, name); | |
| 634 | 646 | assert.strictEqual(privateKey.algorithm.name, name); | |
| 647 | + assert.strictEqual(privateKey.algorithm, privateKey.algorithm); | ||
| 648 | + assert.strictEqual(privateKey.usages, privateKey.usages); | ||
| 649 | + assert.strictEqual(publicKey.algorithm, publicKey.algorithm); | ||
| 650 | + assert.strictEqual(publicKey.usages, publicKey.usages); | ||
| 635 | 651 | } | |
| 636 | 652 | ||
| 637 | 653 | const kTests = [ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments