| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -629,11 +629,13 @@ function getBlockSize(name) { | |||
| 629 | 629 | case 'SHA-512': | |
| 630 | 630 | return 1024; | |
| 631 | 631 | case 'SHA3-256': | |
| 632 | - return 1088; | ||
| 632 | + // Fall through | ||
| 633 | 633 | case 'SHA3-384': | |
| 634 | - return 832; | ||
| 634 | + // Fall through | ||
| 635 | 635 | case 'SHA3-512': | |
| 636 | - return 576; | ||
| 636 | + // This interaction is not defined for now. | ||
| 637 | + // https://github.com/WICG/webcrypto-modern-algos/issues/23 | ||
| 638 | + throw lazyDOMException('Explicit algorithm length member is required', 'NotSupportedError'); | ||
| 637 | 639 | } | |
| 638 | 640 | } | |
| 639 | 641 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ const { | |||
| 9 | 9 | ReflectConstruct, | |
| 10 | 10 | StringPrototypeRepeat, | |
| 11 | 11 | StringPrototypeSlice, | |
| 12 | + StringPrototypeStartsWith, | ||
| 12 | 13 | SymbolToStringTag, | |
| 13 | 14 | } = primordials; | |
| 14 | 15 | ||
@@ -1235,7 +1236,6 @@ function check(op, alg, length) { | |||
| 1235 | 1236 | case 'sign': | |
| 1236 | 1237 | case 'verify': | |
| 1237 | 1238 | case 'digest': | |
| 1238 | - case 'generateKey': | ||
| 1239 | 1239 | case 'importKey': | |
| 1240 | 1240 | case 'exportKey': | |
| 1241 | 1241 | case 'wrapKey': | |
@@ -1260,6 +1260,17 @@ function check(op, alg, length) { | |||
| 1260 | 1260 | ||
| 1261 | 1261 | return true; | |
| 1262 | 1262 | } | |
| 1263 | + case 'generateKey': { | ||
| 1264 | + if ( | ||
| 1265 | + normalizedAlgorithm.name === 'HMAC' && | ||
| 1266 | + normalizedAlgorithm.length === undefined && | ||
| 1267 | + StringPrototypeStartsWith(normalizedAlgorithm.hash.name, 'SHA3-') | ||
| 1268 | + ) { | ||
| 1269 | + return false; | ||
| 1270 | + } | ||
| 1271 | + | ||
| 1272 | + return true; | ||
| 1273 | + } | ||
| 1263 | 1274 | default: { | |
| 1264 | 1275 | const assert = require('internal/assert'); | |
| 1265 | 1276 | assert.fail('Unreachable code'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,24 +19,26 @@ export const vectors = { | |||
| 19 | 19 | [!boringSSL, 'SHA3-512'], | |
| 20 | 20 | ], | |
| 21 | 21 | 'generateKey': [ | |
| 22 | - [!boringSSL, { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 23 | 22 | [!boringSSL, { name: 'HMAC', hash: 'SHA3-256', length: 256 }], | |
| 24 | 23 | [false, { name: 'HMAC', hash: 'SHA3-256', length: 25 }], | |
| 25 | 24 | [!boringSSL, { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA3-256', ...RSA_KEY_GEN }], | |
| 26 | 25 | [!boringSSL, { name: 'RSA-PSS', hash: 'SHA3-256', ...RSA_KEY_GEN }], | |
| 27 | 26 | [!boringSSL, { name: 'RSA-OAEP', hash: 'SHA3-256', ...RSA_KEY_GEN }], | |
| 28 | - [!boringSSL, { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 29 | 27 | [!boringSSL, { name: 'HMAC', hash: 'SHA3-256', length: 256 }], | |
| 30 | 28 | [false, { name: 'HMAC', hash: 'SHA3-256', length: 25 }], | |
| 31 | 29 | [false, { name: 'HMAC', hash: 'SHA3-256', length: 0 }], | |
| 30 | + | ||
| 31 | + // This interaction is not defined for now. | ||
| 32 | + // https://github.com/WICG/webcrypto-modern-algos/issues/23 | ||
| 33 | + [false, { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 32 | 34 | ], | |
| 33 | 35 | 'deriveKey': [ | |
| 34 | 36 | [!boringSSL, | |
| 35 | 37 | { name: 'HKDF', hash: 'SHA3-256', salt: Buffer.alloc(0), info: Buffer.alloc(0) }, | |
| 36 | 38 | { name: 'AES-CBC', length: 128 }], | |
| 37 | 39 | [!boringSSL, | |
| 38 | 40 | { name: 'HKDF', hash: 'SHA3-256', salt: Buffer.alloc(0), info: Buffer.alloc(0) }, | |
| 39 | - { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 41 | + { name: 'HMAC', hash: 'SHA3-256', length: 256 }], | ||
| 40 | 42 | [false, | |
| 41 | 43 | { name: 'HKDF', hash: 'SHA3-256', salt: Buffer.alloc(0), info: Buffer.alloc(0) }, | |
| 42 | 44 | 'HKDF'], | |
@@ -45,14 +47,29 @@ export const vectors = { | |||
| 45 | 47 | { name: 'AES-CBC', length: 128 }], | |
| 46 | 48 | [!boringSSL, | |
| 47 | 49 | { name: 'PBKDF2', hash: 'SHA3-256', salt: Buffer.alloc(0), iterations: 1 }, | |
| 48 | - { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 50 | + { name: 'HMAC', hash: 'SHA3-256', length: 256 }], | ||
| 49 | 51 | [false, | |
| 50 | 52 | { name: 'PBKDF2', hash: 'SHA3-256', salt: Buffer.alloc(0), iterations: 1 }, | |
| 51 | 53 | 'HKDF'], | |
| 52 | 54 | [!boringSSL, | |
| 53 | 55 | { name: 'X25519', public: X25519.publicKey }, | |
| 54 | - { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 56 | + { name: 'HMAC', hash: 'SHA3-256', length: 256 }], | ||
| 55 | 57 | [!boringSSL, | |
| 58 | + { name: 'ECDH', public: ECDH.publicKey }, | ||
| 59 | + { name: 'HMAC', hash: 'SHA3-256', length: 256 }], | ||
| 60 | + | ||
| 61 | + // This interaction is not defined for now. | ||
| 62 | + // https://github.com/WICG/webcrypto-modern-algos/issues/23 | ||
| 63 | + [false, | ||
| 64 | + { name: 'HKDF', hash: 'SHA3-256', salt: Buffer.alloc(0), info: Buffer.alloc(0) }, | ||
| 65 | + { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 66 | + [false, | ||
| 67 | + { name: 'PBKDF2', hash: 'SHA3-256', salt: Buffer.alloc(0), iterations: 1 }, | ||
| 68 | + { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 69 | + [false, | ||
| 70 | + { name: 'X25519', public: X25519.publicKey }, | ||
| 71 | + { name: 'HMAC', hash: 'SHA3-256' }], | ||
| 72 | + [false, | ||
| 56 | 73 | { name: 'ECDH', public: ECDH.publicKey }, | |
| 57 | 74 | { name: 'HMAC', hash: 'SHA3-256' }], | |
| 58 | 75 | ], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,9 +157,14 @@ const { KeyObject } = require('crypto'); | |||
| 157 | 157 | // Not long enough secret generated by ECDH | |
| 158 | 158 | [{ name: 'HMAC', hash: 'SHA-384' }, 'sign', 1024], | |
| 159 | 159 | [{ name: 'HMAC', hash: 'SHA-512' }, 'sign', 1024], | |
| 160 | - [{ name: 'HMAC', hash: 'SHA3-256' }, 'sign', 1088], | ||
| 161 | - [{ name: 'HMAC', hash: 'SHA3-384' }, 'sign', 832], | ||
| 162 | - [{ name: 'HMAC', hash: 'SHA3-512' }, 'sign', 576], | ||
| 160 | + [{ name: 'HMAC', hash: 'SHA3-256', length: 256 }, 'sign', 256], | ||
| 161 | + [{ name: 'HMAC', hash: 'SHA3-384', length: 384 }, 'sign', 384], | ||
| 162 | + [{ name: 'HMAC', hash: 'SHA3-512', length: 512 }, 'sign', 512], | ||
| 163 | + // This interaction is not defined for now. | ||
| 164 | + // https://github.com/WICG/webcrypto-modern-algos/issues/23 | ||
| 165 | + // [{ name: 'HMAC', hash: 'SHA3-256' }, 'sign', 256], | ||
| 166 | + // [{ name: 'HMAC', hash: 'SHA3-384' }, 'sign', 384], | ||
| 167 | + // [{ name: 'HMAC', hash: 'SHA3-512' }, 'sign', 512], | ||
| 163 | 168 | ]; | |
| 164 | 169 | ||
| 165 | 170 | (async () => { | |
@@ -196,9 +201,14 @@ const { KeyObject } = require('crypto'); | |||
| 196 | 201 | [{ name: 'HMAC', hash: 'SHA-256' }, 'sign', 512], | |
| 197 | 202 | [{ name: 'HMAC', hash: 'SHA-384' }, 'sign', 1024], | |
| 198 | 203 | [{ name: 'HMAC', hash: 'SHA-512' }, 'sign', 1024], | |
| 199 | - [{ name: 'HMAC', hash: 'SHA3-256' }, 'sign', 1088], | ||
| 200 | - [{ name: 'HMAC', hash: 'SHA3-384' }, 'sign', 832], | ||
| 201 | - [{ name: 'HMAC', hash: 'SHA3-512' }, 'sign', 576], | ||
| 204 | + [{ name: 'HMAC', hash: 'SHA3-256', length: 256 }, 'sign', 256], | ||
| 205 | + [{ name: 'HMAC', hash: 'SHA3-384', length: 384 }, 'sign', 384], | ||
| 206 | + [{ name: 'HMAC', hash: 'SHA3-512', length: 512 }, 'sign', 512], | ||
| 207 | + // This interaction is not defined for now. | ||
| 208 | + // https://github.com/WICG/webcrypto-modern-algos/issues/23 | ||
| 209 | + // [{ name: 'HMAC', hash: 'SHA3-256' }, 'sign', 256], | ||
| 210 | + // [{ name: 'HMAC', hash: 'SHA3-384' }, 'sign', 384], | ||
| 211 | + // [{ name: 'HMAC', hash: 'SHA3-512' }, 'sign', 512], | ||
| 202 | 212 | ]; | |
| 203 | 213 | ||
| 204 | 214 | (async () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -614,9 +614,6 @@ if (hasOpenSSL(3, 5)) { | |||
| 614 | 614 | case 'SHA-256': length = 512; break; | |
| 615 | 615 | case 'SHA-384': length = 1024; break; | |
| 616 | 616 | case 'SHA-512': length = 1024; break; | |
| 617 | - case 'SHA3-256': length = 1088; break; | ||
| 618 | - case 'SHA3-384': length = 832; break; | ||
| 619 | - case 'SHA3-512': length = 576; break; | ||
| 620 | 617 | } | |
| 621 | 618 | } | |
| 622 | 619 | ||
@@ -642,20 +639,24 @@ if (hasOpenSSL(3, 5)) { | |||
| 642 | 639 | } | |
| 643 | 640 | ||
| 644 | 641 | const kTests = [ | |
| 645 | - [ undefined, 'SHA-1', ['sign', 'verify']], | ||
| 646 | - [ undefined, 'SHA-256', ['sign', 'verify']], | ||
| 647 | - [ undefined, 'SHA-384', ['sign', 'verify']], | ||
| 648 | - [ undefined, 'SHA-512', ['sign', 'verify']], | ||
| 649 | - [ 128, 'SHA-256', ['sign', 'verify']], | ||
| 650 | - [ 1024, 'SHA-512', ['sign', 'verify']], | ||
| 642 | + [undefined, 'SHA-1', ['sign', 'verify']], | ||
| 643 | + [undefined, 'SHA-256', ['sign', 'verify']], | ||
| 644 | + [undefined, 'SHA-384', ['sign', 'verify']], | ||
| 645 | + [undefined, 'SHA-512', ['sign', 'verify']], | ||
| 646 | + [128, 'SHA-256', ['sign', 'verify']], | ||
| 647 | + [1024, 'SHA-512', ['sign', 'verify']], | ||
| 651 | 648 | ]; | |
| 652 | 649 | ||
| 653 | 650 | if (!process.features.openssl_is_boringssl) { | |
| 654 | 651 | kTests.push( | |
| 655 | - | ||
| 656 | - [ undefined, 'SHA3-256', ['sign', 'verify']], | ||
| 657 | - [ undefined, 'SHA3-384', ['sign', 'verify']], | ||
| 658 | - [ undefined, 'SHA3-512', ['sign', 'verify']], | ||
| 652 | + [256, 'SHA3-256', ['sign', 'verify']], | ||
| 653 | + [384, 'SHA3-384', ['sign', 'verify']], | ||
| 654 | + [512, 'SHA3-512', ['sign', 'verify']], | ||
| 655 | + // This interaction is not defined for now. | ||
| 656 | + // https://github.com/WICG/webcrypto-modern-algos/issues/23 | ||
| 657 | + // [undefined, 'SHA3-256', ['sign', 'verify']], | ||
| 658 | + // [undefined, 'SHA3-384', ['sign', 'verify']], | ||
| 659 | + // [undefined, 'SHA3-512', ['sign', 'verify']], | ||
| 659 | 660 | ); | |
| 660 | 661 | } else { | |
| 661 | 662 | common.printSkipMessage('Skipping unsupported SHA-3 test cases'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments