@protontech/openpgp 5.9.1-1 → 5.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/openpgp.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v5.9.1-1 - 2023-09-06 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v5.10.2 - 2023-09-18 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
2
  var openpgp = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1510,6 +1510,526 @@ var openpgp = (function (exports) {
1510
1510
  }
1511
1511
  }
1512
1512
 
1513
+ /**
1514
+ * @module enums
1515
+ */
1516
+
1517
+ const byValue = Symbol('byValue');
1518
+
1519
+ var enums = {
1520
+
1521
+ /** Maps curve names under various standards to one
1522
+ * @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
1523
+ * @enum {String}
1524
+ * @readonly
1525
+ */
1526
+ curve: {
1527
+ /** NIST P-256 Curve */
1528
+ 'p256': 'p256',
1529
+ 'P-256': 'p256',
1530
+ 'secp256r1': 'p256',
1531
+ 'prime256v1': 'p256',
1532
+ '1.2.840.10045.3.1.7': 'p256',
1533
+ '2a8648ce3d030107': 'p256',
1534
+ '2A8648CE3D030107': 'p256',
1535
+
1536
+ /** NIST P-384 Curve */
1537
+ 'p384': 'p384',
1538
+ 'P-384': 'p384',
1539
+ 'secp384r1': 'p384',
1540
+ '1.3.132.0.34': 'p384',
1541
+ '2b81040022': 'p384',
1542
+ '2B81040022': 'p384',
1543
+
1544
+ /** NIST P-521 Curve */
1545
+ 'p521': 'p521',
1546
+ 'P-521': 'p521',
1547
+ 'secp521r1': 'p521',
1548
+ '1.3.132.0.35': 'p521',
1549
+ '2b81040023': 'p521',
1550
+ '2B81040023': 'p521',
1551
+
1552
+ /** SECG SECP256k1 Curve */
1553
+ 'secp256k1': 'secp256k1',
1554
+ '1.3.132.0.10': 'secp256k1',
1555
+ '2b8104000a': 'secp256k1',
1556
+ '2B8104000A': 'secp256k1',
1557
+
1558
+ /** Ed25519 */
1559
+ 'ED25519': 'ed25519',
1560
+ 'ed25519': 'ed25519',
1561
+ 'Ed25519': 'ed25519',
1562
+ '1.3.6.1.4.1.11591.15.1': 'ed25519',
1563
+ '2b06010401da470f01': 'ed25519',
1564
+ '2B06010401DA470F01': 'ed25519',
1565
+
1566
+ /** Curve25519 */
1567
+ 'X25519': 'curve25519',
1568
+ 'cv25519': 'curve25519',
1569
+ 'curve25519': 'curve25519',
1570
+ 'Curve25519': 'curve25519',
1571
+ '1.3.6.1.4.1.3029.1.5.1': 'curve25519',
1572
+ '2b060104019755010501': 'curve25519',
1573
+ '2B060104019755010501': 'curve25519',
1574
+
1575
+ /** BrainpoolP256r1 Curve */
1576
+ 'brainpoolP256r1': 'brainpoolP256r1',
1577
+ '1.3.36.3.3.2.8.1.1.7': 'brainpoolP256r1',
1578
+ '2b2403030208010107': 'brainpoolP256r1',
1579
+ '2B2403030208010107': 'brainpoolP256r1',
1580
+
1581
+ /** BrainpoolP384r1 Curve */
1582
+ 'brainpoolP384r1': 'brainpoolP384r1',
1583
+ '1.3.36.3.3.2.8.1.1.11': 'brainpoolP384r1',
1584
+ '2b240303020801010b': 'brainpoolP384r1',
1585
+ '2B240303020801010B': 'brainpoolP384r1',
1586
+
1587
+ /** BrainpoolP512r1 Curve */
1588
+ 'brainpoolP512r1': 'brainpoolP512r1',
1589
+ '1.3.36.3.3.2.8.1.1.13': 'brainpoolP512r1',
1590
+ '2b240303020801010d': 'brainpoolP512r1',
1591
+ '2B240303020801010D': 'brainpoolP512r1'
1592
+ },
1593
+
1594
+ /** KDF parameters flags
1595
+ * Non-standard extensions (for now) to allow email forwarding
1596
+ * @enum {Integer}
1597
+ * @readonly
1598
+ */
1599
+ kdfFlags: {
1600
+ /** Specify fingerprint to use instead of the recipient's */
1601
+ replace_fingerprint: 0x01,
1602
+ /** Specify custom parameters to use in the KDF digest computation */
1603
+ replace_kdf_params: 0x02
1604
+ },
1605
+
1606
+ /** A string to key specifier type
1607
+ * @enum {Integer}
1608
+ * @readonly
1609
+ */
1610
+ s2k: {
1611
+ simple: 0,
1612
+ salted: 1,
1613
+ iterated: 3,
1614
+ argon2: 4,
1615
+ gnu: 101
1616
+ },
1617
+
1618
+ /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-crypto-refresh-08.html#section-9.1|crypto-refresh RFC, section 9.1}
1619
+ * @enum {Integer}
1620
+ * @readonly
1621
+ */
1622
+ publicKey: {
1623
+ /** RSA (Encrypt or Sign) [HAC] */
1624
+ rsaEncryptSign: 1,
1625
+ /** RSA (Encrypt only) [HAC] */
1626
+ rsaEncrypt: 2,
1627
+ /** RSA (Sign only) [HAC] */
1628
+ rsaSign: 3,
1629
+ /** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
1630
+ elgamal: 16,
1631
+ /** DSA (Sign only) [FIPS186] [HAC] */
1632
+ dsa: 17,
1633
+ /** ECDH (Encrypt only) [RFC6637] */
1634
+ ecdh: 18,
1635
+ /** ECDSA (Sign only) [RFC6637] */
1636
+ ecdsa: 19,
1637
+ /** EdDSA (Sign only) - deprecated by crypto-refresh (replaced by `ed25519` identifier below)
1638
+ * [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
1639
+ ed25519Legacy: 22, // NB: this is declared before `eddsa` to translate 22 to 'eddsa' for backwards compatibility
1640
+ eddsa: 22, // to be deprecated in v6
1641
+ /** Reserved for AEDH */
1642
+ aedh: 23,
1643
+ /** Reserved for AEDSA */
1644
+ aedsa: 24,
1645
+ /** X25519 (Encrypt only) */
1646
+ x25519: 25,
1647
+ /** X448 (Encrypt only) */
1648
+ x448: 26,
1649
+ /** Ed25519 (Sign only) */
1650
+ ed25519: 27,
1651
+ /** Ed448 (Sign only) */
1652
+ ed448: 28,
1653
+ /** Symmetric authenticated encryption algorithms */
1654
+ aead: 100,
1655
+ /** Authentication using CMAC */
1656
+ hmac: 101
1657
+ },
1658
+
1659
+ /** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
1660
+ * @enum {Integer}
1661
+ * @readonly
1662
+ */
1663
+ symmetric: {
1664
+ plaintext: 0,
1665
+ /** Not implemented! */
1666
+ idea: 1,
1667
+ tripledes: 2,
1668
+ cast5: 3,
1669
+ blowfish: 4,
1670
+ aes128: 7,
1671
+ aes192: 8,
1672
+ aes256: 9,
1673
+ twofish: 10
1674
+ },
1675
+
1676
+ /** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
1677
+ * @enum {Integer}
1678
+ * @readonly
1679
+ */
1680
+ compression: {
1681
+ uncompressed: 0,
1682
+ /** RFC1951 */
1683
+ zip: 1,
1684
+ /** RFC1950 */
1685
+ zlib: 2,
1686
+ bzip2: 3
1687
+ },
1688
+
1689
+ /** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
1690
+ * @enum {Integer}
1691
+ * @readonly
1692
+ */
1693
+ hash: {
1694
+ md5: 1,
1695
+ sha1: 2,
1696
+ ripemd: 3,
1697
+ sha256: 8,
1698
+ sha384: 9,
1699
+ sha512: 10,
1700
+ sha224: 11
1701
+ },
1702
+
1703
+ /** A list of hash names as accepted by webCrypto functions.
1704
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
1705
+ * @enum {String}
1706
+ */
1707
+ webHash: {
1708
+ 'SHA-1': 2,
1709
+ 'SHA-256': 8,
1710
+ 'SHA-384': 9,
1711
+ 'SHA-512': 10
1712
+ },
1713
+
1714
+ /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
1715
+ * @enum {Integer}
1716
+ * @readonly
1717
+ */
1718
+ aead: {
1719
+ eax: 1,
1720
+ ocb: 2,
1721
+ experimentalGCM: 100 // Private algorithm
1722
+ },
1723
+
1724
+ /** A list of packet types and numeric tags associated with them.
1725
+ * @enum {Integer}
1726
+ * @readonly
1727
+ */
1728
+ packet: {
1729
+ publicKeyEncryptedSessionKey: 1,
1730
+ signature: 2,
1731
+ symEncryptedSessionKey: 3,
1732
+ onePassSignature: 4,
1733
+ secretKey: 5,
1734
+ publicKey: 6,
1735
+ secretSubkey: 7,
1736
+ compressedData: 8,
1737
+ symmetricallyEncryptedData: 9,
1738
+ marker: 10,
1739
+ literalData: 11,
1740
+ trust: 12,
1741
+ userID: 13,
1742
+ publicSubkey: 14,
1743
+ userAttribute: 17,
1744
+ symEncryptedIntegrityProtectedData: 18,
1745
+ modificationDetectionCode: 19,
1746
+ aeadEncryptedData: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
1747
+ },
1748
+
1749
+ /** Data types in the literal packet
1750
+ * @enum {Integer}
1751
+ * @readonly
1752
+ */
1753
+ literal: {
1754
+ /** Binary data 'b' */
1755
+ binary: 'b'.charCodeAt(),
1756
+ /** Text data 't' */
1757
+ text: 't'.charCodeAt(),
1758
+ /** Utf8 data 'u' */
1759
+ utf8: 'u'.charCodeAt(),
1760
+ /** MIME message body part 'm' */
1761
+ mime: 'm'.charCodeAt()
1762
+ },
1763
+
1764
+
1765
+ /** One pass signature packet type
1766
+ * @enum {Integer}
1767
+ * @readonly
1768
+ */
1769
+ signature: {
1770
+ /** 0x00: Signature of a binary document. */
1771
+ binary: 0,
1772
+ /** 0x01: Signature of a canonical text document.
1773
+ *
1774
+ * Canonicalyzing the document by converting line endings. */
1775
+ text: 1,
1776
+ /** 0x02: Standalone signature.
1777
+ *
1778
+ * This signature is a signature of only its own subpacket contents.
1779
+ * It is calculated identically to a signature over a zero-lengh
1780
+ * binary document. Note that it doesn't make sense to have a V3
1781
+ * standalone signature. */
1782
+ standalone: 2,
1783
+ /** 0x10: Generic certification of a User ID and Public-Key packet.
1784
+ *
1785
+ * The issuer of this certification does not make any particular
1786
+ * assertion as to how well the certifier has checked that the owner
1787
+ * of the key is in fact the person described by the User ID. */
1788
+ certGeneric: 16,
1789
+ /** 0x11: Persona certification of a User ID and Public-Key packet.
1790
+ *
1791
+ * The issuer of this certification has not done any verification of
1792
+ * the claim that the owner of this key is the User ID specified. */
1793
+ certPersona: 17,
1794
+ /** 0x12: Casual certification of a User ID and Public-Key packet.
1795
+ *
1796
+ * The issuer of this certification has done some casual
1797
+ * verification of the claim of identity. */
1798
+ certCasual: 18,
1799
+ /** 0x13: Positive certification of a User ID and Public-Key packet.
1800
+ *
1801
+ * The issuer of this certification has done substantial
1802
+ * verification of the claim of identity.
1803
+ *
1804
+ * Most OpenPGP implementations make their "key signatures" as 0x10
1805
+ * certifications. Some implementations can issue 0x11-0x13
1806
+ * certifications, but few differentiate between the types. */
1807
+ certPositive: 19,
1808
+ /** 0x30: Certification revocation signature
1809
+ *
1810
+ * This signature revokes an earlier User ID certification signature
1811
+ * (signature class 0x10 through 0x13) or direct-key signature
1812
+ * (0x1F). It should be issued by the same key that issued the
1813
+ * revoked signature or an authorized revocation key. The signature
1814
+ * is computed over the same data as the certificate that it
1815
+ * revokes, and should have a later creation date than that
1816
+ * certificate. */
1817
+ certRevocation: 48,
1818
+ /** 0x18: Subkey Binding Signature
1819
+ *
1820
+ * This signature is a statement by the top-level signing key that
1821
+ * indicates that it owns the subkey. This signature is calculated
1822
+ * directly on the primary key and subkey, and not on any User ID or
1823
+ * other packets. A signature that binds a signing subkey MUST have
1824
+ * an Embedded Signature subpacket in this binding signature that
1825
+ * contains a 0x19 signature made by the signing subkey on the
1826
+ * primary key and subkey. */
1827
+ subkeyBinding: 24,
1828
+ /** 0x19: Primary Key Binding Signature
1829
+ *
1830
+ * This signature is a statement by a signing subkey, indicating
1831
+ * that it is owned by the primary key and subkey. This signature
1832
+ * is calculated the same way as a 0x18 signature: directly on the
1833
+ * primary key and subkey, and not on any User ID or other packets.
1834
+ *
1835
+ * When a signature is made over a key, the hash data starts with the
1836
+ * octet 0x99, followed by a two-octet length of the key, and then body
1837
+ * of the key packet. (Note that this is an old-style packet header for
1838
+ * a key packet with two-octet length.) A subkey binding signature
1839
+ * (type 0x18) or primary key binding signature (type 0x19) then hashes
1840
+ * the subkey using the same format as the main key (also using 0x99 as
1841
+ * the first octet). */
1842
+ keyBinding: 25,
1843
+ /** 0x1F: Signature directly on a key
1844
+ *
1845
+ * This signature is calculated directly on a key. It binds the
1846
+ * information in the Signature subpackets to the key, and is
1847
+ * appropriate to be used for subpackets that provide information
1848
+ * about the key, such as the Revocation Key subpacket. It is also
1849
+ * appropriate for statements that non-self certifiers want to make
1850
+ * about the key itself, rather than the binding between a key and a
1851
+ * name. */
1852
+ key: 31,
1853
+ /** 0x20: Key revocation signature
1854
+ *
1855
+ * The signature is calculated directly on the key being revoked. A
1856
+ * revoked key is not to be used. Only revocation signatures by the
1857
+ * key being revoked, or by an authorized revocation key, should be
1858
+ * considered valid revocation signatures.a */
1859
+ keyRevocation: 32,
1860
+ /** 0x28: Subkey revocation signature
1861
+ *
1862
+ * The signature is calculated directly on the subkey being revoked.
1863
+ * A revoked subkey is not to be used. Only revocation signatures
1864
+ * by the top-level signature key that is bound to this subkey, or
1865
+ * by an authorized revocation key, should be considered valid
1866
+ * revocation signatures.
1867
+ *
1868
+ * Key revocation signatures (types 0x20 and 0x28)
1869
+ * hash only the key being revoked. */
1870
+ subkeyRevocation: 40,
1871
+ /** 0x40: Timestamp signature.
1872
+ * This signature is only meaningful for the timestamp contained in
1873
+ * it. */
1874
+ timestamp: 64,
1875
+ /** 0x50: Third-Party Confirmation signature.
1876
+ *
1877
+ * This signature is a signature over some other OpenPGP Signature
1878
+ * packet(s). It is analogous to a notary seal on the signed data.
1879
+ * A third-party signature SHOULD include Signature Target
1880
+ * subpacket(s) to give easy identification. Note that we really do
1881
+ * mean SHOULD. There are plausible uses for this (such as a blind
1882
+ * party that only sees the signature, not the key or source
1883
+ * document) that cannot include a target subpacket. */
1884
+ thirdParty: 80
1885
+ },
1886
+
1887
+ /** Signature subpacket type
1888
+ * @enum {Integer}
1889
+ * @readonly
1890
+ */
1891
+ signatureSubpacket: {
1892
+ signatureCreationTime: 2,
1893
+ signatureExpirationTime: 3,
1894
+ exportableCertification: 4,
1895
+ trustSignature: 5,
1896
+ regularExpression: 6,
1897
+ revocable: 7,
1898
+ keyExpirationTime: 9,
1899
+ placeholderBackwardsCompatibility: 10,
1900
+ preferredSymmetricAlgorithms: 11,
1901
+ revocationKey: 12,
1902
+ issuer: 16,
1903
+ notationData: 20,
1904
+ preferredHashAlgorithms: 21,
1905
+ preferredCompressionAlgorithms: 22,
1906
+ keyServerPreferences: 23,
1907
+ preferredKeyServer: 24,
1908
+ primaryUserID: 25,
1909
+ policyURI: 26,
1910
+ keyFlags: 27,
1911
+ signersUserID: 28,
1912
+ reasonForRevocation: 29,
1913
+ features: 30,
1914
+ signatureTarget: 31,
1915
+ embeddedSignature: 32,
1916
+ issuerFingerprint: 33,
1917
+ preferredAEADAlgorithms: 34
1918
+ },
1919
+
1920
+ /** Key flags
1921
+ * @enum {Integer}
1922
+ * @readonly
1923
+ */
1924
+ keyFlags: {
1925
+ /** 0x01 - This key may be used to certify other keys. */
1926
+ certifyKeys: 1,
1927
+ /** 0x02 - This key may be used to sign data. */
1928
+ signData: 2,
1929
+ /** 0x04 - This key may be used to encrypt communications. */
1930
+ encryptCommunication: 4,
1931
+ /** 0x08 - This key may be used to encrypt storage. */
1932
+ encryptStorage: 8,
1933
+ /** 0x10 - The private component of this key may have been split
1934
+ * by a secret-sharing mechanism. */
1935
+ splitPrivateKey: 16,
1936
+ /** 0x20 - This key may be used for authentication. */
1937
+ authentication: 32,
1938
+ /** This key may be used for forwarded communications */
1939
+ forwardedCommunication: 64,
1940
+ /** 0x80 - The private component of this key may be in the
1941
+ * possession of more than one person. */
1942
+ sharedPrivateKey: 128
1943
+ },
1944
+
1945
+ /** Armor type
1946
+ * @enum {Integer}
1947
+ * @readonly
1948
+ */
1949
+ armor: {
1950
+ multipartSection: 0,
1951
+ multipartLast: 1,
1952
+ signed: 2,
1953
+ message: 3,
1954
+ publicKey: 4,
1955
+ privateKey: 5,
1956
+ signature: 6
1957
+ },
1958
+
1959
+ /** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
1960
+ * @enum {Integer}
1961
+ * @readonly
1962
+ */
1963
+ reasonForRevocation: {
1964
+ /** No reason specified (key revocations or cert revocations) */
1965
+ noReason: 0,
1966
+ /** Key is superseded (key revocations) */
1967
+ keySuperseded: 1,
1968
+ /** Key material has been compromised (key revocations) */
1969
+ keyCompromised: 2,
1970
+ /** Key is retired and no longer used (key revocations) */
1971
+ keyRetired: 3,
1972
+ /** User ID information is no longer valid (cert revocations) */
1973
+ userIDInvalid: 32
1974
+ },
1975
+
1976
+ /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
1977
+ * @enum {Integer}
1978
+ * @readonly
1979
+ */
1980
+ features: {
1981
+ /** 0x01 - Modification Detection (packets 18 and 19) */
1982
+ modificationDetection: 1,
1983
+ /** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
1984
+ * Symmetric-Key Encrypted Session Key Packets (packet 3) */
1985
+ aead: 2,
1986
+ /** 0x04 - Version 5 Public-Key Packet format and corresponding new
1987
+ * fingerprint format */
1988
+ v5Keys: 4
1989
+ },
1990
+
1991
+ /**
1992
+ * Asserts validity of given value and converts from string/integer to integer.
1993
+ * @param {Object} type target enum type
1994
+ * @param {String|Integer} e value to check and/or convert
1995
+ * @returns {Integer} enum value if it exists
1996
+ * @throws {Error} if the value is invalid
1997
+ */
1998
+ write: function(type, e) {
1999
+ if (typeof e === 'number') {
2000
+ e = this.read(type, e);
2001
+ }
2002
+
2003
+ if (type[e] !== undefined) {
2004
+ return type[e];
2005
+ }
2006
+
2007
+ throw new Error('Invalid enum value.');
2008
+ },
2009
+
2010
+ /**
2011
+ * Converts enum integer value to the corresponding string, if it exists.
2012
+ * @param {Object} type target enum type
2013
+ * @param {Integer} e value to convert
2014
+ * @returns {String} name of enum value if it exists
2015
+ * @throws {Error} if the value is invalid
2016
+ */
2017
+ read: function(type, e) {
2018
+ if (!type[byValue]) {
2019
+ type[byValue] = [];
2020
+ Object.entries(type).forEach(([key, value]) => {
2021
+ type[byValue][value] = key;
2022
+ });
2023
+ }
2024
+
2025
+ if (type[byValue][e] !== undefined) {
2026
+ return type[byValue][e];
2027
+ }
2028
+
2029
+ throw new Error('Invalid enum value.');
2030
+ }
2031
+ };
2032
+
1513
2033
  // GPG4Browsers - An OpenPGP implementation in javascript
