@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/lightweight/argon2id.min.mjs +1 -1
- package/dist/lightweight/argon2id.mjs +1 -1
- package/dist/lightweight/bn.interface.min.mjs +1 -1
- package/dist/lightweight/bn.interface.mjs +1 -1
- package/dist/lightweight/bn.min.mjs +1 -1
- package/dist/lightweight/bn.mjs +1 -1
- package/dist/lightweight/elliptic.min.mjs +1 -1
- package/dist/lightweight/elliptic.mjs +1 -1
- package/dist/lightweight/openpgp.min.mjs +2 -2
- package/dist/lightweight/openpgp.min.mjs.map +1 -1
- package/dist/lightweight/openpgp.mjs +1734 -1208
- package/dist/lightweight/ponyfill.es6.min.mjs +1 -1
- package/dist/lightweight/ponyfill.es6.mjs +1 -1
- package/dist/lightweight/web-streams-adapter.min.mjs +1 -1
- package/dist/lightweight/web-streams-adapter.mjs +1 -1
- package/dist/node/openpgp.js +1210 -684
- package/dist/node/openpgp.min.js +3 -3
- package/dist/node/openpgp.min.js.map +1 -1
- package/dist/node/openpgp.min.mjs +3 -3
- package/dist/node/openpgp.min.mjs.map +1 -1
- package/dist/node/openpgp.mjs +1207 -681
- package/dist/openpgp.js +1210 -684
- package/dist/openpgp.min.js +3 -3
- package/dist/openpgp.min.js.map +1 -1
- package/dist/openpgp.min.mjs +3 -3
- package/dist/openpgp.min.mjs.map +1 -1
- package/dist/openpgp.mjs +1207 -681
- package/openpgp.d.ts +1 -0
- package/package.json +2 -2
package/dist/node/openpgp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v5.
|
|
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
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -1529,6 +1529,526 @@ async function getBigInteger() {
|
|
|
1529
1529
|
}
|
|
1530
1530
|
}
|
|
1531
1531
|
|
|
1532
|
+
/**
|
|
1533
|
+
* @module enums
|
|
1534
|
+
*/
|
|
1535
|
+
|
|
1536
|
+
const byValue = Symbol('byValue');
|
|
1537
|
+
|
|
1538
|
+
var enums = {
|
|
1539
|
+
|
|
1540
|
+
/** Maps curve names under various standards to one
|
|
1541
|
+
* @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
|
|
1542
|
+
* @enum {String}
|
|
1543
|
+
* @readonly
|
|
1544
|
+
*/
|
|
1545
|
+
curve: {
|
|
1546
|
+
/** NIST P-256 Curve */
|
|
1547
|
+
'p256': 'p256',
|
|
1548
|
+
'P-256': 'p256',
|
|
1549
|
+
'secp256r1': 'p256',
|
|
1550
|
+
'prime256v1': 'p256',
|
|
1551
|
+
'1.2.840.10045.3.1.7': 'p256',
|
|
1552
|
+
'2a8648ce3d030107': 'p256',
|
|
1553
|
+
'2A8648CE3D030107': 'p256',
|
|
1554
|
+
|
|
1555
|
+
/** NIST P-384 Curve */
|
|
1556
|
+
'p384': 'p384',
|
|
1557
|
+
'P-384': 'p384',
|
|
1558
|
+
'secp384r1': 'p384',
|
|
1559
|
+
'1.3.132.0.34': 'p384',
|
|
1560
|
+
'2b81040022': 'p384',
|
|
1561
|
+
'2B81040022': 'p384',
|
|
1562
|
+
|
|
1563
|
+
/** NIST P-521 Curve */
|
|
1564
|
+
'p521': 'p521',
|
|
1565
|
+
'P-521': 'p521',
|
|
1566
|
+
'secp521r1': 'p521',
|
|
1567
|
+
'1.3.132.0.35': 'p521',
|
|
1568
|
+
'2b81040023': 'p521',
|
|
1569
|
+
'2B81040023': 'p521',
|
|
1570
|
+
|
|
1571
|
+
/** SECG SECP256k1 Curve */
|
|
1572
|
+
'secp256k1': 'secp256k1',
|
|
1573
|
+
'1.3.132.0.10': 'secp256k1',
|
|
1574
|
+
'2b8104000a': 'secp256k1',
|
|
1575
|
+
'2B8104000A': 'secp256k1',
|
|
1576
|
+
|
|
1577
|
+
/** Ed25519 */
|
|
1578
|
+
'ED25519': 'ed25519',
|
|
1579
|
+
'ed25519': 'ed25519',
|
|
1580
|
+
'Ed25519': 'ed25519',
|
|
1581
|
+
'1.3.6.1.4.1.11591.15.1': 'ed25519',
|
|
1582
|
+
'2b06010401da470f01': 'ed25519',
|
|
1583
|
+
'2B06010401DA470F01': 'ed25519',
|
|
1584
|
+
|
|
1585
|
+
/** Curve25519 */
|
|
1586
|
+
'X25519': 'curve25519',
|
|
1587
|
+
'cv25519': 'curve25519',
|
|
1588
|
+
'curve25519': 'curve25519',
|
|
1589
|
+
'Curve25519': 'curve25519',
|
|
1590
|
+
'1.3.6.1.4.1.3029.1.5.1': 'curve25519',
|
|
1591
|
+
'2b060104019755010501': 'curve25519',
|
|
1592
|
+
'2B060104019755010501': 'curve25519',
|
|
1593
|
+
|
|
1594
|
+
/** BrainpoolP256r1 Curve */
|
|
1595
|
+
'brainpoolP256r1': 'brainpoolP256r1',
|
|
1596
|
+
'1.3.36.3.3.2.8.1.1.7': 'brainpoolP256r1',
|
|
1597
|
+
'2b2403030208010107': 'brainpoolP256r1',
|
|
1598
|
+
'2B2403030208010107': 'brainpoolP256r1',
|
|
1599
|
+
|
|
1600
|
+
/** BrainpoolP384r1 Curve */
|
|
1601
|
+
'brainpoolP384r1': 'brainpoolP384r1',
|
|
1602
|
+
'1.3.36.3.3.2.8.1.1.11': 'brainpoolP384r1',
|
|
1603
|
+
'2b240303020801010b': 'brainpoolP384r1',
|
|
1604
|
+
'2B240303020801010B': 'brainpoolP384r1',
|
|
1605
|
+
|
|
1606
|
+
/** BrainpoolP512r1 Curve */
|
|
1607
|
+
'brainpoolP512r1': 'brainpoolP512r1',
|
|
1608
|
+
'1.3.36.3.3.2.8.1.1.13': 'brainpoolP512r1',
|
|
1609
|
+
'2b240303020801010d': 'brainpoolP512r1',
|
|
1610
|
+
'2B240303020801010D': 'brainpoolP512r1'
|
|
1611
|
+
},
|
|
1612
|
+
|
|
1613
|
+
/** KDF parameters flags
|
|
1614
|
+
* Non-standard extensions (for now) to allow email forwarding
|
|
1615
|
+
* @enum {Integer}
|
|
1616
|
+
* @readonly
|
|
1617
|
+
*/
|
|
1618
|
+
kdfFlags: {
|
|
1619
|
+
/** Specify fingerprint to use instead of the recipient's */
|
|
1620
|
+
replace_fingerprint: 0x01,
|
|
1621
|
+
/** Specify custom parameters to use in the KDF digest computation */
|
|
1622
|
+
replace_kdf_params: 0x02
|
|
1623
|
+
},
|
|
1624
|
+
|
|
1625
|
+
/** A string to key specifier type
|
|
1626
|
+
* @enum {Integer}
|
|
1627
|
+
* @readonly
|
|
1628
|
+
*/
|
|
1629
|
+
s2k: {
|
|
1630
|
+
simple: 0,
|
|
1631
|
+
salted: 1,
|
|
1632
|
+
iterated: 3,
|
|
1633
|
+
argon2: 4,
|
|
1634
|
+
gnu: 101
|
|
1635
|
+
},
|
|
1636
|
+
|
|
1637
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-crypto-refresh-08.html#section-9.1|crypto-refresh RFC, section 9.1}
|
|
1638
|
+
* @enum {Integer}
|
|
1639
|
+
* @readonly
|
|
1640
|
+
*/
|
|
1641
|
+
publicKey: {
|
|
1642
|
+
/** RSA (Encrypt or Sign) [HAC] */
|
|
1643
|
+
rsaEncryptSign: 1,
|
|
1644
|
+
/** RSA (Encrypt only) [HAC] */
|
|
1645
|
+
rsaEncrypt: 2,
|
|
1646
|
+
/** RSA (Sign only) [HAC] */
|
|
1647
|
+
rsaSign: 3,
|
|
1648
|
+
/** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
|
|
1649
|
+
elgamal: 16,
|
|
1650
|
+
/** DSA (Sign only) [FIPS186] [HAC] */
|
|
1651
|
+
dsa: 17,
|
|
1652
|
+
/** ECDH (Encrypt only) [RFC6637] */
|
|
1653
|
+
ecdh: 18,
|
|
1654
|
+
/** ECDSA (Sign only) [RFC6637] */
|
|
1655
|
+
ecdsa: 19,
|
|
1656
|
+
/** EdDSA (Sign only) - deprecated by crypto-refresh (replaced by `ed25519` identifier below)
|
|
1657
|
+
* [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
|
|
1658
|
+
ed25519Legacy: 22, // NB: this is declared before `eddsa` to translate 22 to 'eddsa' for backwards compatibility
|
|
1659
|
+
eddsa: 22, // to be deprecated in v6
|
|
1660
|
+
/** Reserved for AEDH */
|
|
1661
|
+
aedh: 23,
|
|
1662
|
+
/** Reserved for AEDSA */
|
|
1663
|
+
aedsa: 24,
|
|
1664
|
+
/** X25519 (Encrypt only) */
|
|
1665
|
+
x25519: 25,
|
|
1666
|
+
/** X448 (Encrypt only) */
|
|
1667
|
+
x448: 26,
|
|
1668
|
+
/** Ed25519 (Sign only) */
|
|
1669
|
+
ed25519: 27,
|
|
1670
|
+
/** Ed448 (Sign only) */
|
|
1671
|
+
ed448: 28,
|
|
1672
|
+
/** Symmetric authenticated encryption algorithms */
|
|
1673
|
+
aead: 100,
|
|
1674
|
+
/** Authentication using CMAC */
|
|
1675
|
+
hmac: 101
|
|
1676
|
+
},
|
|
1677
|
+
|
|
1678
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
|
|
1679
|
+
* @enum {Integer}
|
|
1680
|
+
* @readonly
|
|
1681
|
+
*/
|
|
1682
|
+
symmetric: {
|
|
1683
|
+
plaintext: 0,
|
|
1684
|
+
/** Not implemented! */
|
|
1685
|
+
idea: 1,
|
|
1686
|
+
tripledes: 2,
|
|
1687
|
+
cast5: 3,
|
|
1688
|
+
blowfish: 4,
|
|
1689
|
+
aes128: 7,
|
|
1690
|
+
aes192: 8,
|
|
1691
|
+
aes256: 9,
|
|
1692
|
+
twofish: 10
|
|
1693
|
+
},
|
|
1694
|
+
|
|
1695
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
|
|
1696
|
+
* @enum {Integer}
|
|
1697
|
+
* @readonly
|
|
1698
|
+
*/
|
|
1699
|
+
compression: {
|
|
1700
|
+
uncompressed: 0,
|
|
1701
|
+
/** RFC1951 */
|
|
1702
|
+
zip: 1,
|
|
1703
|
+
/** RFC1950 */
|
|
1704
|
+
zlib: 2,
|
|
1705
|
+
bzip2: 3
|
|
1706
|
+
},
|
|
1707
|
+
|
|
1708
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
|
|
1709
|
+
* @enum {Integer}
|
|
1710
|
+
* @readonly
|
|
1711
|
+
*/
|
|
1712
|
+
hash: {
|
|
1713
|
+
md5: 1,
|
|
1714
|
+
sha1: 2,
|
|
1715
|
+
ripemd: 3,
|
|
1716
|
+
sha256: 8,
|
|
1717
|
+
sha384: 9,
|
|
1718
|
+
sha512: 10,
|
|
1719
|
+
sha224: 11
|
|
1720
|
+
},
|
|
1721
|
+
|
|
1722
|
+
/** A list of hash names as accepted by webCrypto functions.
|
|
1723
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
|
|
1724
|
+
* @enum {String}
|
|
1725
|
+
*/
|
|
1726
|
+
webHash: {
|
|
1727
|
+
'SHA-1': 2,
|
|
1728
|
+
'SHA-256': 8,
|
|
1729
|
+
'SHA-384': 9,
|
|
1730
|
+
'SHA-512': 10
|
|
1731
|
+
},
|
|
1732
|
+
|
|
1733
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
|
|
1734
|
+
* @enum {Integer}
|
|
1735
|
+
* @readonly
|
|
1736
|
+
*/
|
|
1737
|
+
aead: {
|
|
1738
|
+
eax: 1,
|
|
1739
|
+
ocb: 2,
|
|
1740
|
+
experimentalGCM: 100 // Private algorithm
|
|
1741
|
+
},
|
|
1742
|
+
|
|
1743
|
+
/** A list of packet types and numeric tags associated with them.
|
|
1744
|
+
* @enum {Integer}
|
|
1745
|
+
* @readonly
|
|
1746
|
+
*/
|
|
1747
|
+
packet: {
|
|
1748
|
+
publicKeyEncryptedSessionKey: 1,
|
|
1749
|
+
signature: 2,
|
|
1750
|
+
symEncryptedSessionKey: 3,
|
|
1751
|
+
onePassSignature: 4,
|
|
1752
|
+
secretKey: 5,
|
|
1753
|
+
publicKey: 6,
|
|
1754
|
+
secretSubkey: 7,
|
|
1755
|
+
compressedData: 8,
|
|
1756
|
+
symmetricallyEncryptedData: 9,
|
|
1757
|
+
marker: 10,
|
|
1758
|
+
literalData: 11,
|
|
1759
|
+
trust: 12,
|
|
1760
|
+
userID: 13,
|
|
1761
|
+
publicSubkey: 14,
|
|
1762
|
+
userAttribute: 17,
|
|
1763
|
+
symEncryptedIntegrityProtectedData: 18,
|
|
1764
|
+
modificationDetectionCode: 19,
|
|
1765
|
+
aeadEncryptedData: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
|
|
1766
|
+
},
|
|
1767
|
+
|
|
1768
|
+
/** Data types in the literal packet
|
|
1769
|
+
* @enum {Integer}
|
|
1770
|
+
* @readonly
|
|
1771
|
+
*/
|
|
1772
|
+
literal: {
|
|
1773
|
+
/** Binary data 'b' */
|
|
1774
|
+
binary: 'b'.charCodeAt(),
|
|
1775
|
+
/** Text data 't' */
|
|
1776
|
+
text: 't'.charCodeAt(),
|
|
1777
|
+
/** Utf8 data 'u' */
|
|
1778
|
+
utf8: 'u'.charCodeAt(),
|
|
1779
|
+
/** MIME message body part 'm' */
|
|
1780
|
+
mime: 'm'.charCodeAt()
|
|
1781
|
+
},
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
/** One pass signature packet type
|
|
1785
|
+
* @enum {Integer}
|
|
1786
|
+
* @readonly
|
|
1787
|
+
*/
|
|
1788
|
+
signature: {
|
|
1789
|
+
/** 0x00: Signature of a binary document. */
|
|
1790
|
+
binary: 0,
|
|
1791
|
+
/** 0x01: Signature of a canonical text document.
|
|
1792
|
+
*
|
|
1793
|
+
* Canonicalyzing the document by converting line endings. */
|
|
1794
|
+
text: 1,
|
|
1795
|
+
/** 0x02: Standalone signature.
|
|
1796
|
+
*
|
|
1797
|
+
* This signature is a signature of only its own subpacket contents.
|
|
1798
|
+
* It is calculated identically to a signature over a zero-lengh
|
|
1799
|
+
* binary document. Note that it doesn't make sense to have a V3
|
|
1800
|
+
* standalone signature. */
|
|
1801
|
+
standalone: 2,
|
|
1802
|
+
/** 0x10: Generic certification of a User ID and Public-Key packet.
|
|
1803
|
+
*
|
|
1804
|
+
* The issuer of this certification does not make any particular
|
|
1805
|
+
* assertion as to how well the certifier has checked that the owner
|
|
1806
|
+
* of the key is in fact the person described by the User ID. */
|
|
1807
|
+
certGeneric: 16,
|
|
1808
|
+
/** 0x11: Persona certification of a User ID and Public-Key packet.
|
|
1809
|
+
*
|
|
1810
|
+
* The issuer of this certification has not done any verification of
|
|
1811
|
+
* the claim that the owner of this key is the User ID specified. */
|
|
1812
|
+
certPersona: 17,
|
|
1813
|
+
/** 0x12: Casual certification of a User ID and Public-Key packet.
|
|
1814
|
+
*
|
|
1815
|
+
* The issuer of this certification has done some casual
|
|
1816
|
+
* verification of the claim of identity. */
|
|
1817
|
+
certCasual: 18,
|
|
1818
|
+
/** 0x13: Positive certification of a User ID and Public-Key packet.
|
|
1819
|
+
*
|
|
1820
|
+
* The issuer of this certification has done substantial
|
|
1821
|
+
* verification of the claim of identity.
|
|
1822
|
+
*
|
|
1823
|
+
* Most OpenPGP implementations make their "key signatures" as 0x10
|
|
1824
|
+
* certifications. Some implementations can issue 0x11-0x13
|
|
1825
|
+
* certifications, but few differentiate between the types. */
|
|
1826
|
+
certPositive: 19,
|
|
1827
|
+
/** 0x30: Certification revocation signature
|
|
1828
|
+
*
|
|
1829
|
+
* This signature revokes an earlier User ID certification signature
|
|
1830
|
+
* (signature class 0x10 through 0x13) or direct-key signature
|
|
1831
|
+
* (0x1F). It should be issued by the same key that issued the
|
|
1832
|
+
* revoked signature or an authorized revocation key. The signature
|
|
1833
|
+
* is computed over the same data as the certificate that it
|
|
1834
|
+
* revokes, and should have a later creation date than that
|
|
1835
|
+
* certificate. */
|
|
1836
|
+
certRevocation: 48,
|
|
1837
|
+
/** 0x18: Subkey Binding Signature
|
|
1838
|
+
*
|
|
1839
|
+
* This signature is a statement by the top-level signing key that
|
|
1840
|
+
* indicates that it owns the subkey. This signature is calculated
|
|
1841
|
+
* directly on the primary key and subkey, and not on any User ID or
|
|
1842
|
+
* other packets. A signature that binds a signing subkey MUST have
|
|
1843
|
+
* an Embedded Signature subpacket in this binding signature that
|
|
1844
|
+
* contains a 0x19 signature made by the signing subkey on the
|
|
1845
|
+
* primary key and subkey. */
|
|
1846
|
+
subkeyBinding: 24,
|
|
1847
|
+
/** 0x19: Primary Key Binding Signature
|
|
1848
|
+
*
|
|
1849
|
+
* This signature is a statement by a signing subkey, indicating
|
|
1850
|
+
* that it is owned by the primary key and subkey. This signature
|
|
1851
|
+
* is calculated the same way as a 0x18 signature: directly on the
|
|
1852
|
+
* primary key and subkey, and not on any User ID or other packets.
|
|
1853
|
+
*
|
|
1854
|
+
* When a signature is made over a key, the hash data starts with the
|
|
1855
|
+
* octet 0x99, followed by a two-octet length of the key, and then body
|
|
1856
|
+
* of the key packet. (Note that this is an old-style packet header for
|
|
1857
|
+
* a key packet with two-octet length.) A subkey binding signature
|
|
1858
|
+
* (type 0x18) or primary key binding signature (type 0x19) then hashes
|
|
1859
|
+
* the subkey using the same format as the main key (also using 0x99 as
|
|
1860
|
+
* the first octet). */
|
|
1861
|
+
keyBinding: 25,
|
|
1862
|
+
/** 0x1F: Signature directly on a key
|
|
1863
|
+
*
|
|
1864
|
+
* This signature is calculated directly on a key. It binds the
|
|
1865
|
+
* information in the Signature subpackets to the key, and is
|
|
1866
|
+
* appropriate to be used for subpackets that provide information
|
|
1867
|
+
* about the key, such as the Revocation Key subpacket. It is also
|
|
1868
|
+
* appropriate for statements that non-self certifiers want to make
|
|
1869
|
+
* about the key itself, rather than the binding between a key and a
|
|
1870
|
+
* name. */
|
|
1871
|
+
key: 31,
|
|
1872
|
+
/** 0x20: Key revocation signature
|
|
1873
|
+
*
|
|
1874
|
+
* The signature is calculated directly on the key being revoked. A
|
|
1875
|
+
* revoked key is not to be used. Only revocation signatures by the
|
|
1876
|
+
* key being revoked, or by an authorized revocation key, should be
|
|
1877
|
+
* considered valid revocation signatures.a */
|
|
1878
|
+
keyRevocation: 32,
|
|
1879
|
+
/** 0x28: Subkey revocation signature
|
|
1880
|
+
*
|
|
1881
|
+
* The signature is calculated directly on the subkey being revoked.
|
|
1882
|
+
* A revoked subkey is not to be used. Only revocation signatures
|
|
1883
|
+
* by the top-level signature key that is bound to this subkey, or
|
|
1884
|
+
* by an authorized revocation key, should be considered valid
|
|
1885
|
+
* revocation signatures.
|
|
1886
|
+
*
|
|
1887
|
+
* Key revocation signatures (types 0x20 and 0x28)
|
|
1888
|
+
* hash only the key being revoked. */
|
|
1889
|
+
subkeyRevocation: 40,
|
|
1890
|
+
/** 0x40: Timestamp signature.
|
|
1891
|
+
* This signature is only meaningful for the timestamp contained in
|
|
1892
|
+
* it. */
|
|
1893
|
+
timestamp: 64,
|
|
1894
|
+
/** 0x50: Third-Party Confirmation signature.
|
|
1895
|
+
*
|
|
1896
|
+
* This signature is a signature over some other OpenPGP Signature
|
|
1897
|
+
* packet(s). It is analogous to a notary seal on the signed data.
|
|
1898
|
+
* A third-party signature SHOULD include Signature Target
|
|
1899
|
+
* subpacket(s) to give easy identification. Note that we really do
|
|
1900
|
+
* mean SHOULD. There are plausible uses for this (such as a blind
|
|
1901
|
+
* party that only sees the signature, not the key or source
|
|
1902
|
+
* document) that cannot include a target subpacket. */
|
|
1903
|
+
thirdParty: 80
|
|
1904
|
+
},
|
|
1905
|
+
|
|
1906
|
+
/** Signature subpacket type
|
|
1907
|
+
* @enum {Integer}
|
|
1908
|
+
* @readonly
|
|
1909
|
+
*/
|
|
1910
|
+
signatureSubpacket: {
|
|
1911
|
+
signatureCreationTime: 2,
|
|
1912
|
+
signatureExpirationTime: 3,
|
|
1913
|
+
exportableCertification: 4,
|
|
1914
|
+
trustSignature: 5,
|
|
1915
|
+
regularExpression: 6,
|
|
1916
|
+
revocable: 7,
|
|
1917
|
+
keyExpirationTime: 9,
|
|
1918
|
+
placeholderBackwardsCompatibility: 10,
|
|
1919
|
+
preferredSymmetricAlgorithms: 11,
|
|
1920
|
+
revocationKey: 12,
|
|
1921
|
+
issuer: 16,
|
|
1922
|
+
notationData: 20,
|
|
1923
|
+
preferredHashAlgorithms: 21,
|
|
1924
|
+
preferredCompressionAlgorithms: 22,
|
|
1925
|
+
keyServerPreferences: 23,
|
|
1926
|
+
preferredKeyServer: 24,
|
|
1927
|
+
primaryUserID: 25,
|
|
1928
|
+
policyURI: 26,
|
|
1929
|
+
keyFlags: 27,
|
|
1930
|
+
signersUserID: 28,
|
|
1931
|
+
reasonForRevocation: 29,
|
|
1932
|
+
features: 30,
|
|
1933
|
+
signatureTarget: 31,
|
|
1934
|
+
embeddedSignature: 32,
|
|
1935
|
+
issuerFingerprint: 33,
|
|
1936
|
+
preferredAEADAlgorithms: 34
|
|
1937
|
+
},
|
|
1938
|
+
|
|
1939
|
+
/** Key flags
|
|
1940
|
+
* @enum {Integer}
|
|
1941
|
+
* @readonly
|
|
1942
|
+
*/
|
|
1943
|
+
keyFlags: {
|
|
1944
|
+
/** 0x01 - This key may be used to certify other keys. */
|
|
1945
|
+
certifyKeys: 1,
|
|
1946
|
+
/** 0x02 - This key may be used to sign data. */
|
|
1947
|
+
signData: 2,
|
|
1948
|
+
/** 0x04 - This key may be used to encrypt communications. */
|
|
1949
|
+
encryptCommunication: 4,
|
|
1950
|
+
/** 0x08 - This key may be used to encrypt storage. */
|
|
1951
|
+
encryptStorage: 8,
|
|
1952
|
+
/** 0x10 - The private component of this key may have been split
|
|
1953
|
+
* by a secret-sharing mechanism. */
|
|
1954
|
+
splitPrivateKey: 16,
|
|
1955
|
+
/** 0x20 - This key may be used for authentication. */
|
|
1956
|
+
authentication: 32,
|
|
1957
|
+
/** This key may be used for forwarded communications */
|
|
1958
|
+
forwardedCommunication: 64,
|
|
1959
|
+
/** 0x80 - The private component of this key may be in the
|
|
1960
|
+
* possession of more than one person. */
|
|
1961
|
+
sharedPrivateKey: 128
|
|
1962
|
+
},
|
|
1963
|
+
|
|
1964
|
+
/** Armor type
|
|
1965
|
+
* @enum {Integer}
|
|
1966
|
+
* @readonly
|
|
1967
|
+
*/
|
|
1968
|
+
armor: {
|
|
1969
|
+
multipartSection: 0,
|
|
1970
|
+
multipartLast: 1,
|
|
1971
|
+
signed: 2,
|
|
1972
|
+
message: 3,
|
|
1973
|
+
publicKey: 4,
|
|
1974
|
+
privateKey: 5,
|
|
1975
|
+
signature: 6
|
|
1976
|
+
},
|
|
1977
|
+
|
|
1978
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
|
|
1979
|
+
* @enum {Integer}
|
|
1980
|
+
* @readonly
|
|
1981
|
+
*/
|
|
1982
|
+
reasonForRevocation: {
|
|
1983
|
+
/** No reason specified (key revocations or cert revocations) */
|
|
1984
|
+
noReason: 0,
|
|
1985
|
+
/** Key is superseded (key revocations) */
|
|
1986
|
+
keySuperseded: 1,
|
|
1987
|
+
/** Key material has been compromised (key revocations) */
|
|
1988
|
+
keyCompromised: 2,
|
|
1989
|
+
/** Key is retired and no longer used (key revocations) */
|
|
1990
|
+
keyRetired: 3,
|
|
1991
|
+
/** User ID information is no longer valid (cert revocations) */
|
|
1992
|
+
userIDInvalid: 32
|
|
1993
|
+
},
|
|
1994
|
+
|
|
1995
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
|
|
1996
|
+
* @enum {Integer}
|
|
1997
|
+
* @readonly
|
|
1998
|
+
*/
|
|
1999
|
+
features: {
|
|
2000
|
+
/** 0x01 - Modification Detection (packets 18 and 19) */
|
|
2001
|
+
modificationDetection: 1,
|
|
2002
|
+
/** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
|
|
2003
|
+
* Symmetric-Key Encrypted Session Key Packets (packet 3) */
|
|
2004
|
+
aead: 2,
|
|
2005
|
+
/** 0x04 - Version 5 Public-Key Packet format and corresponding new
|
|
2006
|
+
* fingerprint format */
|
|
2007
|
+
v5Keys: 4
|
|
2008
|
+
},
|
|
2009
|
+
|
|
2010
|
+
/**
|
|
2011
|
+
* Asserts validity of given value and converts from string/integer to integer.
|
|
2012
|
+
* @param {Object} type target enum type
|
|
2013
|
+
* @param {String|Integer} e value to check and/or convert
|
|
2014
|
+
* @returns {Integer} enum value if it exists
|
|
2015
|
+
* @throws {Error} if the value is invalid
|
|
2016
|
+
*/
|
|
2017
|
+
write: function(type, e) {
|
|
2018
|
+
if (typeof e === 'number') {
|
|
2019
|
+
e = this.read(type, e);
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
if (type[e] !== undefined) {
|
|
2023
|
+
return type[e];
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
throw new Error('Invalid enum value.');
|
|
2027
|
+
},
|
|
2028
|
+
|
|
2029
|
+
/**
|
|
2030
|
+
* Converts enum integer value to the corresponding string, if it exists.
|
|
2031
|
+
* @param {Object} type target enum type
|
|
2032
|
+
* @param {Integer} e value to convert
|
|
2033
|
+
* @returns {String} name of enum value if it exists
|
|
2034
|
+
* @throws {Error} if the value is invalid
|
|
2035
|
+
*/
|
|
2036
|
+
read: function(type, e) {
|
|
2037
|
+
if (!type[byValue]) {
|
|
2038
|
+
type[byValue] = [];
|
|
2039
|
+
Object.entries(type).forEach(([key, value]) => {
|
|
2040
|
+
type[byValue][value] = key;
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
if (type[byValue][e] !== undefined) {
|
|
2045
|
+
return type[byValue][e];
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
throw new Error('Invalid enum value.');
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
|
|
1532
2052
|
const debugMode = (() => {
|
|
1533
2053
|
try {
|
|
1534
2054
|
return process.env.NODE_ENV === 'development'; // eslint-disable-line no-process-env
|
|
@@ -2108,6 +2628,12 @@ const util = {
|
|
|
2108
2628
|
*/
|
|
2109
2629
|
selectUint8: function(cond, a, b) {
|
|
2110
2630
|
return (a & (256 - cond)) | (b & (255 + cond));
|
|
2631
|
+
},
|
|
2632
|
+
/**
|
|
2633
|
+
* @param {module:enums.symmetric} cipherAlgo
|
|
2634
|
+
*/
|
|
2635
|
+
isAES: function(cipherAlgo) {
|
|
2636
|
+
return cipherAlgo === enums.symmetric.aes128 || cipherAlgo === enums.symmetric.aes192 || cipherAlgo === enums.symmetric.aes256;
|
|
2111
2637
|
}
|
|
2112
2638
|
};
|
|
2113
2639
|
|
|
@@ -2222,517 +2748,6 @@ function uint8ArrayToB64(bytes, url) {
|
|
|
2222
2748
|
return encoded;
|
|
2223
2749
|
}
|
|
2224
2750
|
|
|
2225
|
-
/**
|
|
2226
|
-
* @module enums
|
|
2227
|
-
*/
|
|
2228
|
-
|
|
2229
|
-
const byValue = Symbol('byValue');
|
|
2230
|
-
|
|
2231
|
-
var enums = {
|
|
2232
|
-
|
|
2233
|
-
/** Maps curve names under various standards to one
|
|
2234
|
-
* @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
|
|
2235
|
-
* @enum {String}
|
|
2236
|
-
* @readonly
|
|
2237
|
-
*/
|
|
2238
|
-
curve: {
|
|
2239
|
-
/** NIST P-256 Curve */
|
|
2240
|
-
'p256': 'p256',
|
|
2241
|
-
'P-256': 'p256',
|
|
2242
|
-
'secp256r1': 'p256',
|
|
2243
|
-
'prime256v1': 'p256',
|
|
2244
|
-
'1.2.840.10045.3.1.7': 'p256',
|
|
2245
|
-
'2a8648ce3d030107': 'p256',
|
|
2246
|
-
'2A8648CE3D030107': 'p256',
|
|
2247
|
-
|
|
2248
|
-
/** NIST P-384 Curve */
|
|
2249
|
-
'p384': 'p384',
|
|
2250
|
-
'P-384': 'p384',
|
|
2251
|
-
'secp384r1': 'p384',
|
|
2252
|
-
'1.3.132.0.34': 'p384',
|
|
2253
|
-
'2b81040022': 'p384',
|
|
2254
|
-
'2B81040022': 'p384',
|
|
2255
|
-
|
|
2256
|
-
/** NIST P-521 Curve */
|
|
2257
|
-
'p521': 'p521',
|
|
2258
|
-
'P-521': 'p521',
|
|
2259
|
-
'secp521r1': 'p521',
|
|
2260
|
-
'1.3.132.0.35': 'p521',
|
|
2261
|
-
'2b81040023': 'p521',
|
|
2262
|
-
'2B81040023': 'p521',
|
|
2263
|
-
|
|
2264
|
-
/** SECG SECP256k1 Curve */
|
|
2265
|
-
'secp256k1': 'secp256k1',
|
|
2266
|
-
'1.3.132.0.10': 'secp256k1',
|
|
2267
|
-
'2b8104000a': 'secp256k1',
|
|
2268
|
-
'2B8104000A': 'secp256k1',
|
|
2269
|
-
|
|
2270
|
-
/** Ed25519 */
|
|
2271
|
-
'ED25519': 'ed25519',
|
|
2272
|
-
'ed25519': 'ed25519',
|
|
2273
|
-
'Ed25519': 'ed25519',
|
|
2274
|
-
'1.3.6.1.4.1.11591.15.1': 'ed25519',
|
|
2275
|
-
'2b06010401da470f01': 'ed25519',
|
|
2276
|
-
'2B06010401DA470F01': 'ed25519',
|
|
2277
|
-
|
|
2278
|
-
/** Curve25519 */
|
|
2279
|
-
'X25519': 'curve25519',
|
|
2280
|
-
'cv25519': 'curve25519',
|
|
2281
|
-
'curve25519': 'curve25519',
|
|
2282
|
-
'Curve25519': 'curve25519',
|
|
2283
|
-
'1.3.6.1.4.1.3029.1.5.1': 'curve25519',
|
|
2284
|
-
'2b060104019755010501': 'curve25519',
|
|
2285
|
-
'2B060104019755010501': 'curve25519',
|
|
2286
|
-
|
|
2287
|
-
/** BrainpoolP256r1 Curve */
|
|
2288
|
-
'brainpoolP256r1': 'brainpoolP256r1',
|
|
2289
|
-
'1.3.36.3.3.2.8.1.1.7': 'brainpoolP256r1',
|
|
2290
|
-
'2b2403030208010107': 'brainpoolP256r1',
|
|
2291
|
-
'2B2403030208010107': 'brainpoolP256r1',
|
|
2292
|
-
|
|
2293
|
-
/** BrainpoolP384r1 Curve */
|
|
2294
|
-
'brainpoolP384r1': 'brainpoolP384r1',
|
|
2295
|
-
'1.3.36.3.3.2.8.1.1.11': 'brainpoolP384r1',
|
|
2296
|
-
'2b240303020801010b': 'brainpoolP384r1',
|
|
2297
|
-
'2B240303020801010B': 'brainpoolP384r1',
|
|
2298
|
-
|
|
2299
|
-
/** BrainpoolP512r1 Curve */
|
|
2300
|
-
'brainpoolP512r1': 'brainpoolP512r1',
|
|
2301
|
-
'1.3.36.3.3.2.8.1.1.13': 'brainpoolP512r1',
|
|
2302
|
-
'2b240303020801010d': 'brainpoolP512r1',
|
|
2303
|
-
'2B240303020801010D': 'brainpoolP512r1'
|
|
2304
|
-
},
|
|
2305
|
-
|
|
2306
|
-
/** KDF parameters flags
|
|
2307
|
-
* Non-standard extensions (for now) to allow email forwarding
|
|
2308
|
-
* @enum {Integer}
|
|
2309
|
-
* @readonly
|
|
2310
|
-
*/
|
|
2311
|
-
kdfFlags: {
|
|
2312
|
-
/** Specify fingerprint to use instead of the recipient's */
|
|
2313
|
-
replace_fingerprint: 0x01,
|
|
2314
|
-
/** Specify custom parameters to use in the KDF digest computation */
|
|
2315
|
-
replace_kdf_params: 0x02
|
|
2316
|
-
},
|
|
2317
|
-
|
|
2318
|
-
/** A string to key specifier type
|
|
2319
|
-
* @enum {Integer}
|
|
2320
|
-
* @readonly
|
|
2321
|
-
*/
|
|
2322
|
-
s2k: {
|
|
2323
|
-
simple: 0,
|
|
2324
|
-
salted: 1,
|
|
2325
|
-
iterated: 3,
|
|
2326
|
-
argon2: 4,
|
|
2327
|
-
gnu: 101
|
|
2328
|
-
},
|
|
2329
|
-
|
|
2330
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.1|RFC4880bis-04, section 9.1}
|
|
2331
|
-
* @enum {Integer}
|
|
2332
|
-
* @readonly
|
|
2333
|
-
*/
|
|
2334
|
-
publicKey: {
|
|
2335
|
-
/** RSA (Encrypt or Sign) [HAC] */
|
|
2336
|
-
rsaEncryptSign: 1,
|
|
2337
|
-
/** RSA (Encrypt only) [HAC] */
|
|
2338
|
-
rsaEncrypt: 2,
|
|
2339
|
-
/** RSA (Sign only) [HAC] */
|
|
2340
|
-
rsaSign: 3,
|
|
2341
|
-
/** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
|
|
2342
|
-
elgamal: 16,
|
|
2343
|
-
/** DSA (Sign only) [FIPS186] [HAC] */
|
|
2344
|
-
dsa: 17,
|
|
2345
|
-
/** ECDH (Encrypt only) [RFC6637] */
|
|
2346
|
-
ecdh: 18,
|
|
2347
|
-
/** ECDSA (Sign only) [RFC6637] */
|
|
2348
|
-
ecdsa: 19,
|
|
2349
|
-
/** EdDSA (Sign only)
|
|
2350
|
-
* [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
|
|
2351
|
-
eddsa: 22,
|
|
2352
|
-
/** Reserved for AEDH */
|
|
2353
|
-
aedh: 23,
|
|
2354
|
-
/** Reserved for AEDSA */
|
|
2355
|
-
aedsa: 24,
|
|
2356
|
-
/** Symmetric authenticated encryption algorithms */
|
|
2357
|
-
aead: 100,
|
|
2358
|
-
/** Authentication using CMAC */
|
|
2359
|
-
hmac: 101
|
|
2360
|
-
},
|
|
2361
|
-
|
|
2362
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
|
|
2363
|
-
* @enum {Integer}
|
|
2364
|
-
* @readonly
|
|
2365
|
-
*/
|
|
2366
|
-
symmetric: {
|
|
2367
|
-
plaintext: 0,
|
|
2368
|
-
/** Not implemented! */
|
|
2369
|
-
idea: 1,
|
|
2370
|
-
tripledes: 2,
|
|
2371
|
-
cast5: 3,
|
|
2372
|
-
blowfish: 4,
|
|
2373
|
-
aes128: 7,
|
|
2374
|
-
aes192: 8,
|
|
2375
|
-
aes256: 9,
|
|
2376
|
-
twofish: 10
|
|
2377
|
-
},
|
|
2378
|
-
|
|
2379
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
|
|
2380
|
-
* @enum {Integer}
|
|
2381
|
-
* @readonly
|
|
2382
|
-
*/
|
|
2383
|
-
compression: {
|
|
2384
|
-
uncompressed: 0,
|
|
2385
|
-
/** RFC1951 */
|
|
2386
|
-
zip: 1,
|
|
2387
|
-
/** RFC1950 */
|
|
2388
|
-
zlib: 2,
|
|
2389
|
-
bzip2: 3
|
|
2390
|
-
},
|
|
2391
|
-
|
|
2392
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
|
|
2393
|
-
* @enum {Integer}
|
|
2394
|
-
* @readonly
|
|
2395
|
-
*/
|
|
2396
|
-
hash: {
|
|
2397
|
-
md5: 1,
|
|
2398
|
-
sha1: 2,
|
|
2399
|
-
ripemd: 3,
|
|
2400
|
-
sha256: 8,
|
|
2401
|
-
sha384: 9,
|
|
2402
|
-
sha512: 10,
|
|
2403
|
-
sha224: 11
|
|
2404
|
-
},
|
|
2405
|
-
|
|
2406
|
-
/** A list of hash names as accepted by webCrypto functions.
|
|
2407
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
|
|
2408
|
-
* @enum {String}
|
|
2409
|
-
*/
|
|
2410
|
-
webHash: {
|
|
2411
|
-
'SHA-1': 2,
|
|
2412
|
-
'SHA-256': 8,
|
|
2413
|
-
'SHA-384': 9,
|
|
2414
|
-
'SHA-512': 10
|
|
2415
|
-
},
|
|
2416
|
-
|
|
2417
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
|
|
2418
|
-
* @enum {Integer}
|
|
2419
|
-
* @readonly
|
|
2420
|
-
*/
|
|
2421
|
-
aead: {
|
|
2422
|
-
eax: 1,
|
|
2423
|
-
ocb: 2,
|
|
2424
|
-
experimentalGCM: 100 // Private algorithm
|
|
2425
|
-
},
|
|
2426
|
-
|
|
2427
|
-
/** A list of packet types and numeric tags associated with them.
|
|
2428
|
-
* @enum {Integer}
|
|
2429
|
-
* @readonly
|
|
2430
|
-
*/
|
|
2431
|
-
packet: {
|
|
2432
|
-
publicKeyEncryptedSessionKey: 1,
|
|
2433
|
-
signature: 2,
|
|
2434
|
-
symEncryptedSessionKey: 3,
|
|
2435
|
-
onePassSignature: 4,
|
|
2436
|
-
secretKey: 5,
|
|
2437
|
-
publicKey: 6,
|
|
2438
|
-
secretSubkey: 7,
|
|
2439
|
-
compressedData: 8,
|
|
2440
|
-
symmetricallyEncryptedData: 9,
|
|
2441
|
-
marker: 10,
|
|
2442
|
-
literalData: 11,
|
|
2443
|
-
trust: 12,
|
|
2444
|
-
userID: 13,
|
|
2445
|
-
publicSubkey: 14,
|
|
2446
|
-
userAttribute: 17,
|
|
2447
|
-
symEncryptedIntegrityProtectedData: 18,
|
|
2448
|
-
modificationDetectionCode: 19,
|
|
2449
|
-
aeadEncryptedData: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
|
|
2450
|
-
},
|
|
2451
|
-
|
|
2452
|
-
/** Data types in the literal packet
|
|
2453
|
-
* @enum {Integer}
|
|
2454
|
-
* @readonly
|
|
2455
|
-
*/
|
|
2456
|
-
literal: {
|
|
2457
|
-
/** Binary data 'b' */
|
|
2458
|
-
binary: 'b'.charCodeAt(),
|
|
2459
|
-
/** Text data 't' */
|
|
2460
|
-
text: 't'.charCodeAt(),
|
|
2461
|
-
/** Utf8 data 'u' */
|
|
2462
|
-
utf8: 'u'.charCodeAt(),
|
|
2463
|
-
/** MIME message body part 'm' */
|
|
2464
|
-
mime: 'm'.charCodeAt()
|
|
2465
|
-
},
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
/** One pass signature packet type
|
|
2469
|
-
* @enum {Integer}
|
|
2470
|
-
* @readonly
|
|
2471
|
-
*/
|
|
2472
|
-
signature: {
|
|
2473
|
-
/** 0x00: Signature of a binary document. */
|
|
2474
|
-
binary: 0,
|
|
2475
|
-
/** 0x01: Signature of a canonical text document.
|
|
2476
|
-
*
|
|
2477
|
-
* Canonicalyzing the document by converting line endings. */
|
|
2478
|
-
text: 1,
|
|
2479
|
-
/** 0x02: Standalone signature.
|
|
2480
|
-
*
|
|
2481
|
-
* This signature is a signature of only its own subpacket contents.
|
|
2482
|
-
* It is calculated identically to a signature over a zero-lengh
|
|
2483
|
-
* binary document. Note that it doesn't make sense to have a V3
|
|
2484
|
-
* standalone signature. */
|
|
2485
|
-
standalone: 2,
|
|
2486
|
-
/** 0x10: Generic certification of a User ID and Public-Key packet.
|
|
2487
|
-
*
|
|
2488
|
-
* The issuer of this certification does not make any particular
|
|
2489
|
-
* assertion as to how well the certifier has checked that the owner
|
|
2490
|
-
* of the key is in fact the person described by the User ID. */
|
|
2491
|
-
certGeneric: 16,
|
|
2492
|
-
/** 0x11: Persona certification of a User ID and Public-Key packet.
|
|
2493
|
-
*
|
|
2494
|
-
* The issuer of this certification has not done any verification of
|
|
2495
|
-
* the claim that the owner of this key is the User ID specified. */
|
|
2496
|
-
certPersona: 17,
|
|
2497
|
-
/** 0x12: Casual certification of a User ID and Public-Key packet.
|
|
2498
|
-
*
|
|
2499
|
-
* The issuer of this certification has done some casual
|
|
2500
|
-
* verification of the claim of identity. */
|
|
2501
|
-
certCasual: 18,
|
|
2502
|
-
/** 0x13: Positive certification of a User ID and Public-Key packet.
|
|
2503
|
-
*
|
|
2504
|
-
* The issuer of this certification has done substantial
|
|
2505
|
-
* verification of the claim of identity.
|
|
2506
|
-
*
|
|
2507
|
-
* Most OpenPGP implementations make their "key signatures" as 0x10
|
|
2508
|
-
* certifications. Some implementations can issue 0x11-0x13
|
|
2509
|
-
* certifications, but few differentiate between the types. */
|
|
2510
|
-
certPositive: 19,
|
|
2511
|
-
/** 0x30: Certification revocation signature
|
|
2512
|
-
*
|
|
2513
|
-
* This signature revokes an earlier User ID certification signature
|
|
2514
|
-
* (signature class 0x10 through 0x13) or direct-key signature
|
|
2515
|
-
* (0x1F). It should be issued by the same key that issued the
|
|
2516
|
-
* revoked signature or an authorized revocation key. The signature
|
|
2517
|
-
* is computed over the same data as the certificate that it
|
|
2518
|
-
* revokes, and should have a later creation date than that
|
|
2519
|
-
* certificate. */
|
|
2520
|
-
certRevocation: 48,
|
|
2521
|
-
/** 0x18: Subkey Binding Signature
|
|
2522
|
-
*
|
|
2523
|
-
* This signature is a statement by the top-level signing key that
|
|
2524
|
-
* indicates that it owns the subkey. This signature is calculated
|
|
2525
|
-
* directly on the primary key and subkey, and not on any User ID or
|
|
2526
|
-
* other packets. A signature that binds a signing subkey MUST have
|
|
2527
|
-
* an Embedded Signature subpacket in this binding signature that
|
|
2528
|
-
* contains a 0x19 signature made by the signing subkey on the
|
|
2529
|
-
* primary key and subkey. */
|
|
2530
|
-
subkeyBinding: 24,
|
|
2531
|
-
/** 0x19: Primary Key Binding Signature
|
|
2532
|
-
*
|
|
2533
|
-
* This signature is a statement by a signing subkey, indicating
|
|
2534
|
-
* that it is owned by the primary key and subkey. This signature
|
|
2535
|
-
* is calculated the same way as a 0x18 signature: directly on the
|
|
2536
|
-
* primary key and subkey, and not on any User ID or other packets.
|
|
2537
|
-
*
|
|
2538
|
-
* When a signature is made over a key, the hash data starts with the
|
|
2539
|
-
* octet 0x99, followed by a two-octet length of the key, and then body
|
|
2540
|
-
* of the key packet. (Note that this is an old-style packet header for
|
|
2541
|
-
* a key packet with two-octet length.) A subkey binding signature
|
|
2542
|
-
* (type 0x18) or primary key binding signature (type 0x19) then hashes
|
|
2543
|
-
* the subkey using the same format as the main key (also using 0x99 as
|
|
2544
|
-
* the first octet). */
|
|
2545
|
-
keyBinding: 25,
|
|
2546
|
-
/** 0x1F: Signature directly on a key
|
|
2547
|
-
*
|
|
2548
|
-
* This signature is calculated directly on a key. It binds the
|
|
2549
|
-
* information in the Signature subpackets to the key, and is
|
|
2550
|
-
* appropriate to be used for subpackets that provide information
|
|
2551
|
-
* about the key, such as the Revocation Key subpacket. It is also
|
|
2552
|
-
* appropriate for statements that non-self certifiers want to make
|
|
2553
|
-
* about the key itself, rather than the binding between a key and a
|
|
2554
|
-
* name. */
|
|
2555
|
-
key: 31,
|
|
2556
|
-
/** 0x20: Key revocation signature
|
|
2557
|
-
*
|
|
2558
|
-
* The signature is calculated directly on the key being revoked. A
|
|
2559
|
-
* revoked key is not to be used. Only revocation signatures by the
|
|
2560
|
-
* key being revoked, or by an authorized revocation key, should be
|
|
2561
|
-
* considered valid revocation signatures.a */
|
|
2562
|
-
keyRevocation: 32,
|
|
2563
|
-
/** 0x28: Subkey revocation signature
|
|
2564
|
-
*
|
|
2565
|
-
* The signature is calculated directly on the subkey being revoked.
|
|
2566
|
-
* A revoked subkey is not to be used. Only revocation signatures
|
|
2567
|
-
* by the top-level signature key that is bound to this subkey, or
|
|
2568
|
-
* by an authorized revocation key, should be considered valid
|
|
2569
|
-
* revocation signatures.
|
|
2570
|
-
*
|
|
2571
|
-
* Key revocation signatures (types 0x20 and 0x28)
|
|
2572
|
-
* hash only the key being revoked. */
|
|
2573
|
-
subkeyRevocation: 40,
|
|
2574
|
-
/** 0x40: Timestamp signature.
|
|
2575
|
-
* This signature is only meaningful for the timestamp contained in
|
|
2576
|
-
* it. */
|
|
2577
|
-
timestamp: 64,
|
|
2578
|
-
/** 0x50: Third-Party Confirmation signature.
|
|
2579
|
-
*
|
|
2580
|
-
* This signature is a signature over some other OpenPGP Signature
|
|
2581
|
-
* packet(s). It is analogous to a notary seal on the signed data.
|
|
2582
|
-
* A third-party signature SHOULD include Signature Target
|
|
2583
|
-
* subpacket(s) to give easy identification. Note that we really do
|
|
2584
|
-
* mean SHOULD. There are plausible uses for this (such as a blind
|
|
2585
|
-
* party that only sees the signature, not the key or source
|
|
2586
|
-
* document) that cannot include a target subpacket. */
|
|
2587
|
-
thirdParty: 80
|
|
2588
|
-
},
|
|
2589
|
-
|
|
2590
|
-
/** Signature subpacket type
|
|
2591
|
-
* @enum {Integer}
|
|
2592
|
-
* @readonly
|
|
2593
|
-
*/
|
|
2594
|
-
signatureSubpacket: {
|
|
2595
|
-
signatureCreationTime: 2,
|
|
2596
|
-
signatureExpirationTime: 3,
|
|
2597
|
-
exportableCertification: 4,
|
|
2598
|
-
trustSignature: 5,
|
|
2599
|
-
regularExpression: 6,
|
|
2600
|
-
revocable: 7,
|
|
2601
|
-
keyExpirationTime: 9,
|
|
2602
|
-
placeholderBackwardsCompatibility: 10,
|
|
2603
|
-
preferredSymmetricAlgorithms: 11,
|
|
2604
|
-
revocationKey: 12,
|
|
2605
|
-
issuer: 16,
|
|
2606
|
-
notationData: 20,
|
|
2607
|
-
preferredHashAlgorithms: 21,
|
|
2608
|
-
preferredCompressionAlgorithms: 22,
|
|
2609
|
-
keyServerPreferences: 23,
|
|
2610
|
-
preferredKeyServer: 24,
|
|
2611
|
-
primaryUserID: 25,
|
|
2612
|
-
policyURI: 26,
|
|
2613
|
-
keyFlags: 27,
|
|
2614
|
-
signersUserID: 28,
|
|
2615
|
-
reasonForRevocation: 29,
|
|
2616
|
-
features: 30,
|
|
2617
|
-
signatureTarget: 31,
|
|
2618
|
-
embeddedSignature: 32,
|
|
2619
|
-
issuerFingerprint: 33,
|
|
2620
|
-
preferredAEADAlgorithms: 34
|
|
2621
|
-
},
|
|
2622
|
-
|
|
2623
|
-
/** Key flags
|
|
2624
|
-
* @enum {Integer}
|
|
2625
|
-
* @readonly
|
|
2626
|
-
*/
|
|
2627
|
-
keyFlags: {
|
|
2628
|
-
/** 0x01 - This key may be used to certify other keys. */
|
|
2629
|
-
certifyKeys: 1,
|
|
2630
|
-
/** 0x02 - This key may be used to sign data. */
|
|
2631
|
-
signData: 2,
|
|
2632
|
-
/** 0x04 - This key may be used to encrypt communications. */
|
|
2633
|
-
encryptCommunication: 4,
|
|
2634
|
-
/** 0x08 - This key may be used to encrypt storage. */
|
|
2635
|
-
encryptStorage: 8,
|
|
2636
|
-
/** 0x10 - The private component of this key may have been split
|
|
2637
|
-
* by a secret-sharing mechanism. */
|
|
2638
|
-
splitPrivateKey: 16,
|
|
2639
|
-
/** 0x20 - This key may be used for authentication. */
|
|
2640
|
-
authentication: 32,
|
|
2641
|
-
/** This key may be used for forwarded communications */
|
|
2642
|
-
forwardedCommunication: 64,
|
|
2643
|
-
/** 0x80 - The private component of this key may be in the
|
|
2644
|
-
* possession of more than one person. */
|
|
2645
|
-
sharedPrivateKey: 128
|
|
2646
|
-
},
|
|
2647
|
-
|
|
2648
|
-
/** Armor type
|
|
2649
|
-
* @enum {Integer}
|
|
2650
|
-
* @readonly
|
|
2651
|
-
*/
|
|
2652
|
-
armor: {
|
|
2653
|
-
multipartSection: 0,
|
|
2654
|
-
multipartLast: 1,
|
|
2655
|
-
signed: 2,
|
|
2656
|
-
message: 3,
|
|
2657
|
-
publicKey: 4,
|
|
2658
|
-
privateKey: 5,
|
|
2659
|
-
signature: 6
|
|
2660
|
-
},
|
|
2661
|
-
|
|
2662
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
|
|
2663
|
-
* @enum {Integer}
|
|
2664
|
-
* @readonly
|
|
2665
|
-
*/
|
|
2666
|
-
reasonForRevocation: {
|
|
2667
|
-
/** No reason specified (key revocations or cert revocations) */
|
|
2668
|
-
noReason: 0,
|
|
2669
|
-
/** Key is superseded (key revocations) */
|
|
2670
|
-
keySuperseded: 1,
|
|
2671
|
-
/** Key material has been compromised (key revocations) */
|
|
2672
|
-
keyCompromised: 2,
|
|
2673
|
-
/** Key is retired and no longer used (key revocations) */
|
|
2674
|
-
keyRetired: 3,
|
|
2675
|
-
/** User ID information is no longer valid (cert revocations) */
|
|
2676
|
-
userIDInvalid: 32
|
|
2677
|
-
},
|
|
2678
|
-
|
|
2679
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
|
|
2680
|
-
* @enum {Integer}
|
|
2681
|
-
* @readonly
|
|
2682
|
-
*/
|
|
2683
|
-
features: {
|
|
2684
|
-
/** 0x01 - Modification Detection (packets 18 and 19) */
|
|
2685
|
-
modificationDetection: 1,
|
|
2686
|
-
/** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
|
|
2687
|
-
* Symmetric-Key Encrypted Session Key Packets (packet 3) */
|
|
2688
|
-
aead: 2,
|
|
2689
|
-
/** 0x04 - Version 5 Public-Key Packet format and corresponding new
|
|
2690
|
-
* fingerprint format */
|
|
2691
|
-
v5Keys: 4
|
|
2692
|
-
},
|
|
2693
|
-
|
|
2694
|
-
/**
|
|
2695
|
-
* Asserts validity of given value and converts from string/integer to integer.
|
|
2696
|
-
* @param {Object} type target enum type
|
|
2697
|
-
* @param {String|Integer} e value to check and/or convert
|
|
2698
|
-
* @returns {Integer} enum value if it exists
|
|
2699
|
-
* @throws {Error} if the value is invalid
|
|
2700
|
-
*/
|
|
2701
|
-
write: function(type, e) {
|
|
2702
|
-
if (typeof e === 'number') {
|
|
2703
|
-
e = this.read(type, e);
|
|
2704
|
-
}
|
|
2705
|
-
|
|
2706
|
-
if (type[e] !== undefined) {
|
|
2707
|
-
return type[e];
|
|
2708
|
-
}
|
|
2709
|
-
|
|
2710
|
-
throw new Error('Invalid enum value.');
|
|
2711
|
-
},
|
|
2712
|
-
|
|
2713
|
-
/**
|
|
2714
|
-
* Converts enum integer value to the corresponding string, if it exists.
|
|
2715
|
-
* @param {Object} type target enum type
|
|
2716
|
-
* @param {Integer} e value to convert
|
|
2717
|
-
* @returns {String} name of enum value if it exists
|
|
2718
|
-
* @throws {Error} if the value is invalid
|
|
2719
|
-
*/
|
|
2720
|
-
read: function(type, e) {
|
|
2721
|
-
if (!type[byValue]) {
|
|
2722
|
-
type[byValue] = [];
|
|
2723
|
-
Object.entries(type).forEach(([key, value]) => {
|
|
2724
|
-
type[byValue][value] = key;
|
|
2725
|
-
});
|
|
2726
|
-
}
|
|
2727
|
-
|
|
2728
|
-
if (type[byValue][e] !== undefined) {
|
|
2729
|
-
return type[byValue][e];
|
|
2730
|
-
}
|
|
2731
|
-
|
|
2732
|
-
throw new Error('Invalid enum value.');
|
|
2733
|
-
}
|
|
2734
|
-
};
|
|
2735
|
-
|
|
2736
2751
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
2737
2752
|
|
|
2738
2753
|
var config = {
|
|
@@ -2949,7 +2964,7 @@ var config = {
|
|
|
2949
2964
|
* @memberof module:config
|
|
2950
2965
|
* @property {String} versionString A version string to be included in armored messages
|
|
2951
2966
|
*/
|
|
2952
|
-
versionString: 'OpenPGP.js 5.
|
|
2967
|
+
versionString: 'OpenPGP.js 5.10.2',
|
|
2953
2968
|
/**
|
|
2954
2969
|
* @memberof module:config
|
|
2955
2970
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -3441,6 +3456,7 @@ class KeyID {
|
|
|
3441
3456
|
*/
|
|
3442
3457
|
read(bytes) {
|
|
3443
3458
|
this.bytes = util.uint8ArrayToString(bytes.subarray(0, 8));
|
|
3459
|
+
return this.bytes.length;
|
|
3444
3460
|
}
|
|
3445
3461
|
|
|
3446
3462
|
/**
|
|
@@ -9997,7 +10013,7 @@ async function encrypt(algo, key, plaintext, iv, config) {
|
|
|
9997
10013
|
if (util.getNodeCrypto() && nodeAlgos[algoName]) { // Node crypto library.
|
|
9998
10014
|
return nodeEncrypt(algo, key, plaintext, iv);
|
|
9999
10015
|
}
|
|
10000
|
-
if (
|
|
10016
|
+
if (util.isAES(algo)) {
|
|
10001
10017
|
return aesEncrypt(algo, key, plaintext, iv, config);
|
|
10002
10018
|
}
|
|
10003
10019
|
|
|
@@ -10040,7 +10056,7 @@ async function decrypt(algo, key, ciphertext, iv) {
|
|
|
10040
10056
|
if (util.getNodeCrypto() && nodeAlgos[algoName]) { // Node crypto library.
|
|
10041
10057
|
return nodeDecrypt(algo, key, ciphertext, iv);
|
|
10042
10058
|
}
|
|
10043
|
-
if (
|
|
10059
|
+
if (util.isAES(algo)) {
|
|
10044
10060
|
return aesDecrypt(algo, key, ciphertext, iv);
|
|
10045
10061
|
}
|
|
10046
10062
|
|
|
@@ -10059,7 +10075,7 @@ async function decrypt(algo, key, ciphertext, iv) {
|
|
|
10059
10075
|
let j = 0;
|
|
10060
10076
|
while (chunk ? ct.length >= block_size : ct.length) {
|
|
10061
10077
|
const decblock = cipherfn.encrypt(blockp);
|
|
10062
|
-
blockp = ct;
|
|
10078
|
+
blockp = ct.subarray(0, block_size);
|
|
10063
10079
|
for (i = 0; i < block_size; i++) {
|
|
10064
10080
|
plaintext[j++] = blockp[i] ^ decblock[i];
|
|
10065
10081
|
}
|
|
@@ -13626,7 +13642,7 @@ const curves = {
|
|
|
13626
13642
|
}
|
|
13627
13643
|
};
|
|
13628
13644
|
|
|
13629
|
-
class
|
|
13645
|
+
class CurveWithOID {
|
|
13630
13646
|
constructor(oidOrName, params) {
|
|
13631
13647
|
try {
|
|
13632
13648
|
if (util.isArray(oidOrName) ||
|
|
@@ -13703,7 +13719,7 @@ class Curve {
|
|
|
13703
13719
|
async function generate$1(curve) {
|
|
13704
13720
|
const BigInteger = await util.getBigInteger();
|
|
13705
13721
|
|
|
13706
|
-
curve = new
|
|
13722
|
+
curve = new CurveWithOID(curve);
|
|
13707
13723
|
const keyPair = await curve.genKeyPair();
|
|
13708
13724
|
const Q = new BigInteger(keyPair.publicKey).toUint8Array();
|
|
13709
13725
|
const secret = new BigInteger(keyPair.privateKey).toUint8Array('be', curve.payloadSize);
|
|
@@ -13892,7 +13908,7 @@ const nodeCrypto$8 = util.getNodeCrypto();
|
|
|
13892
13908
|
* @async
|
|
13893
13909
|
*/
|
|
13894
13910
|
async function sign$1(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
13895
|
-
const curve = new
|
|
13911
|
+
const curve = new CurveWithOID(oid);
|
|
13896
13912
|
if (message && !util.isStream(message)) {
|
|
13897
13913
|
const keyPair = { publicKey, privateKey };
|
|
13898
13914
|
switch (curve.type) {
|
|
@@ -13937,7 +13953,7 @@ async function sign$1(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
13937
13953
|
* @async
|
|
13938
13954
|
*/
|
|
13939
13955
|
async function verify$1(oid, hashAlgo, signature, message, publicKey, hashed) {
|
|
13940
|
-
const curve = new
|
|
13956
|
+
const curve = new CurveWithOID(oid);
|
|
13941
13957
|
if (message && !util.isStream(message)) {
|
|
13942
13958
|
switch (curve.type) {
|
|
13943
13959
|
case 'web':
|
|
@@ -13971,7 +13987,7 @@ async function verify$1(oid, hashAlgo, signature, message, publicKey, hashed) {
|
|
|
13971
13987
|
* @async
|
|
13972
13988
|
*/
|
|
13973
13989
|
async function validateParams$2(oid, Q, d) {
|
|
13974
|
-
const curve = new
|
|
13990
|
+
const curve = new CurveWithOID(oid);
|
|
13975
13991
|
// Reject curves x25519 and ed25519
|
|
13976
13992
|
if (curve.keyType !== enums.publicKey.ecdsa) {
|
|
13977
13993
|
return false;
|
|
@@ -14174,7 +14190,7 @@ var ecdsa = /*#__PURE__*/Object.freeze({
|
|
|
14174
14190
|
naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
|
|
14175
14191
|
|
|
14176
14192
|
/**
|
|
14177
|
-
* Sign a message using the provided key
|
|
14193
|
+
* Sign a message using the provided legacy EdDSA key
|
|
14178
14194
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14179
14195
|
* @param {module:enums.hash} hashAlgo - Hash algorithm used to sign (must be sha256 or stronger)
|
|
14180
14196
|
* @param {Uint8Array} message - Message to sign
|
|
@@ -14202,7 +14218,7 @@ async function sign$2(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
14202
14218
|
}
|
|
14203
14219
|
|
|
14204
14220
|
/**
|
|
14205
|
-
* Verifies if a signature is valid for a message
|
|
14221
|
+
* Verifies if a legacy EdDSA signature is valid for a message
|
|
14206
14222
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14207
14223
|
* @param {module:enums.hash} hashAlgo - Hash algorithm used in the signature
|
|
14208
14224
|
* @param {{r: Uint8Array,
|
|
@@ -14218,7 +14234,7 @@ async function verify$2(oid, hashAlgo, { r, s }, m, publicKey, hashed) {
|
|
|
14218
14234
|
return naclFastLight.sign.detached.verify(hashed, signature, publicKey.subarray(1));
|
|
14219
14235
|
}
|
|
14220
14236
|
/**
|
|
14221
|
-
* Validate EdDSA parameters
|
|
14237
|
+
* Validate legacy EdDSA parameters
|
|
14222
14238
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14223
14239
|
* @param {Uint8Array} Q - EdDSA public point
|
|
14224
14240
|
* @param {Uint8Array} k - EdDSA secret seed
|
|
@@ -14238,9 +14254,10 @@ async function validateParams$3(oid, Q, k) {
|
|
|
14238
14254
|
const { publicKey } = naclFastLight.sign.keyPair.fromSeed(k);
|
|
14239
14255
|
const dG = new Uint8Array([0x40, ...publicKey]); // Add public key prefix
|
|
14240
14256
|
return util.equalsUint8Array(Q, dG);
|
|
14257
|
+
|
|
14241
14258
|
}
|
|
14242
14259
|
|
|
14243
|
-
var
|
|
14260
|
+
var eddsa_legacy = /*#__PURE__*/Object.freeze({
|
|
14244
14261
|
__proto__: null,
|
|
14245
14262
|
sign: sign$2,
|
|
14246
14263
|
verify: verify$2,
|
|
@@ -14249,6 +14266,113 @@ var eddsa = /*#__PURE__*/Object.freeze({
|
|
|
14249
14266
|
|
|
14250
14267
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14251
14268
|
|
|
14269
|
+
naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
|
|
14270
|
+
|
|
14271
|
+
/**
|
|
14272
|
+
* Generate (non-legacy) EdDSA key
|
|
14273
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14274
|
+
* @returns {Promise<{ A: Uint8Array, seed: Uint8Array }>}
|
|
14275
|
+
*/
|
|
14276
|
+
async function generate$2(algo) {
|
|
14277
|
+
switch (algo) {
|
|
14278
|
+
case enums.publicKey.ed25519: {
|
|
14279
|
+
const seed = getRandomBytes(32);
|
|
14280
|
+
const { publicKey: A } = naclFastLight.sign.keyPair.fromSeed(seed);
|
|
14281
|
+
return { A, seed };
|
|
14282
|
+
}
|
|
14283
|
+
default:
|
|
14284
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14285
|
+
}
|
|
14286
|
+
}
|
|
14287
|
+
|
|
14288
|
+
/**
|
|
14289
|
+
* Sign a message using the provided key
|
|
14290
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14291
|
+
* @param {module:enums.hash} hashAlgo - Hash algorithm used to sign (must be sha256 or stronger)
|
|
14292
|
+
* @param {Uint8Array} message - Message to sign
|
|
14293
|
+
* @param {Uint8Array} publicKey - Public key
|
|
14294
|
+
* @param {Uint8Array} privateKey - Private key used to sign the message
|
|
14295
|
+
* @param {Uint8Array} hashed - The hashed message
|
|
14296
|
+
* @returns {Promise<{
|
|
14297
|
+
* RS: Uint8Array
|
|
14298
|
+
* }>} Signature of the message
|
|
14299
|
+
* @async
|
|
14300
|
+
*/
|
|
14301
|
+
async function sign$3(algo, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
14302
|
+
if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(enums.hash.sha256)) {
|
|
14303
|
+
// see https://tools.ietf.org/id/draft-ietf-openpgp-rfc4880bis-10.html#section-15-7.2
|
|
14304
|
+
throw new Error('Hash algorithm too weak: sha256 or stronger is required for EdDSA.');
|
|
14305
|
+
}
|
|
14306
|
+
switch (algo) {
|
|
14307
|
+
case enums.publicKey.ed25519: {
|
|
14308
|
+
const secretKey = util.concatUint8Array([privateKey, publicKey]);
|
|
14309
|
+
const signature = naclFastLight.sign.detached(hashed, secretKey);
|
|
14310
|
+
return { RS: signature };
|
|
14311
|
+
}
|
|
14312
|
+
case enums.publicKey.ed448:
|
|
14313
|
+
default:
|
|
14314
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14315
|
+
}
|
|
14316
|
+
|
|
14317
|
+
}
|
|
14318
|
+
|
|
14319
|
+
/**
|
|
14320
|
+
* Verifies if a signature is valid for a message
|
|
14321
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14322
|
+
* @param {module:enums.hash} hashAlgo - Hash algorithm used in the signature
|
|
14323
|
+
* @param {{ RS: Uint8Array }} signature Signature to verify the message
|
|
14324
|
+
* @param {Uint8Array} m - Message to verify
|
|
14325
|
+
* @param {Uint8Array} publicKey - Public key used to verify the message
|
|
14326
|
+
* @param {Uint8Array} hashed - The hashed message
|
|
14327
|
+
* @returns {Boolean}
|
|
14328
|
+
* @async
|
|
14329
|
+
*/
|
|
14330
|
+
async function verify$3(algo, hashAlgo, { RS }, m, publicKey, hashed) {
|
|
14331
|
+
switch (algo) {
|
|
14332
|
+
case enums.publicKey.ed25519: {
|
|
14333
|
+
return naclFastLight.sign.detached.verify(hashed, RS, publicKey);
|
|
14334
|
+
}
|
|
14335
|
+
case enums.publicKey.ed448:
|
|
14336
|
+
default:
|
|
14337
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14338
|
+
}
|
|
14339
|
+
}
|
|
14340
|
+
/**
|
|
14341
|
+
* Validate (non-legacy) EdDSA parameters
|
|
14342
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14343
|
+
* @param {Uint8Array} A - EdDSA public point
|
|
14344
|
+
* @param {Uint8Array} seed - EdDSA secret seed
|
|
14345
|
+
* @param {Uint8Array} oid - (legacy only) EdDSA OID
|
|
14346
|
+
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14347
|
+
* @async
|
|
14348
|
+
*/
|
|
14349
|
+
async function validateParams$4(algo, A, seed) {
|
|
14350
|
+
switch (algo) {
|
|
14351
|
+
case enums.publicKey.ed25519: {
|
|
14352
|
+
/**
|
|
14353
|
+
* Derive public point A' from private key
|
|
14354
|
+
* and expect A == A'
|
|
14355
|
+
*/
|
|
14356
|
+
const { publicKey } = naclFastLight.sign.keyPair.fromSeed(seed);
|
|
14357
|
+
return util.equalsUint8Array(A, publicKey);
|
|
14358
|
+
}
|
|
14359
|
+
|
|
14360
|
+
case enums.publicKey.ed448: // unsupported
|
|
14361
|
+
default:
|
|
14362
|
+
return false;
|
|
14363
|
+
}
|
|
14364
|
+
}
|
|
14365
|
+
|
|
14366
|
+
var eddsa = /*#__PURE__*/Object.freeze({
|
|
14367
|
+
__proto__: null,
|
|
14368
|
+
generate: generate$2,
|
|
14369
|
+
sign: sign$3,
|
|
14370
|
+
verify: verify$3,
|
|
14371
|
+
validateParams: validateParams$4
|
|
14372
|
+
});
|
|
14373
|
+
|
|
14374
|
+
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14375
|
+
|
|
14252
14376
|
/**
|
|
14253
14377
|
* AES key wrap
|
|
14254
14378
|
* @function
|
|
@@ -14436,7 +14560,7 @@ const nodeCrypto$9 = util.getNodeCrypto();
|
|
|
14436
14560
|
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14437
14561
|
* @async
|
|
14438
14562
|
*/
|
|
14439
|
-
async function validateParams$
|
|
14563
|
+
async function validateParams$5(oid, Q, d) {
|
|
14440
14564
|
return validateStandardParams(enums.publicKey.ecdh, oid, Q, d);
|
|
14441
14565
|
}
|
|
14442
14566
|
|
|
@@ -14478,7 +14602,7 @@ async function kdf(hashAlgo, X, length, param, stripLeading = false, stripTraili
|
|
|
14478
14602
|
/**
|
|
14479
14603
|
* Generate ECDHE ephemeral key and secret from public key
|
|
14480
14604
|
*
|
|
14481
|
-
* @param {
|
|
14605
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14482
14606
|
* @param {Uint8Array} Q - Recipient public key
|
|
14483
14607
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14484
14608
|
* @async
|
|
@@ -14521,7 +14645,7 @@ async function genPublicEphemeralKey(curve, Q) {
|
|
|
14521
14645
|
async function encrypt$3(oid, kdfParams, data, Q, fingerprint) {
|
|
14522
14646
|
const m = encode$1(data);
|
|
14523
14647
|
|
|
14524
|
-
const curve = new
|
|
14648
|
+
const curve = new CurveWithOID(oid);
|
|
14525
14649
|
const { publicKey, sharedKey } = await genPublicEphemeralKey(curve, Q);
|
|
14526
14650
|
const param = buildEcdhParam(enums.publicKey.ecdh, oid, kdfParams, fingerprint);
|
|
14527
14651
|
const { keySize } = getCipher(kdfParams.cipher);
|
|
@@ -14533,7 +14657,7 @@ async function encrypt$3(oid, kdfParams, data, Q, fingerprint) {
|
|
|
14533
14657
|
/**
|
|
14534
14658
|
* Generate ECDHE secret from private key and public part of ephemeral key
|
|
14535
14659
|
*
|
|
14536
|
-
* @param {
|
|
14660
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14537
14661
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14538
14662
|
* @param {Uint8Array} Q - Recipient public key
|
|
14539
14663
|
* @param {Uint8Array} d - Recipient private key
|
|
@@ -14581,7 +14705,7 @@ async function genPrivateEphemeralKey(curve, V, Q, d) {
|
|
|
14581
14705
|
* @async
|
|
14582
14706
|
*/
|
|
14583
14707
|
async function decrypt$3(oid, kdfParams, V, C, Q, d, fingerprint) {
|
|
14584
|
-
const curve = new
|
|
14708
|
+
const curve = new CurveWithOID(oid);
|
|
14585
14709
|
const { sharedKey } = await genPrivateEphemeralKey(curve, V, Q, d);
|
|
14586
14710
|
const param = buildEcdhParam(enums.publicKey.ecdh, oid, kdfParams, fingerprint);
|
|
14587
14711
|
const { keySize } = getCipher(kdfParams.cipher);
|
|
@@ -14601,7 +14725,7 @@ async function decrypt$3(oid, kdfParams, V, C, Q, d, fingerprint) {
|
|
|
14601
14725
|
/**
|
|
14602
14726
|
* Generate ECDHE secret from private key and public part of ephemeral key using webCrypto
|
|
14603
14727
|
*
|
|
14604
|
-
* @param {
|
|
14728
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14605
14729
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14606
14730
|
* @param {Uint8Array} Q - Recipient public key
|
|
14607
14731
|
* @param {Uint8Array} d - Recipient private key
|
|
@@ -14654,7 +14778,7 @@ async function webPrivateEphemeralKey(curve, V, Q, d) {
|
|
|
14654
14778
|
/**
|
|
14655
14779
|
* Generate ECDHE ephemeral key and secret from public key using webCrypto
|
|
14656
14780
|
*
|
|
14657
|
-
* @param {
|
|
14781
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14658
14782
|
* @param {Uint8Array} Q - Recipient public key
|
|
14659
14783
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14660
14784
|
* @async
|
|
@@ -14702,7 +14826,7 @@ async function webPublicEphemeralKey(curve, Q) {
|
|
|
14702
14826
|
/**
|
|
14703
14827
|
* Generate ECDHE secret from private key and public part of ephemeral key using indutny/elliptic
|
|
14704
14828
|
*
|
|
14705
|
-
* @param {
|
|
14829
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14706
14830
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14707
14831
|
* @param {Uint8Array} d - Recipient private key
|
|
14708
14832
|
* @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
@@ -14722,7 +14846,7 @@ async function ellipticPrivateEphemeralKey(curve, V, d) {
|
|
|
14722
14846
|
/**
|
|
14723
14847
|
* Generate ECDHE ephemeral key and secret from public key using indutny/elliptic
|
|
14724
14848
|
*
|
|
14725
|
-
* @param {
|
|
14849
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14726
14850
|
* @param {Uint8Array} Q - Recipient public key
|
|
14727
14851
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14728
14852
|
* @async
|
|
@@ -14742,7 +14866,7 @@ async function ellipticPublicEphemeralKey(curve, Q) {
|
|
|
14742
14866
|
/**
|
|
14743
14867
|
* Generate ECDHE secret from private key and public part of ephemeral key using nodeCrypto
|
|
14744
14868
|
*
|
|
14745
|
-
* @param {
|
|
14869
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14746
14870
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14747
14871
|
* @param {Uint8Array} d - Recipient private key
|
|
14748
14872
|
* @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
@@ -14759,7 +14883,7 @@ async function nodePrivateEphemeralKey(curve, V, d) {
|
|
|
14759
14883
|
/**
|
|
14760
14884
|
* Generate ECDHE ephemeral key and secret from public key using nodeCrypto
|
|
14761
14885
|
*
|
|
14762
|
-
* @param {
|
|
14886
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14763
14887
|
* @param {Uint8Array} Q - Recipient public key
|
|
14764
14888
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14765
14889
|
* @async
|
|
@@ -14774,18 +14898,204 @@ async function nodePublicEphemeralKey(curve, Q) {
|
|
|
14774
14898
|
|
|
14775
14899
|
var ecdh = /*#__PURE__*/Object.freeze({
|
|
14776
14900
|
__proto__: null,
|
|
14777
|
-
validateParams: validateParams$
|
|
14901
|
+
validateParams: validateParams$5,
|
|
14778
14902
|
encrypt: encrypt$3,
|
|
14779
14903
|
decrypt: decrypt$3
|
|
14780
14904
|
});
|
|
14781
14905
|
|
|
14906
|
+
/**
|
|
14907
|
+
* @fileoverview This module implements HKDF using either the WebCrypto API or Node.js' crypto API.
|
|
14908
|
+
* @module crypto/hkdf
|
|
14909
|
+
* @private
|
|
14910
|
+
*/
|
|
14911
|
+
|
|
14912
|
+
const webCrypto$9 = util.getWebCrypto();
|
|
14913
|
+
const nodeCrypto$a = util.getNodeCrypto();
|
|
14914
|
+
const nodeSubtleCrypto = nodeCrypto$a && nodeCrypto$a.webcrypto && nodeCrypto$a.webcrypto.subtle;
|
|
14915
|
+
|
|
14916
|
+
async function HKDF(hashAlgo, inputKey, salt, info, outLen) {
|
|
14917
|
+
const hash = enums.read(enums.webHash, hashAlgo);
|
|
14918
|
+
if (!hash) throw new Error('Hash algo not supported with HKDF');
|
|
14919
|
+
|
|
14920
|
+
if (webCrypto$9 || nodeSubtleCrypto) {
|
|
14921
|
+
const crypto = webCrypto$9 || nodeSubtleCrypto;
|
|
14922
|
+
const importedKey = await crypto.importKey('raw', inputKey, 'HKDF', false, ['deriveBits']);
|
|
14923
|
+
const bits = await crypto.deriveBits({ name: 'HKDF', hash, salt, info }, importedKey, outLen * 8);
|
|
14924
|
+
return new Uint8Array(bits);
|
|
14925
|
+
}
|
|
14926
|
+
|
|
14927
|
+
if (nodeCrypto$a) {
|
|
14928
|
+
const hashAlgoName = enums.read(enums.hash, hashAlgo);
|
|
14929
|
+
// Node-only HKDF implementation based on https://www.rfc-editor.org/rfc/rfc5869
|
|
14930
|
+
|
|
14931
|
+
const computeHMAC = (hmacKey, hmacMessage) => nodeCrypto$a.createHmac(hashAlgoName, hmacKey).update(hmacMessage).digest();
|
|
14932
|
+
// Step 1: Extract
|
|
14933
|
+
// PRK = HMAC-Hash(salt, IKM)
|
|
14934
|
+
const pseudoRandomKey = computeHMAC(salt, inputKey);
|
|
14935
|
+
|
|
14936
|
+
const hashLen = pseudoRandomKey.length;
|
|
14937
|
+
|
|
14938
|
+
// Step 2: Expand
|
|
14939
|
+
// HKDF-Expand(PRK, info, L) -> OKM
|
|
14940
|
+
const n = Math.ceil(outLen / hashLen);
|
|
14941
|
+
const outputKeyingMaterial = new Uint8Array(n * hashLen);
|
|
14942
|
+
|
|
14943
|
+
// HMAC input buffer updated at each iteration
|
|
14944
|
+
const roundInput = new Uint8Array(hashLen + info.length + 1);
|
|
14945
|
+
// T_i and last byte are updated at each iteration, but `info` remains constant
|
|
14946
|
+
roundInput.set(info, hashLen);
|
|
14947
|
+
|
|
14948
|
+
for (let i = 0; i < n; i++) {
|
|
14949
|
+
// T(0) = empty string (zero length)
|
|
14950
|
+
// T(i) = HMAC-Hash(PRK, T(i-1) | info | i)
|
|
14951
|
+
roundInput[roundInput.length - 1] = i + 1;
|
|
14952
|
+
// t = T(i+1)
|
|
14953
|
+
const t = computeHMAC(pseudoRandomKey, i > 0 ? roundInput : roundInput.subarray(hashLen));
|
|
14954
|
+
roundInput.set(t, 0);
|
|
14955
|
+
|
|
14956
|
+
outputKeyingMaterial.set(t, i * hashLen);
|
|
14957
|
+
}
|
|
14958
|
+
|
|
14959
|
+
return outputKeyingMaterial.subarray(0, outLen);
|
|
14960
|
+
}
|
|
14961
|
+
|
|
14962
|
+
throw new Error('No HKDF implementation available');
|
|
14963
|
+
}
|
|
14964
|
+
|
|
14965
|
+
/**
|
|
14966
|
+
* @fileoverview Key encryption and decryption for RFC 6637 ECDH
|
|
14967
|
+
* @module crypto/public_key/elliptic/ecdh
|
|
14968
|
+
* @private
|
|
14969
|
+
*/
|
|
14970
|
+
|
|
14971
|
+
const HKDF_INFO = {
|
|
14972
|
+
x25519: util.encodeUTF8('OpenPGP X25519')
|
|
14973
|
+
};
|
|
14974
|
+
|
|
14975
|
+
/**
|
|
14976
|
+
* Generate ECDH key for Montgomery curves
|
|
14977
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14978
|
+
* @returns {Promise<{ A: Uint8Array, k: Uint8Array }>}
|
|
14979
|
+
*/
|
|
14980
|
+
async function generate$3(algo) {
|
|
14981
|
+
switch (algo) {
|
|
14982
|
+
case enums.publicKey.x25519: {
|
|
14983
|
+
// k stays in little-endian, unlike legacy ECDH over curve25519
|
|
14984
|
+
const k = getRandomBytes(32);
|
|
14985
|
+
k[0] &= 248;
|
|
14986
|
+
k[31] = (k[31] & 127) | 64;
|
|
14987
|
+
const { publicKey: A } = naclFastLight.box.keyPair.fromSecretKey(k);
|
|
14988
|
+
return { A, k };
|
|
14989
|
+
}
|
|
14990
|
+
default:
|
|
14991
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
14992
|
+
}
|
|
14993
|
+
}
|
|
14994
|
+
|
|
14995
|
+
/**
|
|
14996
|
+
* Validate ECDH parameters
|
|
14997
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14998
|
+
* @param {Uint8Array} A - ECDH public point
|
|
14999
|
+
* @param {Uint8Array} k - ECDH secret scalar
|
|
15000
|
+
* @returns {Promise<Boolean>} Whether params are valid.
|
|
15001
|
+
* @async
|
|
15002
|
+
*/
|
|
15003
|
+
async function validateParams$6(algo, A, k) {
|
|
15004
|
+
switch (algo) {
|
|
15005
|
+
case enums.publicKey.x25519: {
|
|
15006
|
+
/**
|
|
15007
|
+
* Derive public point A' from private key
|
|
15008
|
+
* and expect A == A'
|
|
15009
|
+
*/
|
|
15010
|
+
const { publicKey } = naclFastLight.box.keyPair.fromSecretKey(k);
|
|
15011
|
+
return util.equalsUint8Array(A, publicKey);
|
|
15012
|
+
}
|
|
15013
|
+
|
|
15014
|
+
default:
|
|
15015
|
+
return false;
|
|
15016
|
+
}
|
|
15017
|
+
}
|
|
15018
|
+
|
|
15019
|
+
/**
|
|
15020
|
+
* Wrap and encrypt a session key
|
|
15021
|
+
*
|
|
15022
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
15023
|
+
* @param {Uint8Array} data - session key data to be encrypted
|
|
15024
|
+
* @param {Uint8Array} recipientA - Recipient public key (K_B)
|
|
15025
|
+
* @returns {Promise<{
|
|
15026
|
+
* ephemeralPublicKey: Uint8Array,
|
|
15027
|
+
* wrappedKey: Uint8Array
|
|
15028
|
+
* }>} ephemeral public key (K_A) and encrypted key
|
|
15029
|
+
* @async
|
|
15030
|
+
*/
|
|
15031
|
+
async function encrypt$4(algo, data, recipientA) {
|
|
15032
|
+
switch (algo) {
|
|
15033
|
+
case enums.publicKey.x25519: {
|
|
15034
|
+
const ephemeralSecretKey = getRandomBytes(32);
|
|
15035
|
+
const sharedSecret = naclFastLight.scalarMult(ephemeralSecretKey, recipientA);
|
|
15036
|
+
const { publicKey: ephemeralPublicKey } = naclFastLight.box.keyPair.fromSecretKey(ephemeralSecretKey);
|
|
15037
|
+
const hkdfInput = util.concatUint8Array([
|
|
15038
|
+
ephemeralPublicKey,
|
|
15039
|
+
recipientA,
|
|
15040
|
+
sharedSecret
|
|
15041
|
+
]);
|
|
15042
|
+
const { keySize } = getCipher(enums.symmetric.aes128);
|
|
15043
|
+
const encryptionKey = await HKDF(enums.hash.sha256, hkdfInput, new Uint8Array(), HKDF_INFO.x25519, keySize);
|
|
15044
|
+
const wrappedKey = wrap(encryptionKey, data);
|
|
15045
|
+
return { ephemeralPublicKey, wrappedKey };
|
|
15046
|
+
}
|
|
15047
|
+
|
|
15048
|
+
default:
|
|
15049
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
15050
|
+
}
|
|
15051
|
+
}
|
|
15052
|
+
|
|
15053
|
+
/**
|
|
15054
|
+
* Decrypt and unwrap the session key
|
|
15055
|
+
*
|
|
15056
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
15057
|
+
* @param {Uint8Array} ephemeralPublicKey - (K_A)
|
|
15058
|
+
* @param {Uint8Array} wrappedKey,
|
|
15059
|
+
* @param {Uint8Array} A - Recipient public key (K_b), needed for KDF
|
|
15060
|
+
* @param {Uint8Array} k - Recipient secret key (b)
|
|
15061
|
+
* @returns {Promise<Uint8Array>} decrypted session key data
|
|
15062
|
+
* @async
|
|
15063
|
+
*/
|
|
15064
|
+
async function decrypt$4(algo, ephemeralPublicKey, wrappedKey, A, k) {
|
|
15065
|
+
switch (algo) {
|
|
15066
|
+
case enums.publicKey.x25519: {
|
|
15067
|
+
const sharedSecret = naclFastLight.scalarMult(k, ephemeralPublicKey);
|
|
15068
|
+
const hkdfInput = util.concatUint8Array([
|
|
15069
|
+
ephemeralPublicKey,
|
|
15070
|
+
A,
|
|
15071
|
+
sharedSecret
|
|
15072
|
+
]);
|
|
15073
|
+
const { keySize } = getCipher(enums.symmetric.aes128);
|
|
15074
|
+
const encryptionKey = await HKDF(enums.hash.sha256, hkdfInput, new Uint8Array(), HKDF_INFO.x25519, keySize);
|
|
15075
|
+
return unwrap(encryptionKey, wrappedKey);
|
|
15076
|
+
}
|
|
15077
|
+
default:
|
|
15078
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
15079
|
+
}
|
|
15080
|
+
}
|
|
15081
|
+
|
|
15082
|
+
var ecdh_x = /*#__PURE__*/Object.freeze({
|
|
15083
|
+
__proto__: null,
|
|
15084
|
+
generate: generate$3,
|
|
15085
|
+
validateParams: validateParams$6,
|
|
15086
|
+
encrypt: encrypt$4,
|
|
15087
|
+
decrypt: decrypt$4
|
|
15088
|
+
});
|
|
15089
|
+
|
|
14782
15090
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14783
15091
|
|
|
14784
15092
|
var elliptic = /*#__PURE__*/Object.freeze({
|
|
14785
15093
|
__proto__: null,
|
|
14786
|
-
|
|
15094
|
+
CurveWithOID: CurveWithOID,
|
|
14787
15095
|
ecdh: ecdh,
|
|
15096
|
+
ecdhX: ecdh_x,
|
|
14788
15097
|
ecdsa: ecdsa,
|
|
15098
|
+
eddsaLegacy: eddsa_legacy,
|
|
14789
15099
|
eddsa: eddsa,
|
|
14790
15100
|
generate: generate$1,
|
|
14791
15101
|
getPreferredHashAlgo: getPreferredHashAlgo
|
|
@@ -14810,7 +15120,7 @@ var elliptic = /*#__PURE__*/Object.freeze({
|
|
|
14810
15120
|
* @returns {Promise<{ r: Uint8Array, s: Uint8Array }>}
|
|
14811
15121
|
* @async
|
|
14812
15122
|
*/
|
|
14813
|
-
async function sign$
|
|
15123
|
+
async function sign$4(hashAlgo, hashed, g, p, q, x) {
|
|
14814
15124
|
const BigInteger = await util.getBigInteger();
|
|
14815
15125
|
const one = new BigInteger(1);
|
|
14816
15126
|
p = new BigInteger(p);
|
|
@@ -14869,7 +15179,7 @@ async function sign$3(hashAlgo, hashed, g, p, q, x) {
|
|
|
14869
15179
|
* @returns {boolean}
|
|
14870
15180
|
* @async
|
|
14871
15181
|
*/
|
|
14872
|
-
async function verify$
|
|
15182
|
+
async function verify$4(hashAlgo, r, s, hashed, g, p, q, y) {
|
|
14873
15183
|
const BigInteger = await util.getBigInteger();
|
|
14874
15184
|
const zero = new BigInteger(0);
|
|
14875
15185
|
r = new BigInteger(r);
|
|
@@ -14912,7 +15222,7 @@ async function verify$3(hashAlgo, r, s, hashed, g, p, q, y) {
|
|
|
14912
15222
|
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14913
15223
|
* @async
|
|
14914
15224
|
*/
|
|
14915
|
-
async function validateParams$
|
|
15225
|
+
async function validateParams$7(p, q, g, y, x) {
|
|
14916
15226
|
const BigInteger = await util.getBigInteger();
|
|
14917
15227
|
p = new BigInteger(p);
|
|
14918
15228
|
q = new BigInteger(q);
|
|
@@ -14967,9 +15277,9 @@ async function validateParams$5(p, q, g, y, x) {
|
|
|
14967
15277
|
|
|
14968
15278
|
var dsa = /*#__PURE__*/Object.freeze({
|
|
14969
15279
|
__proto__: null,
|
|
14970
|
-
sign: sign$
|
|
14971
|
-
verify: verify$
|
|
14972
|
-
validateParams: validateParams$
|
|
15280
|
+
sign: sign$4,
|
|
15281
|
+
verify: verify$4,
|
|
15282
|
+
validateParams: validateParams$7
|
|
14973
15283
|
});
|
|
14974
15284
|
|
|
14975
15285
|
/**
|
|
@@ -15105,10 +15415,11 @@ function parseSignatureParams(algo, signature) {
|
|
|
15105
15415
|
const s = util.readMPI(signature.subarray(read));
|
|
15106
15416
|
return { r, s };
|
|
15107
15417
|
}
|
|
15108
|
-
// Algorithm-Specific Fields for EdDSA signatures:
|
|
15418
|
+
// Algorithm-Specific Fields for legacy EdDSA signatures:
|
|
15109
15419
|
// - MPI of an EC point r.
|
|
15110
15420
|
// - EdDSA value s, in MPI, in the little endian representation
|
|
15111
|
-
case enums.publicKey.eddsa:
|
|
15421
|
+
case enums.publicKey.eddsa:
|
|
15422
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15112
15423
|
// When parsing little-endian MPI data, we always need to left-pad it, as done with big-endian values:
|
|
15113
15424
|
// https://www.ietf.org/archive/id/draft-ietf-openpgp-rfc4880bis-10.html#section-3.2-9
|
|
15114
15425
|
let r = util.readMPI(signature.subarray(read)); read += r.length + 2;
|
|
@@ -15117,7 +15428,12 @@ function parseSignatureParams(algo, signature) {
|
|
|
15117
15428
|
s = util.leftPad(s, 32);
|
|
15118
15429
|
return { r, s };
|
|
15119
15430
|
}
|
|
15120
|
-
|
|
15431
|
+
// Algorithm-Specific Fields for Ed25519 signatures:
|
|
15432
|
+
// - 64 octets of the native signature
|
|
15433
|
+
case enums.publicKey.ed25519: {
|
|
15434
|
+
const RS = signature.subarray(read, read + 64); read += RS.length;
|
|
15435
|
+
return { RS };
|
|
15436
|
+
}
|
|
15121
15437
|
case enums.publicKey.hmac: {
|
|
15122
15438
|
const mac = new ShortByteString(); mac.read(signature.subarray(read));
|
|
15123
15439
|
return { mac };
|
|
@@ -15142,7 +15458,7 @@ function parseSignatureParams(algo, signature) {
|
|
|
15142
15458
|
* @returns {Promise<Boolean>} True if signature is valid.
|
|
15143
15459
|
* @async
|
|
15144
15460
|
*/
|
|
15145
|
-
async function verify$
|
|
15461
|
+
async function verify$5(algo, hashAlgo, signature, publicParams, privateParams, data, hashed) {
|
|
15146
15462
|
switch (algo) {
|
|
15147
15463
|
case enums.publicKey.rsaEncryptSign:
|
|
15148
15464
|
case enums.publicKey.rsaEncrypt:
|
|
@@ -15158,16 +15474,21 @@ async function verify$4(algo, hashAlgo, signature, publicParams, privateParams,
|
|
|
15158
15474
|
}
|
|
15159
15475
|
case enums.publicKey.ecdsa: {
|
|
15160
15476
|
const { oid, Q } = publicParams;
|
|
15161
|
-
const curveSize = new publicKey.elliptic.
|
|
15477
|
+
const curveSize = new publicKey.elliptic.CurveWithOID(oid).payloadSize;
|
|
15162
15478
|
// padding needed for webcrypto
|
|
15163
15479
|
const r = util.leftPad(signature.r, curveSize);
|
|
15164
15480
|
const s = util.leftPad(signature.s, curveSize);
|
|
15165
15481
|
return publicKey.elliptic.ecdsa.verify(oid, hashAlgo, { r, s }, data, Q, hashed);
|
|
15166
15482
|
}
|
|
15167
|
-
case enums.publicKey.eddsa:
|
|
15483
|
+
case enums.publicKey.eddsa:
|
|
15484
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15168
15485
|
const { oid, Q } = publicParams;
|
|
15169
15486
|
// signature already padded on parsing
|
|
15170
|
-
return publicKey.elliptic.
|
|
15487
|
+
return publicKey.elliptic.eddsaLegacy.verify(oid, hashAlgo, signature, data, Q, hashed);
|
|
15488
|
+
}
|
|
15489
|
+
case enums.publicKey.ed25519: {
|
|
15490
|
+
const { A } = publicParams;
|
|
15491
|
+
return publicKey.elliptic.eddsa.verify(algo, hashAlgo, signature, data, A, hashed);
|
|
15171
15492
|
}
|
|
15172
15493
|
case enums.publicKey.hmac: {
|
|
15173
15494
|
if (!privateParams) {
|
|
@@ -15197,7 +15518,7 @@ async function verify$4(algo, hashAlgo, signature, publicParams, privateParams,
|
|
|
15197
15518
|
* @returns {Promise<Object>} Signature Object containing named signature parameters.
|
|
15198
15519
|
* @async
|
|
15199
15520
|
*/
|
|
15200
|
-
async function sign$
|
|
15521
|
+
async function sign$5(algo, hashAlgo, publicKeyParams, privateKeyParams, data, hashed) {
|
|
15201
15522
|
if (!publicKeyParams || !privateKeyParams) {
|
|
15202
15523
|
throw new Error('Missing key parameters');
|
|
15203
15524
|
}
|
|
@@ -15223,10 +15544,16 @@ async function sign$4(algo, hashAlgo, publicKeyParams, privateKeyParams, data, h
|
|
|
15223
15544
|
const { d } = privateKeyParams;
|
|
15224
15545
|
return publicKey.elliptic.ecdsa.sign(oid, hashAlgo, data, Q, d, hashed);
|
|
15225
15546
|
}
|
|
15226
|
-
case enums.publicKey.eddsa:
|
|
15547
|
+
case enums.publicKey.eddsa:
|
|
15548
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15227
15549
|
const { oid, Q } = publicKeyParams;
|
|
15228
15550
|
const { seed } = privateKeyParams;
|
|
15229
|
-
return publicKey.elliptic.
|
|
15551
|
+
return publicKey.elliptic.eddsaLegacy.sign(oid, hashAlgo, data, Q, seed, hashed);
|
|
15552
|
+
}
|
|
15553
|
+
case enums.publicKey.ed25519: {
|
|
15554
|
+
const { A } = publicKeyParams;
|
|
15555
|
+
const { seed } = privateKeyParams;
|
|
15556
|
+
return publicKey.elliptic.eddsa.sign(algo, hashAlgo, data, A, seed, hashed);
|
|
15230
15557
|
}
|
|
15231
15558
|
case enums.publicKey.hmac: {
|
|
15232
15559
|
const { cipher: algo } = publicKeyParams;
|
|
@@ -15242,34 +15569,31 @@ async function sign$4(algo, hashAlgo, publicKeyParams, privateKeyParams, data, h
|
|
|
15242
15569
|
var signature = /*#__PURE__*/Object.freeze({
|
|
15243
15570
|
__proto__: null,
|
|
15244
15571
|
parseSignatureParams: parseSignatureParams,
|
|
15245
|
-
verify: verify$
|
|
15246
|
-
sign: sign$
|
|
15572
|
+
verify: verify$5,
|
|
15573
|
+
sign: sign$5
|
|
15247
15574
|
});
|
|
15248
15575
|
|
|
15249
15576
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
15250
15577
|
|
|
15251
15578
|
class ECDHSymmetricKey {
|
|
15252
15579
|
constructor(data) {
|
|
15253
|
-
if (
|
|
15254
|
-
data =
|
|
15255
|
-
} else if (util.isString(data)) {
|
|
15256
|
-
data = util.stringToUint8Array(data);
|
|
15257
|
-
} else {
|
|
15258
|
-
data = new Uint8Array(data);
|
|
15580
|
+
if (data) {
|
|
15581
|
+
this.data = data;
|
|
15259
15582
|
}
|
|
15260
|
-
this.data = data;
|
|
15261
15583
|
}
|
|
15262
15584
|
|
|
15263
15585
|
/**
|
|
15264
|
-
* Read an ECDHSymmetricKey from an Uint8Array
|
|
15265
|
-
*
|
|
15586
|
+
* Read an ECDHSymmetricKey from an Uint8Array:
|
|
15587
|
+
* - 1 octect for the length `l`
|
|
15588
|
+
* - `l` octects of encoded session key data
|
|
15589
|
+
* @param {Uint8Array} bytes
|
|
15266
15590
|
* @returns {Number} Number of read bytes.
|
|
15267
15591
|
*/
|
|
15268
|
-
read(
|
|
15269
|
-
if (
|
|
15270
|
-
const length =
|
|
15271
|
-
if (
|
|
15272
|
-
this.data =
|
|
15592
|
+
read(bytes) {
|
|
15593
|
+
if (bytes.length >= 1) {
|
|
15594
|
+
const length = bytes[0];
|
|
15595
|
+
if (bytes.length >= 1 + length) {
|
|
15596
|
+
this.data = bytes.subarray(1, 1 + length);
|
|
15273
15597
|
return 1 + this.data.length;
|
|
15274
15598
|
}
|
|
15275
15599
|
}
|
|
@@ -15278,7 +15602,7 @@ class ECDHSymmetricKey {
|
|
|
15278
15602
|
|
|
15279
15603
|
/**
|
|
15280
15604
|
* Write an ECDHSymmetricKey as an Uint8Array
|
|
15281
|
-
* @returns {Uint8Array}
|
|
15605
|
+
* @returns {Uint8Array} Serialised data
|
|
15282
15606
|
*/
|
|
15283
15607
|
write() {
|
|
15284
15608
|
return util.concatUint8Array([new Uint8Array([this.data.length]), this.data]);
|
|
@@ -15318,6 +15642,9 @@ class KDFParams {
|
|
|
15318
15642
|
* @returns {Number} Number of read bytes.
|
|
15319
15643
|
*/
|
|
15320
15644
|
read(input) {
|
|
15645
|
+
if (input.length < 4 || (input[1] !== 1 && input[1] !== VERSION_FORWARDING)) {
|
|
15646
|
+
throw new UnsupportedError('Cannot read KDFParams');
|
|
15647
|
+
}
|
|
15321
15648
|
const totalBytes = input[0];
|
|
15322
15649
|
this.version = input[1];
|
|
15323
15650
|
this.hash = input[2];
|
|
@@ -15405,12 +15732,57 @@ const AEADEnum = type_enum(enums.aead);
|
|
|
15405
15732
|
const SymAlgoEnum = type_enum(enums.symmetric);
|
|
15406
15733
|
const HashEnum = type_enum(enums.hash);
|
|
15407
15734
|
|
|
15735
|
+
/**
|
|
15736
|
+
* Encoded symmetric key for x25519 and x448
|
|
15737
|
+
* The payload format varies for v3 and v6 PKESK:
|
|
15738
|
+
* the former includes an algorithm byte preceeding the encrypted session key.
|
|
15739
|
+
*
|
|
15740
|
+
* @module type/x25519x448_symkey
|
|
15741
|
+
*/
|
|
15742
|
+
|
|
15743
|
+
class ECDHXSymmetricKey {
|
|
15744
|
+
static fromObject({ wrappedKey, algorithm }) {
|
|
15745
|
+
const instance = new ECDHXSymmetricKey();
|
|
15746
|
+
instance.wrappedKey = wrappedKey;
|
|
15747
|
+
instance.algorithm = algorithm;
|
|
15748
|
+
return instance;
|
|
15749
|
+
}
|
|
15750
|
+
|
|
15751
|
+
/**
|
|
15752
|
+
* - 1 octect for the length `l`
|
|
15753
|
+
* - `l` octects of encoded session key data (with optional leading algorithm byte)
|
|
15754
|
+
* @param {Uint8Array} bytes
|
|
15755
|
+
* @returns {Number} Number of read bytes.
|
|
15756
|
+
*/
|
|
15757
|
+
read(bytes) {
|
|
15758
|
+
let read = 0;
|
|
15759
|
+
let followLength = bytes[read++];
|
|
15760
|
+
this.algorithm = followLength % 2 ? bytes[read++] : null; // session key size is always even
|
|
15761
|
+
followLength -= followLength % 2;
|
|
15762
|
+
this.wrappedKey = bytes.subarray(read, read + followLength); read += followLength;
|
|
15763
|
+
}
|
|
15764
|
+
|
|
15765
|
+
/**
|
|
15766
|
+
* Write an MontgomerySymmetricKey as an Uint8Array
|
|
15767
|
+
* @returns {Uint8Array} Serialised data
|
|
15768
|
+
*/
|
|
15769
|
+
write() {
|
|
15770
|
+
return util.concatUint8Array([
|
|
15771
|
+
this.algorithm ?
|
|
15772
|
+
new Uint8Array([this.wrappedKey.length + 1, this.algorithm]) :
|
|
15773
|
+
new Uint8Array([this.wrappedKey.length]),
|
|
15774
|
+
this.wrappedKey
|
|
15775
|
+
]);
|
|
15776
|
+
}
|
|
15777
|
+
}
|
|
15778
|
+
|
|
15408
15779
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
15409
15780
|
|
|
15410
15781
|
/**
|
|
15411
15782
|
* Encrypts data using specified algorithm and public key parameters.
|
|
15412
15783
|
* See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1} for public key algorithms.
|
|
15413
|
-
* @param {module:enums.publicKey}
|
|
15784
|
+
* @param {module:enums.publicKey} keyAlgo - Public key algorithm
|
|
15785
|
+
* @param {module:enums.symmetric} symmetricAlgo - Cipher algorithm
|
|
15414
15786
|
* @param {Object} publicParams - Algorithm-specific public key parameters
|
|
15415
15787
|
* @param {Object} privateParams - Algorithm-specific private key parameters
|
|
15416
15788
|
* @param {Uint8Array} data - Data to be encrypted
|
|
@@ -15418,8 +15790,8 @@ const HashEnum = type_enum(enums.hash);
|
|
|
15418
15790
|
* @returns {Promise<Object>} Encrypted session key parameters.
|
|
15419
15791
|
* @async
|
|
15420
15792
|
*/
|
|
15421
|
-
async function publicKeyEncrypt(
|
|
15422
|
-
switch (
|
|
15793
|
+
async function publicKeyEncrypt(keyAlgo, symmetricAlgo, publicParams, privateParams, data, fingerprint) {
|
|
15794
|
+
switch (keyAlgo) {
|
|
15423
15795
|
case enums.publicKey.rsaEncrypt:
|
|
15424
15796
|
case enums.publicKey.rsaEncryptSign: {
|
|
15425
15797
|
const { n, e } = publicParams;
|
|
@@ -15436,6 +15808,17 @@ async function publicKeyEncrypt(algo, publicParams, privateParams, data, fingerp
|
|
|
15436
15808
|
oid, kdfParams, data, Q, fingerprint);
|
|
15437
15809
|
return { V, C: new ECDHSymmetricKey(C) };
|
|
15438
15810
|
}
|
|
15811
|
+
case enums.publicKey.x25519: {
|
|
15812
|
+
if (!util.isAES(symmetricAlgo)) {
|
|
15813
|
+
// see https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/276
|
|
15814
|
+
throw new Error('X25519 keys can only encrypt AES session keys');
|
|
15815
|
+
}
|
|
15816
|
+
const { A } = publicParams;
|
|
15817
|
+
const { ephemeralPublicKey, wrappedKey } = await publicKey.elliptic.ecdhX.encrypt(
|
|
15818
|
+
keyAlgo, data, A);
|
|
15819
|
+
const C = ECDHXSymmetricKey.fromObject({ algorithm: symmetricAlgo, wrappedKey });
|
|
15820
|
+
return { ephemeralPublicKey, C };
|
|
15821
|
+
}
|
|
15439
15822
|
case enums.publicKey.aead: {
|
|
15440
15823
|
if (!privateParams) {
|
|
15441
15824
|
throw new Error('Cannot encrypt with symmetric key missing private parameters');
|
|
@@ -15492,6 +15875,16 @@ async function publicKeyDecrypt(algo, publicKeyParams, privateKeyParams, session
|
|
|
15492
15875
|
return publicKey.elliptic.ecdh.decrypt(
|
|
15493
15876
|
oid, kdfParams, V, C.data, Q, d, fingerprint);
|
|
15494
15877
|
}
|
|
15878
|
+
case enums.publicKey.x25519: {
|
|
15879
|
+
const { A } = publicKeyParams;
|
|
15880
|
+
const { k } = privateKeyParams;
|
|
15881
|
+
const { ephemeralPublicKey, C } = sessionKeyParams;
|
|
15882
|
+
if (!util.isAES(C.algorithm)) {
|
|
15883
|
+
throw new Error('AES session key expected');
|
|
15884
|
+
}
|
|
15885
|
+
return publicKey.elliptic.ecdhX.decrypt(
|
|
15886
|
+
algo, ephemeralPublicKey, C.wrappedKey, A, k);
|
|
15887
|
+
}
|
|
15495
15888
|
case enums.publicKey.aead: {
|
|
15496
15889
|
const { cipher: algo } = publicKeyParams;
|
|
15497
15890
|
const algoValue = algo.getValue();
|
|
@@ -15543,7 +15936,8 @@ function parsePublicKeyParams(algo, bytes) {
|
|
|
15543
15936
|
const Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
|
15544
15937
|
return { read: read, publicParams: { oid, Q } };
|
|
15545
15938
|
}
|
|
15546
|
-
case enums.publicKey.eddsa:
|
|
15939
|
+
case enums.publicKey.eddsa:
|
|
15940
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15547
15941
|
const oid = new OID(); read += oid.read(bytes);
|
|
15548
15942
|
checkSupportedCurve(oid);
|
|
15549
15943
|
let Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
|
@@ -15557,6 +15951,11 @@ function parsePublicKeyParams(algo, bytes) {
|
|
|
15557
15951
|
const kdfParams = new KDFParams(); read += kdfParams.read(bytes.subarray(read));
|
|
15558
15952
|
return { read: read, publicParams: { oid, Q, kdfParams } };
|
|
15559
15953
|
}
|
|
15954
|
+
case enums.publicKey.ed25519:
|
|
15955
|
+
case enums.publicKey.x25519: {
|
|
15956
|
+
const A = bytes.subarray(read, read + 32); read += A.length;
|
|
15957
|
+
return { read, publicParams: { A } };
|
|
15958
|
+
}
|
|
15560
15959
|
case enums.publicKey.hmac:
|
|
15561
15960
|
case enums.publicKey.aead: {
|
|
15562
15961
|
const algo = new SymAlgoEnum(); read += algo.read(bytes);
|
|
@@ -15595,17 +15994,26 @@ function parsePrivateKeyParams(algo, bytes, publicParams) {
|
|
|
15595
15994
|
}
|
|
15596
15995
|
case enums.publicKey.ecdsa:
|
|
15597
15996
|
case enums.publicKey.ecdh: {
|
|
15598
|
-
const curve = new
|
|
15997
|
+
const curve = new CurveWithOID(publicParams.oid);
|
|
15599
15998
|
let d = util.readMPI(bytes.subarray(read)); read += d.length + 2;
|
|
15600
15999
|
d = util.leftPad(d, curve.payloadSize);
|
|
15601
16000
|
return { read, privateParams: { d } };
|
|
15602
16001
|
}
|
|
15603
|
-
case enums.publicKey.eddsa:
|
|
15604
|
-
|
|
16002
|
+
case enums.publicKey.eddsa:
|
|
16003
|
+
case enums.publicKey.ed25519Legacy: {
|
|
16004
|
+
const curve = new CurveWithOID(publicParams.oid);
|
|
15605
16005
|
let seed = util.readMPI(bytes.subarray(read)); read += seed.length + 2;
|
|
15606
16006
|
seed = util.leftPad(seed, curve.payloadSize);
|
|
15607
16007
|
return { read, privateParams: { seed } };
|
|
15608
16008
|
}
|
|
16009
|
+
case enums.publicKey.ed25519: {
|
|
16010
|
+
const seed = bytes.subarray(read, read + 32); read += seed.length;
|
|
16011
|
+
return { read, privateParams: { seed } };
|
|
16012
|
+
}
|
|
16013
|
+
case enums.publicKey.x25519: {
|
|
16014
|
+
const k = bytes.subarray(read, read + 32); read += k.length;
|
|
16015
|
+
return { read, privateParams: { k } };
|
|
16016
|
+
}
|
|
15609
16017
|
case enums.publicKey.hmac: {
|
|
15610
16018
|
const { cipher: algo } = publicParams;
|
|
15611
16019
|
const keySize = hash.getHashByteLength(algo.getValue());
|
|
@@ -15657,6 +16065,16 @@ function parseEncSessionKeyParams(algo, bytes) {
|
|
|
15657
16065
|
const C = new ECDHSymmetricKey(); C.read(bytes.subarray(read));
|
|
15658
16066
|
return { V, C };
|
|
15659
16067
|
}
|
|
16068
|
+
// Algorithm-Specific Fields for X25519 encrypted session keys:
|
|
16069
|
+
// - 32 octets representing an ephemeral X25519 public key.
|
|
16070
|
+
// - A one-octet size of the following fields.
|
|
16071
|
+
// - The one-octet algorithm identifier, if it was passed (in the case of a v3 PKESK packet).
|
|
16072
|
+
// - The encrypted session key.
|
|
16073
|
+
case enums.publicKey.x25519: {
|
|
16074
|
+
const ephemeralPublicKey = bytes.subarray(read, read + 32); read += ephemeralPublicKey.length;
|
|
16075
|
+
const C = new ECDHXSymmetricKey(); C.read(bytes.subarray(read));
|
|
16076
|
+
return { ephemeralPublicKey, C };
|
|
16077
|
+
}
|
|
15660
16078
|
// Algorithm-Specific Fields for symmetric AEAD encryption:
|
|
15661
16079
|
// - AEAD algorithm
|
|
15662
16080
|
// - Starting initialization vector
|
|
@@ -15683,22 +16101,13 @@ function parseEncSessionKeyParams(algo, bytes) {
|
|
|
15683
16101
|
* @returns {Uint8Array} The array containing the MPIs.
|
|
15684
16102
|
*/
|
|
15685
16103
|
function serializeParams(algo, params) {
|
|
15686
|
-
|
|
15687
|
-
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
});
|
|
15694
|
-
break;
|
|
15695
|
-
}
|
|
15696
|
-
default:
|
|
15697
|
-
orderedParams = Object.keys(params).map(name => {
|
|
15698
|
-
const param = params[name];
|
|
15699
|
-
return util.isUint8Array(param) ? util.uint8ArrayToMPI(param) : param.write();
|
|
15700
|
-
});
|
|
15701
|
-
}
|
|
16104
|
+
// Some algorithms do not rely on MPIs to store the binary params
|
|
16105
|
+
const algosWithNativeRepresentation = new Set([enums.publicKey.ed25519, enums.publicKey.x25519, enums.publicKey.aead, enums.publicKey.hmac]);
|
|
16106
|
+
const orderedParams = Object.keys(params).map(name => {
|
|
16107
|
+
const param = params[name];
|
|
16108
|
+
if (!util.isUint8Array(param)) return param.write();
|
|
16109
|
+
return algosWithNativeRepresentation.has(algo) ? param : util.uint8ArrayToMPI(param);
|
|
16110
|
+
});
|
|
15702
16111
|
return util.concatUint8Array(orderedParams);
|
|
15703
16112
|
}
|
|
15704
16113
|
|
|
@@ -15727,6 +16136,7 @@ function generateParams(algo, bits, oid, symmetric) {
|
|
|
15727
16136
|
publicParams: { oid: new OID(oid), Q }
|
|
15728
16137
|
}));
|
|
15729
16138
|
case enums.publicKey.eddsa:
|
|
16139
|
+
case enums.publicKey.ed25519Legacy:
|
|
15730
16140
|
return publicKey.elliptic.generate(oid).then(({ oid, Q, secret }) => ({
|
|
15731
16141
|
privateParams: { seed: secret },
|
|
15732
16142
|
publicParams: { oid: new OID(oid), Q }
|
|
@@ -15740,6 +16150,16 @@ function generateParams(algo, bits, oid, symmetric) {
|
|
|
15740
16150
|
kdfParams: new KDFParams({ hash, cipher })
|
|
15741
16151
|
}
|
|
15742
16152
|
}));
|
|
16153
|
+
case enums.publicKey.ed25519:
|
|
16154
|
+
return publicKey.elliptic.eddsa.generate(algo).then(({ A, seed }) => ({
|
|
16155
|
+
privateParams: { seed },
|
|
16156
|
+
publicParams: { A }
|
|
16157
|
+
}));
|
|
16158
|
+
case enums.publicKey.x25519:
|
|
16159
|
+
return publicKey.elliptic.ecdhX.generate(algo).then(({ A, k }) => ({
|
|
16160
|
+
privateParams: { k },
|
|
16161
|
+
publicParams: { A }
|
|
16162
|
+
}));
|
|
15743
16163
|
case enums.publicKey.hmac: {
|
|
15744
16164
|
const symAlgo = enums.write(enums.hash, symmetric);
|
|
15745
16165
|
const keyMaterial = getRandomBytes(hash.getHashByteLength(symAlgo));
|
|
@@ -15781,7 +16201,7 @@ async function createSymmetricParams(key, algo) {
|
|
|
15781
16201
|
* @returns {Promise<Boolean>} Whether the parameters are valid.
|
|
15782
16202
|
* @async
|
|
15783
16203
|
*/
|
|
15784
|
-
async function validateParams$
|
|
16204
|
+
async function validateParams$8(algo, publicParams, privateParams) {
|
|
15785
16205
|
if (!publicParams || !privateParams) {
|
|
15786
16206
|
throw new Error('Missing key parameters');
|
|
15787
16207
|
}
|
|
@@ -15810,10 +16230,21 @@ async function validateParams$6(algo, publicParams, privateParams) {
|
|
|
15810
16230
|
const { d } = privateParams;
|
|
15811
16231
|
return algoModule.validateParams(oid, Q, d);
|
|
15812
16232
|
}
|
|
15813
|
-
case enums.publicKey.eddsa:
|
|
15814
|
-
|
|
16233
|
+
case enums.publicKey.eddsa:
|
|
16234
|
+
case enums.publicKey.ed25519Legacy: {
|
|
16235
|
+
const { Q, oid } = publicParams;
|
|
15815
16236
|
const { seed } = privateParams;
|
|
15816
|
-
return publicKey.elliptic.
|
|
16237
|
+
return publicKey.elliptic.eddsaLegacy.validateParams(oid, Q, seed);
|
|
16238
|
+
}
|
|
16239
|
+
case enums.publicKey.ed25519: {
|
|
16240
|
+
const { A } = publicParams;
|
|
16241
|
+
const { seed } = privateParams;
|
|
16242
|
+
return publicKey.elliptic.eddsa.validateParams(algo, A, seed);
|
|
16243
|
+
}
|
|
16244
|
+
case enums.publicKey.x25519: {
|
|
16245
|
+
const { A } = publicParams;
|
|
16246
|
+
const { k } = privateParams;
|
|
16247
|
+
return publicKey.elliptic.ecdhX.validateParams(algo, A, k);
|
|
15817
16248
|
}
|
|
15818
16249
|
case enums.publicKey.hmac: {
|
|
15819
16250
|
const { cipher: algo, digest } = publicParams;
|
|
@@ -15892,7 +16323,7 @@ var crypto$1 = /*#__PURE__*/Object.freeze({
|
|
|
15892
16323
|
parseEncSessionKeyParams: parseEncSessionKeyParams,
|
|
15893
16324
|
serializeParams: serializeParams,
|
|
15894
16325
|
generateParams: generateParams,
|
|
15895
|
-
validateParams: validateParams$
|
|
16326
|
+
validateParams: validateParams$8,
|
|
15896
16327
|
getPrefixRandom: getPrefixRandom,
|
|
15897
16328
|
generateSessionKey: generateSessionKey,
|
|
15898
16329
|
getAEADMode: getAEADMode,
|
|
@@ -16139,15 +16570,15 @@ class GenericS2K {
|
|
|
16139
16570
|
this.type = 'gnu-dummy';
|
|
16140
16571
|
// GnuPG extension mode 1001 -- don't write secret key at all
|
|
16141
16572
|
} else {
|
|
16142
|
-
throw new
|
|
16573
|
+
throw new UnsupportedError('Unknown s2k gnu protection mode.');
|
|
16143
16574
|
}
|
|
16144
16575
|
} else {
|
|
16145
|
-
throw new
|
|
16576
|
+
throw new UnsupportedError('Unknown s2k type.');
|
|
16146
16577
|
}
|
|
16147
16578
|
break;
|
|
16148
16579
|
|
|
16149
16580
|
default:
|
|
16150
|
-
throw new
|
|
16581
|
+
throw new UnsupportedError('Unknown s2k type.'); // unreachable
|
|
16151
16582
|
}
|
|
16152
16583
|
|
|
16153
16584
|
return i;
|
|
@@ -16251,7 +16682,7 @@ function newS2KFromType(type, config$1 = config) {
|
|
|
16251
16682
|
case enums.s2k.simple:
|
|
16252
16683
|
return new GenericS2K(type, config$1);
|
|
16253
16684
|
default:
|
|
16254
|
-
throw new
|
|
16685
|
+
throw new UnsupportedError(`Unsupported S2K type ${type}`);
|
|
16255
16686
|
}
|
|
16256
16687
|
}
|
|
16257
16688
|
|
|
@@ -25005,13 +25436,17 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
25005
25436
|
* @param {Uint8Array} bytes - Payload of a tag 1 packet
|
|
25006
25437
|
*/
|
|
25007
25438
|
read(bytes) {
|
|
25008
|
-
|
|
25439
|
+
let i = 0;
|
|
25440
|
+
this.version = bytes[i++];
|
|
25009
25441
|
if (this.version !== VERSION$3) {
|
|
25010
25442
|
throw new UnsupportedError(`Version ${this.version} of the PKESK packet is unsupported.`);
|
|
25011
25443
|
}
|
|
25012
|
-
this.publicKeyID.read(bytes.subarray(
|
|
25013
|
-
this.publicKeyAlgorithm = bytes[
|
|
25014
|
-
this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(
|
|
25444
|
+
i += this.publicKeyID.read(bytes.subarray(i));
|
|
25445
|
+
this.publicKeyAlgorithm = bytes[i++];
|
|
25446
|
+
this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(i), this.version);
|
|
25447
|
+
if (this.publicKeyAlgorithm === enums.publicKey.x25519) {
|
|
25448
|
+
this.sessionKeyAlgorithm = enums.write(enums.symmetric, this.encrypted.C.algorithm);
|
|
25449
|
+
}
|
|
25015
25450
|
}
|
|
25016
25451
|
|
|
25017
25452
|
/**
|
|
@@ -25037,15 +25472,11 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
25037
25472
|
* @async
|
|
25038
25473
|
*/
|
|
25039
25474
|
async encrypt(key) {
|
|
25040
|
-
const data = util.concatUint8Array([
|
|
25041
|
-
new Uint8Array([enums.write(enums.symmetric, this.sessionKeyAlgorithm)]),
|
|
25042
|
-
this.sessionKey,
|
|
25043
|
-
util.writeChecksum(this.sessionKey)
|
|
25044
|
-
]);
|
|
25045
25475
|
const algo = enums.write(enums.publicKey, this.publicKeyAlgorithm);
|
|
25476
|
+
const encoded = encodeSessionKey(this.version, algo, this.sessionKeyAlgorithm, this.sessionKey);
|
|
25046
25477
|
const privateParams = algo === enums.publicKey.aead ? key.privateParams : null;
|
|
25047
25478
|
this.encrypted = await mod.publicKeyEncrypt(
|
|
25048
|
-
algo, key.publicParams, privateParams,
|
|
25479
|
+
algo, this.sessionKeyAlgorithm, key.publicParams, privateParams, encoded, key.getFingerprintBytes());
|
|
25049
25480
|
}
|
|
25050
25481
|
|
|
25051
25482
|
/**
|
|
@@ -25062,34 +25493,86 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
25062
25493
|
throw new Error('Decryption error');
|
|
25063
25494
|
}
|
|
25064
25495
|
|
|
25065
|
-
const randomPayload = randomSessionKey ?
|
|
25066
|
-
|
|
25067
|
-
|
|
25068
|
-
|
|
25069
|
-
]) : null;
|
|
25070
|
-
const decoded = await mod.publicKeyDecrypt(this.publicKeyAlgorithm, key.publicParams, key.privateParams, this.encrypted, key.getFingerprintBytes(), randomPayload);
|
|
25071
|
-
const symmetricAlgoByte = decoded[0];
|
|
25072
|
-
const sessionKey = decoded.subarray(1, decoded.length - 2);
|
|
25073
|
-
const checksum = decoded.subarray(decoded.length - 2);
|
|
25074
|
-
const computedChecksum = util.writeChecksum(sessionKey);
|
|
25075
|
-
const isValidChecksum = computedChecksum[0] === checksum[0] & computedChecksum[1] === checksum[1];
|
|
25076
|
-
|
|
25077
|
-
if (randomSessionKey) {
|
|
25078
|
-
// We must not leak info about the validity of the decrypted checksum or cipher algo.
|
|
25079
|
-
// 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.
|
|
25080
|
-
const isValidPayload = isValidChecksum & symmetricAlgoByte === randomSessionKey.sessionKeyAlgorithm & sessionKey.length === randomSessionKey.sessionKey.length;
|
|
25081
|
-
this.sessionKeyAlgorithm = util.selectUint8(isValidPayload, symmetricAlgoByte, randomSessionKey.sessionKeyAlgorithm);
|
|
25082
|
-
this.sessionKey = util.selectUint8Array(isValidPayload, sessionKey, randomSessionKey.sessionKey);
|
|
25496
|
+
const randomPayload = randomSessionKey ?
|
|
25497
|
+
encodeSessionKey(this.version, this.publicKeyAlgorithm, randomSessionKey.sessionKeyAlgorithm, randomSessionKey.sessionKey) :
|
|
25498
|
+
null;
|
|
25499
|
+
const decryptedData = await mod.publicKeyDecrypt(this.publicKeyAlgorithm, key.publicParams, key.privateParams, this.encrypted, key.getFingerprintBytes(), randomPayload);
|
|
25083
25500
|
|
|
25084
|
-
}
|
|
25085
|
-
|
|
25086
|
-
|
|
25087
|
-
|
|
25088
|
-
|
|
25501
|
+
const { sessionKey, sessionKeyAlgorithm } = decodeSessionKey(this.version, this.publicKeyAlgorithm, decryptedData, randomSessionKey);
|
|
25502
|
+
|
|
25503
|
+
// v3 Montgomery curves have cleartext cipher algo
|
|
25504
|
+
if (this.publicKeyAlgorithm !== enums.publicKey.x25519) {
|
|
25505
|
+
this.sessionKeyAlgorithm = sessionKeyAlgorithm;
|
|
25506
|
+
}
|
|
25507
|
+
this.sessionKey = sessionKey;
|
|
25508
|
+
}
|
|
25509
|
+
}
|
|
25510
|
+
|
|
25511
|
+
|
|
25512
|
+
function encodeSessionKey(version, keyAlgo, cipherAlgo, sessionKeyData) {
|
|
25513
|
+
switch (keyAlgo) {
|
|
25514
|
+
case enums.publicKey.rsaEncrypt:
|
|
25515
|
+
case enums.publicKey.rsaEncryptSign:
|
|
25516
|
+
case enums.publicKey.elgamal:
|
|
25517
|
+
case enums.publicKey.ecdh:
|
|
25518
|
+
case enums.publicKey.aead: {
|
|
25519
|
+
// add checksum
|
|
25520
|
+
return util.concatUint8Array([
|
|
25521
|
+
new Uint8Array([cipherAlgo]),
|
|
25522
|
+
sessionKeyData,
|
|
25523
|
+
util.writeChecksum(sessionKeyData.subarray(sessionKeyData.length % 8))
|
|
25524
|
+
]);
|
|
25525
|
+
}
|
|
25526
|
+
case enums.publicKey.x25519:
|
|
25527
|
+
return sessionKeyData;
|
|
25528
|
+
default:
|
|
25529
|
+
throw new Error('Unsupported public key algorithm');
|
|
25530
|
+
}
|
|
25531
|
+
}
|
|
25532
|
+
|
|
25533
|
+
|
|
25534
|
+
function decodeSessionKey(version, keyAlgo, decryptedData, randomSessionKey) {
|
|
25535
|
+
switch (keyAlgo) {
|
|
25536
|
+
case enums.publicKey.rsaEncrypt:
|
|
25537
|
+
case enums.publicKey.rsaEncryptSign:
|
|
25538
|
+
case enums.publicKey.elgamal:
|
|
25539
|
+
case enums.publicKey.ecdh:
|
|
25540
|
+
case enums.publicKey.aead: {
|
|
25541
|
+
// verify checksum in constant time
|
|
25542
|
+
const result = decryptedData.subarray(0, decryptedData.length - 2);
|
|
25543
|
+
const checksum = decryptedData.subarray(decryptedData.length - 2);
|
|
25544
|
+
const computedChecksum = util.writeChecksum(result.subarray(result.length % 8));
|
|
25545
|
+
const isValidChecksum = computedChecksum[0] === checksum[0] & computedChecksum[1] === checksum[1];
|
|
25546
|
+
const decryptedSessionKey = { sessionKeyAlgorithm: result[0], sessionKey: result.subarray(1) };
|
|
25547
|
+
if (randomSessionKey) {
|
|
25548
|
+
// We must not leak info about the validity of the decrypted checksum or cipher algo.
|
|
25549
|
+
// 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.
|
|
25550
|
+
const isValidPayload = isValidChecksum &
|
|
25551
|
+
decryptedSessionKey.sessionKeyAlgorithm === randomSessionKey.sessionKeyAlgorithm &
|
|
25552
|
+
decryptedSessionKey.sessionKey.length === randomSessionKey.sessionKey.length;
|
|
25553
|
+
return {
|
|
25554
|
+
sessionKey: util.selectUint8Array(isValidPayload, decryptedSessionKey.sessionKey, randomSessionKey.sessionKey),
|
|
25555
|
+
sessionKeyAlgorithm: util.selectUint8(
|
|
25556
|
+
isValidPayload,
|
|
25557
|
+
decryptedSessionKey.sessionKeyAlgorithm,
|
|
25558
|
+
randomSessionKey.sessionKeyAlgorithm
|
|
25559
|
+
)
|
|
25560
|
+
};
|
|
25089
25561
|
} else {
|
|
25090
|
-
|
|
25562
|
+
const isValidPayload = isValidChecksum && enums.read(enums.symmetric, decryptedSessionKey.sessionKeyAlgorithm);
|
|
25563
|
+
if (isValidPayload) {
|
|
25564
|
+
return decryptedSessionKey;
|
|
25565
|
+
} else {
|
|
25566
|
+
throw new Error('Decryption error');
|
|
25567
|
+
}
|
|
25091
25568
|
}
|
|
25092
25569
|
}
|
|
25570
|
+
case enums.publicKey.x25519:
|
|
25571
|
+
return {
|
|
25572
|
+
sessionKey: decryptedData
|
|
25573
|
+
};
|
|
25574
|
+
default:
|
|
25575
|
+
throw new Error('Unsupported public key algorithm');
|
|
25093
25576
|
}
|
|
25094
25577
|
}
|
|
25095
25578
|
|
|
@@ -25520,7 +26003,7 @@ class PublicKeyPacket {
|
|
|
25520
26003
|
result.bits = util.uint8ArrayBitLength(modulo);
|
|
25521
26004
|
} else if (this.publicParams.oid) {
|
|
25522
26005
|
result.curve = this.publicParams.oid.getName();
|
|
25523
|
-
} else {
|
|
26006
|
+
} else if (this.publicParams.cipher) {
|
|
25524
26007
|
result.symmetric = this.publicParams.cipher.getName();
|
|
25525
26008
|
}
|
|
25526
26009
|
return result;
|
|
@@ -25852,6 +26335,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25852
26335
|
async read(bytes) {
|
|
25853
26336
|
// - A Public-Key or Public-Subkey packet, as described above.
|
|
25854
26337
|
let i = await this.readPublicKey(bytes);
|
|
26338
|
+
const startOfSecretKeyData = i;
|
|
25855
26339
|
|
|
25856
26340
|
// - One octet indicating string-to-key usage conventions. Zero
|
|
25857
26341
|
// indicates that the secret-key data is not encrypted. 255 or 254
|
|
@@ -25865,41 +26349,48 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25865
26349
|
i++;
|
|
25866
26350
|
}
|
|
25867
26351
|
|
|
25868
|
-
|
|
25869
|
-
|
|
25870
|
-
|
|
25871
|
-
this.
|
|
26352
|
+
try {
|
|
26353
|
+
// - [Optional] If string-to-key usage octet was 255, 254, or 253, a
|
|
26354
|
+
// one-octet symmetric encryption algorithm.
|
|
26355
|
+
if (this.s2kUsage === 255 || this.s2kUsage === 254 || this.s2kUsage === 253) {
|
|
26356
|
+
this.symmetric = bytes[i++];
|
|
25872
26357
|
|
|
25873
|
-
|
|
25874
|
-
|
|
25875
|
-
|
|
25876
|
-
|
|
25877
|
-
|
|
26358
|
+
// - [Optional] If string-to-key usage octet was 253, a one-octet
|
|
26359
|
+
// AEAD algorithm.
|
|
26360
|
+
if (this.s2kUsage === 253) {
|
|
26361
|
+
this.aead = bytes[i++];
|
|
26362
|
+
}
|
|
25878
26363
|
|
|
25879
|
-
|
|
25880
|
-
|
|
25881
|
-
|
|
25882
|
-
|
|
25883
|
-
|
|
25884
|
-
|
|
26364
|
+
// - [Optional] If string-to-key usage octet was 255, 254, or 253, a
|
|
26365
|
+
// string-to-key specifier. The length of the string-to-key
|
|
26366
|
+
// specifier is implied by its type, as described above.
|
|
26367
|
+
const s2kType = bytes[i++];
|
|
26368
|
+
this.s2k = newS2KFromType(s2kType);
|
|
26369
|
+
i += this.s2k.read(bytes.subarray(i, bytes.length));
|
|
25885
26370
|
|
|
25886
|
-
|
|
25887
|
-
|
|
26371
|
+
if (this.s2k.type === 'gnu-dummy') {
|
|
26372
|
+
return;
|
|
26373
|
+
}
|
|
26374
|
+
} else if (this.s2kUsage) {
|
|
26375
|
+
this.symmetric = this.s2kUsage;
|
|
25888
26376
|
}
|
|
25889
|
-
} else if (this.s2kUsage) {
|
|
25890
|
-
this.symmetric = this.s2kUsage;
|
|
25891
|
-
}
|
|
25892
26377
|
|
|
25893
|
-
|
|
25894
|
-
|
|
25895
|
-
|
|
25896
|
-
|
|
25897
|
-
|
|
25898
|
-
|
|
25899
|
-
|
|
25900
|
-
|
|
26378
|
+
// - [Optional] If secret data is encrypted (string-to-key usage octet
|
|
26379
|
+
// not zero), an Initial Vector (IV) of the same length as the
|
|
26380
|
+
// cipher's block size.
|
|
26381
|
+
if (this.s2kUsage) {
|
|
26382
|
+
this.iv = bytes.subarray(
|
|
26383
|
+
i,
|
|
26384
|
+
i + mod.getCipher(this.symmetric).blockSize
|
|
26385
|
+
);
|
|
25901
26386
|
|
|
25902
|
-
|
|
26387
|
+
i += this.iv.length;
|
|
26388
|
+
}
|
|
26389
|
+
} catch (e) {
|
|
26390
|
+
// if the s2k is unsupported, we still want to support encrypting and verifying with the given key
|
|
26391
|
+
if (!this.s2kUsage) throw e; // always throw for decrypted keys
|
|
26392
|
+
this.unparseableKeyMaterial = bytes.subarray(startOfSecretKeyData);
|
|
26393
|
+
this.isEncrypted = true;
|
|
25903
26394
|
}
|
|
25904
26395
|
|
|
25905
26396
|
// - Only for a version 5 packet, a four-octet scalar octet count for
|
|
@@ -25935,8 +26426,15 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25935
26426
|
* @returns {Uint8Array} A string of bytes containing the secret key OpenPGP packet.
|
|
25936
26427
|
*/
|
|
25937
26428
|
write() {
|
|
25938
|
-
const
|
|
26429
|
+
const serializedPublicKey = this.writePublicKey();
|
|
26430
|
+
if (this.unparseableKeyMaterial) {
|
|
26431
|
+
return util.concatUint8Array([
|
|
26432
|
+
serializedPublicKey,
|
|
26433
|
+
this.unparseableKeyMaterial
|
|
26434
|
+
]);
|
|
26435
|
+
}
|
|
25939
26436
|
|
|
26437
|
+
const arr = [serializedPublicKey];
|
|
25940
26438
|
arr.push(new Uint8Array([this.s2kUsage]));
|
|
25941
26439
|
|
|
25942
26440
|
const optionalFieldsArr = [];
|
|
@@ -25996,6 +26494,18 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25996
26494
|
return this.isEncrypted === false;
|
|
25997
26495
|
}
|
|
25998
26496
|
|
|
26497
|
+
/**
|
|
26498
|
+
* Check whether the key includes secret key material.
|
|
26499
|
+
* Some secret keys do not include it, and can thus only be used
|
|
26500
|
+
* for public-key operations (encryption and verification).
|
|
26501
|
+
* Such keys are:
|
|
26502
|
+
* - GNU-dummy keys, where the secret material has been stripped away
|
|
26503
|
+
* - encrypted keys with unsupported S2K or cipher
|
|
26504
|
+
*/
|
|
26505
|
+
isMissingSecretKeyMaterial() {
|
|
26506
|
+
return this.unparseableKeyMaterial !== undefined || this.isDummy();
|
|
26507
|
+
}
|
|
26508
|
+
|
|
25999
26509
|
/**
|
|
26000
26510
|
* Check whether this is a gnu-dummy key
|
|
26001
26511
|
* @returns {Boolean}
|
|
@@ -26016,6 +26526,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
26016
26526
|
if (this.isDecrypted()) {
|
|
26017
26527
|
this.clearPrivateParams();
|
|
26018
26528
|
}
|
|
26529
|
+
delete this.unparseableKeyMaterial;
|
|
26019
26530
|
this.isEncrypted = null;
|
|
26020
26531
|
this.keyMaterial = null;
|
|
26021
26532
|
this.s2k = newS2KFromType(enums.s2k.gnu, config$1);
|
|
@@ -26087,6 +26598,10 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
26087
26598
|
return false;
|
|
26088
26599
|
}
|
|
26089
26600
|
|
|
26601
|
+
if (this.unparseableKeyMaterial) {
|
|
26602
|
+
throw new Error('Key packet cannot be decrypted: unsupported S2K or cipher algo');
|
|
26603
|
+
}
|
|
26604
|
+
|
|
26090
26605
|
if (this.isDecrypted()) {
|
|
26091
26606
|
throw new Error('Key packet is already decrypted.');
|
|
26092
26607
|
}
|
|
@@ -26171,7 +26686,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
26171
26686
|
* Clear private key parameters
|
|
26172
26687
|
*/
|
|
26173
26688
|
clearPrivateParams() {
|
|
26174
|
-
if (this.
|
|
26689
|
+
if (this.isMissingSecretKeyMaterial()) {
|
|
26175
26690
|
return;
|
|
26176
26691
|
}
|
|
26177
26692
|
|
|
@@ -27864,6 +28379,7 @@ function isValidSigningKeyPacket(keyPacket, signature) {
|
|
|
27864
28379
|
return keyAlgo !== enums.publicKey.rsaEncrypt &&
|
|
27865
28380
|
keyAlgo !== enums.publicKey.elgamal &&
|
|
27866
28381
|
keyAlgo !== enums.publicKey.ecdh &&
|
|
28382
|
+
keyAlgo !== enums.publicKey.x25519 &&
|
|
27867
28383
|
(!signature.keyFlags ||
|
|
27868
28384
|
(signature.keyFlags[0] & enums.keyFlags.signData) !== 0);
|
|
27869
28385
|
}
|
|
@@ -27874,6 +28390,7 @@ function isValidEncryptionKeyPacket(keyPacket, signature) {
|
|
|
27874
28390
|
keyAlgo !== enums.publicKey.rsaSign &&
|
|
27875
28391
|
keyAlgo !== enums.publicKey.ecdsa &&
|
|
27876
28392
|
keyAlgo !== enums.publicKey.eddsa &&
|
|
28393
|
+
keyAlgo !== enums.publicKey.ed25519 &&
|
|
27877
28394
|
(!signature.keyFlags ||
|
|
27878
28395
|
(signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
|
|
27879
28396
|
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0);
|
|
@@ -29428,7 +29945,7 @@ function createKey(packetlist) {
|
|
|
29428
29945
|
* @static
|
|
29429
29946
|
* @private
|
|
29430
29947
|
*/
|
|
29431
|
-
async function generate$
|
|
29948
|
+
async function generate$4(options, config) {
|
|
29432
29949
|
options.sign = true; // primary key is always a signing key
|
|
29433
29950
|
options = sanitizeKeyOptions(options);
|
|
29434
29951
|
options.subkeys = options.subkeys.map((subkey, index) => sanitizeKeyOptions(options.subkeys[index], options));
|
|
@@ -30107,6 +30624,15 @@ class Message {
|
|
|
30107
30624
|
enums.read(enums.aead, await getPreferredAlgo('aead', encryptionKeys, date, userIDs, config$1)) :
|
|
30108
30625
|
undefined;
|
|
30109
30626
|
|
|
30627
|
+
await Promise.all(encryptionKeys.map(key => key.getEncryptionKey()
|
|
30628
|
+
.catch(() => null) // ignore key strength requirements
|
|
30629
|
+
.then(maybeKey => {
|
|
30630
|
+
if (maybeKey && (maybeKey.keyPacket.algorithm === enums.publicKey.x25519) && !util.isAES(algo)) {
|
|
30631
|
+
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.');
|
|
30632
|
+
}
|
|
30633
|
+
})
|
|
30634
|
+
));
|
|
30635
|
+
|
|
30110
30636
|
const sessionKeyData = mod.generateSessionKey(algo);
|
|
30111
30637
|
return { data: sessionKeyData, algorithm: algorithmName, aeadAlgorithm: aeadAlgorithmName };
|
|
30112
30638
|
}
|
|
@@ -30414,7 +30940,7 @@ class Message {
|
|
|
30414
30940
|
if (literalDataList.length !== 1) {
|
|
30415
30941
|
throw new Error('Can only verify message with one literal data packet.');
|
|
30416
30942
|
}
|
|
30417
|
-
const signatureList = signature.packets;
|
|
30943
|
+
const signatureList = signature.packets.filterByTag(enums.packet.signature); // drop UnparsablePackets
|
|
30418
30944
|
return createVerificationObjects(signatureList, literalDataList, verificationKeys, date, true, config$1);
|
|
30419
30945
|
}
|
|
30420
30946
|
|
|
@@ -30761,7 +31287,7 @@ class CleartextMessage {
|
|
|
30761
31287
|
* @async
|
|
30762
31288
|
*/
|
|
30763
31289
|
verify(keys, date = new Date(), config$1 = config) {
|
|
30764
|
-
const signatureList = this.signature.packets;
|
|
31290
|
+
const signatureList = this.signature.packets.filterByTag(enums.packet.signature); // drop UnparsablePackets
|
|
30765
31291
|
const literalDataPacket = new LiteralDataPacket();
|
|
30766
31292
|
// we assume that cleartext signature is generated based on UTF8 cleartext
|
|
30767
31293
|
literalDataPacket.setText(this.text);
|
|
@@ -30846,7 +31372,7 @@ function verifyHeaders$1(headers, packetlist) {
|
|
|
30846
31372
|
let oneHeader = null;
|
|
30847
31373
|
let hashAlgos = [];
|
|
30848
31374
|
headers.forEach(function(header) {
|
|
30849
|
-
oneHeader = header.match(
|
|
31375
|
+
oneHeader = header.match(/^Hash: (.+)$/); // get header value
|
|
30850
31376
|
if (oneHeader) {
|
|
30851
31377
|
oneHeader = oneHeader[1].replace(/\s/g, ''); // remove whitespace
|
|
30852
31378
|
oneHeader = oneHeader.split(',');
|
|
@@ -30938,7 +31464,7 @@ async function generateKey({ userIDs = [], passphrase, type = 'ecc', rsaBits = 4
|
|
|
30938
31464
|
const options = { userIDs, passphrase, type, rsaBits, curve, keyExpirationTime, date, subkeys, symmetricHash, symmetricCipher };
|
|
30939
31465
|
|
|
30940
31466
|
try {
|
|
30941
|
-
const { key, revocationCertificate } = await generate$
|
|
31467
|
+
const { key, revocationCertificate } = await generate$4(options, config$1);
|
|
30942
31468
|
key.getKeys().forEach(({ keyPacket }) => checkKeyRequirements(keyPacket, config$1));
|
|
30943
31469
|
|
|
30944
31470
|
return {
|
|
@@ -31132,7 +31658,7 @@ async function encryptKey({ privateKey, passphrase, config: config$1, ...rest })
|
|
|
31132
31658
|
* @async
|
|
31133
31659
|
* @static
|
|
31134
31660
|
*/
|
|
31135
|
-
async function encrypt$
|
|
31661
|
+
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 }) {
|
|
31136
31662
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31137
31663
|
checkMessage(message); checkOutputMessageFormat(format);
|
|
31138
31664
|
encryptionKeys = toArray$1(encryptionKeys); signingKeys = toArray$1(signingKeys); passwords = toArray$1(passwords);
|
|
@@ -31201,7 +31727,7 @@ async function encrypt$4({ message, encryptionKeys, signingKeys, passwords, sess
|
|
|
31201
31727
|
* @async
|
|
31202
31728
|
* @static
|
|
31203
31729
|
*/
|
|
31204
|
-
async function decrypt$
|
|
31730
|
+
async function decrypt$5({ message, decryptionKeys, passwords, sessionKeys, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
|
|
31205
31731
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31206
31732
|
checkMessage(message); verificationKeys = toArray$1(verificationKeys); decryptionKeys = toArray$1(decryptionKeys); passwords = toArray$1(passwords); sessionKeys = toArray$1(sessionKeys);
|
|
31207
31733
|
if (rest.privateKeys) throw new Error('The `privateKeys` option has been removed from openpgp.decrypt, pass `decryptionKeys` instead');
|
|
@@ -31264,7 +31790,7 @@ async function decrypt$4({ message, decryptionKeys, passwords, sessionKeys, veri
|
|
|
31264
31790
|
* @async
|
|
31265
31791
|
* @static
|
|
31266
31792
|
*/
|
|
31267
|
-
async function sign$
|
|
31793
|
+
async function sign$6({ message, signingKeys, format = 'armored', detached = false, signingKeyIDs = [], date = new Date(), signingUserIDs = [], signatureNotations = [], config: config$1, ...rest }) {
|
|
31268
31794
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31269
31795
|
checkCleartextOrMessage(message); checkOutputMessageFormat(format);
|
|
31270
31796
|
signingKeys = toArray$1(signingKeys); signingKeyIDs = toArray$1(signingKeyIDs); signingUserIDs = toArray$1(signingUserIDs); signatureNotations = toArray$1(signatureNotations);
|
|
@@ -31333,7 +31859,7 @@ async function sign$5({ message, signingKeys, format = 'armored', detached = fal
|
|
|
31333
31859
|
* @async
|
|
31334
31860
|
* @static
|
|
31335
31861
|
*/
|
|
31336
|
-
async function verify$
|
|
31862
|
+
async function verify$6({ message, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
|
|
31337
31863
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31338
31864
|
checkCleartextOrMessage(message); verificationKeys = toArray$1(verificationKeys);
|
|
31339
31865
|
if (rest.publicKeys) throw new Error('The `publicKeys` option has been removed from openpgp.verify, pass `verificationKeys` instead');
|
|
@@ -44502,7 +45028,7 @@ function* makePRNG(wasmContext, pass, lane, slice, m_, totalPasses, segmentLengt
|
|
|
44502
45028
|
return [];
|
|
44503
45029
|
}
|
|
44504
45030
|
|
|
44505
|
-
function validateParams$
|
|
45031
|
+
function validateParams$9({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {
|
|
44506
45032
|
const assertLength = (name, value, min, max) => {
|
|
44507
45033
|
if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }
|
|
44508
45034
|
};
|
|
@@ -44525,7 +45051,7 @@ const WASM_PAGE_SIZE = 64 * KB;
|
|
|
44525
45051
|
function argon2id(params, { memory, instance: wasmInstance }) {
|
|
44526
45052
|
if (!isLittleEndian$1) throw new Error('BigEndian system not supported'); // optmisations assume LE system
|
|
44527
45053
|
|
|
44528
|
-
const ctx = validateParams$
|
|
45054
|
+
const ctx = validateParams$9({ type: TYPE$2, version: VERSION$4, ...params });
|
|
44529
45055
|
|
|
44530
45056
|
const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;
|
|
44531
45057
|
const wasmRefs = {};
|
|
@@ -44835,10 +45361,10 @@ exports.armor = armor;
|
|
|
44835
45361
|
exports.config = config;
|
|
44836
45362
|
exports.createCleartextMessage = createCleartextMessage;
|
|
44837
45363
|
exports.createMessage = createMessage;
|
|
44838
|
-
exports.decrypt = decrypt$
|
|
45364
|
+
exports.decrypt = decrypt$5;
|
|
44839
45365
|
exports.decryptKey = decryptKey;
|
|
44840
45366
|
exports.decryptSessionKeys = decryptSessionKeys;
|
|
44841
|
-
exports.encrypt = encrypt$
|
|
45367
|
+
exports.encrypt = encrypt$5;
|
|
44842
45368
|
exports.encryptKey = encryptKey;
|
|
44843
45369
|
exports.encryptSessionKey = encryptSessionKey;
|
|
44844
45370
|
exports.enums = enums;
|
|
@@ -44853,6 +45379,6 @@ exports.readPrivateKeys = readPrivateKeys;
|
|
|
44853
45379
|
exports.readSignature = readSignature;
|
|
44854
45380
|
exports.reformatKey = reformatKey;
|
|
44855
45381
|
exports.revokeKey = revokeKey;
|
|
44856
|
-
exports.sign = sign$
|
|
45382
|
+
exports.sign = sign$6;
|
|
44857
45383
|
exports.unarmor = unarmor;
|
|
44858
|
-
exports.verify = verify$
|
|
45384
|
+
exports.verify = verify$6;
|