@@ -65,6 +65,26 @@ async function generateEcKey(namedCurve = 'P-521') { |
65 | 65 | } |
66 | 66 | ``` |
67 | 67 |
|
| 68 | +#### ED25519/ED448/X25519/X448 Elliptic curve key pairs |
| 69 | + |
| 70 | +```js |
| 71 | +const { subtle } = require('crypto').webcrypto; |
| 72 | + |
| 73 | +async function generateEd25519Key() { |
| 74 | + return subtle.generateKey({ |
| 75 | + name: 'NODE-ED25519', |
| 76 | + namedCurve: 'NODE-ED25519', |
| 77 | + }, true, ['sign', 'verify']); |
| 78 | +} |
| 79 | + |
| 80 | +async function generateX25519Key() { |
| 81 | + return subtle.generateKey({ |
| 82 | + name: 'ECDH', |
| 83 | + namedCurve: 'NODE-X25519', |
| 84 | + }, true, ['deriveKey']); |
| 85 | +} |
| 86 | +``` |
| 87 | + |
68 | 88 | #### HMAC keys |
69 | 89 |
|
70 | 90 | ```js |
@@ -305,6 +325,8 @@ implementation and the APIs supported for each: |
305 | 325 | | `'SHA-512'` | | | | | | | | | | | | ✔ | |
306 | 326 | | `'NODE-DSA'`<sup>1</sup> | ✔ | ✔ | ✔ | | | | | | | ✔ | ✔ | | |
307 | 327 | | `'NODE-DH'`<sup>1</sup> | ✔ | ✔ | ✔ | | | | | ✔ | ✔ | | | | |
| 328 | +| `'NODE-ED25519'`<sup>1</sup> | ✔ | ✔ | ✔ | | | | | | | ✔ | ✔ | | |
| 329 | +| `'NODE-ED448'`<sup>1</sup> | ✔ | ✔ | ✔ | | | | | | | ✔ | ✔ | | |
308 | 330 |
|
309 | 331 | <sup>1</sup> Node.js-specific extension |
310 | 332 |
|
@@ -420,6 +442,8 @@ Valid key usages depend on the key algorithm (identified by |
420 | 442 | | `'NODE-DSA'` <sup>1</sup> | | | ✔ | ✔ | | | | | |
421 | 443 | | `'NODE-DH'` <sup>1</sup> | | | | | ✔ | ✔ | | | |
422 | 444 | | `'NODE-SCRYPT'` <sup>1</sup> | | | | | ✔ | ✔ | | | |
| 445 | +| `'NODE-ED25519'` <sup>1</sup> | | | ✔ | ✔ | | | | | |
| 446 | +| `'NODE-ED448'` <sup>1</sup> | | | ✔ | ✔ | | | | | |
423 | 447 |
|
424 | 448 | <sup>1</sup> Node.js-specific extension. |
425 | 449 |
|
@@ -620,6 +644,8 @@ extension that allows converting a {CryptoKey} into a Node.js {KeyObject}. |
620 | 644 | | `'NODE-DSA'` <sup>1</sup> | ✔ | ✔ | ✔ | | |
621 | 645 | | `'NODE-DH'` <sup>1</sup> | ✔ | ✔ | | | |
622 | 646 | | `'NODE-SCRYPT'` <sup>1</sup> | | | | | |
| 647 | +| `'NODE-ED25519'` <sup>1</sup> | ✔ | ✔ | ✔ | ✔ | |
| 648 | +| `'NODE-ED448'` <sup>1</sup> | ✔ | ✔ | ✔ | ✔ | |
623 | 649 |
|
624 | 650 | <sup>1</sup> Node.js-specific extension |
625 | 651 |
|
@@ -629,7 +655,7 @@ added: v15.0.0 |
629 | 655 | --> |
630 | 656 |
|
631 | 657 | <!--lint disable maximum-line-length remark-lint--> |
632 | | -* `algorithm`: {RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams|AesKeyGenParams|NodeDsaKeyGenParams|NodeDhKeyGenParams} |
| 658 | +* `algorithm`: {RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams|AesKeyGenParams|NodeDsaKeyGenParams|NodeDhKeyGenParams|NodeEdKeyGenParams} |
633 | 659 | <!--lint enable maximum-line-length remark-lint--> |
634 | 660 | * `extractable`: {boolean} |
635 | 661 | * `keyUsages`: {string[]} See [Key usages][]. |
@@ -649,6 +675,8 @@ include: |
649 | 675 | * `'ECDH'` |
650 | 676 | * `'NODE-DSA'` <sup>1</sup> |
651 | 677 | * `'NODE-DH'` <sup>1</sup> |
| 678 | +* `'NODE-ED25519'` <sup>1</sup> |
| 679 | +* `'NODE-ED448'` <sup>1</sup> |
652 | 680 |
|
653 | 681 | The {CryptoKey} (secret key) generating algorithms supported include: |
654 | 682 |
|
@@ -669,7 +697,7 @@ added: v15.0.0 |
669 | 697 | `node.keyObject`. |
670 | 698 | * `keyData`: {ArrayBuffer|TypedArray|DataView|Buffer|KeyObject} |
671 | 699 | <!--lint disable maximum-line-length remark-lint--> |
672 | | -* `algorithm`: {RsaHashedImportParams|EcKeyImportParams|HmacImportParams|AesImportParams|Pbkdf2ImportParams|NodeDsaImportParams|NodeDhImportParams|NodeScryptImportParams} |
| 700 | +* `algorithm`: {RsaHashedImportParams|EcKeyImportParams|HmacImportParams|AesImportParams|Pbkdf2ImportParams|NodeDsaImportParams|NodeDhImportParams|NodeScryptImportParams|NodeEdKeyImportParams} |
673 | 701 | <!--lint enable maximum-line-length remark-lint--> |
674 | 702 | * `extractable`: {boolean} |
675 | 703 | * `keyUsages`: {string[]} See [Key usages][]. |
@@ -704,6 +732,8 @@ The algorithms currently supported include: |
704 | 732 | | `'NODE-DSA'` <sup>1</sup> | ✔ | ✔ | ✔ | | |
705 | 733 | | `'NODE-DH'` <sup>1</sup> | ✔ | ✔ | | | |
706 | 734 | | `'NODE-SCRYPT'` <sup>1</sup> | | | | ✔ | |
| 735 | +| `'NODE-ED25519'` <sup>1</sup> | ✔ | ✔ | ✔ | ✔ | |
| 736 | +| `'NODE-ED448'` <sup>1</sup> | ✔ | ✔ | ✔ | ✔ | |
707 | 737 |
|
708 | 738 | <sup>1</sup> Node.js-specific extension |
709 | 739 |
|
@@ -731,6 +761,8 @@ The algorithms currently supported include: |
731 | 761 | * `'ECDSA'` |
732 | 762 | * `'HMAC'` |
733 | 763 | * `'NODE-DSA'`<sup>1</sup> |
| 764 | +* `'NODE-ED25519'`<sup>1</sup> |
| 765 | +* `'NODE-ED448'`<sup>1</sup> |
734 | 766 |
|
735 | 767 | <sup>1</sup> Non-standadrd Node.js extension |
736 | 768 |
|
@@ -809,6 +841,8 @@ The algorithms currently supported include: |
809 | 841 | * `'ECDSA'` |
810 | 842 | * `'HMAC'` |
811 | 843 | * `'NODE-DSA'`<sup>1</sup> |
| 844 | +* `'NODE-ED25519'`<sup>1</sup> |
| 845 | +* `'NODE-ED448'`<sup>1</sup> |
812 | 846 |
|
813 | 847 | <sup>1</sup> Non-standard Node.js extension |
814 | 848 |
|
@@ -1062,7 +1096,8 @@ added: v15.0.0 |
1062 | 1096 | added: v15.0.0 |
1063 | 1097 | --> |
1064 | 1098 |
|
1065 | | -* Type: {string} Must be one of `'P-256'`, `'P-384'` or `'P-521'`. |
| 1099 | +* Type: {string} Must be one of `'P-256'`, `'P-384'`, `'P-521'`, |
| 1100 | + `'NODE-ED25519'`, `'NODE-ED448'`, `'NODE-X25519'`, or `'NODE-X448'`. |
1066 | 1101 |
|
1067 | 1102 | ### Class: `EcKeyImportParams` |
1068 | 1103 | <!-- YAML |
@@ -1081,7 +1116,8 @@ added: v15.0.0 |
1081 | 1116 | added: v15.0.0 |
1082 | 1117 | --> |
1083 | 1118 |
|
1084 | | -* Type: {string} Must be one of `'P-256'`, `'P-384'` or `'P-521'`. |
| 1119 | +* Type: {string} Must be one of `'P-256'`, `'P-384'`, `'P-521'`, |
| 1120 | + `'NODE-ED25519'`, `'NODE-ED448'`, `'NODE-X25519'`, or `'NODE-X448'`. |
1085 | 1121 |
|
1086 | 1122 | ### Class: `HkdfParams` |
1087 | 1123 | <!-- YAML |
@@ -1598,6 +1634,63 @@ added: v15.0.0 |
1598 | 1634 |
|
1599 | 1635 | * Type: {string} Must be `'NODE-DSA'` |
1600 | 1636 |
|
| 1637 | +### `NODE-ED25519` and `NODE-ED448` Algorithms |
| 1638 | +<!-- YAML |
| 1639 | +added: REPLACEME |
| 1640 | +--> |
| 1641 | + |
| 1642 | +#### Class: `NodeEdKeyGenParams` |
| 1643 | +<!-- YAML |
| 1644 | +added: REPLACEME |
| 1645 | +--> |
| 1646 | + |
| 1647 | +##### `nodeEdKeyGenParams.name` |
| 1648 | +<!-- YAML |
| 1649 | +added: REPLACEME |
| 1650 | +--> |
| 1651 | + |
| 1652 | +* Type: {string} Must be one of `'NODE-ED25519'`, `'NODE-ED448'` or `'ECDH'`. |
| 1653 | + |
| 1654 | +##### `nodeEdKeyGenParams.namedCurve` |
| 1655 | +<!-- YAML |
| 1656 | +added: REPLACEME |
| 1657 | +--> |
| 1658 | + |
| 1659 | +* Type: {string} Must be one of `'NODE-ED25519'`, `'NODE-ED448'`, |
| 1660 | + `'NODE-X25519'`, or `'NODE-X448'`. |
| 1661 | + |
| 1662 | +#### Class: `NodeEdKeyImportParams` |
| 1663 | +<!-- YAML |
| 1664 | +added: REPLACEME |
| 1665 | +--> |
| 1666 | + |
| 1667 | +##### `nodeEdKeyImportParams.name` |
| 1668 | +<!-- YAML |
| 1669 | +added: REPLACEME |
| 1670 | +--> |
| 1671 | + |
| 1672 | +* Type: {string} Must be one of `'NODE-ED25519'` or `'NODE-ED448'` |
| 1673 | + if importing an `Ed25519` or `Ed448` key, or `'ECDH'` if importing |
| 1674 | + an `X25519` or `X448` key. |
| 1675 | + |
| 1676 | +##### `nodeEdKeyImportParams.namedCurve` |
| 1677 | +<!-- YAML |
| 1678 | +added: REPLACEME |
| 1679 | +--> |
| 1680 | + |
| 1681 | +* Type: {string} Must be one of `'NODE-ED25519'`, `'NODE-ED448'`, |
| 1682 | + `'NODE-X25519'`, or `'NODE-X448'`. |
| 1683 | + |
| 1684 | +##### `nodeEdKeyImportParams.public` |
| 1685 | +<!-- YAML |
| 1686 | +added: REPLACEME |
| 1687 | +--> |
| 1688 | + |
| 1689 | +* Type: {boolean} |
| 1690 | + |
| 1691 | +The `public` parameter is used to specify that the key is to be interpreted |
| 1692 | +as a public key. |
| 1693 | + |
1601 | 1694 | ### `NODE-SCRYPT` Algorithm |
1602 | 1695 | <!-- YAML |
1603 | 1696 | added: v15.0.0 |
|