1514
2034
 
1515
2035
  const debugMode = (() => {
@@ -2091,6 +2611,12 @@ var openpgp = (function (exports) {
2091
2611
  */
2092
2612
  selectUint8: function(cond, a, b) {
2093
2613
  return (a & (256 - cond)) | (b & (255 + cond));
2614
+ },
2615
+ /**
2616
+ * @param {module:enums.symmetric} cipherAlgo
2617
+ */
2618
+ isAES: function(cipherAlgo) {
2619
+ return cipherAlgo === enums.symmetric.aes128 || cipherAlgo === enums.symmetric.aes192 || cipherAlgo === enums.symmetric.aes256;
2094
2620
  }
2095
2621
  };
2096
2622
 
@@ -2205,517 +2731,6 @@ var openpgp = (function (exports) {
2205
2731
  return encoded;
2206
2732
  }
2207
2733
 
2208
- /**
2209
- * @module enums
2210
- */
2211
-
2212
- const byValue = Symbol('byValue');
2213
-
2214
- var enums = {
2215
-
2216
- /** Maps curve names under various standards to one
2217
- * @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
2218
- * @enum {String}
2219
- * @readonly
2220
- */
2221
- curve: {
2222
- /** NIST P-256 Curve */
2223
- 'p256': 'p256',
2224
- 'P-256': 'p256',
2225
- 'secp256r1': 'p256',
2226
- 'prime256v1': 'p256',
2227
- '1.2.840.10045.3.1.7': 'p256',
2228
- '2a8648ce3d030107': 'p256',
2229
- '2A8648CE3D030107': 'p256',
2230
-
2231
- /** NIST P-384 Curve */
2232
- 'p384': 'p384',
2233
- 'P-384': 'p384',
2234
- 'secp384r1': 'p384',
2235
- '1.3.132.0.34': 'p384',
2236
- '2b81040022': 'p384',
2237
- '2B81040022': 'p384',
2238
-
2239
- /** NIST P-521 Curve */
2240
- 'p521': 'p521',
2241
- 'P-521': 'p521',
2242
- 'secp521r1': 'p521',
2243
- '1.3.132.0.35': 'p521',
2244
- '2b81040023': 'p521',
2245
- '2B81040023': 'p521',
2246
-
2247
- /** SECG SECP256k1 Curve */
2248
- 'secp256k1': 'secp256k1',
2249
- '1.3.132.0.10': 'secp256k1',
2250
- '2b8104000a': 'secp256k1',
2251
- '2B8104000A': 'secp256k1',
2252
-
2253
- /** Ed25519 */
2254
- 'ED25519': 'ed25519',
2255
- 'ed25519': 'ed25519',
2256
- 'Ed25519': 'ed25519',
2257
- '1.3.6.1.4.1.11591.15.1': 'ed25519',
2258
- '2b06010401da470f01': 'ed25519',
2259
- '2B06010401DA470F01': 'ed25519',
2260
-
2261
- /** Curve25519 */
2262
- 'X25519': 'curve25519',
2263
- 'cv25519': 'curve25519',
2264
- 'curve25519': 'curve25519',
2265
- 'Curve25519': 'curve25519',
2266
- '1.3.6.1.4.1.3029.1.5.1': 'curve25519',
2267
- '2b060104019755010501': 'curve25519',
2268
- '2B060104019755010501': 'curve25519',
2269
-
2270
- /** BrainpoolP256r1 Curve */
2271
- 'brainpoolP256r1': 'brainpoolP256r1',
2272
- '1.3.36.3.3.2.8.1.1.7': 'brainpoolP256r1',
2273
- '2b2403030208010107': 'brainpoolP256r1',
2274
- '2B2403030208010107': 'brainpoolP256r1',
2275
-
2276
- /** BrainpoolP384r1 Curve */
2277
- 'brainpoolP384r1': 'brainpoolP384r1',
2278
- '1.3.36.3.3.2.8.1.1.11': 'brainpoolP384r1',
2279
- '2b240303020801010b': 'brainpoolP384r1',
2280
- '2B240303020801010B': 'brainpoolP384r1',
2281
-
2282
- /** BrainpoolP512r1 Curve */
2283
- 'brainpoolP512r1': 'brainpoolP512r1',
2284
- '1.3.36.3.3.2.8.1.1.13': 'brainpoolP512r1',
2285
- '2b240303020801010d': 'brainpoolP512r1',
2286
- '2B240303020801010D': 'brainpoolP512r1'
2287
- },
2288
-
2289
- /** KDF parameters flags
2290
- * Non-standard extensions (for now) to allow email forwarding
2291
- * @enum {Integer}
2292
- * @readonly
2293
- */
2294
- kdfFlags: {
2295
- /** Specify fingerprint to use instead of the recipient's */
2296
- replace_fingerprint: 0x01,
2297
- /** Specify custom parameters to use in the KDF digest computation */
2298
- replace_kdf_params: 0x02
2299
- },
2300
-
2301
- /** A string to key specifier type
2302
- * @enum {Integer}
2303
- * @readonly
2304
- */
2305
- s2k: {
2306
- simple: 0,
2307
- salted: 1,
2308
- iterated: 3,
2309
- argon2: 4,
2310
- gnu: 101
2311
- },
2312
-
2313
- /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.1|RFC4880bis-04, section 9.1}
2314
- * @enum {Integer}
2315
- * @readonly
2316
- */
2317
- publicKey: {
2318
- /** RSA (Encrypt or Sign) [HAC] */
2319
- rsaEncryptSign: 1,
2320
- /** RSA (Encrypt only) [HAC] */
2321
- rsaEncrypt: 2,
2322
- /** RSA (Sign only) [HAC] */
2323
- rsaSign: 3,
2324
- /** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
2325
- elgamal: 16,
2326
- /** DSA (Sign only) [FIPS186] [HAC] */
2327
- dsa: 17,
2328
- /** ECDH (Encrypt only) [RFC6637] */
2329
- ecdh: 18,
2330
- /** ECDSA (Sign only) [RFC6637] */
2331
- ecdsa: 19,
2332
- /** EdDSA (Sign only)
2333
- * [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
2334
- eddsa: 22,
2335
- /** Reserved for AEDH */
2336
- aedh: 23,
2337
- /** Reserved for AEDSA */
2338
- aedsa: 24,
2339
- /** Symmetric authenticated encryption algorithms */
2340
- aead: 100,
2341
- /** Authentication using CMAC */
2342
- hmac: 101
2343
- },
2344
-
2345
- /** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
2346
- * @enum {Integer}
2347
- * @readonly
2348
- */
2349
- symmetric: {
2350
- plaintext: 0,
2351
- /** Not implemented! */
2352
- idea: 1,
2353
- tripledes: 2,
2354
- cast5: 3,
2355
- blowfish: 4,
2356
- aes128: 7,
2357
- aes192: 8,
2358
- aes256: 9,
2359
- twofish: 10
2360
- },
2361
-
2362
- /** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
2363
- * @enum {Integer}
2364
- * @readonly
2365
- */
2366
- compression: {
2367
- uncompressed: 0,
2368
- /** RFC1951 */
2369
- zip: 1,
2370
- /** RFC1950 */
2371
- zlib: 2,
2372
- bzip2: 3
2373
- },
2374
-
2375
- /** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
2376
- * @enum {Integer}
2377
- * @readonly
2378
- */
2379
- hash: {
2380
- md5: 1,
2381
- sha1: 2,
2382
- ripemd: 3,
2383
- sha256: 8,
2384
- sha384: 9,
2385
- sha512: 10,
2386
- sha224: 11
2387
- },
2388
-
2389
- /** A list of hash names as accepted by webCrypto functions.
2390
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
2391
- * @enum {String}
2392
- */
2393
- webHash: {
2394
- 'SHA-1': 2,
2395
- 'SHA-256': 8,
2396
- 'SHA-384': 9,
2397
- 'SHA-512': 10
2398
- },
2399
-
2400
- /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
2401
- * @enum {Integer}
2402
- * @readonly
2403
- */
2404
- aead: {
2405
- eax: 1,
2406
- ocb: 2,
2407
- experimentalGCM: 100 // Private algorithm
2408
- },
2409
-
2410
- /** A list of packet types and numeric tags associated with them.
2411
- * @enum {Integer}
2412
- * @readonly
2413
- */
2414
- packet: {
2415
- publicKeyEncryptedSessionKey: 1,
2416
- signature: 2,
2417
- symEncryptedSessionKey: 3,
2418
- onePassSignature: 4,
2419
- secretKey: 5,
2420
- publicKey: 6,
2421
- secretSubkey: 7,
2422
- compressedData: 8,
2423
- symmetricallyEncryptedData: 9,
2424
- marker: 10,
2425
- literalData: 11,
2426
- trust: 12,
2427
- userID: 13,
2428
- publicSubkey: 14,
2429
- userAttribute: 17,
2430
- symEncryptedIntegrityProtectedData: 18,
2431
- modificationDetectionCode: 19,
2432
- aeadEncryptedData: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
2433
- },
2434
-
2435
- /** Data types in the literal packet
2436
- * @enum {Integer}
2437
- * @readonly
2438
- */
2439
- literal: {
2440
- /** Binary data 'b' */
2441
- binary: 'b'.charCodeAt(),
2442
- /** Text data 't' */
2443
- text: 't'.charCodeAt(),
2444
- /** Utf8 data 'u' */
2445
- utf8: 'u'.charCodeAt(),
2446
- /** MIME message body part 'm' */
2447
- mime: 'm'.charCodeAt()
2448
- },
2449
-
2450
-
2451
- /** One pass signature packet type
2452
- * @enum {Integer}
2453
- * @readonly
2454
- */
2455
- signature: {
2456
- /** 0x00: Signature of a binary document. */
2457
- binary: 0,
2458
- /** 0x01: Signature of a canonical text document.
2459
- *
2460
- * Canonicalyzing the document by converting line endings. */
2461
- text: 1,
2462
- /** 0x02: Standalone signature.
2463
- *
2464
- * This signature is a signature of only its own subpacket contents.
2465
- * It is calculated identically to a signature over a zero-lengh
2466
- * binary document. Note that it doesn't make sense to have a V3
2467
- * standalone signature. */
2468
- standalone: 2,
2469
- /** 0x10: Generic certification of a User ID and Public-Key packet.
2470
- *
2471
- * The issuer of this certification does not make any particular
2472
- * assertion as to how well the certifier has checked that the owner
2473
- * of the key is in fact the person described by the User ID. */
2474
- certGeneric: 16,
2475
- /** 0x11: Persona certification of a User ID and Public-Key packet.
2476
- *
2477
- * The issuer of this certification has not done any verification of
2478
- * the claim that the owner of this key is the User ID specified. */
2479
- certPersona: 17,
2480
- /** 0x12: Casual certification of a User ID and Public-Key packet.
2481
- *
2482
- * The issuer of this certification has done some casual
2483
- * verification of the claim of identity. */
2484
- certCasual: 18,
2485
- /** 0x13: Positive certification of a User ID and Public-Key packet.
2486
- *
2487
- * The issuer of this certification has done substantial
2488
- * verification of the claim of identity.
2489
- *
2490
- * Most OpenPGP implementations make their "key signatures" as 0x10
2491
- * certifications. Some implementations can issue 0x11-0x13
2492
- * certifications, but few differentiate between the types. */
2493
- certPositive: 19,
2494
- /** 0x30: Certification revocation signature
2495
- *
2496
- * This signature revokes an earlier User ID certification signature
2497
- * (signature class 0x10 through 0x13) or direct-key signature
2498
- * (0x1F). It should be issued by the same key that issued the
2499
- * revoked signature or an authorized revocation key. The signature
2500
- * is computed over the same data as the certificate that it
2501
- * revokes, and should have a later creation date than that
2502
- * certificate. */
2503
- certRevocation: 48,
2504
- /** 0x18: Subkey Binding Signature
2505
- *
2506
- * This signature is a statement by the top-level signing key that
2507
- * indicates that it owns the subkey. This signature is calculated
2508
- * directly on the primary key and subkey, and not on any User ID or
2509
- * other packets. A signature that binds a signing subkey MUST have
2510
- * an Embedded Signature subpacket in this binding signature that
2511
- * contains a 0x19 signature made by the signing subkey on the
2512
- * primary key and subkey. */
2513
- subkeyBinding: 24,
2514
- /** 0x19: Primary Key Binding Signature
2515
- *
2516
- * This signature is a statement by a signing subkey, indicating
2517
- * that it is owned by the primary key and subkey. This signature
2518
- * is calculated the same way as a 0x18 signature: directly on the
2519
- * primary key and subkey, and not on any User ID or other packets.
2520
- *
2521
- * When a signature is made over a key, the hash data starts with the
2522
- * octet 0x99, followed by a two-octet length of the key, and then body
2523
- * of the key packet. (Note that this is an old-style packet header for
2524
- * a key packet with two-octet length.) A subkey binding signature
2525
- * (type 0x18) or primary key binding signature (type 0x19) then hashes
2526
- * the subkey using the same format as the main key (also using 0x99 as
2527
- * the first octet). */
2528
- keyBinding: 25,
2529
- /** 0x1F: Signature directly on a key
2530
- *
2531
- * This signature is calculated directly on a key. It binds the
2532
- * information in the Signature subpackets to the key, and is
2533
- * appropriate to be used for subpackets that provide information
2534
- * about the key, such as the Revocation Key subpacket. It is also
2535
- * appropriate for statements that non-self certifiers want to make
2536
- * about the key itself, rather than the binding between a key and a
2537
- * name. */
2538
- key: 31,
2539
- /** 0x20: Key revocation signature
2540
- *
2541
- * The signature is calculated directly on the key being revoked. A
2542
- * revoked key is not to be used. Only revocation signatures by the
2543
- * key being revoked, or by an authorized revocation key, should be
2544
- * considered valid revocation signatures.a */
2545
- keyRevocation: 32,
2546
- /** 0x28: Subkey revocation signature
2547
- *
2548
- * The signature is calculated directly on the subkey being revoked.
2549
- * A revoked subkey is not to be used. Only revocation signatures
2550
- * by the top-level signature key that is bound to this subkey, or
2551
- * by an authorized revocation key, should be considered valid
2552
- * revocation signatures.
2553
- *
2554
- * Key revocation signatures (types 0x20 and 0x28)
2555
- * hash only the key being revoked. */
2556
- subkeyRevocation: 40,
2557
- /** 0x40: Timestamp signature.
2558
- * This signature is only meaningful for the timestamp contained in
2559
- * it. */
2560
- timestamp: 64,
2561
- /** 0x50: Third-Party Confirmation signature.
2562
- *
2563
- * This signature is a signature over some other OpenPGP Signature
2564
- * packet(s). It is analogous to a notary seal on the signed data.
2565
- * A third-party signature SHOULD include Signature Target
2566
- * subpacket(s) to give easy identification. Note that we really do
2567
- * mean SHOULD. There are plausible uses for this (such as a blind
2568
- * party that only sees the signature, not the key or source
2569
- * document) that cannot include a target subpacket. */
2570
- thirdParty: 80
2571
- },
2572
-
2573
- /** Signature subpacket type
2574
- * @enum {Integer}
2575
- * @readonly
2576
- */
2577
- signatureSubpacket: {
2578
- signatureCreationTime: 2,
2579
- signatureExpirationTime: 3,
2580
- exportableCertification: 4,
2581
- trustSignature: 5,
2582
- regularExpression: 6,
2583
- revocable: 7,
2584
- keyExpirationTime: 9,
2585
- placeholderBackwardsCompatibility: 10,
2586
- preferredSymmetricAlgorithms: 11,
2587
- revocationKey: 12,
2588
- issuer: 16,
2589
- notationData: 20,
2590
- preferredHashAlgorithms: 21,
2591
- preferredCompressionAlgorithms: 22,
2592
- keyServerPreferences: 23,
2593
- preferredKeyServer: 24,
2594
- primaryUserID: 25,
2595
- policyURI: 26,
2596
- keyFlags: 27,
2597
- signersUserID: 28,
2598
- reasonForRevocation: 29,
2599
- features: 30,
2600
- signatureTarget: 31,
2601
- embeddedSignature: 32,
2602
- issuerFingerprint: 33,
2603
- preferredAEADAlgorithms: 34
2604
- },
2605
-
2606
- /** Key flags
2607
- * @enum {Integer}
2608
- * @readonly
2609
- */
2610
- keyFlags: {
2611
- /** 0x01 - This key may be used to certify other keys. */
2612
- certifyKeys: 1,
2613
- /** 0x02 - This key may be used to sign data. */
2614
- signData: 2,
2615
- /** 0x04 - This key may be used to encrypt communications. */
2616
- encryptCommunication: 4,
2617
- /** 0x08 - This key may be used to encrypt storage. */
2618
- encryptStorage: 8,
2619
- /** 0x10 - The private component of this key may have been split
2620
- * by a secret-sharing mechanism. */
2621
- splitPrivateKey: 16,
2622
- /** 0x20 - This key may be used for authentication. */
2623
- authentication: 32,
2624
- /** This key may be used for forwarded communications */
2625
- forwardedCommunication: 64,
2626
- /** 0x80 - The private component of this key may be in the
2627
- * possession of more than one person. */
2628
- sharedPrivateKey: 128
2629
- },
2630
-
2631
- /** Armor type
2632
- * @enum {Integer}
2633
- * @readonly
2634
- */
2635
- armor: {
2636
- multipartSection: 0,
2637
- multipartLast: 1,
2638
- signed: 2,
2639
- message: 3,
2640
- publicKey: 4,
2641
- privateKey: 5,
2642
- signature: 6
2643
- },
2644
-
2645
- /** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
2646
- * @enum {Integer}
2647
- * @readonly
2648
- */
2649
- reasonForRevocation: {
2650
- /** No reason specified (key revocations or cert revocations) */
2651
- noReason: 0,
2652
- /** Key is superseded (key revocations) */
2653
- keySuperseded: 1,
2654
- /** Key material has been compromised (key revocations) */
2655
- keyCompromised: 2,
2656
- /** Key is retired and no longer used (key revocations) */
2657
- keyRetired: 3,
2658
- /** User ID information is no longer valid (cert revocations) */
2659
- userIDInvalid: 32
2660
- },
2661
-
2662
- /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
2663
- * @enum {Integer}
2664
- * @readonly
2665
- */
2666
- features: {
2667
- /** 0x01 - Modification Detection (packets 18 and 19) */
2668
- modificationDetection: 1,
2669
- /** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
2670
- * Symmetric-Key Encrypted Session Key Packets (packet 3) */
2671
- aead: 2,
2672
- /** 0x04 - Version 5 Public-Key Packet format and corresponding new
2673
- * fingerprint format */
2674
- v5Keys: 4
2675
- },
2676
-
2677
- /**
2678
- * Asserts validity of given value and converts from string/integer to integer.
2679
- * @param {Object} type target enum type
2680
- * @param {String|Integer} e value to check and/or convert
2681
- * @returns {Integer} enum value if it exists
2682
- * @throws {Error} if the value is invalid
2683
- */
2684
- write: function(type, e) {
2685
- if (typeof e === 'number') {
2686
- e = this.read(type, e);
2687
- }
2688
-
2689
- if (type[e] !== undefined) {
2690
- return type[e];
2691
- }
2692
-
2693
- throw new Error('Invalid enum value.');
2694
- },
2695
-
2696
- /**
2697
- * Converts enum integer value to the corresponding string, if it exists.
2698
- * @param {Object} type target enum type
2699
- * @param {Integer} e value to convert
2700
- * @returns {String} name of enum value if it exists
2701
- * @throws {Error} if the value is invalid
2702
- */
2703
- read: function(type, e) {
2704
- if (!type[byValue]) {
2705
- type[byValue] = [];
2706
- Object.entries(type).forEach(([key, value]) => {
2707
- type[byValue][value] = key;
2708
- });
2709
- }
2710
-
2711
- if (type[byValue][e] !== undefined) {
2712
- return type[byValue][e];
2713
- }
2714
-
2715
- throw new Error('Invalid enum value.');
2716
- }
2717
- };
2718
-
2719
2734
  // GPG4Browsers - An OpenPGP implementation in javascript
2720
2735
 
2721
2736
  var config = {
@@ -2932,7 +2947,7 @@ var openpgp = (function (exports) {
2932
2947
  * @memberof module:config
2933
2948
  * @property {String} versionString A version string to be included in armored messages
2934
2949
  */
2935
- versionString: 'OpenPGP.js 5.9.1-1',
2950
+ versionString: 'OpenPGP.js 5.10.2',
2936
2951
  /**
2937
2952
  * @memberof module:config
2938
2953
  * @property {String} commentString A comment string to be included in armored messages
@@ -3424,6 +3439,7 @@ var openpgp = (function (exports) {
3424
3439
  */
3425
3440
  read(bytes) {
3426
3441
  this.bytes = util.uint8ArrayToString(bytes.subarray(0, 8));
3442
+ return this.bytes.length;
3427
3443
  }
3428
3444
 
3429
3445
  /**
@@ -9970,7 +9986,7 @@ var openpgp = (function (exports) {
9970
9986
  if (util.getNodeCrypto() && nodeAlgos[algoName]) { // Node crypto library.
9971
9987
  return nodeEncrypt(algo, key, plaintext, iv);
9972
9988
  }
9973
- if (algoName.substr(0, 3) === 'aes') {
9989
+ if (util.isAES(algo)) {
9974
9990
  return aesEncrypt(algo, key, plaintext, iv, config);
9975
9991
  }
9976
9992
 
@@ -10013,7 +10029,7 @@ var openpgp = (function (exports) {
10013
10029
  if (util.getNodeCrypto() && nodeAlgos[algoName]) { // Node crypto library.
10014
10030
  return nodeDecrypt(algo, key, ciphertext, iv);
10015
10031
  }
10016
- if (algoName.substr(0, 3) === 'aes') {
10032
+ if (util.isAES(algo)) {
10017
10033
  return aesDecrypt(algo, key, ciphertext, iv);
10018
10034
  }
10019
10035
 
@@ -10032,7 +10048,7 @@ var openpgp = (function (exports) {
10032
10048
  let j = 0;
10033
10049
  while (chunk ? ct.length >= block_size : ct.length) {
10034
10050
  const decblock = cipherfn.encrypt(blockp);
10035
- blockp = ct;
10051
+ blockp = ct.subarray(0, block_size);
10036
10052
  for (i = 0; i < block_size; i++) {
10037
10053
  plaintext[j++] = blockp[i] ^ decblock[i];
10038
10054
  }
@@ -13601,7 +13617,7 @@ var openpgp = (function (exports) {
13601
13617
  }
13602
13618
  };
13603
13619
 
13604
- class Curve {
13620
+ class CurveWithOID {
13605
13621
  constructor(oidOrName, params) {
13606
13622
  try {
13607
13623
  if (util.isArray(oidOrName) ||
@@ -13678,7 +13694,7 @@ var openpgp = (function (exports) {
13678
13694
  async function generate$1(curve) {
13679
13695
  const BigInteger = await util.getBigInteger();
13680
13696
 
13681
- curve = new Curve(curve);
13697
+ curve = new CurveWithOID(curve);
13682
13698
  const keyPair = await curve.genKeyPair();
13683
13699
  const Q = new BigInteger(keyPair.publicKey).toUint8Array();
13684
13700
  const secret = new BigInteger(keyPair.privateKey).toUint8Array('be', curve.payloadSize);
@@ -13869,7 +13885,7 @@ var openpgp = (function (exports) {
13869
13885
  * @async
13870
13886
  */
13871
13887
  async function sign$1(oid, hashAlgo, message, publicKey, privateKey, hashed) {
13872
- const curve = new Curve(oid);
13888
+ const curve = new CurveWithOID(oid);
13873
13889
  if (message && !util.isStream(message)) {
13874
13890
  const keyPair = { publicKey, privateKey };
13875
13891
  switch (curve.type) {
@@ -13914,7 +13930,7 @@ var openpgp = (function (exports) {
13914
13930
  * @async
13915
13931
  */
13916
13932
  async function verify$1(oid, hashAlgo, signature, message, publicKey, hashed) {
13917
- const curve = new Curve(oid);
13933
+ const curve = new CurveWithOID(oid);
13918
13934
  if (message && !util.isStream(message)) {
13919
13935
  switch (curve.type) {
13920
13936
  case 'web':
@@ -13948,7 +13964,7 @@ var openpgp = (function (exports) {
13948
13964
  * @async
13949
13965
  */
13950
13966
  async function validateParams$2(oid, Q, d) {
13951
- const curve = new Curve(oid);
13967
+ const curve = new CurveWithOID(oid);
13952
13968
  // Reject curves x25519 and ed25519
13953
13969
  if (curve.keyType !== enums.publicKey.ecdsa) {
13954
13970
  return false;
@@ -14151,7 +14167,7 @@ var openpgp = (function (exports) {
14151
14167
  naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
14152
14168
 
14153
14169
  /**
14154
- * Sign a message using the provided key
14170
+ * Sign a message using the provided legacy EdDSA key
14155
14171
  * @param {module:type/oid} oid - Elliptic curve object identifier
14156
14172
  * @param {module:enums.hash} hashAlgo - Hash algorithm used to sign (must be sha256 or stronger)
14157
14173
  * @param {Uint8Array} message - Message to sign
@@ -14179,7 +14195,7 @@ var openpgp = (function (exports) {
14179
14195
  }
14180
14196
 
14181
14197
  /**
14182
- * Verifies if a signature is valid for a message
14198
+ * Verifies if a legacy EdDSA signature is valid for a message
14183
14199
  * @param {module:type/oid} oid - Elliptic curve object identifier
14184
14200
  * @param {module:enums.hash} hashAlgo - Hash algorithm used in the signature
14185
14201
  * @param {{r: Uint8Array,
@@ -14195,7 +14211,7 @@ var openpgp = (function (exports) {
14195
14211
  return naclFastLight.sign.detached.verify(hashed, signature, publicKey.subarray(1));
14196
14212
  }
14197
14213
  /**
14198
- * Validate EdDSA parameters
14214
+ * Validate legacy EdDSA parameters
14199
14215
  * @param {module:type/oid} oid - Elliptic curve object identifier
14200
14216
  * @param {Uint8Array} Q - EdDSA public point
14201
14217
  * @param {Uint8Array} k - EdDSA secret seed
@@ -14215,9 +14231,10 @@ var openpgp = (function (exports) {
14215
14231
  const { publicKey } = naclFastLight.sign.keyPair.fromSeed(k);
14216
14232
  const dG = new Uint8Array([0x40, ...publicKey]); // Add public key prefix
14217
14233
  return util.equalsUint8Array(Q, dG);
14234
+
14218
14235
  }
14219
14236
 
14220
- var eddsa = /*#__PURE__*/Object.freeze({
14237
+ var eddsa_legacy = /*#__PURE__*/Object.freeze({
14221
14238
  __proto__: null,
14222
14239
  sign: sign$2,
14223
14240
  verify: verify$2,
@@ -14226,6 +14243,113 @@ var openpgp = (function (exports) {
14226
14243
 
14227
14244
  // OpenPGP.js - An OpenPGP implementation in javascript
14228
14245
 
14246
+ naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
14247
+
14248
+ /**
14249
+ * Generate (non-legacy) EdDSA key
14250
+ * @param {module:enums.publicKey} algo - Algorithm identifier
14251
+ * @returns {Promise<{ A: Uint8Array, seed: Uint8Array }>}
14252
+ */
14253
+ async function generate$2(algo) {
14254
+ switch (algo) {
14255
+ case enums.publicKey.ed25519: {
14256
+ const seed = getRandomBytes(32);
14257
+ const { publicKey: A } = naclFastLight.sign.keyPair.fromSeed(seed);
14258
+ return { A, seed };
14259
+ }
14260
+ default:
14261
+ throw new Error('Unsupported EdDSA algorithm');
14262
+ }
14263
+ }
14264
+
14265
+ /**
14266
+ * Sign a message using the provided key
14267
+ * @param {module:enums.publicKey} algo - Algorithm identifier
14268
+ * @param {module:enums.hash} hashAlgo - Hash algorithm used to sign (must be sha256 or stronger)
14269
+ * @param {Uint8Array} message - Message to sign
14270
+ * @param {Uint8Array} publicKey - Public key
14271
+ * @param {Uint8Array} privateKey - Private key used to sign the message
14272
+ * @param {Uint8Array} hashed - The hashed message
14273
+ * @returns {Promise<{
14274
+ * RS: Uint8Array
14275
+ * }>} Signature of the message
14276
+ * @async
14277
+ */
14278
+ async function sign$3(algo, hashAlgo, message, publicKey, privateKey, hashed) {
14279
+ if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(enums.hash.sha256)) {
14280
+ // see https://tools.ietf.org/id/draft-ietf-openpgp-rfc4880bis-10.html#section-15-7.2
14281
+ throw new Error('Hash algorithm too weak: sha256 or stronger is required for EdDSA.');
14282
+ }
14283
+ switch (algo) {
14284
+ case enums.publicKey.ed25519: {
14285
+ const secretKey = util.concatUint8Array([privateKey, publicKey]);
14286
+ const signature = naclFastLight.sign.detached(hashed, secretKey);
14287
+ return { RS: signature };
14288
+ }
14289
+ case enums.publicKey.ed448:
14290
+ default:
14291
+ throw new Error('Unsupported EdDSA algorithm');
14292
+ }
14293
+
14294
+ }
14295
+
14296
+ /**
14297
+ * Verifies if a signature is valid for a message
14298
+ * @param {module:enums.publicKey} algo - Algorithm identifier
14299
+ * @param {module:enums.hash} hashAlgo - Hash algorithm used in the signature
14300
+ * @param {{ RS: Uint8Array }} signature Signature to verify the message
14301
+ * @param {Uint8Array} m - Message to verify
14302
+ * @param {Uint8Array} publicKey - Public key used to verify the message
14303
+ * @param {Uint8Array} hashed - The hashed message
14304
+ * @returns {Boolean}
14305
+ * @async
14306
+ */
14307
+ async function verify$3(algo, hashAlgo, { RS }, m, publicKey, hashed) {
14308
+ switch (algo) {
14309
+ case enums.publicKey.ed25519: {
14310
+ return naclFastLight.sign.detached.verify(hashed, RS, publicKey);
14311
+ }
14312
+ case enums.publicKey.ed448:
14313
+ default:
14314
+ throw new Error('Unsupported EdDSA algorithm');
14315
+ }
14316
+ }
14317
+ /**
14318
+ * Validate (non-legacy) EdDSA parameters
14319
+ * @param {module:enums.publicKey} algo - Algorithm identifier
14320
+ * @param {Uint8Array} A - EdDSA public point
14321
+ * @param {Uint8Array} seed - EdDSA secret seed
14322
+ * @param {Uint8Array} oid - (legacy only) EdDSA OID
14323
+ * @returns {Promise<Boolean>} Whether params are valid.
14324
+ * @async
14325
+ */
14326
+ async function validateParams$4(algo, A, seed) {
14327
+ switch (algo) {
14328
+ case enums.publicKey.ed25519: {
14329
+ /**
14330
+ * Derive public point A' from private key
14331
+ * and expect A == A'
14332
+ */
14333
+ const { publicKey } = naclFastLight.sign.keyPair.fromSeed(seed);
14334
+ return util.equalsUint8Array(A, publicKey);
14335
+ }
14336
+
14337
+ case enums.publicKey.ed448: // unsupported
14338
+ default:
14339
+ return false;
14340
+ }
14341
+ }
14342
+
14343
+ var eddsa = /*#__PURE__*/Object.freeze({
14344
+ __proto__: null,
14345
+ generate: generate$2,
14346
+ sign: sign$3,
14347
+ verify: verify$3,
14348
+ validateParams: validateParams$4
14349
+ });
14350
+
14351
+ // OpenPGP.js - An OpenPGP implementation in javascript
14352
+
14229
14353
  /**
14230
14354
  * AES key wrap
14231
14355
  * @function
@@ -14413,7 +14537,7 @@ var openpgp = (function (exports) {
14413
14537
  * @returns {Promise<Boolean>} Whether params are valid.
14414
14538
  * @async
14415
14539
  */
14416
- async function validateParams$4(oid, Q, d) {
14540
+ async function validateParams$5(oid, Q, d) {
14417
14541
  return validateStandardParams(enums.publicKey.ecdh, oid, Q, d);
14418
14542
  }
14419
14543
 
@@ -14455,7 +14579,7 @@ var openpgp = (function (exports) {
14455
14579
  /**
14456
14580
  * Generate ECDHE ephemeral key and secret from public key
14457
14581
  *
14458
- * @param {Curve} curve - Elliptic curve object
14582
+ * @param {CurveWithOID} curve - Elliptic curve object
14459
14583
  * @param {Uint8Array} Q - Recipient public key
14460
14584
  * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
14461
14585
  * @async
@@ -14498,7 +14622,7 @@ var openpgp = (function (exports) {
14498
14622
  async function encrypt$3(oid, kdfParams, data, Q, fingerprint) {
14499
14623
  const m = encode$1(data);
14500
14624
 
14501
- const curve = new Curve(oid);
14625
+ const curve = new CurveWithOID(oid);
14502
14626
  const { publicKey, sharedKey } = await genPublicEphemeralKey(curve, Q);
14503
14627
  const param = buildEcdhParam(enums.publicKey.ecdh, oid, kdfParams, fingerprint);
14504
14628
  const { keySize } = getCipher(kdfParams.cipher);
@@ -14510,7 +14634,7 @@ var openpgp = (function (exports) {
14510
14634
  /**
14511
14635
  * Generate ECDHE secret from private key and public part of ephemeral key
14512
14636
  *
14513
- * @param {Curve} curve - Elliptic curve object
14637
+ * @param {CurveWithOID} curve - Elliptic curve object
14514
14638
  * @param {Uint8Array} V - Public part of ephemeral key
14515
14639
  * @param {Uint8Array} Q - Recipient public key
14516
14640
  * @param {Uint8Array} d - Recipient private key
@@ -14558,7 +14682,7 @@ var openpgp = (function (exports) {
14558
14682
  * @async
14559
14683
  */
14560
14684
  async function decrypt$3(oid, kdfParams, V, C, Q, d, fingerprint) {
14561
- const curve = new Curve(oid);
14685
+ const curve = new CurveWithOID(oid);
14562
14686
  const { sharedKey } = await genPrivateEphemeralKey(curve, V, Q, d);
14563
14687
  const param = buildEcdhParam(enums.publicKey.ecdh, oid, kdfParams, fingerprint);
14564
14688
  const { keySize } = getCipher(kdfParams.cipher);
@@ -14578,7 +14702,7 @@ var openpgp = (function (exports) {
14578
14702
  /**
14579
14703
  * Generate ECDHE secret from private key and public part of ephemeral key using webCrypto
14580
14704
  *
14581
- * @param {Curve} curve - Elliptic curve object
14705
+ * @param {CurveWithOID} curve - Elliptic curve object
14582
14706
  * @param {Uint8Array} V - Public part of ephemeral key
14583
14707
  * @param {Uint8Array} Q - Recipient public key
14584
14708
  * @param {Uint8Array} d - Recipient private key
@@ -14631,7 +14755,7 @@ var openpgp = (function (exports) {
14631
14755
  /**
14632
14756
  * Generate ECDHE ephemeral key and secret from public key using webCrypto
14633
14757
  *
14634
- * @param {Curve} curve - Elliptic curve object
14758
+ * @param {CurveWithOID} curve - Elliptic curve object
14635
14759
  * @param {Uint8Array} Q - Recipient public key
14636
14760
  * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
14637
14761
  * @async
@@ -14679,7 +14803,7 @@ var openpgp = (function (exports) {
14679
14803
  /**
14680
14804
  * Generate ECDHE secret from private key and public part of ephemeral key using indutny/elliptic
14681
14805
  *
14682
- * @param {Curve} curve - Elliptic curve object
14806
+ * @param {CurveWithOID} curve - Elliptic curve object
14683
14807
  * @param {Uint8Array} V - Public part of ephemeral key
14684
14808
  * @param {Uint8Array} d - Recipient private key
14685
14809
  * @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>}
@@ -14699,7 +14823,7 @@ var openpgp = (function (exports) {
14699
14823
  /**
14700
14824
  * Generate ECDHE ephemeral key and secret from public key using indutny/elliptic
14701
14825
  *
14702
- * @param {Curve} curve - Elliptic curve object
14826
+ * @param {CurveWithOID} curve - Elliptic curve object
14703
14827
  * @param {Uint8Array} Q - Recipient public key
14704
14828
  * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
14705
14829
  * @async
@@ -14719,7 +14843,7 @@ var openpgp = (function (exports) {
14719
14843
  /**
14720
14844
  * Generate ECDHE secret from private key and public part of ephemeral key using nodeCrypto
14721
14845
  *
14722
- * @param {Curve} curve - Elliptic curve object
14846
+ * @param {CurveWithOID} curve - Elliptic curve object
14723
14847
  * @param {Uint8Array} V - Public part of ephemeral key
14724
14848
  * @param {Uint8Array} d - Recipient private key
14725
14849
  * @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>}
@@ -14736,7 +14860,7 @@ var openpgp = (function (exports) {
14736
14860
  /**
14737
14861
  * Generate ECDHE ephemeral key and secret from public key using nodeCrypto
14738
14862
  *
14739
- * @param {Curve} curve - Elliptic curve object
14863
+ * @param {CurveWithOID} curve - Elliptic curve object
14740
14864
  * @param {Uint8Array} Q - Recipient public key
14741
14865
  * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
14742
14866
  * @async
@@ -14751,18 +14875,204 @@ var openpgp = (function (exports) {
14751
14875
 
14752
14876
  var ecdh = /*#__PURE__*/Object.freeze({
14753
14877
  __proto__: null,
14754
- validateParams: validateParams$4,
14878
+ validateParams: validateParams$5,
14755
14879
  encrypt: encrypt$3,
14756
14880
  decrypt: decrypt$3
14757
14881
  });
14758
14882
 
14883
+ /**
14884
+ * @fileoverview This module implements HKDF using either the WebCrypto API or Node.js' crypto API.
14885
+ * @module crypto/hkdf
14886
+ * @private
14887
+ */
14888
+
14889
+ const webCrypto$9 = util.getWebCrypto();
14890
+ const nodeCrypto$a = util.getNodeCrypto();
14891
+ const nodeSubtleCrypto = nodeCrypto$a && nodeCrypto$a.webcrypto && nodeCrypto$a.webcrypto.subtle;
14892
+
14893
+ async function HKDF(hashAlgo, inputKey, salt, info, outLen) {
14894
+ const hash = enums.read(enums.webHash, hashAlgo);
14895
+ if (!hash) throw new Error('Hash algo not supported with HKDF');
14896
+
14897
+ if (webCrypto$9 || nodeSubtleCrypto) {
14898
+ const crypto = webCrypto$9 || nodeSubtleCrypto;
14899
+ const importedKey = await crypto.importKey('raw', inputKey, 'HKDF', false, ['deriveBits']);
14900
+ const bits = await crypto.deriveBits({ name: 'HKDF', hash, salt, info }, importedKey, outLen * 8);
14901
+ return new Uint8Array(bits);
14902
+ }
14903
+
14904
+ if (nodeCrypto$a) {
14905
+ const hashAlgoName = enums.read(enums.hash, hashAlgo);
14906
+ // Node-only HKDF implementation based on https://www.rfc-editor.org/rfc/rfc5869
14907
+
14908
+ const computeHMAC = (hmacKey, hmacMessage) => nodeCrypto$a.createHmac(hashAlgoName, hmacKey).update(hmacMessage).digest();
14909
+ // Step 1: Extract
14910
+ // PRK = HMAC-Hash(salt, IKM)
14911
+ const pseudoRandomKey = computeHMAC(salt, inputKey);
14912
+
14913
+ const hashLen = pseudoRandomKey.length;
14914
+
14915
+ // Step 2: Expand
14916
+ // HKDF-Expand(PRK, info, L) -> OKM
14917
+ const n = Math.ceil(outLen / hashLen);
14918
+ const outputKeyingMaterial = new Uint8Array(n * hashLen);
14919
+
14920
+ // HMAC input buffer updated at each iteration
14921
+ const roundInput = new Uint8Array(hashLen + info.length + 1);
14922
+ // T_i and last byte are updated at each iteration, but `info` remains constant
14923
+ roundInput.set(info, hashLen);
14924
+
14925
+ for (let i = 0; i < n; i++) {
14926
+ // T(0) = empty string (zero length)
14927
+ // T(i) = HMAC-Hash(PRK, T(i-1) | info | i)
14928
+ roundInput[roundInput.length - 1] = i + 1;
14929
+ // t = T(i+1)
14930
+ const t = computeHMAC(pseudoRandomKey, i > 0 ? roundInput : roundInput.subarray(hashLen));
14931
+ roundInput.set(t, 0);
14932
+
14933
+ outputKeyingMaterial.set(t, i * hashLen);
14934
+ }
14935
+
14936
+ return outputKeyingMaterial.subarray(0, outLen);
14937
+ }
14938
+
14939
+ throw new Error('No HKDF implementation available');
14940
+ }
14941
+
14942
+ /**
14943
+ * @fileoverview Key encryption and decryption for RFC 6637 ECDH
14944
+ * @module crypto/public_key/elliptic/ecdh
14945
+ * @private
14946
+ */
14947
+
14948
+ const HKDF_INFO = {
14949
+ x25519: util.encodeUTF8('OpenPGP X25519')
14950
+ };
14951
+
14952
+ /**
14953
+ * Generate ECDH key for Montgomery curves
14954
+ * @param {module:enums.publicKey} algo - Algorithm identifier
14955
+ * @returns {Promise<{ A: Uint8Array, k: Uint8Array }>}
14956
+ */
14957
+ async function generate$3(algo) {
14958
+ switch (algo) {
14959
+ case enums.publicKey.x25519: {
14960
+ // k stays in little-endian, unlike legacy ECDH over curve25519
14961
+ const k = getRandomBytes(32);
14962
+ k[0] &= 248;
14963
+ k[31] = (k[31] & 127) | 64;
14964
+ const { publicKey: A } = naclFastLight.box.keyPair.fromSecretKey(k);
14965
+ return { A, k };
14966
+ }
14967
+ default:
14968
+ throw new Error('Unsupported ECDH algorithm');
14969
+ }
14970
+ }
14971
+
14972
+ /**
14973
+ * Validate ECDH parameters
14974
+ * @param {module:enums.publicKey} algo - Algorithm identifier
14975
+ * @param {Uint8Array} A - ECDH public point
14976
+ * @param {Uint8Array} k - ECDH secret scalar
14977
+ * @returns {Promise<Boolean>} Whether params are valid.
14978
+ * @async
14979
+ */
14980
+ async function validateParams$6(algo, A, k) {
14981
+ switch (algo) {
14982
+ case enums.publicKey.x25519: {
14983
+ /**
14984
+ * Derive public point A' from private key
14985
+ * and expect A == A'
14986
+ */
14987
+ const { publicKey } = naclFastLight.box.keyPair.fromSecretKey(k);
14988
+ return util.equalsUint8Array(A, publicKey);
14989
+ }
14990
+
14991
+ default:
14992
+ return false;
14993
+ }
14994
+ }
14995
+
14996
+ /**
14997
+ * Wrap and encrypt a session key
14998
+ *
14999
+ * @param {module:enums.publicKey} algo - Algorithm identifier
15000
+ * @param {Uint8Array} data - session key data to be encrypted
15001
+ * @param {Uint8Array} recipientA - Recipient public key (K_B)
15002
+ * @returns {Promise<{
15003
+ * ephemeralPublicKey: Uint8Array,
15004
+ * wrappedKey: Uint8Array
15005
+ * }>} ephemeral public key (K_A) and encrypted key
15006
+ * @async
15007
+ */
15008
+ async function encrypt$4(algo, data, recipientA) {
15009
+ switch (algo) {
15010
+ case enums.publicKey.x25519: {
15011
+ const ephemeralSecretKey = getRandomBytes(32);
15012
+ const sharedSecret = naclFastLight.scalarMult(ephemeralSecretKey, recipientA);
15013
+ const { publicKey: ephemeralPublicKey } = naclFastLight.box.keyPair.fromSecretKey(ephemeralSecretKey);
15014
+ const hkdfInput = util.concatUint8Array([
15015
+ ephemeralPublicKey,
15016
+ recipientA,
15017
+ sharedSecret
15018
+ ]);
15019
+ const { keySize } = getCipher(enums.symmetric.aes128);
15020
+ const encryptionKey = await HKDF(enums.hash.sha256, hkdfInput, new Uint8Array(), HKDF_INFO.x25519, keySize);
15021
+ const wrappedKey = wrap(encryptionKey, data);
15022
+ return { ephemeralPublicKey, wrappedKey };
15023
+ }
15024
+
15025
+ default:
15026
+ throw new Error('Unsupported ECDH algorithm');
15027
+ }
15028
+ }
15029
+
15030
+ /**
15031
+ * Decrypt and unwrap the session key
15032
+ *
15033
+ * @param {module:enums.publicKey} algo - Algorithm identifier
15034
+ * @param {Uint8Array} ephemeralPublicKey - (K_A)
15035
+ * @param {Uint8Array} wrappedKey,
15036
+ * @param {Uint8Array} A - Recipient public key (K_b), needed for KDF
15037
+ * @param {Uint8Array} k - Recipient secret key (b)
15038
+ * @returns {Promise<Uint8Array>} decrypted session key data
15039
+ * @async
15040
+ */
15041
+ async function decrypt$4(algo, ephemeralPublicKey, wrappedKey, A, k) {
15042
+ switch (algo) {
15043
+ case enums.publicKey.x25519: {
15044
+ const sharedSecret = naclFastLight.scalarMult(k, ephemeralPublicKey);
15045
+ const hkdfInput = util.concatUint8Array([
15046
+ ephemeralPublicKey,
15047
+ A,
15048
+ sharedSecret
15049
+ ]);
15050
+ const { keySize } = getCipher(enums.symmetric.aes128);
15051
+ const encryptionKey = await HKDF(enums.hash.sha256, hkdfInput, new Uint8Array(), HKDF_INFO.x25519, keySize);
15052
+ return unwrap(encryptionKey, wrappedKey);
15053
+ }
15054
+ default:
15055
+ throw new Error('Unsupported ECDH algorithm');
15056
+ }
15057
+ }
15058
+
15059
+ var ecdh_x = /*#__PURE__*/Object.freeze({
15060
+ __proto__: null,
15061
+ generate: generate$3,
15062
+ validateParams: validateParams$6,
15063
+ encrypt: encrypt$4,
15064
+ decrypt: decrypt$4
15065
+ });
15066
+
14759
15067
  // OpenPGP.js - An OpenPGP implementation in javascript
14760
15068
 
14761
15069
  var elliptic = /*#__PURE__*/Object.freeze({
14762
15070
  __proto__: null,
14763
- Curve: Curve,
15071
+ CurveWithOID: CurveWithOID,
14764
15072
  ecdh: ecdh,
15073
+ ecdhX: ecdh_x,
14765
15074
  ecdsa: ecdsa,
15075
+ eddsaLegacy: eddsa_legacy,
14766
15076
  eddsa: eddsa,
14767
15077
  generate: generate$1,
14768
15078
  getPreferredHashAlgo: getPreferredHashAlgo
@@ -14787,7 +15097,7 @@ var openpgp = (function (exports) {
14787
15097
  * @returns {Promise<{ r: Uint8Array, s: Uint8Array }>}
14788
15098
  * @async
14789
15099
  */
14790
- async function sign$3(hashAlgo, hashed, g, p, q, x) {
15100
+ async function sign$4(hashAlgo, hashed, g, p, q, x) {
14791
15101
  const BigInteger = await util.getBigInteger();
14792
15102
  const one = new BigInteger(1);
14793
15103
  p = new BigInteger(p);
@@ -14846,7 +15156,7 @@ var openpgp = (function (exports) {
14846
15156
  * @returns {boolean}
14847
15157
  * @async
14848
15158
  */
14849
- async function verify$3(hashAlgo, r, s, hashed, g, p, q, y) {
15159
+ async function verify$4(hashAlgo, r, s, hashed, g, p, q, y) {
14850
15160
  const BigInteger = await util.getBigInteger();
14851
15161
  const zero = new BigInteger(0);
14852
15162
  r = new BigInteger(r);
@@ -14889,7 +15199,7 @@ var openpgp = (function (exports) {
14889
15199
  * @returns {Promise<Boolean>} Whether params are valid.
14890
15200
  * @async
14891
15201
  */
14892
- async function validateParams$5(p, q, g, y, x) {
15202
+ async function validateParams$7(p, q, g, y, x) {
14893
15203
  const BigInteger = await util.getBigInteger();
14894
15204
  p = new BigInteger(p);
14895
15205
  q = new BigInteger(q);
@@ -14944,9 +15254,9 @@ var openpgp = (function (exports) {
14944
15254
 
14945
15255
  var dsa = /*#__PURE__*/Object.freeze({
14946
15256
  __proto__: null,
14947
- sign: sign$3,
14948
- verify: verify$3,
14949
- validateParams: validateParams$5
15257
+ sign: sign$4,
15258
+ verify: verify$4,
15259
+ validateParams: validateParams$7
14950
15260
  });
14951
15261
 
14952
15262
  /**
@@ -15082,10 +15392,11 @@ var openpgp = (function (exports) {
15082
15392
  const s = util.readMPI(signature.subarray(read));
15083
15393
  return { r, s };
15084
15394
  }
15085
- // Algorithm-Specific Fields for EdDSA signatures:
15395
+ // Algorithm-Specific Fields for legacy EdDSA signatures:
15086
15396
  // - MPI of an EC point r.
15087
15397
  // - EdDSA value s, in MPI, in the little endian representation
15088
- case enums.publicKey.eddsa: {
15398
+ case enums.publicKey.eddsa:
15399
+ case enums.publicKey.ed25519Legacy: {
15089
15400
  // When parsing little-endian MPI data, we always need to left-pad it, as done with big-endian values:
15090
15401
  // https://www.ietf.org/archive/id/draft-ietf-openpgp-rfc4880bis-10.html#section-3.2-9
15091
15402
  let r = util.readMPI(signature.subarray(read)); read += r.length + 2;
@@ -15094,7 +15405,12 @@ var openpgp = (function (exports) {
15094
15405
  s = util.leftPad(s, 32);
15095
15406
  return { r, s };
15096
15407
  }
15097
-
15408
+ // Algorithm-Specific Fields for Ed25519 signatures:
15409
+ // - 64 octets of the native signature
15410
+ case enums.publicKey.ed25519: {
15411
+ const RS = signature.subarray(read, read + 64); read += RS.length;
15412
+ return { RS };
15413
+ }
15098
15414
  case enums.publicKey.hmac: {
15099
15415
  const mac = new ShortByteString(); mac.read(signature.subarray(read));
15100
15416
  return { mac };
@@ -15119,7 +15435,7 @@ var openpgp = (function (exports) {
15119
15435
  * @returns {Promise<Boolean>} True if signature is valid.
15120
15436
  * @async
15121
15437
  */
15122
- async function verify$4(algo, hashAlgo, signature, publicParams, privateParams, data, hashed) {
15438
+ async function verify$5(algo, hashAlgo, signature, publicParams, privateParams, data, hashed) {
15123
15439
  switch (algo) {
15124
15440
  case enums.publicKey.rsaEncryptSign:
15125
15441
  case enums.publicKey.rsaEncrypt:
@@ -15135,16 +15451,21 @@ var openpgp = (function (exports) {
15135
15451
  }
15136
15452
  case enums.publicKey.ecdsa: {
15137
15453
  const { oid, Q } = publicParams;
15138
- const curveSize = new publicKey.elliptic.Curve(oid).payloadSize;
15454
+ const curveSize = new publicKey.elliptic.CurveWithOID(oid).payloadSize;
15139
15455
  // padding needed for webcrypto
15140
15456
  const r = util.leftPad(signature.r, curveSize);
15141
15457
  const s = util.leftPad(signature.s, curveSize);
15142
15458
  return publicKey.elliptic.ecdsa.verify(oid, hashAlgo, { r, s }, data, Q, hashed);
15143
15459
  }
15144
- case enums.publicKey.eddsa: {
15460
+ case enums.publicKey.eddsa:
15461
+ case enums.publicKey.ed25519Legacy: {
15145
15462
  const { oid, Q } = publicParams;
15146
15463
  // signature already padded on parsing
15147
- return publicKey.elliptic.eddsa.verify(oid, hashAlgo, signature, data, Q, hashed);
15464
+ return publicKey.elliptic.eddsaLegacy.verify(oid, hashAlgo, signature, data, Q, hashed);
15465
+ }
15466
+ case enums.publicKey.ed25519: {
15467
+ const { A } = publicParams;
15468
+ return publicKey.elliptic.eddsa.verify(algo, hashAlgo, signature, data, A, hashed);
15148
15469
  }
15149
15470
  case enums.publicKey.hmac: {
15150
15471
  if (!privateParams) {
@@ -15174,7 +15495,7 @@ var openpgp = (function (exports) {
15174
15495
  * @returns {Promise<Object>} Signature Object containing named signature parameters.
15175
15496
  * @async
15176
15497
  */
15177
- async function sign$4(algo, hashAlgo, publicKeyParams, privateKeyParams, data, hashed) {
15498
+ async function sign$5(algo, hashAlgo, publicKeyParams, privateKeyParams, data, hashed) {
15178
15499
  if (!publicKeyParams || !privateKeyParams) {
15179
15500
  throw new Error('Missing key parameters');
15180
15501
  }
@@ -15200,10 +15521,16 @@ var openpgp = (function (exports) {
15200
15521
  const { d } = privateKeyParams;
15201
15522
  return publicKey.elliptic.ecdsa.sign(oid, hashAlgo, data, Q, d, hashed);
15202
15523
  }
15203
- case enums.publicKey.eddsa: {
15524
+ case enums.publicKey.eddsa:
15525
+ case enums.publicKey.ed25519Legacy: {
15204
15526
  const { oid, Q } = publicKeyParams;
15205
15527
  const { seed } = privateKeyParams;
15206
- return publicKey.elliptic.eddsa.sign(oid, hashAlgo, data, Q, seed, hashed);
15528
+ return publicKey.elliptic.eddsaLegacy.sign(oid, hashAlgo, data, Q, seed, hashed);
15529
+ }
15530
+ case enums.publicKey.ed25519: {
15531
+ const { A } = publicKeyParams;
15532
+ const { seed } = privateKeyParams;
15533
+ return publicKey.elliptic.eddsa.sign(algo, hashAlgo, data, A, seed, hashed);
15207
15534
  }
15208
15535
  case enums.publicKey.hmac: {
15209
15536
  const { cipher: algo } = publicKeyParams;
@@ -15219,34 +15546,31 @@ var openpgp = (function (exports) {
15219
15546
  var signature = /*#__PURE__*/Object.freeze({
15220
15547
  __proto__: null,
15221
15548
  parseSignatureParams: parseSignatureParams,
15222
- verify: verify$4,
15223
- sign: sign$4
15549
+ verify: verify$5,
15550
+ sign: sign$5
15224
15551
  });
15225
15552
 
15226
15553
  // OpenPGP.js - An OpenPGP implementation in javascript
15227
15554
 
15228
15555
  class ECDHSymmetricKey {
15229
15556
  constructor(data) {
15230
- if (typeof data === 'undefined') {
15231
- data = new Uint8Array([]);
15232
- } else if (util.isString(data)) {
15233
- data = util.stringToUint8Array(data);
15234
- } else {
15235
- data = new Uint8Array(data);
15557
+ if (data) {
15558
+ this.data = data;
15236
15559
  }
15237
- this.data = data;
15238
15560
  }
15239
15561
 
15240
15562
  /**
15241
- * Read an ECDHSymmetricKey from an Uint8Array
15242
- * @param {Uint8Array} input - Where to read the encoded symmetric key from
15563
+ * Read an ECDHSymmetricKey from an Uint8Array:
15564
+ * - 1 octect for the length `l`
15565
+ * - `l` octects of encoded session key data
15566
+ * @param {Uint8Array} bytes
15243
15567
  * @returns {Number} Number of read bytes.
15244
15568
  */
15245
- read(input) {
15246
- if (input.length >= 1) {
15247
- const length = input[0];
15248
- if (input.length >= 1 + length) {
15249
- this.data = input.subarray(1, 1 + length);
15569
+ read(bytes) {
15570
+ if (bytes.length >= 1) {
15571
+ const length = bytes[0];
15572
+ if (bytes.length >= 1 + length) {
15573
+ this.data = bytes.subarray(1, 1 + length);
15250
15574
  return 1 + this.data.length;
15251
15575
  }
15252
15576
  }
@@ -15255,7 +15579,7 @@ var openpgp = (function (exports) {
15255
15579
 
15256
15580
  /**
15257
15581
  * Write an ECDHSymmetricKey as an Uint8Array
15258
- * @returns {Uint8Array} An array containing the value
15582
+ * @returns {Uint8Array} Serialised data
15259
15583
  */
15260
15584
  write() {
15261
15585
  return util.concatUint8Array([new Uint8Array([this.data.length]), this.data]);
@@ -15295,6 +15619,9 @@ var openpgp = (function (exports) {
15295
15619
  * @returns {Number} Number of read bytes.
15296
15620
  */
15297
15621
  read(input) {
15622
+ if (input.length < 4 || (input[1] !== 1 && input[1] !== VERSION_FORWARDING)) {
15623
+ throw new UnsupportedError('Cannot read KDFParams');
15624
+ }
15298
15625
  const totalBytes = input[0];
15299
15626
  this.version = input[1];
15300
15627
  this.hash = input[2];
@@ -15382,12 +15709,57 @@ var openpgp = (function (exports) {
15382
15709
  const SymAlgoEnum = type_enum(enums.symmetric);
15383
15710
  const HashEnum = type_enum(enums.hash);
15384
15711
 
15712
+ /**
15713
+ * Encoded symmetric key for x25519 and x448
15714
+ * The payload format varies for v3 and v6 PKESK:
15715
+ * the former includes an algorithm byte preceeding the encrypted session key.
15716
+ *
15717
+ * @module type/x25519x448_symkey
15718
+ */
15719
+
15720
+ class ECDHXSymmetricKey {
15721
+ static fromObject({ wrappedKey, algorithm }) {
15722
+ const instance = new ECDHXSymmetricKey();
15723
+ instance.wrappedKey = wrappedKey;
15724
+ instance.algorithm = algorithm;
15725
+ return instance;
15726
+ }
15727
+
15728
+ /**
15729
+ * - 1 octect for the length `l`
15730
+ * - `l` octects of encoded session key data (with optional leading algorithm byte)
15731
+ * @param {Uint8Array} bytes
15732
+ * @returns {Number} Number of read bytes.
15733
+ */
15734
+ read(bytes) {
15735
+ let read = 0;
15736
+ let followLength = bytes[read++];
15737
+ this.algorithm = followLength % 2 ? bytes[read++] : null; // session key size is always even
15738
+ followLength -= followLength % 2;
15739
+ this.wrappedKey = bytes.subarray(read, read + followLength); read += followLength;
15740
+ }
15741
+
15742
+ /**
15743
+ * Write an MontgomerySymmetricKey as an Uint8Array
15744
+ * @returns {Uint8Array} Serialised data
15745
+ */
15746
+ write() {
15747
+ return util.concatUint8Array([
15748
+ this.algorithm ?
15749
+ new Uint8Array([this.wrappedKey.length + 1, this.algorithm]) :
15750
+ new Uint8Array([this.wrappedKey.length]),
15751
+ this.wrappedKey
15752
+ ]);
15753
+ }
15754
+ }
15755
+
15385
15756
  // GPG4Browsers - An OpenPGP implementation in javascript
15386
15757
 
15387
15758
  /**
15388
15759
  * Encrypts data using specified algorithm and public key parameters.
15389
15760
  * See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1} for public key algorithms.
15390
- * @param {module:enums.publicKey} algo - Public key algorithm
15761
+ * @param {module:enums.publicKey} keyAlgo - Public key algorithm
15762
+ * @param {module:enums.symmetric} symmetricAlgo - Cipher algorithm
15391
15763
  * @param {Object} publicParams - Algorithm-specific public key parameters
15392
15764
  * @param {Object} privateParams - Algorithm-specific private key parameters
15393
15765
  * @param {Uint8Array} data - Data to be encrypted
@@ -15395,8 +15767,8 @@ var openpgp = (function (exports) {
15395
15767
  * @returns {Promise<Object>} Encrypted session key parameters.
15396
15768
  * @async
15397
15769
  */
15398
- async function publicKeyEncrypt(algo, publicParams, privateParams, data, fingerprint) {
15399
- switch (algo) {
15770
+ async function publicKeyEncrypt(keyAlgo, symmetricAlgo, publicParams, privateParams, data, fingerprint) {
15771
+ switch (keyAlgo) {
15400
15772
  case enums.publicKey.rsaEncrypt:
15401
15773
  case enums.publicKey.rsaEncryptSign: {
15402
15774
  const { n, e } = publicParams;
@@ -15413,6 +15785,17 @@ var openpgp = (function (exports) {
15413
15785
  oid, kdfParams, data, Q, fingerprint);
15414
15786
  return { V, C: new ECDHSymmetricKey(C) };
15415
15787
  }
15788
+ case enums.publicKey.x25519: {
15789
+ if (!util.isAES(symmetricAlgo)) {
15790
+ // see https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/276
15791
+ throw new Error('X25519 keys can only encrypt AES session keys');
15792
+ }
15793
+ const { A } = publicParams;
15794
+ const { ephemeralPublicKey, wrappedKey } = await publicKey.elliptic.ecdhX.encrypt(
15795
+ keyAlgo, data, A);
15796
+ const C = ECDHXSymmetricKey.fromObject({ algorithm: symmetricAlgo, wrappedKey });
15797
+ return { ephemeralPublicKey, C };
15798
+ }
15416
15799
  case enums.publicKey.aead: {
15417
15800
  if (!privateParams) {
15418
15801
  throw new Error('Cannot encrypt with symmetric key missing private parameters');
@@ -15469,6 +15852,16 @@ var openpgp = (function (exports) {
15469
15852
  return publicKey.elliptic.ecdh.decrypt(
15470
15853
  oid, kdfParams, V, C.data, Q, d, fingerprint);
15471
15854
  }
15855
+ case enums.publicKey.x25519: {
15856
+ const { A } = publicKeyParams;
15857
+ const { k } = privateKeyParams;
15858
+ const { ephemeralPublicKey, C } = sessionKeyParams;
15859
+ if (!util.isAES(C.algorithm)) {
15860
+ throw new Error('AES session key expected');
15861
+ }
15862
+ return publicKey.elliptic.ecdhX.decrypt(
15863
+ algo, ephemeralPublicKey, C.wrappedKey, A, k);
15864
+ }
15472
15865
  case enums.publicKey.aead: {
15473
15866
  const { cipher: algo } = publicKeyParams;
15474
15867
  const algoValue = algo.getValue();
@@ -15520,7 +15913,8 @@ var openpgp = (function (exports) {
15520
15913
  const Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
15521
15914
  return { read: read, publicParams: { oid, Q } };
15522
15915
  }
15523
- case enums.publicKey.eddsa: {
15916
+ case enums.publicKey.eddsa:
15917
+ case enums.publicKey.ed25519Legacy: {
15524
15918
  const oid = new OID(); read += oid.read(bytes);
15525
15919
  checkSupportedCurve(oid);
15526
15920
  let Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
@@ -15534,6 +15928,11 @@ var openpgp = (function (exports) {
15534
15928
  const kdfParams = new KDFParams(); read += kdfParams.read(bytes.subarray(read));
15535
15929
  return { read: read, publicParams: { oid, Q, kdfParams } };
15536
15930
  }
15931
+ case enums.publicKey.ed25519:
15932
+ case enums.publicKey.x25519: {
15933
+ const A = bytes.subarray(read, read + 32); read += A.length;
15934
+ return { read, publicParams: { A } };
15935
+ }
15537
15936
  case enums.publicKey.hmac:
15538
15937
  case enums.publicKey.aead: {
15539
15938
  const algo = new SymAlgoEnum(); read += algo.read(bytes);
@@ -15572,17 +15971,26 @@ var openpgp = (function (exports) {
15572
15971
  }
15573
15972
  case enums.publicKey.ecdsa:
15574
15973
  case enums.publicKey.ecdh: {
15575
- const curve = new Curve(publicParams.oid);
15974
+ const curve = new CurveWithOID(publicParams.oid);
15576
15975
  let d = util.readMPI(bytes.subarray(read)); read += d.length + 2;
15577
15976
  d = util.leftPad(d, curve.payloadSize);
15578
15977
  return { read, privateParams: { d } };
15579
15978
  }
15580
- case enums.publicKey.eddsa: {
15581
- const curve = new Curve(publicParams.oid);
15979
+ case enums.publicKey.eddsa:
15980
+ case enums.publicKey.ed25519Legacy: {
15981
+ const curve = new CurveWithOID(publicParams.oid);
15582
15982
  let seed = util.readMPI(bytes.subarray(read)); read += seed.length + 2;
15583
15983
  seed = util.leftPad(seed, curve.payloadSize);
15584
15984
  return { read, privateParams: { seed } };
15585
15985
  }
15986
+ case enums.publicKey.ed25519: {
15987
+ const seed = bytes.subarray(read, read + 32); read += seed.length;
15988
+ return { read, privateParams: { seed } };
15989
+ }
15990
+ case enums.publicKey.x25519: {
15991
+ const k = bytes.subarray(read, read + 32); read += k.length;
15992
+ return { read, privateParams: { k } };
15993
+ }
15586
15994
  case enums.publicKey.hmac: {
15587
15995
  const { cipher: algo } = publicParams;
15588
15996
  const keySize = hash.getHashByteLength(algo.getValue());
@@ -15634,6 +16042,16 @@ var openpgp = (function (exports) {
15634
16042
  const C = new ECDHSymmetricKey(); C.read(bytes.subarray(read));
15635
16043
  return { V, C };
15636
16044
  }
16045
+ // Algorithm-Specific Fields for X25519 encrypted session keys:
16046
+ // - 32 octets representing an ephemeral X25519 public key.
16047
+ // - A one-octet size of the following fields.
16048
+ // - The one-octet algorithm identifier, if it was passed (in the case of a v3 PKESK packet).
16049
+ // - The encrypted session key.
16050
+ case enums.publicKey.x25519: {
16051
+ const ephemeralPublicKey = bytes.subarray(read, read + 32); read += ephemeralPublicKey.length;
16052
+ const C = new ECDHXSymmetricKey(); C.read(bytes.subarray(read));
16053
+ return { ephemeralPublicKey, C };
16054
+ }
15637
16055
  // Algorithm-Specific Fields for symmetric AEAD encryption:
15638
16056
  // - AEAD algorithm
15639
16057
  // - Starting initialization vector
@@ -15660,22 +16078,13 @@ var openpgp = (function (exports) {
15660
16078
  * @returns {Uint8Array} The array containing the MPIs.
15661
16079
  */
15662
16080
  function serializeParams(algo, params) {
15663
- let orderedParams;
15664
- switch (algo) {
15665
- case enums.publicKey.hmac:
15666
- case enums.publicKey.aead: {
15667
- orderedParams = Object.keys(params).map(name => {
15668
- const param = params[name];
15669
- return util.isUint8Array(param) ? param : param.write();
15670
- });
15671
- break;
15672
- }
15673
- default:
15674
- orderedParams = Object.keys(params).map(name => {
15675
- const param = params[name];
15676
- return util.isUint8Array(param) ? util.uint8ArrayToMPI(param) : param.write();
15677
- });
15678
- }
16081
+ // Some algorithms do not rely on MPIs to store the binary params
16082
+ const algosWithNativeRepresentation = new Set([enums.publicKey.ed25519, enums.publicKey.x25519, enums.publicKey.aead, enums.publicKey.hmac]);
16083
+ const orderedParams = Object.keys(params).map(name => {
16084
+ const param = params[name];
16085
+ if (!util.isUint8Array(param)) return param.write();
16086
+ return algosWithNativeRepresentation.has(algo) ? param : util.uint8ArrayToMPI(param);
16087
+ });
15679
16088
  return util.concatUint8Array(orderedParams);
15680
16089
  }
15681
16090
 
@@ -15704,6 +16113,7 @@ var openpgp = (function (exports) {
15704
16113
  publicParams: { oid: new OID(oid), Q }
15705
16114
  }));
15706
16115
  case enums.publicKey.eddsa:
16116
+ case enums.publicKey.ed25519Legacy:
15707
16117
  return publicKey.elliptic.generate(oid).then(({ oid, Q, secret }) => ({
15708
16118
  privateParams: { seed: secret },
15709
16119
  publicParams: { oid: new OID(oid), Q }
@@ -15717,6 +16127,16 @@ var openpgp = (function (exports) {
15717
16127
  kdfParams: new KDFParams({ hash, cipher })
15718
16128
  }
15719
16129
  }));
16130
+ case enums.publicKey.ed25519:
16131
+ return publicKey.elliptic.eddsa.generate(algo).then(({ A, seed }) => ({
16132
+ privateParams: { seed },
16133
+ publicParams: { A }
16134
+ }));
16135
+ case enums.publicKey.x25519:
16136
+ return publicKey.elliptic.ecdhX.generate(algo).then(({ A, k }) => ({
16137
+ privateParams: { k },
16138
+ publicParams: { A }
16139
+ }));
15720
16140
  case enums.publicKey.hmac: {
15721
16141
  const symAlgo = enums.write(enums.hash, symmetric);
15722
16142
  const keyMaterial = getRandomBytes(hash.getHashByteLength(symAlgo));
@@ -15758,7 +16178,7 @@ var openpgp = (function (exports) {
15758
16178
  * @returns {Promise<Boolean>} Whether the parameters are valid.
15759
16179
  * @async
15760
16180
  */
15761
- async function validateParams$6(algo, publicParams, privateParams) {
16181
+ async function validateParams$8(algo, publicParams, privateParams) {
15762
16182
  if (!publicParams || !privateParams) {
15763
16183
  throw new Error('Missing key parameters');
15764
16184
  }
@@ -15787,10 +16207,21 @@ var openpgp = (function (exports) {
15787
16207
  const { d } = privateParams;
15788
16208
  return algoModule.validateParams(oid, Q, d);
15789
16209
  }
15790
- case enums.publicKey.eddsa: {
15791
- const { oid, Q } = publicParams;
16210
+ case enums.publicKey.eddsa:
16211
+ case enums.publicKey.ed25519Legacy: {
16212
+ const { Q, oid } = publicParams;
15792
16213
  const { seed } = privateParams;
15793
- return publicKey.elliptic.eddsa.validateParams(oid, Q, seed);
16214
+ return publicKey.elliptic.eddsaLegacy.validateParams(oid, Q, seed);
16215
+ }
16216
+ case enums.publicKey.ed25519: {
16217
+ const { A } = publicParams;
16218
+ const { seed } = privateParams;
16219
+ return publicKey.elliptic.eddsa.validateParams(algo, A, seed);
16220
+ }
16221
+ case enums.publicKey.x25519: {
16222
+ const { A } = publicParams;
16223
+ const { k } = privateParams;
16224
+ return publicKey.elliptic.ecdhX.validateParams(algo, A, k);
15794
16225
  }
15795
16226
  case enums.publicKey.hmac: {
15796
16227
  const { cipher: algo, digest } = publicParams;
@@ -15869,7 +16300,7 @@ var openpgp = (function (exports) {
15869
16300
  parseEncSessionKeyParams: parseEncSessionKeyParams,
15870
16301
  serializeParams: serializeParams,
15871
16302
  generateParams: generateParams,
15872
- validateParams: validateParams$6,
16303
+ validateParams: validateParams$8,
15873
16304
  getPrefixRandom: getPrefixRandom,
15874
16305
  generateSessionKey: generateSessionKey,
15875
16306
  getAEADMode: getAEADMode,
@@ -16116,15 +16547,15 @@ var openpgp = (function (exports) {
16116
16547
  this.type = 'gnu-dummy';
16117
16548
  // GnuPG extension mode 1001 -- don't write secret key at all
16118
16549
  } else {
16119
- throw new Error('Unknown s2k gnu protection mode.');
16550
+ throw new UnsupportedError('Unknown s2k gnu protection mode.');
16120
16551
  }
16121
16552
  } else {
16122
- throw new Error('Unknown s2k type.');
16553
+ throw new UnsupportedError('Unknown s2k type.');
16123
16554
  }
16124
16555
  break;
16125
16556
 
16126
16557
  default:
16127
- throw new Error('Unknown s2k type.');
16558
+ throw new UnsupportedError('Unknown s2k type.'); // unreachable
16128
16559
  }
16129
16560
 
16130
16561
  return i;
@@ -16228,7 +16659,7 @@ var openpgp = (function (exports) {
16228
16659
  case enums.s2k.simple:
16229
16660
  return new GenericS2K(type, config$1);
16230
16661
  default:
16231
- throw new Error(`Unsupported S2K type ${type}`);
16662
+ throw new UnsupportedError(`Unsupported S2K type ${type}`);
16232
16663
  }
16233
16664
  }
16234
16665
 
@@ -24982,13 +25413,17 @@ var openpgp = (function (exports) {
24982
25413
  * @param {Uint8Array} bytes - Payload of a tag 1 packet
24983
25414
  */
24984
25415
  read(bytes) {
24985
- this.version = bytes[0];
25416
+ let i = 0;
25417
+ this.version = bytes[i++];
24986
25418
  if (this.version !== VERSION$3) {
24987
25419
  throw new UnsupportedError(`Version ${this.version} of the PKESK packet is unsupported.`);
24988
25420
  }
24989
- this.publicKeyID.read(bytes.subarray(1, bytes.length));
24990
- this.publicKeyAlgorithm = bytes[9];
24991
- this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(10));
25421
+ i += this.publicKeyID.read(bytes.subarray(i));
25422
+ this.publicKeyAlgorithm = bytes[i++];
25423
+ this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(i), this.version);
25424
+ if (this.publicKeyAlgorithm === enums.publicKey.x25519) {
25425
+ this.sessionKeyAlgorithm = enums.write(enums.symmetric, this.encrypted.C.algorithm);
25426
+ }
24992
25427
  }
24993
25428
 
24994
25429
  /**
@@ -25014,15 +25449,11 @@ var openpgp = (function (exports) {
25014
25449
  * @async
25015
25450
  */
25016
25451
  async encrypt(key) {
25017
- const data = util.concatUint8Array([
25018
- new Uint8Array([enums.write(enums.symmetric, this.sessionKeyAlgorithm)]),
25019
- this.sessionKey,
25020
- util.writeChecksum(this.sessionKey)
25021
- ]);
25022
25452
  const algo = enums.write(enums.publicKey, this.publicKeyAlgorithm);
25453
+ const encoded = encodeSessionKey(this.version, algo, this.sessionKeyAlgorithm, this.sessionKey);
25023
25454
  const privateParams = algo === enums.publicKey.aead ? key.privateParams : null;
25024
25455
  this.encrypted = await mod.publicKeyEncrypt(
25025
- algo, key.publicParams, privateParams, data, key.getFingerprintBytes());
25456
+ algo, this.sessionKeyAlgorithm, key.publicParams, privateParams, encoded, key.getFingerprintBytes());
25026
25457
  }
25027
25458
 
25028
25459
  /**
@@ -25039,34 +25470,86 @@ var openpgp = (function (exports) {
25039
25470
  throw new Error('Decryption error');
25040
25471
  }
25041
25472
 
25042
- const randomPayload = randomSessionKey ? util.concatUint8Array([
25043
- new Uint8Array([randomSessionKey.sessionKeyAlgorithm]),
25044
- randomSessionKey.sessionKey,
25045
- util.writeChecksum(randomSessionKey.sessionKey)
25046
- ]) : null;
25047
- const decoded = await mod.publicKeyDecrypt(this.publicKeyAlgorithm, key.publicParams, key.privateParams, this.encrypted, key.getFingerprintBytes(), randomPayload);
25048
- const symmetricAlgoByte = decoded[0];
25049
- const sessionKey = decoded.subarray(1, decoded.length - 2);
25050
- const checksum = decoded.subarray(decoded.length - 2);
25051
- const computedChecksum = util.writeChecksum(sessionKey);
25052
- const isValidChecksum = computedChecksum[0] === checksum[0] & computedChecksum[1] === checksum[1];
25053
-
25054
- if (randomSessionKey) {
25055
- // We must not leak info about the validity of the decrypted checksum or cipher algo.
25056
- // The decrypted session key must be of the same algo and size as the random session key, otherwise we discard it and use the random data.
25057
- const isValidPayload = isValidChecksum & symmetricAlgoByte === randomSessionKey.sessionKeyAlgorithm & sessionKey.length === randomSessionKey.sessionKey.length;
25058
- this.sessionKeyAlgorithm = util.selectUint8(isValidPayload, symmetricAlgoByte, randomSessionKey.sessionKeyAlgorithm);
25059
- this.sessionKey = util.selectUint8Array(isValidPayload, sessionKey, randomSessionKey.sessionKey);
25473
+ const randomPayload = randomSessionKey ?
25474
+ encodeSessionKey(this.version, this.publicKeyAlgorithm, randomSessionKey.sessionKeyAlgorithm, randomSessionKey.sessionKey) :
25475
+ null;
25476
+ const decryptedData = await mod.publicKeyDecrypt(this.publicKeyAlgorithm, key.publicParams, key.privateParams, this.encrypted, key.getFingerprintBytes(), randomPayload);
25060
25477
 
25061
- } else {
25062
- const isValidPayload = isValidChecksum && enums.read(enums.symmetric, symmetricAlgoByte);
25063
- if (isValidPayload) {
25064
- this.sessionKey = sessionKey;
25065
- this.sessionKeyAlgorithm = symmetricAlgoByte;
25478
+ const { sessionKey, sessionKeyAlgorithm } = decodeSessionKey(this.version, this.publicKeyAlgorithm, decryptedData, randomSessionKey);
25479
+
25480
+ // v3 Montgomery curves have cleartext cipher algo
25481
+ if (this.publicKeyAlgorithm !== enums.publicKey.x25519) {
25482
+ this.sessionKeyAlgorithm = sessionKeyAlgorithm;
25483
+ }
25484
+ this.sessionKey = sessionKey;
25485
+ }
25486
+ }
25487
+
25488
+
25489
+ function encodeSessionKey(version, keyAlgo, cipherAlgo, sessionKeyData) {
25490
+ switch (keyAlgo) {
25491
+ case enums.publicKey.rsaEncrypt:
25492
+ case enums.publicKey.rsaEncryptSign:
25493
+ case enums.publicKey.elgamal:
25494
+ case enums.publicKey.ecdh:
25495
+ case enums.publicKey.aead: {
25496
+ // add checksum
25497
+ return util.concatUint8Array([
25498
+ new Uint8Array([cipherAlgo]),
25499
+ sessionKeyData,
25500
+ util.writeChecksum(sessionKeyData.subarray(sessionKeyData.length % 8))
25501
+ ]);
25502
+ }
25503
+ case enums.publicKey.x25519:
25504
+ return sessionKeyData;
25505
+ default:
25506
+ throw new Error('Unsupported public key algorithm');
25507
+ }
25508
+ }
25509
+
25510
+
25511
+ function decodeSessionKey(version, keyAlgo, decryptedData, randomSessionKey) {
25512
+ switch (keyAlgo) {
25513
+ case enums.publicKey.rsaEncrypt:
25514
+ case enums.publicKey.rsaEncryptSign:
25515
+ case enums.publicKey.elgamal:
25516
+ case enums.publicKey.ecdh:
25517
+ case enums.publicKey.aead: {
25518
+ // verify checksum in constant time
25519
+ const result = decryptedData.subarray(0, decryptedData.length - 2);
25520
+ const checksum = decryptedData.subarray(decryptedData.length - 2);
25521
+ const computedChecksum = util.writeChecksum(result.subarray(result.length % 8));
25522
+ const isValidChecksum = computedChecksum[0] === checksum[0] & computedChecksum[1] === checksum[1];
25523
+ const decryptedSessionKey = { sessionKeyAlgorithm: result[0], sessionKey: result.subarray(1) };
25524
+ if (randomSessionKey) {
25525
+ // We must not leak info about the validity of the decrypted checksum or cipher algo.
25526
+ // The decrypted session key must be of the same algo and size as the random session key, otherwise we discard it and use the random data.
25527
+ const isValidPayload = isValidChecksum &
25528
+ decryptedSessionKey.sessionKeyAlgorithm === randomSessionKey.sessionKeyAlgorithm &
25529
+ decryptedSessionKey.sessionKey.length === randomSessionKey.sessionKey.length;
25530
+ return {
25531
+ sessionKey: util.selectUint8Array(isValidPayload, decryptedSessionKey.sessionKey, randomSessionKey.sessionKey),
25532
+ sessionKeyAlgorithm: util.selectUint8(
25533
+ isValidPayload,
25534
+ decryptedSessionKey.sessionKeyAlgorithm,
25535
+ randomSessionKey.sessionKeyAlgorithm
25536
+ )
25537
+ };
25066
25538
  } else {
25067
- throw new Error('Decryption error');
25539
+ const isValidPayload = isValidChecksum && enums.read(enums.symmetric, decryptedSessionKey.sessionKeyAlgorithm);
25540
+ if (isValidPayload) {
25541
+ return decryptedSessionKey;
25542
+ } else {
25543
+ throw new Error('Decryption error');
25544
+ }
25068
25545
  }
25069
25546
  }
25547
+ case enums.publicKey.x25519:
25548
+ return {
25549
+ sessionKey: decryptedData
25550
+ };
25551
+ default:
25552
+ throw new Error('Unsupported public key algorithm');
25070
25553
  }
25071
25554
  }
25072
25555
 
@@ -25497,7 +25980,7 @@ var openpgp = (function (exports) {
25497
25980
  result.bits = util.uint8ArrayBitLength(modulo);
25498
25981
  } else if (this.publicParams.oid) {
25499
25982
  result.curve = this.publicParams.oid.getName();
25500
- } else {
25983
+ } else if (this.publicParams.cipher) {
25501
25984
  result.symmetric = this.publicParams.cipher.getName();
25502
25985
  }
25503
25986
  return result;
@@ -25829,6 +26312,7 @@ var openpgp = (function (exports) {
25829
26312
  async read(bytes) {
25830
26313
  // - A Public-Key or Public-Subkey packet, as described above.
25831
26314
  let i = await this.readPublicKey(bytes);
26315
+ const startOfSecretKeyData = i;
25832
26316
 
25833
26317
  // - One octet indicating string-to-key usage conventions. Zero
25834
26318
  // indicates that the secret-key data is not encrypted. 255 or 254
@@ -25842,41 +26326,48 @@ var openpgp = (function (exports) {
25842
26326
  i++;
25843
26327
  }
25844
26328
 
25845
- // - [Optional] If string-to-key usage octet was 255, 254, or 253, a
25846
- // one-octet symmetric encryption algorithm.
25847
- if (this.s2kUsage === 255 || this.s2kUsage === 254 || this.s2kUsage === 253) {
25848
- this.symmetric = bytes[i++];
26329
+ try {
26330
+ // - [Optional] If string-to-key usage octet was 255, 254, or 253, a
26331
+ // one-octet symmetric encryption algorithm.
26332
+ if (this.s2kUsage === 255 || this.s2kUsage === 254 || this.s2kUsage === 253) {
26333
+ this.symmetric = bytes[i++];
25849
26334
 
25850
- // - [Optional] If string-to-key usage octet was 253, a one-octet
25851
- // AEAD algorithm.
25852
- if (this.s2kUsage === 253) {
25853
- this.aead = bytes[i++];
25854
- }
26335
+ // - [Optional] If string-to-key usage octet was 253, a one-octet
26336
+ // AEAD algorithm.
26337
+ if (this.s2kUsage === 253) {
26338
+ this.aead = bytes[i++];
26339
+ }
25855
26340
 
25856
- // - [Optional] If string-to-key usage octet was 255, 254, or 253, a
25857
- // string-to-key specifier. The length of the string-to-key
25858
- // specifier is implied by its type, as described above.
25859
- const s2kType = bytes[i++];
25860
- this.s2k = newS2KFromType(s2kType);
25861
- i += this.s2k.read(bytes.subarray(i, bytes.length));
26341
+ // - [Optional] If string-to-key usage octet was 255, 254, or 253, a
26342
+ // string-to-key specifier. The length of the string-to-key
26343
+ // specifier is implied by its type, as described above.
26344
+ const s2kType = bytes[i++];
26345
+ this.s2k = newS2KFromType(s2kType);
26346
+ i += this.s2k.read(bytes.subarray(i, bytes.length));
25862
26347
 
25863
- if (this.s2k.type === 'gnu-dummy') {
25864
- return;
26348
+ if (this.s2k.type === 'gnu-dummy') {
26349
+ return;
26350
+ }
26351
+ } else if (this.s2kUsage) {
26352
+ this.symmetric = this.s2kUsage;
25865
26353
  }
25866
- } else if (this.s2kUsage) {
25867
- this.symmetric = this.s2kUsage;
25868
- }
25869
26354
 
25870
- // - [Optional] If secret data is encrypted (string-to-key usage octet
25871
- // not zero), an Initial Vector (IV) of the same length as the
25872
- // cipher's block size.
25873
- if (this.s2kUsage) {
25874
- this.iv = bytes.subarray(
25875
- i,
25876
- i + mod.getCipher(this.symmetric).blockSize
25877
- );
26355
+ // - [Optional] If secret data is encrypted (string-to-key usage octet
26356
+ // not zero), an Initial Vector (IV) of the same length as the
26357
+ // cipher's block size.
26358
+ if (this.s2kUsage) {
26359
+ this.iv = bytes.subarray(
26360
+ i,
26361
+ i + mod.getCipher(this.symmetric).blockSize
26362
+ );
25878
26363
 
25879
- i += this.iv.length;
26364
+ i += this.iv.length;
26365
+ }
26366
+ } catch (e) {
26367
+ // if the s2k is unsupported, we still want to support encrypting and verifying with the given key
26368
+ if (!this.s2kUsage) throw e; // always throw for decrypted keys
26369
+ this.unparseableKeyMaterial = bytes.subarray(startOfSecretKeyData);
26370
+ this.isEncrypted = true;
25880
26371
  }
25881
26372
 
25882
26373
  // - Only for a version 5 packet, a four-octet scalar octet count for
@@ -25912,8 +26403,15 @@ var openpgp = (function (exports) {
25912
26403
  * @returns {Uint8Array} A string of bytes containing the secret key OpenPGP packet.
25913
26404
  */
25914
26405
  write() {
25915
- const arr = [this.writePublicKey()];
26406
+ const serializedPublicKey = this.writePublicKey();
26407
+ if (this.unparseableKeyMaterial) {
26408
+ return util.concatUint8Array([
26409
+ serializedPublicKey,
26410
+ this.unparseableKeyMaterial
26411
+ ]);
26412
+ }
25916
26413
 
26414
+ const arr = [serializedPublicKey];
25917
26415
  arr.push(new Uint8Array([this.s2kUsage]));
25918
26416
 
25919
26417
  const optionalFieldsArr = [];
@@ -25973,6 +26471,18 @@ var openpgp = (function (exports) {
25973
26471
  return this.isEncrypted === false;
25974
26472
  }
25975
26473
 
26474
+ /**
26475
+ * Check whether the key includes secret key material.
26476
+ * Some secret keys do not include it, and can thus only be used
26477
+ * for public-key operations (encryption and verification).
26478
+ * Such keys are:
26479
+ * - GNU-dummy keys, where the secret material has been stripped away
26480
+ * - encrypted keys with unsupported S2K or cipher
26481
+ */
26482
+ isMissingSecretKeyMaterial() {
26483
+ return this.unparseableKeyMaterial !== undefined || this.isDummy();
26484
+ }
26485
+
25976
26486
  /**
25977
26487
  * Check whether this is a gnu-dummy key
25978
26488
  * @returns {Boolean}
@@ -25993,6 +26503,7 @@ var openpgp = (function (exports) {
25993
26503
  if (this.isDecrypted()) {
25994
26504
  this.clearPrivateParams();
25995
26505
  }
26506
+ delete this.unparseableKeyMaterial;
25996
26507
  this.isEncrypted = null;
25997
26508
  this.keyMaterial = null;
25998
26509
  this.s2k = newS2KFromType(enums.s2k.gnu, config$1);
@@ -26064,6 +26575,10 @@ var openpgp = (function (exports) {
26064
26575
  return false;
26065
26576
  }
26066
26577
 
26578
+ if (this.unparseableKeyMaterial) {
26579
+ throw new Error('Key packet cannot be decrypted: unsupported S2K or cipher algo');
26580
+ }
26581
+
26067
26582
  if (this.isDecrypted()) {
26068
26583
  throw new Error('Key packet is already decrypted.');
26069
26584
  }
@@ -26148,7 +26663,7 @@ var openpgp = (function (exports) {
26148
26663
  * Clear private key parameters
26149
26664
  */
26150
26665
  clearPrivateParams() {
26151
- if (this.isDummy()) {
26666
+ if (this.isMissingSecretKeyMaterial()) {
26152
26667
  return;
26153
26668
  }
26154
26669
 
@@ -27841,6 +28356,7 @@ var openpgp = (function (exports) {
27841
28356
  return keyAlgo !== enums.publicKey.rsaEncrypt &&
27842
28357
  keyAlgo !== enums.publicKey.elgamal &&
27843
28358
  keyAlgo !== enums.publicKey.ecdh &&
28359
+ keyAlgo !== enums.publicKey.x25519 &&
27844
28360
  (!signature.keyFlags ||
27845
28361
  (signature.keyFlags[0] & enums.keyFlags.signData) !== 0);
27846
28362
  }
@@ -27851,6 +28367,7 @@ var openpgp = (function (exports) {
27851
28367
  keyAlgo !== enums.publicKey.rsaSign &&
27852
28368
  keyAlgo !== enums.publicKey.ecdsa &&
27853
28369
  keyAlgo !== enums.publicKey.eddsa &&
28370
+ keyAlgo !== enums.publicKey.ed25519 &&
27854
28371
  (!signature.keyFlags ||
27855
28372
  (signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
27856
28373
  (signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0);
@@ -29405,7 +29922,7 @@ var openpgp = (function (exports) {
29405
29922
  * @static
29406
29923
  * @private
29407
29924
  */
29408
- async function generate$2(options, config) {
29925
+ async function generate$4(options, config) {
29409
29926
  options.sign = true; // primary key is always a signing key
29410
29927
  options = sanitizeKeyOptions(options);
29411
29928
  options.subkeys = options.subkeys.map((subkey, index) => sanitizeKeyOptions(options.subkeys[index], options));
@@ -30084,6 +30601,15 @@ var openpgp = (function (exports) {
30084
30601
  enums.read(enums.aead, await getPreferredAlgo('aead', encryptionKeys, date, userIDs, config$1)) :
30085
30602
  undefined;
30086
30603
 
30604
+ await Promise.all(encryptionKeys.map(key => key.getEncryptionKey()
30605
+ .catch(() => null) // ignore key strength requirements
30606
+ .then(maybeKey => {
30607
+ if (maybeKey && (maybeKey.keyPacket.algorithm === enums.publicKey.x25519) && !util.isAES(algo)) {
30608
+ throw new Error('Could not generate a session key compatible with the given `encryptionKeys`: X22519 keys can only be used to encrypt AES session keys; change `config.preferredSymmetricAlgorithm` accordingly.');
30609
+ }
30610
+ })
30611
+ ));
30612
+
30087
30613
  const sessionKeyData = mod.generateSessionKey(algo);
30088
30614
  return { data: sessionKeyData, algorithm: algorithmName, aeadAlgorithm: aeadAlgorithmName };
30089
30615
  }
@@ -30391,7 +30917,7 @@ var openpgp = (function (exports) {
30391
30917
  if (literalDataList.length !== 1) {
30392
30918
  throw new Error('Can only verify message with one literal data packet.');
30393
30919
  }
30394
- const signatureList = signature.packets;
30920
+ const signatureList = signature.packets.filterByTag(enums.packet.signature); // drop UnparsablePackets
30395
30921
  return createVerificationObjects(signatureList, literalDataList, verificationKeys, date, true, config$1);
30396
30922
  }
30397
30923
 
@@ -30738,7 +31264,7 @@ var openpgp = (function (exports) {
30738
31264
  * @async
30739
31265
  */
30740
31266
  verify(keys, date = new Date(), config$1 = config) {
30741
- const signatureList = this.signature.packets;
31267
+ const signatureList = this.signature.packets.filterByTag(enums.packet.signature); // drop UnparsablePackets
30742
31268
  const literalDataPacket = new LiteralDataPacket();
30743
31269
  // we assume that cleartext signature is generated based on UTF8 cleartext
30744
31270
  literalDataPacket.setText(this.text);
@@ -30823,7 +31349,7 @@ var openpgp = (function (exports) {
30823
31349
  let oneHeader = null;
30824
31350
  let hashAlgos = [];
30825
31351
  headers.forEach(function(header) {
30826
- oneHeader = header.match(/Hash: (.+)/); // get header value
31352
+ oneHeader = header.match(/^Hash: (.+)$/); // get header value
30827
31353
  if (oneHeader) {
30828
31354
  oneHeader = oneHeader[1].replace(/\s/g, ''); // remove whitespace
30829
31355
  oneHeader = oneHeader.split(',');
@@ -30915,7 +31441,7 @@ var openpgp = (function (exports) {
30915
31441
  const options = { userIDs, passphrase, type, rsaBits, curve, keyExpirationTime, date, subkeys, symmetricHash, symmetricCipher };
30916
31442
 
30917
31443
  try {
30918
- const { key, revocationCertificate } = await generate$2(options, config$1);
31444
+ const { key, revocationCertificate } = await generate$4(options, config$1);
30919
31445
  key.getKeys().forEach(({ keyPacket }) => checkKeyRequirements(keyPacket, config$1));
30920
31446
 
30921
31447
  return {
@@ -31109,7 +31635,7 @@ var openpgp = (function (exports) {
31109
31635
  * @async
31110
31636
  * @static
31111
31637
  */
31112
- async function encrypt$4({ message, encryptionKeys, signingKeys, passwords, sessionKey, format = 'armored', signature = null, wildcard = false, signingKeyIDs = [], encryptionKeyIDs = [], date = new Date(), signingUserIDs = [], encryptionUserIDs = [], signatureNotations = [], config: config$1, ...rest }) {
31638
+ async function encrypt$5({ message, encryptionKeys, signingKeys, passwords, sessionKey, format = 'armored', signature = null, wildcard = false, signingKeyIDs = [], encryptionKeyIDs = [], date = new Date(), signingUserIDs = [], encryptionUserIDs = [], signatureNotations = [], config: config$1, ...rest }) {
31113
31639
  config$1 = { ...config, ...config$1 }; checkConfig(config$1);
31114
31640
  checkMessage(message); checkOutputMessageFormat(format);
31115
31641
  encryptionKeys = toArray$1(encryptionKeys); signingKeys = toArray$1(signingKeys); passwords = toArray$1(passwords);
@@ -31178,7 +31704,7 @@ var openpgp = (function (exports) {
31178
31704
  * @async
31179
31705
  * @static
31180
31706
  */
31181
- async function decrypt$4({ message, decryptionKeys, passwords, sessionKeys, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
31707
+ async function decrypt$5({ message, decryptionKeys, passwords, sessionKeys, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
31182
31708
  config$1 = { ...config, ...config$1 }; checkConfig(config$1);
31183
31709
  checkMessage(message); verificationKeys = toArray$1(verificationKeys); decryptionKeys = toArray$1(decryptionKeys); passwords = toArray$1(passwords); sessionKeys = toArray$1(sessionKeys);
31184
31710
  if (rest.privateKeys) throw new Error('The `privateKeys` option has been removed from openpgp.decrypt, pass `decryptionKeys` instead');
@@ -31241,7 +31767,7 @@ var openpgp = (function (exports) {
31241
31767
  * @async
31242
31768
  * @static
31243
31769
  */
31244
- async function sign$5({ message, signingKeys, format = 'armored', detached = false, signingKeyIDs = [], date = new Date(), signingUserIDs = [], signatureNotations = [], config: config$1, ...rest }) {
31770
+ async function sign$6({ message, signingKeys, format = 'armored', detached = false, signingKeyIDs = [], date = new Date(), signingUserIDs = [], signatureNotations = [], config: config$1, ...rest }) {
31245
31771
  config$1 = { ...config, ...config$1 }; checkConfig(config$1);
31246
31772
  checkCleartextOrMessage(message); checkOutputMessageFormat(format);
31247
31773
  signingKeys = toArray$1(signingKeys); signingKeyIDs = toArray$1(signingKeyIDs); signingUserIDs = toArray$1(signingUserIDs); signatureNotations = toArray$1(signatureNotations);
@@ -31310,7 +31836,7 @@ var openpgp = (function (exports) {
31310
31836
  * @async
31311
31837
  * @static
31312
31838
  */
31313
- async function verify$5({ message, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
31839
+ async function verify$6({ message, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
31314
31840
  config$1 = { ...config, ...config$1 }; checkConfig(config$1);
31315
31841
  checkCleartextOrMessage(message); verificationKeys = toArray$1(verificationKeys);
31316
31842
  if (rest.publicKeys) throw new Error('The `publicKeys` option has been removed from openpgp.verify, pass `verificationKeys` instead');
@@ -44479,7 +45005,7 @@ var openpgp = (function (exports) {
44479
45005
  return [];
44480
45006
  }
44481
45007
 
44482
- function validateParams$7({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {
45008
+ function validateParams$9({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {
44483
45009
  const assertLength = (name, value, min, max) => {
44484
45010
  if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }
44485
45011
  };
@@ -44502,7 +45028,7 @@ var openpgp = (function (exports) {
44502
45028
  function argon2id(params, { memory, instance: wasmInstance }) {
44503
45029
  if (!isLittleEndian$1) throw new Error('BigEndian system not supported'); // optmisations assume LE system
44504
45030
 
44505
- const ctx = validateParams$7({ type: TYPE$2, version: VERSION$4, ...params });
45031
+ const ctx = validateParams$9({ type: TYPE$2, version: VERSION$4, ...params });
44506
45032
 
44507
45033
  const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;
44508
45034
  const wasmRefs = {};
@@ -44806,10 +45332,10 @@ var openpgp = (function (exports) {
44806
45332
  exports.config = config;
44807
45333
  exports.createCleartextMessage = createCleartextMessage;
44808
45334
  exports.createMessage = createMessage;
44809
- exports.decrypt = decrypt$4;
45335
+ exports.decrypt = decrypt$5;
44810
45336
  exports.decryptKey = decryptKey;
44811
45337
  exports.decryptSessionKeys = decryptSessionKeys;
44812
- exports.encrypt = encrypt$4;
45338
+ exports.encrypt = encrypt$5;
44813
45339
  exports.encryptKey = encryptKey;
44814
45340
  exports.encryptSessionKey = encryptSessionKey;
44815
45341
  exports.enums = enums;
@@ -44824,9 +45350,9 @@ var openpgp = (function (exports) {
44824
45350
  exports.readSignature = readSignature;
44825
45351
  exports.reformatKey = reformatKey;
44826
45352
  exports.revokeKey = revokeKey;
44827
- exports.sign = sign$5;
45353
+ exports.sign = sign$6;
44828
45354
  exports.unarmor = unarmor;
44829
- exports.verify = verify$5;
45355
+ exports.verify = verify$6;
44830
45356
 
44831
45357
  Object.defineProperty(exports, '__esModule', { value: true });
44832
45358