| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 247d017 commit 76cde76
22 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | 3 | <!-- YAML | |
| 4 | 4 | changes: | |
| 5 | + - version: REPLACEME | ||
| 6 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 7 | + description: SHA-3 algorithms are now supported. | ||
| 5 | 8 | - version: REPLACEME | |
| 6 | 9 | pr-url: https://github.com/nodejs/node/pull/59365 | |
| 7 | 10 | description: SHAKE algorithms are now supported. | |
@@ -99,6 +102,9 @@ Algorithms: | |||
| 99 | 102 | * `'ML-DSA-44'`[^openssl35] | |
| 100 | 103 | * `'ML-DSA-65'`[^openssl35] | |
| 101 | 104 | * `'ML-DSA-87'`[^openssl35] | |
| 105 | + * `'SHA3-256'` | ||
| 106 | + * `'SHA3-384'` | ||
| 107 | + * `'SHA3-512'` | ||
| 102 | 108 | ||
| 103 | 109 | Key Formats: | |
| 104 | 110 | ||
@@ -496,6 +502,9 @@ implementation and the APIs supported for each: | |||
| 496 | 502 | | `'SHA-256'` | | | | | | | | | | | | ✔ | | |
| 497 | 503 | | `'SHA-384'` | | | | | | | | | | | | ✔ | | |
| 498 | 504 | | `'SHA-512'` | | | | | | | | | | | | ✔ | | |
| 505 | + | `'SHA3-256'`[^modern-algos] | | | | | | | | | | | | ✔ | | ||
| 506 | + | `'SHA3-384'`[^modern-algos] | | | | | | | | | | | | ✔ | | ||
| 507 | + | `'SHA3-512'`[^modern-algos] | | | | | | | | | | | | ✔ | | ||
| 499 | 508 | | `'X25519'` | ✔ | ✔ | ✔ | | | | | ✔ | ✔ | | | | | |
| 500 | 509 | | `'X448'`[^secure-curves] | ✔ | ✔ | ✔ | | | | | ✔ | ✔ | | | | | |
| 501 | 510 | ||
@@ -808,6 +817,9 @@ The algorithms currently supported include: | |||
| 808 | 817 | <!-- YAML | |
| 809 | 818 | added: v15.0.0 | |
| 810 | 819 | changes: | |
| 820 | + - version: REPLACEME | ||
| 821 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 822 | + description: SHA-3 algorithms are now supported. | ||
| 811 | 823 | - version: REPLACEME | |
| 812 | 824 | pr-url: https://github.com/nodejs/node/pull/59365 | |
| 813 | 825 | description: SHAKE algorithms are now supported. | |
@@ -829,6 +841,9 @@ If `algorithm` is provided as a {string}, it must be one of: | |||
| 829 | 841 | * `'SHA-256'` | |
| 830 | 842 | * `'SHA-384'` | |
| 831 | 843 | * `'SHA-512'` | |
| 844 | + * `'SHA3-256'`[^modern-algos] | ||
| 845 | + * `'SHA3-384'`[^modern-algos] | ||
| 846 | + * `'SHA3-512'`[^modern-algos] | ||
| 832 | 847 | ||
| 833 | 848 | If `algorithm` is provided as an {Object}, it must have a `name` property | |
| 834 | 849 | whose value is one of the above. | |
@@ -1520,6 +1535,10 @@ added: v15.0.0 | |||
| 1520 | 1535 | ||
| 1521 | 1536 | <!-- YAML | |
| 1522 | 1537 | added: v15.0.0 | |
| 1538 | + changes: | ||
| 1539 | + - version: REPLACEME | ||
| 1540 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 1541 | + description: SHA-3 algorithms are now supported. | ||
| 1523 | 1542 | --> | |
| 1524 | 1543 | ||
| 1525 | 1544 | * Type: {string|Algorithm} | |
@@ -1530,6 +1549,9 @@ If represented as a {string}, the value must be one of: | |||
| 1530 | 1549 | * `'SHA-256'` | |
| 1531 | 1550 | * `'SHA-384'` | |
| 1532 | 1551 | * `'SHA-512'` | |
| 1552 | + * `'SHA3-256'`[^modern-algos] | ||
| 1553 | + * `'SHA3-384'`[^modern-algos] | ||
| 1554 | + * `'SHA3-512'`[^modern-algos] | ||
| 1533 | 1555 | ||
| 1534 | 1556 | If represented as an {Algorithm}, the object's `name` property | |
| 1535 | 1557 | must be one of the above listed values. | |
@@ -1649,6 +1671,10 @@ added: v15.0.0 | |||
| 1649 | 1671 | ||
| 1650 | 1672 | <!-- YAML | |
| 1651 | 1673 | added: v15.0.0 | |
| 1674 | + changes: | ||
| 1675 | + - version: REPLACEME | ||
| 1676 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 1677 | + description: SHA-3 algorithms are now supported. | ||
| 1652 | 1678 | --> | |
| 1653 | 1679 | ||
| 1654 | 1680 | * Type: {string|Algorithm} | |
@@ -1659,6 +1685,9 @@ If represented as a {string}, the value must be one of: | |||
| 1659 | 1685 | * `'SHA-256'` | |
| 1660 | 1686 | * `'SHA-384'` | |
| 1661 | 1687 | * `'SHA-512'` | |
| 1688 | + * `'SHA3-256'`[^modern-algos] | ||
| 1689 | + * `'SHA3-384'`[^modern-algos] | ||
| 1690 | + * `'SHA3-512'`[^modern-algos] | ||
| 1662 | 1691 | ||
| 1663 | 1692 | If represented as an {Algorithm}, the object's `name` property | |
| 1664 | 1693 | must be one of the above listed values. | |
@@ -1705,6 +1734,10 @@ added: v15.0.0 | |||
| 1705 | 1734 | ||
| 1706 | 1735 | <!-- YAML | |
| 1707 | 1736 | added: v15.0.0 | |
| 1737 | + changes: | ||
| 1738 | + - version: REPLACEME | ||
| 1739 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 1740 | + description: SHA-3 algorithms are now supported. | ||
| 1708 | 1741 | --> | |
| 1709 | 1742 | ||
| 1710 | 1743 | * Type: {string|Algorithm} | |
@@ -1715,6 +1748,9 @@ If represented as a {string}, the value must be one of: | |||
| 1715 | 1748 | * `'SHA-256'` | |
| 1716 | 1749 | * `'SHA-384'` | |
| 1717 | 1750 | * `'SHA-512'` | |
| 1751 | + * `'SHA3-256'`[^modern-algos] | ||
| 1752 | + * `'SHA3-384'`[^modern-algos] | ||
| 1753 | + * `'SHA3-512'`[^modern-algos] | ||
| 1718 | 1754 | ||
| 1719 | 1755 | If represented as an {Algorithm}, the object's `name` property | |
| 1720 | 1756 | must be one of the above listed values. | |
@@ -1780,6 +1816,10 @@ added: v15.0.0 | |||
| 1780 | 1816 | ||
| 1781 | 1817 | <!-- YAML | |
| 1782 | 1818 | added: v15.0.0 | |
| 1819 | + changes: | ||
| 1820 | + - version: REPLACEME | ||
| 1821 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 1822 | + description: SHA-3 algorithms are now supported. | ||
| 1783 | 1823 | --> | |
| 1784 | 1824 | ||
| 1785 | 1825 | * Type: {string|Algorithm} | |
@@ -1790,6 +1830,9 @@ If represented as a {string}, the value must be one of: | |||
| 1790 | 1830 | * `'SHA-256'` | |
| 1791 | 1831 | * `'SHA-384'` | |
| 1792 | 1832 | * `'SHA-512'` | |
| 1833 | + * `'SHA3-256'`[^modern-algos] | ||
| 1834 | + * `'SHA3-384'`[^modern-algos] | ||
| 1835 | + * `'SHA3-512'`[^modern-algos] | ||
| 1793 | 1836 | ||
| 1794 | 1837 | If represented as an {Algorithm}, the object's `name` property | |
| 1795 | 1838 | must be one of the above listed values. | |
@@ -1838,6 +1881,10 @@ added: v15.0.0 | |||
| 1838 | 1881 | ||
| 1839 | 1882 | <!-- YAML | |
| 1840 | 1883 | added: v15.0.0 | |
| 1884 | + changes: | ||
| 1885 | + - version: REPLACEME | ||
| 1886 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 1887 | + description: SHA-3 algorithms are now supported. | ||
| 1841 | 1888 | --> | |
| 1842 | 1889 | ||
| 1843 | 1890 | * Type: {string|Algorithm} | |
@@ -1848,6 +1895,9 @@ If represented as a {string}, the value must be one of: | |||
| 1848 | 1895 | * `'SHA-256'` | |
| 1849 | 1896 | * `'SHA-384'` | |
| 1850 | 1897 | * `'SHA-512'` | |
| 1898 | + * `'SHA3-256'`[^modern-algos] | ||
| 1899 | + * `'SHA3-384'`[^modern-algos] | ||
| 1900 | + * `'SHA3-512'`[^modern-algos] | ||
| 1851 | 1901 | ||
| 1852 | 1902 | If represented as an {Algorithm}, the object's `name` property | |
| 1853 | 1903 | must be one of the above listed values. | |
@@ -1890,6 +1940,10 @@ added: v15.0.0 | |||
| 1890 | 1940 | ||
| 1891 | 1941 | <!-- YAML | |
| 1892 | 1942 | added: v15.0.0 | |
| 1943 | + changes: | ||
| 1944 | + - version: REPLACEME | ||
| 1945 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 1946 | + description: SHA-3 algorithms are now supported. | ||
| 1893 | 1947 | --> | |
| 1894 | 1948 | ||
| 1895 | 1949 | * Type: {string|Algorithm} | |
@@ -1900,6 +1954,9 @@ If represented as a {string}, the value must be one of: | |||
| 1900 | 1954 | * `'SHA-256'` | |
| 1901 | 1955 | * `'SHA-384'` | |
| 1902 | 1956 | * `'SHA-512'` | |
| 1957 | + * `'SHA3-256'`[^modern-algos] | ||
| 1958 | + * `'SHA3-384'`[^modern-algos] | ||
| 1959 | + * `'SHA3-512'`[^modern-algos] | ||
| 1903 | 1960 | ||
| 1904 | 1961 | If represented as an {Algorithm}, the object's `name` property | |
| 1905 | 1962 | must be one of the above listed values. | |
@@ -1965,6 +2022,10 @@ added: v15.0.0 | |||
| 1965 | 2022 | ||
| 1966 | 2023 | <!-- YAML | |
| 1967 | 2024 | added: v15.0.0 | |
| 2025 | + changes: | ||
| 2026 | + - version: REPLACEME | ||
| 2027 | + pr-url: https://github.com/nodejs/node/pull/59365 | ||
| 2028 | + description: SHA-3 algorithms are now supported. | ||
| 1968 | 2029 | --> | |
| 1969 | 2030 | ||
| 1970 | 2031 | * Type: {string|Algorithm} | |
@@ -1975,6 +2036,9 @@ If represented as a {string}, the value must be one of: | |||
| 1975 | 2036 | * `'SHA-256'` | |
| 1976 | 2037 | * `'SHA-384'` | |
| 1977 | 2038 | * `'SHA-512'` | |
| 2039 | + * `'SHA3-256'`[^modern-algos] | ||
| 2040 | + * `'SHA3-384'`[^modern-algos] | ||
| 2041 | + * `'SHA3-512'`[^modern-algos] | ||
| 1978 | 2042 | ||
| 1979 | 2043 | If represented as an {Algorithm}, the object's `name` property | |
| 1980 | 2044 | must be one of the above listed values. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,6 +212,12 @@ async function asyncDigest(algorithm, data) { | |||
| 212 | 212 | // Fall through | |
| 213 | 213 | case 'SHA-512': | |
| 214 | 214 | // Fall through | |
| 215 | + case 'SHA3-256': | ||
| 216 | + // Fall through | ||
| 217 | + case 'SHA3-384': | ||
| 218 | + // Fall through | ||
| 219 | + case 'SHA3-512': | ||
| 220 | + // Fall through | ||
| 215 | 221 | case 'cSHAKE128': | |
| 216 | 222 | // Fall through | |
| 217 | 223 | case 'cSHAKE256': | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,46 +17,58 @@ const kHashContextJwkHmac = 6; | |||
| 17 | 17 | // make it easier in the code. | |
| 18 | 18 | ||
| 19 | 19 | const kHashNames = { | |
| 20 | - sha1: { | ||
| 20 | + 'sha1': { | ||
| 21 | 21 | [kHashContextNode]: 'sha1', | |
| 22 | 22 | [kHashContextWebCrypto]: 'SHA-1', | |
| 23 | 23 | [kHashContextJwkRsa]: 'RS1', | |
| 24 | 24 | [kHashContextJwkRsaPss]: 'PS1', | |
| 25 | 25 | [kHashContextJwkRsaOaep]: 'RSA-OAEP', | |
| 26 | 26 | [kHashContextJwkHmac]: 'HS1', | |
| 27 | 27 | }, | |
| 28 | - sha256: { | ||
| 28 | + 'sha256': { | ||
| 29 | 29 | [kHashContextNode]: 'sha256', | |
| 30 | 30 | [kHashContextWebCrypto]: 'SHA-256', | |
| 31 | 31 | [kHashContextJwkRsa]: 'RS256', | |
| 32 | 32 | [kHashContextJwkRsaPss]: 'PS256', | |
| 33 | 33 | [kHashContextJwkRsaOaep]: 'RSA-OAEP-256', | |
| 34 | 34 | [kHashContextJwkHmac]: 'HS256', | |
| 35 | 35 | }, | |
| 36 | - sha384: { | ||
| 36 | + 'sha384': { | ||
| 37 | 37 | [kHashContextNode]: 'sha384', | |
| 38 | 38 | [kHashContextWebCrypto]: 'SHA-384', | |
| 39 | 39 | [kHashContextJwkRsa]: 'RS384', | |
| 40 | 40 | [kHashContextJwkRsaPss]: 'PS384', | |
| 41 | 41 | [kHashContextJwkRsaOaep]: 'RSA-OAEP-384', | |
| 42 | 42 | [kHashContextJwkHmac]: 'HS384', | |
| 43 | 43 | }, | |
| 44 | - sha512: { | ||
| 44 | + 'sha512': { | ||
| 45 | 45 | [kHashContextNode]: 'sha512', | |
| 46 | 46 | [kHashContextWebCrypto]: 'SHA-512', | |
| 47 | 47 | [kHashContextJwkRsa]: 'RS512', | |
| 48 | 48 | [kHashContextJwkRsaPss]: 'PS512', | |
| 49 | 49 | [kHashContextJwkRsaOaep]: 'RSA-OAEP-512', | |
| 50 | 50 | [kHashContextJwkHmac]: 'HS512', | |
| 51 | 51 | }, | |
| 52 | - shake128: { | ||
| 52 | + 'shake128': { | ||
| 53 | 53 | [kHashContextNode]: 'shake128', | |
| 54 | 54 | [kHashContextWebCrypto]: 'cSHAKE128', | |
| 55 | 55 | }, | |
| 56 | - shake256: { | ||
| 56 | + 'shake256': { | ||
| 57 | 57 | [kHashContextNode]: 'shake256', | |
| 58 | 58 | [kHashContextWebCrypto]: 'cSHAKE256', | |
| 59 | 59 | }, | |
| 60 | + 'sha3-256': { | ||
| 61 | + [kHashContextNode]: 'sha3-256', | ||
| 62 | + [kHashContextWebCrypto]: 'SHA3-256', | ||
| 63 | + }, | ||
| 64 | + 'sha3-384': { | ||
| 65 | + [kHashContextNode]: 'sha3-384', | ||
| 66 | + [kHashContextWebCrypto]: 'SHA3-384', | ||
| 67 | + }, | ||
| 68 | + 'sha3-512': { | ||
| 69 | + [kHashContextNode]: 'sha3-512', | ||
| 70 | + [kHashContextWebCrypto]: 'SHA3-512', | ||
| 71 | + }, | ||
| 60 | 72 | }; | |
| 61 | 73 | ||
| 62 | 74 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,18 +67,6 @@ async function hmacGenerateKey(algorithm, extractable, keyUsages) { | |||
| 67 | 67 | extractable); | |
| 68 | 68 | } | |
| 69 | 69 | ||
| 70 | - function getAlgorithmName(hash) { | ||
| 71 | - switch (hash) { | ||
| 72 | - case 'SHA-1': // Fall through | ||
| 73 | - case 'SHA-256': // Fall through | ||
| 74 | - case 'SHA-384': // Fall through | ||
| 75 | - case 'SHA-512': // Fall through | ||
| 76 | - return `HS${hash.slice(4)}`; | ||
| 77 | - default: | ||
| 78 | - throw lazyDOMException('Unsupported digest algorithm', 'DataError'); | ||
| 79 | - } | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | 70 | function hmacImportKey( | |
| 83 | 71 | format, | |
| 84 | 72 | keyData, | |
@@ -126,7 +114,9 @@ function hmacImportKey( | |||
| 126 | 114 | } | |
| 127 | 115 | ||
| 128 | 116 | if (keyData.alg !== undefined) { | |
| 129 | - if (keyData.alg !== getAlgorithmName(algorithm.hash.name)) | ||
| 117 | + const expected = | ||
| 118 | + normalizeHashName(algorithm.hash.name, normalizeHashName.kContextJwkHmac); | ||
| 119 | + if (expected && keyData.alg !== expected) | ||
| 130 | 120 | throw lazyDOMException( | |
| 131 | 121 | 'JWK "alg" does not match the requested algorithm', | |
| 132 | 122 | 'DataError'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -281,7 +281,7 @@ function rsaImportKey( | |||
| 281 | 281 | algorithm.name === 'RSA-PSS' ? normalizeHashName.kContextJwkRsaPss : | |
| 282 | 282 | normalizeHashName.kContextJwkRsaOaep); | |
| 283 | 283 | ||
| 284 | - if (keyData.alg !== expected) | ||
| 284 | + if (expected && keyData.alg !== expected) | ||
| 285 | 285 | throw lazyDOMException( | |
| 286 | 286 | 'JWK "alg" does not match the requested algorithm', | |
| 287 | 287 | 'DataError'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -287,6 +287,9 @@ const experimentalAlgorithms = ObjectEntries({ | |||
| 287 | 287 | }, | |
| 288 | 288 | 'cSHAKE128': { digest: 'CShakeParams' }, | |
| 289 | 289 | 'cSHAKE256': { digest: 'CShakeParams' }, | |
| 290 | + 'SHA3-256': { digest: null }, | ||
| 291 | + 'SHA3-384': { digest: null }, | ||
| 292 | + 'SHA3-512': { digest: null }, | ||
| 290 | 293 | }); | |
| 291 | 294 | ||
| 292 | 295 | for (const { 0: algorithm, 1: nid } of [ | |
@@ -552,15 +555,28 @@ function getBlockSize(name) { | |||
| 552 | 555 | // Fall through | |
| 553 | 556 | case 'SHA-512': | |
| 554 | 557 | return 1024; | |
| 558 | + case 'SHA3-256': | ||
| 559 | + return 1088; | ||
| 560 | + case 'SHA3-384': | ||
| 561 | + return 832; | ||
| 562 | + case 'SHA3-512': | ||
| 563 | + return 576; | ||
| 555 | 564 | } | |
| 556 | 565 | } | |
| 557 | 566 | ||
| 558 | 567 | function getDigestSizeInBytes(name) { | |
| 559 | 568 | switch (name) { | |
| 560 | - case 'SHA-1': return 20; | ||
| 561 | - case 'SHA-256': return 32; | ||
| 562 | - case 'SHA-384': return 48; | ||
| 563 | - case 'SHA-512': return 64; | ||
| 569 | + case 'SHA-1': | ||
| 570 | + return 20; | ||
| 571 | + case 'SHA-256': // Fall through | ||
| 572 | + case 'SHA3-256': | ||
| 573 | + return 32; | ||
| 574 | + case 'SHA-384': // Fall through | ||
| 575 | + case 'SHA3-384': | ||
| 576 | + return 48; | ||
| 577 | + case 'SHA-512': // Fall through | ||
| 578 | + case 'SHA3-512': | ||
| 579 | + return 64; | ||
| 564 | 580 | } | |
| 565 | 581 | } | |
| 566 | 582 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments