@protontech/openpgp 5.9.1-0 → 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 +1745 -1207
- 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 +1225 -687
- 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 +1222 -684
- package/dist/openpgp.js +1225 -687
- 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 +1222 -684
- package/openpgp.d.ts +3 -0
- package/package.json +2 -2
package/dist/node/openpgp.mjs
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
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
4
|
import buffer from 'buffer';
|
|
@@ -1515,6 +1515,526 @@ async function getBigInteger() {
|
|
|
1515
1515
|
}
|
|
1516
1516
|
}
|
|
1517
1517
|
|
|
1518
|
+
/**
|
|
1519
|
+
* @module enums
|
|
1520
|
+
*/
|
|
1521
|
+
|
|
1522
|
+
const byValue = Symbol('byValue');
|
|
1523
|
+
|
|
1524
|
+
var enums = {
|
|
1525
|
+
|
|
1526
|
+
/** Maps curve names under various standards to one
|
|
1527
|
+
* @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
|
|
1528
|
+
* @enum {String}
|
|
1529
|
+
* @readonly
|
|
1530
|
+
*/
|
|
1531
|
+
curve: {
|
|
1532
|
+
/** NIST P-256 Curve */
|
|
1533
|
+
'p256': 'p256',
|
|
1534
|
+
'P-256': 'p256',
|
|
1535
|
+
'secp256r1': 'p256',
|
|
1536
|
+
'prime256v1': 'p256',
|
|
1537
|
+
'1.2.840.10045.3.1.7': 'p256',
|
|
1538
|
+
'2a8648ce3d030107': 'p256',
|
|
1539
|
+
'2A8648CE3D030107': 'p256',
|
|
1540
|
+
|
|
1541
|
+
/** NIST P-384 Curve */
|
|
1542
|
+
'p384': 'p384',
|
|
1543
|
+
'P-384': 'p384',
|
|
1544
|
+
'secp384r1': 'p384',
|
|
1545
|
+
'1.3.132.0.34': 'p384',
|
|
1546
|
+
'2b81040022': 'p384',
|
|
1547
|
+
'2B81040022': 'p384',
|
|
1548
|
+
|
|
1549
|
+
/** NIST P-521 Curve */
|
|
1550
|
+
'p521': 'p521',
|
|
1551
|
+
'P-521': 'p521',
|
|
1552
|
+
'secp521r1': 'p521',
|
|
1553
|
+
'1.3.132.0.35': 'p521',
|
|
1554
|
+
'2b81040023': 'p521',
|
|
1555
|
+
'2B81040023': 'p521',
|
|
1556
|
+
|
|
1557
|
+
/** SECG SECP256k1 Curve */
|
|
1558
|
+
'secp256k1': 'secp256k1',
|
|
1559
|
+
'1.3.132.0.10': 'secp256k1',
|
|
1560
|
+
'2b8104000a': 'secp256k1',
|
|
1561
|
+
'2B8104000A': 'secp256k1',
|
|
1562
|
+
|
|
1563
|
+
/** Ed25519 */
|
|
1564
|
+
'ED25519': 'ed25519',
|
|
1565
|
+
'ed25519': 'ed25519',
|
|
1566
|
+
'Ed25519': 'ed25519',
|
|
1567
|
+
'1.3.6.1.4.1.11591.15.1': 'ed25519',
|
|
1568
|
+
'2b06010401da470f01': 'ed25519',
|
|
1569
|
+
'2B06010401DA470F01': 'ed25519',
|
|
1570
|
+
|
|
1571
|
+
/** Curve25519 */
|
|
1572
|
+
'X25519': 'curve25519',
|
|
1573
|
+
'cv25519': 'curve25519',
|
|
1574
|
+
'curve25519': 'curve25519',
|
|
1575
|
+
'Curve25519': 'curve25519',
|
|
1576
|
+
'1.3.6.1.4.1.3029.1.5.1': 'curve25519',
|
|
1577
|
+
'2b060104019755010501': 'curve25519',
|
|
1578
|
+
'2B060104019755010501': 'curve25519',
|
|
1579
|
+
|
|
1580
|
+
/** BrainpoolP256r1 Curve */
|
|
1581
|
+
'brainpoolP256r1': 'brainpoolP256r1',
|
|
1582
|
+
'1.3.36.3.3.2.8.1.1.7': 'brainpoolP256r1',
|
|
1583
|
+
'2b2403030208010107': 'brainpoolP256r1',
|
|
1584
|
+
'2B2403030208010107': 'brainpoolP256r1',
|
|
1585
|
+
|
|
1586
|
+
/** BrainpoolP384r1 Curve */
|
|
1587
|
+
'brainpoolP384r1': 'brainpoolP384r1',
|
|
1588
|
+
'1.3.36.3.3.2.8.1.1.11': 'brainpoolP384r1',
|
|
1589
|
+
'2b240303020801010b': 'brainpoolP384r1',
|
|
1590
|
+
'2B240303020801010B': 'brainpoolP384r1',
|
|
1591
|
+
|
|
1592
|
+
/** BrainpoolP512r1 Curve */
|
|
1593
|
+
'brainpoolP512r1': 'brainpoolP512r1',
|
|
1594
|
+
'1.3.36.3.3.2.8.1.1.13': 'brainpoolP512r1',
|
|
1595
|
+
'2b240303020801010d': 'brainpoolP512r1',
|
|
1596
|
+
'2B240303020801010D': 'brainpoolP512r1'
|
|
1597
|
+
},
|
|
1598
|
+
|
|
1599
|
+
/** KDF parameters flags
|
|
1600
|
+
* Non-standard extensions (for now) to allow email forwarding
|
|
1601
|
+
* @enum {Integer}
|
|
1602
|
+
* @readonly
|
|
1603
|
+
*/
|
|
1604
|
+
kdfFlags: {
|
|
1605
|
+
/** Specify fingerprint to use instead of the recipient's */
|
|
1606
|
+
replace_fingerprint: 0x01,
|
|
1607
|
+
/** Specify custom parameters to use in the KDF digest computation */
|
|
1608
|
+
replace_kdf_params: 0x02
|
|
1609
|
+
},
|
|
1610
|
+
|
|
1611
|
+
/** A string to key specifier type
|
|
1612
|
+
* @enum {Integer}
|
|
1613
|
+
* @readonly
|
|
1614
|
+
*/
|
|
1615
|
+
s2k: {
|
|
1616
|
+
simple: 0,
|
|
1617
|
+
salted: 1,
|
|
1618
|
+
iterated: 3,
|
|
1619
|
+
argon2: 4,
|
|
1620
|
+
gnu: 101
|
|
1621
|
+
},
|
|
1622
|
+
|
|
1623
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-crypto-refresh-08.html#section-9.1|crypto-refresh RFC, section 9.1}
|
|
1624
|
+
* @enum {Integer}
|
|
1625
|
+
* @readonly
|
|
1626
|
+
*/
|
|
1627
|
+
publicKey: {
|
|
1628
|
+
/** RSA (Encrypt or Sign) [HAC] */
|
|
1629
|
+
rsaEncryptSign: 1,
|
|
1630
|
+
/** RSA (Encrypt only) [HAC] */
|
|
1631
|
+
rsaEncrypt: 2,
|
|
1632
|
+
/** RSA (Sign only) [HAC] */
|
|
1633
|
+
rsaSign: 3,
|
|
1634
|
+
/** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
|
|
1635
|
+
elgamal: 16,
|
|
1636
|
+
/** DSA (Sign only) [FIPS186] [HAC] */
|
|
1637
|
+
dsa: 17,
|
|
1638
|
+
/** ECDH (Encrypt only) [RFC6637] */
|
|
1639
|
+
ecdh: 18,
|
|
1640
|
+
/** ECDSA (Sign only) [RFC6637] */
|
|
1641
|
+
ecdsa: 19,
|
|
1642
|
+
/** EdDSA (Sign only) - deprecated by crypto-refresh (replaced by `ed25519` identifier below)
|
|
1643
|
+
* [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
|
|
1644
|
+
ed25519Legacy: 22, // NB: this is declared before `eddsa` to translate 22 to 'eddsa' for backwards compatibility
|
|
1645
|
+
eddsa: 22, // to be deprecated in v6
|
|
1646
|
+
/** Reserved for AEDH */
|
|
1647
|
+
aedh: 23,
|
|
1648
|
+
/** Reserved for AEDSA */
|
|
1649
|
+
aedsa: 24,
|
|
1650
|
+
/** X25519 (Encrypt only) */
|
|
1651
|
+
x25519: 25,
|
|
1652
|
+
/** X448 (Encrypt only) */
|
|
1653
|
+
x448: 26,
|
|
1654
|
+
/** Ed25519 (Sign only) */
|
|
1655
|
+
ed25519: 27,
|
|
1656
|
+
/** Ed448 (Sign only) */
|
|
1657
|
+
ed448: 28,
|
|
1658
|
+
/** Symmetric authenticated encryption algorithms */
|
|
1659
|
+
aead: 100,
|
|
1660
|
+
/** Authentication using CMAC */
|
|
1661
|
+
hmac: 101
|
|
1662
|
+
},
|
|
1663
|
+
|
|
1664
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
|
|
1665
|
+
* @enum {Integer}
|
|
1666
|
+
* @readonly
|
|
1667
|
+
*/
|
|
1668
|
+
symmetric: {
|
|
1669
|
+
plaintext: 0,
|
|
1670
|
+
/** Not implemented! */
|
|
1671
|
+
idea: 1,
|
|
1672
|
+
tripledes: 2,
|
|
1673
|
+
cast5: 3,
|
|
1674
|
+
blowfish: 4,
|
|
1675
|
+
aes128: 7,
|
|
1676
|
+
aes192: 8,
|
|
1677
|
+
aes256: 9,
|
|
1678
|
+
twofish: 10
|
|
1679
|
+
},
|
|
1680
|
+
|
|
1681
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
|
|
1682
|
+
* @enum {Integer}
|
|
1683
|
+
* @readonly
|
|
1684
|
+
*/
|
|
1685
|
+
compression: {
|
|
1686
|
+
uncompressed: 0,
|
|
1687
|
+
/** RFC1951 */
|
|
1688
|
+
zip: 1,
|
|
1689
|
+
/** RFC1950 */
|
|
1690
|
+
zlib: 2,
|
|
1691
|
+
bzip2: 3
|
|
1692
|
+
},
|
|
1693
|
+
|
|
1694
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
|
|
1695
|
+
* @enum {Integer}
|
|
1696
|
+
* @readonly
|
|
1697
|
+
*/
|
|
1698
|
+
hash: {
|
|
1699
|
+
md5: 1,
|
|
1700
|
+
sha1: 2,
|
|
1701
|
+
ripemd: 3,
|
|
1702
|
+
sha256: 8,
|
|
1703
|
+
sha384: 9,
|
|
1704
|
+
sha512: 10,
|
|
1705
|
+
sha224: 11
|
|
1706
|
+
},
|
|
1707
|
+
|
|
1708
|
+
/** A list of hash names as accepted by webCrypto functions.
|
|
1709
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
|
|
1710
|
+
* @enum {String}
|
|
1711
|
+
*/
|
|
1712
|
+
webHash: {
|
|
1713
|
+
'SHA-1': 2,
|
|
1714
|
+
'SHA-256': 8,
|
|
1715
|
+
'SHA-384': 9,
|
|
1716
|
+
'SHA-512': 10
|
|
1717
|
+
},
|
|
1718
|
+
|
|
1719
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
|
|
1720
|
+
* @enum {Integer}
|
|
1721
|
+
* @readonly
|
|
1722
|
+
*/
|
|
1723
|
+
aead: {
|
|
1724
|
+
eax: 1,
|
|
1725
|
+
ocb: 2,
|
|
1726
|
+
experimentalGCM: 100 // Private algorithm
|
|
1727
|
+
},
|
|
1728
|
+
|
|
1729
|
+
/** A list of packet types and numeric tags associated with them.
|
|
1730
|
+
* @enum {Integer}
|
|
1731
|
+
* @readonly
|
|
1732
|
+
*/
|
|
1733
|
+
packet: {
|
|
1734
|
+
publicKeyEncryptedSessionKey: 1,
|
|
1735
|
+
signature: 2,
|
|
1736
|
+
symEncryptedSessionKey: 3,
|
|
1737
|
+
onePassSignature: 4,
|
|
1738
|
+
secretKey: 5,
|
|
1739
|
+
publicKey: 6,
|
|
1740
|
+
secretSubkey: 7,
|
|
1741
|
+
compressedData: 8,
|
|
1742
|
+
symmetricallyEncryptedData: 9,
|
|
1743
|
+
marker: 10,
|
|
1744
|
+
literalData: 11,
|
|
1745
|
+
trust: 12,
|
|
1746
|
+
userID: 13,
|
|
1747
|
+
publicSubkey: 14,
|
|
1748
|
+
userAttribute: 17,
|
|
1749
|
+
symEncryptedIntegrityProtectedData: 18,
|
|
1750
|
+
modificationDetectionCode: 19,
|
|
1751
|
+
aeadEncryptedData: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
|
|
1752
|
+
},
|
|
1753
|
+
|
|
1754
|
+
/** Data types in the literal packet
|
|
1755
|
+
* @enum {Integer}
|
|
1756
|
+
* @readonly
|
|
1757
|
+
*/
|
|
1758
|
+
literal: {
|
|
1759
|
+
/** Binary data 'b' */
|
|
1760
|
+
binary: 'b'.charCodeAt(),
|
|
1761
|
+
/** Text data 't' */
|
|
1762
|
+
text: 't'.charCodeAt(),
|
|
1763
|
+
/** Utf8 data 'u' */
|
|
1764
|
+
utf8: 'u'.charCodeAt(),
|
|
1765
|
+
/** MIME message body part 'm' */
|
|
1766
|
+
mime: 'm'.charCodeAt()
|
|
1767
|
+
},
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
/** One pass signature packet type
|
|
1771
|
+
* @enum {Integer}
|
|
1772
|
+
* @readonly
|
|
1773
|
+
*/
|
|
1774
|
+
signature: {
|
|
1775
|
+
/** 0x00: Signature of a binary document. */
|
|
1776
|
+
binary: 0,
|
|
1777
|
+
/** 0x01: Signature of a canonical text document.
|
|
1778
|
+
*
|
|
1779
|
+
* Canonicalyzing the document by converting line endings. */
|
|
1780
|
+
text: 1,
|
|
1781
|
+
/** 0x02: Standalone signature.
|
|
1782
|
+
*
|
|
1783
|
+
* This signature is a signature of only its own subpacket contents.
|
|
1784
|
+
* It is calculated identically to a signature over a zero-lengh
|
|
1785
|
+
* binary document. Note that it doesn't make sense to have a V3
|
|
1786
|
+
* standalone signature. */
|
|
1787
|
+
standalone: 2,
|
|
1788
|
+
/** 0x10: Generic certification of a User ID and Public-Key packet.
|
|
1789
|
+
*
|
|
1790
|
+
* The issuer of this certification does not make any particular
|
|
1791
|
+
* assertion as to how well the certifier has checked that the owner
|
|
1792
|
+
* of the key is in fact the person described by the User ID. */
|
|
1793
|
+
certGeneric: 16,
|
|
1794
|
+
/** 0x11: Persona certification of a User ID and Public-Key packet.
|
|
1795
|
+
*
|
|
1796
|
+
* The issuer of this certification has not done any verification of
|
|
1797
|
+
* the claim that the owner of this key is the User ID specified. */
|
|
1798
|
+
certPersona: 17,
|
|
1799
|
+
/** 0x12: Casual certification of a User ID and Public-Key packet.
|
|
1800
|
+
*
|
|
1801
|
+
* The issuer of this certification has done some casual
|
|
1802
|
+
* verification of the claim of identity. */
|
|
1803
|
+
certCasual: 18,
|
|
1804
|
+
/** 0x13: Positive certification of a User ID and Public-Key packet.
|
|
1805
|
+
*
|
|
1806
|
+
* The issuer of this certification has done substantial
|
|
1807
|
+
* verification of the claim of identity.
|
|
1808
|
+
*
|
|
1809
|
+
* Most OpenPGP implementations make their "key signatures" as 0x10
|
|
1810
|
+
* certifications. Some implementations can issue 0x11-0x13
|
|
1811
|
+
* certifications, but few differentiate between the types. */
|
|
1812
|
+
certPositive: 19,
|
|
1813
|
+
/** 0x30: Certification revocation signature
|
|
1814
|
+
*
|
|
1815
|
+
* This signature revokes an earlier User ID certification signature
|
|
1816
|
+
* (signature class 0x10 through 0x13) or direct-key signature
|
|
1817
|
+
* (0x1F). It should be issued by the same key that issued the
|
|
1818
|
+
* revoked signature or an authorized revocation key. The signature
|
|
1819
|
+
* is computed over the same data as the certificate that it
|
|
1820
|
+
* revokes, and should have a later creation date than that
|
|
1821
|
+
* certificate. */
|
|
1822
|
+
certRevocation: 48,
|
|
1823
|
+
/** 0x18: Subkey Binding Signature
|
|
1824
|
+
*
|
|
1825
|
+
* This signature is a statement by the top-level signing key that
|
|
1826
|
+
* indicates that it owns the subkey. This signature is calculated
|
|
1827
|
+
* directly on the primary key and subkey, and not on any User ID or
|
|
1828
|
+
* other packets. A signature that binds a signing subkey MUST have
|
|
1829
|
+
* an Embedded Signature subpacket in this binding signature that
|
|
1830
|
+
* contains a 0x19 signature made by the signing subkey on the
|
|
1831
|
+
* primary key and subkey. */
|
|
1832
|
+
subkeyBinding: 24,
|
|
1833
|
+
/** 0x19: Primary Key Binding Signature
|
|
1834
|
+
*
|
|
1835
|
+
* This signature is a statement by a signing subkey, indicating
|
|
1836
|
+
* that it is owned by the primary key and subkey. This signature
|
|
1837
|
+
* is calculated the same way as a 0x18 signature: directly on the
|
|
1838
|
+
* primary key and subkey, and not on any User ID or other packets.
|
|
1839
|
+
*
|
|
1840
|
+
* When a signature is made over a key, the hash data starts with the
|
|
1841
|
+
* octet 0x99, followed by a two-octet length of the key, and then body
|
|
1842
|
+
* of the key packet. (Note that this is an old-style packet header for
|
|
1843
|
+
* a key packet with two-octet length.) A subkey binding signature
|
|
1844
|
+
* (type 0x18) or primary key binding signature (type 0x19) then hashes
|
|
1845
|
+
* the subkey using the same format as the main key (also using 0x99 as
|
|
1846
|
+
* the first octet). */
|
|
1847
|
+
keyBinding: 25,
|
|
1848
|
+
/** 0x1F: Signature directly on a key
|
|
1849
|
+
*
|
|
1850
|
+
* This signature is calculated directly on a key. It binds the
|
|
1851
|
+
* information in the Signature subpackets to the key, and is
|
|
1852
|
+
* appropriate to be used for subpackets that provide information
|
|
1853
|
+
* about the key, such as the Revocation Key subpacket. It is also
|
|
1854
|
+
* appropriate for statements that non-self certifiers want to make
|
|
1855
|
+
* about the key itself, rather than the binding between a key and a
|
|
1856
|
+
* name. */
|
|
1857
|
+
key: 31,
|
|
1858
|
+
/** 0x20: Key revocation signature
|
|
1859
|
+
*
|
|
1860
|
+
* The signature is calculated directly on the key being revoked. A
|
|
1861
|
+
* revoked key is not to be used. Only revocation signatures by the
|
|
1862
|
+
* key being revoked, or by an authorized revocation key, should be
|
|
1863
|
+
* considered valid revocation signatures.a */
|
|
1864
|
+
keyRevocation: 32,
|
|
1865
|
+
/** 0x28: Subkey revocation signature
|
|
1866
|
+
*
|
|
1867
|
+
* The signature is calculated directly on the subkey being revoked.
|
|
1868
|
+
* A revoked subkey is not to be used. Only revocation signatures
|
|
1869
|
+
* by the top-level signature key that is bound to this subkey, or
|
|
1870
|
+
* by an authorized revocation key, should be considered valid
|
|
1871
|
+
* revocation signatures.
|
|
1872
|
+
*
|
|
1873
|
+
* Key revocation signatures (types 0x20 and 0x28)
|
|
1874
|
+
* hash only the key being revoked. */
|
|
1875
|
+
subkeyRevocation: 40,
|
|
1876
|
+
/** 0x40: Timestamp signature.
|
|
1877
|
+
* This signature is only meaningful for the timestamp contained in
|
|
1878
|
+
* it. */
|
|
1879
|
+
timestamp: 64,
|
|
1880
|
+
/** 0x50: Third-Party Confirmation signature.
|
|
1881
|
+
*
|
|
1882
|
+
* This signature is a signature over some other OpenPGP Signature
|
|
1883
|
+
* packet(s). It is analogous to a notary seal on the signed data.
|
|
1884
|
+
* A third-party signature SHOULD include Signature Target
|
|
1885
|
+
* subpacket(s) to give easy identification. Note that we really do
|
|
1886
|
+
* mean SHOULD. There are plausible uses for this (such as a blind
|
|
1887
|
+
* party that only sees the signature, not the key or source
|
|
1888
|
+
* document) that cannot include a target subpacket. */
|
|
1889
|
+
thirdParty: 80
|
|
1890
|
+
},
|
|
1891
|
+
|
|
1892
|
+
/** Signature subpacket type
|
|
1893
|
+
* @enum {Integer}
|
|
1894
|
+
* @readonly
|
|
1895
|
+
*/
|
|
1896
|
+
signatureSubpacket: {
|
|
1897
|
+
signatureCreationTime: 2,
|
|
1898
|
+
signatureExpirationTime: 3,
|
|
1899
|
+
exportableCertification: 4,
|
|
1900
|
+
trustSignature: 5,
|
|
1901
|
+
regularExpression: 6,
|
|
1902
|
+
revocable: 7,
|
|
1903
|
+
keyExpirationTime: 9,
|
|
1904
|
+
placeholderBackwardsCompatibility: 10,
|
|
1905
|
+
preferredSymmetricAlgorithms: 11,
|
|
1906
|
+
revocationKey: 12,
|
|
1907
|
+
issuer: 16,
|
|
1908
|
+
notationData: 20,
|
|
1909
|
+
preferredHashAlgorithms: 21,
|
|
1910
|
+
preferredCompressionAlgorithms: 22,
|
|
1911
|
+
keyServerPreferences: 23,
|
|
1912
|
+
preferredKeyServer: 24,
|
|
1913
|
+
primaryUserID: 25,
|
|
1914
|
+
policyURI: 26,
|
|
1915
|
+
keyFlags: 27,
|
|
1916
|
+
signersUserID: 28,
|
|
1917
|
+
reasonForRevocation: 29,
|
|
1918
|
+
features: 30,
|
|
1919
|
+
signatureTarget: 31,
|
|
1920
|
+
embeddedSignature: 32,
|
|
1921
|
+
issuerFingerprint: 33,
|
|
1922
|
+
preferredAEADAlgorithms: 34
|
|
1923
|
+
},
|
|
1924
|
+
|
|
1925
|
+
/** Key flags
|
|
1926
|
+
* @enum {Integer}
|
|
1927
|
+
* @readonly
|
|
1928
|
+
*/
|
|
1929
|
+
keyFlags: {
|
|
1930
|
+
/** 0x01 - This key may be used to certify other keys. */
|
|
1931
|
+
certifyKeys: 1,
|
|
1932
|
+
/** 0x02 - This key may be used to sign data. */
|
|
1933
|
+
signData: 2,
|
|
1934
|
+
/** 0x04 - This key may be used to encrypt communications. */
|
|
1935
|
+
encryptCommunication: 4,
|
|
1936
|
+
/** 0x08 - This key may be used to encrypt storage. */
|
|
1937
|
+
encryptStorage: 8,
|
|
1938
|
+
/** 0x10 - The private component of this key may have been split
|
|
1939
|
+
* by a secret-sharing mechanism. */
|
|
1940
|
+
splitPrivateKey: 16,
|
|
1941
|
+
/** 0x20 - This key may be used for authentication. */
|
|
1942
|
+
authentication: 32,
|
|
1943
|
+
/** This key may be used for forwarded communications */
|
|
1944
|
+
forwardedCommunication: 64,
|
|
1945
|
+
/** 0x80 - The private component of this key may be in the
|
|
1946
|
+
* possession of more than one person. */
|
|
1947
|
+
sharedPrivateKey: 128
|
|
1948
|
+
},
|
|
1949
|
+
|
|
1950
|
+
/** Armor type
|
|
1951
|
+
* @enum {Integer}
|
|
1952
|
+
* @readonly
|
|
1953
|
+
*/
|
|
1954
|
+
armor: {
|
|
1955
|
+
multipartSection: 0,
|
|
1956
|
+
multipartLast: 1,
|
|
1957
|
+
signed: 2,
|
|
1958
|
+
message: 3,
|
|
1959
|
+
publicKey: 4,
|
|
1960
|
+
privateKey: 5,
|
|
1961
|
+
signature: 6
|
|
1962
|
+
},
|
|
1963
|
+
|
|
1964
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
|
|
1965
|
+
* @enum {Integer}
|
|
1966
|
+
* @readonly
|
|
1967
|
+
*/
|
|
1968
|
+
reasonForRevocation: {
|
|
1969
|
+
/** No reason specified (key revocations or cert revocations) */
|
|
1970
|
+
noReason: 0,
|
|
1971
|
+
/** Key is superseded (key revocations) */
|
|
1972
|
+
keySuperseded: 1,
|
|
1973
|
+
/** Key material has been compromised (key revocations) */
|
|
1974
|
+
keyCompromised: 2,
|
|
1975
|
+
/** Key is retired and no longer used (key revocations) */
|
|
1976
|
+
keyRetired: 3,
|
|
1977
|
+
/** User ID information is no longer valid (cert revocations) */
|
|
1978
|
+
userIDInvalid: 32
|
|
1979
|
+
},
|
|
1980
|
+
|
|
1981
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
|
|
1982
|
+
* @enum {Integer}
|
|
1983
|
+
* @readonly
|
|
1984
|
+
*/
|
|
1985
|
+
features: {
|
|
1986
|
+
/** 0x01 - Modification Detection (packets 18 and 19) */
|
|
1987
|
+
modificationDetection: 1,
|
|
1988
|
+
/** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
|
|
1989
|
+
* Symmetric-Key Encrypted Session Key Packets (packet 3) */
|
|
1990
|
+
aead: 2,
|
|
1991
|
+
/** 0x04 - Version 5 Public-Key Packet format and corresponding new
|
|
1992
|
+
* fingerprint format */
|
|
1993
|
+
v5Keys: 4
|
|
1994
|
+
},
|
|
1995
|
+
|
|
1996
|
+
/**
|
|
1997
|
+
* Asserts validity of given value and converts from string/integer to integer.
|
|
1998
|
+
* @param {Object} type target enum type
|
|
1999
|
+
* @param {String|Integer} e value to check and/or convert
|
|
2000
|
+
* @returns {Integer} enum value if it exists
|
|
2001
|
+
* @throws {Error} if the value is invalid
|
|
2002
|
+
*/
|
|
2003
|
+
write: function(type, e) {
|
|
2004
|
+
if (typeof e === 'number') {
|
|
2005
|
+
e = this.read(type, e);
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
if (type[e] !== undefined) {
|
|
2009
|
+
return type[e];
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
throw new Error('Invalid enum value.');
|
|
2013
|
+
},
|
|
2014
|
+
|
|
2015
|
+
/**
|
|
2016
|
+
* Converts enum integer value to the corresponding string, if it exists.
|
|
2017
|
+
* @param {Object} type target enum type
|
|
2018
|
+
* @param {Integer} e value to convert
|
|
2019
|
+
* @returns {String} name of enum value if it exists
|
|
2020
|
+
* @throws {Error} if the value is invalid
|
|
2021
|
+
*/
|
|
2022
|
+
read: function(type, e) {
|
|
2023
|
+
if (!type[byValue]) {
|
|
2024
|
+
type[byValue] = [];
|
|
2025
|
+
Object.entries(type).forEach(([key, value]) => {
|
|
2026
|
+
type[byValue][value] = key;
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
if (type[byValue][e] !== undefined) {
|
|
2031
|
+
return type[byValue][e];
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
throw new Error('Invalid enum value.');
|
|
2035
|
+
}
|
|
2036
|
+
};
|
|
2037
|
+
|
|
1518
2038
|
const debugMode = (() => {
|
|
1519
2039
|
try {
|
|
1520
2040
|
return process.env.NODE_ENV === 'development'; // eslint-disable-line no-process-env
|
|
@@ -2094,6 +2614,12 @@ const util = {
|
|
|
2094
2614
|
*/
|
|
2095
2615
|
selectUint8: function(cond, a, b) {
|
|
2096
2616
|
return (a & (256 - cond)) | (b & (255 + cond));
|
|
2617
|
+
},
|
|
2618
|
+
/**
|
|
2619
|
+
* @param {module:enums.symmetric} cipherAlgo
|
|
2620
|
+
*/
|
|
2621
|
+
isAES: function(cipherAlgo) {
|
|
2622
|
+
return cipherAlgo === enums.symmetric.aes128 || cipherAlgo === enums.symmetric.aes192 || cipherAlgo === enums.symmetric.aes256;
|
|
2097
2623
|
}
|
|
2098
2624
|
};
|
|
2099
2625
|
|
|
@@ -2208,517 +2734,6 @@ function uint8ArrayToB64(bytes, url) {
|
|
|
2208
2734
|
return encoded;
|
|
2209
2735
|
}
|
|
2210
2736
|
|
|
2211
|
-
/**
|
|
2212
|
-
* @module enums
|
|
2213
|
-
*/
|
|
2214
|
-
|
|
2215
|
-
const byValue = Symbol('byValue');
|
|
2216
|
-
|
|
2217
|
-
var enums = {
|
|
2218
|
-
|
|
2219
|
-
/** Maps curve names under various standards to one
|
|
2220
|
-
* @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
|
|
2221
|
-
* @enum {String}
|
|
2222
|
-
* @readonly
|
|
2223
|
-
*/
|
|
2224
|
-
curve: {
|
|
2225
|
-
/** NIST P-256 Curve */
|
|
2226
|
-
'p256': 'p256',
|
|
2227
|
-
'P-256': 'p256',
|
|
2228
|
-
'secp256r1': 'p256',
|
|
2229
|
-
'prime256v1': 'p256',
|
|
2230
|
-
'1.2.840.10045.3.1.7': 'p256',
|
|
2231
|
-
'2a8648ce3d030107': 'p256',
|
|
2232
|
-
'2A8648CE3D030107': 'p256',
|
|
2233
|
-
|
|
2234
|
-
/** NIST P-384 Curve */
|
|
2235
|
-
'p384': 'p384',
|
|
2236
|
-
'P-384': 'p384',
|
|
2237
|
-
'secp384r1': 'p384',
|
|
2238
|
-
'1.3.132.0.34': 'p384',
|
|
2239
|
-
'2b81040022': 'p384',
|
|
2240
|
-
'2B81040022': 'p384',
|
|
2241
|
-
|
|
2242
|
-
/** NIST P-521 Curve */
|
|
2243
|
-
'p521': 'p521',
|
|
2244
|
-
'P-521': 'p521',
|
|
2245
|
-
'secp521r1': 'p521',
|
|
2246
|
-
'1.3.132.0.35': 'p521',
|
|
2247
|
-
'2b81040023': 'p521',
|
|
2248
|
-
'2B81040023': 'p521',
|
|
2249
|
-
|
|
2250
|
-
/** SECG SECP256k1 Curve */
|
|
2251
|
-
'secp256k1': 'secp256k1',
|
|
2252
|
-
'1.3.132.0.10': 'secp256k1',
|
|
2253
|
-
'2b8104000a': 'secp256k1',
|
|
2254
|
-
'2B8104000A': 'secp256k1',
|
|
2255
|
-
|
|
2256
|
-
/** Ed25519 */
|
|
2257
|
-
'ED25519': 'ed25519',
|
|
2258
|
-
'ed25519': 'ed25519',
|
|
2259
|
-
'Ed25519': 'ed25519',
|
|
2260
|
-
'1.3.6.1.4.1.11591.15.1': 'ed25519',
|
|
2261
|
-
'2b06010401da470f01': 'ed25519',
|
|
2262
|
-
'2B06010401DA470F01': 'ed25519',
|
|
2263
|
-
|
|
2264
|
-
/** Curve25519 */
|
|
2265
|
-
'X25519': 'curve25519',
|
|
2266
|
-
'cv25519': 'curve25519',
|
|
2267
|
-
'curve25519': 'curve25519',
|
|
2268
|
-
'Curve25519': 'curve25519',
|
|
2269
|
-
'1.3.6.1.4.1.3029.1.5.1': 'curve25519',
|
|
2270
|
-
'2b060104019755010501': 'curve25519',
|
|
2271
|
-
'2B060104019755010501': 'curve25519',
|
|
2272
|
-
|
|
2273
|
-
/** BrainpoolP256r1 Curve */
|
|
2274
|
-
'brainpoolP256r1': 'brainpoolP256r1',
|
|
2275
|
-
'1.3.36.3.3.2.8.1.1.7': 'brainpoolP256r1',
|
|
2276
|
-
'2b2403030208010107': 'brainpoolP256r1',
|
|
2277
|
-
'2B2403030208010107': 'brainpoolP256r1',
|
|
2278
|
-
|
|
2279
|
-
/** BrainpoolP384r1 Curve */
|
|
2280
|
-
'brainpoolP384r1': 'brainpoolP384r1',
|
|
2281
|
-
'1.3.36.3.3.2.8.1.1.11': 'brainpoolP384r1',
|
|
2282
|
-
'2b240303020801010b': 'brainpoolP384r1',
|
|
2283
|
-
'2B240303020801010B': 'brainpoolP384r1',
|
|
2284
|
-
|
|
2285
|
-
/** BrainpoolP512r1 Curve */
|
|
2286
|
-
'brainpoolP512r1': 'brainpoolP512r1',
|
|
2287
|
-
'1.3.36.3.3.2.8.1.1.13': 'brainpoolP512r1',
|
|
2288
|
-
'2b240303020801010d': 'brainpoolP512r1',
|
|
2289
|
-
'2B240303020801010D': 'brainpoolP512r1'
|
|
2290
|
-
},
|
|
2291
|
-
|
|
2292
|
-
/** KDF parameters flags
|
|
2293
|
-
* Non-standard extensions (for now) to allow email forwarding
|
|
2294
|
-
* @enum {Integer}
|
|
2295
|
-
* @readonly
|
|
2296
|
-
*/
|
|
2297
|
-
kdfFlags: {
|
|
2298
|
-
/** Specify fingerprint to use instead of the recipient's */
|
|
2299
|
-
replace_fingerprint: 0x01,
|
|
2300
|
-
/** Specify custom parameters to use in the KDF digest computation */
|
|
2301
|
-
replace_kdf_params: 0x02
|
|
2302
|
-
},
|
|
2303
|
-
|
|
2304
|
-
/** A string to key specifier type
|
|
2305
|
-
* @enum {Integer}
|
|
2306
|
-
* @readonly
|
|
2307
|
-
*/
|
|
2308
|
-
s2k: {
|
|
2309
|
-
simple: 0,
|
|
2310
|
-
salted: 1,
|
|
2311
|
-
iterated: 3,
|
|
2312
|
-
argon2: 4,
|
|
2313
|
-
gnu: 101
|
|
2314
|
-
},
|
|
2315
|
-
|
|
2316
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.1|RFC4880bis-04, section 9.1}
|
|
2317
|
-
* @enum {Integer}
|
|
2318
|
-
* @readonly
|
|
2319
|
-
*/
|
|
2320
|
-
publicKey: {
|
|
2321
|
-
/** RSA (Encrypt or Sign) [HAC] */
|
|
2322
|
-
rsaEncryptSign: 1,
|
|
2323
|
-
/** RSA (Encrypt only) [HAC] */
|
|
2324
|
-
rsaEncrypt: 2,
|
|
2325
|
-
/** RSA (Sign only) [HAC] */
|
|
2326
|
-
rsaSign: 3,
|
|
2327
|
-
/** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
|
|
2328
|
-
elgamal: 16,
|
|
2329
|
-
/** DSA (Sign only) [FIPS186] [HAC] */
|
|
2330
|
-
dsa: 17,
|
|
2331
|
-
/** ECDH (Encrypt only) [RFC6637] */
|
|
2332
|
-
ecdh: 18,
|
|
2333
|
-
/** ECDSA (Sign only) [RFC6637] */
|
|
2334
|
-
ecdsa: 19,
|
|
2335
|
-
/** EdDSA (Sign only)
|
|
2336
|
-
* [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
|
|
2337
|
-
eddsa: 22,
|
|
2338
|
-
/** Reserved for AEDH */
|
|
2339
|
-
aedh: 23,
|
|
2340
|
-
/** Reserved for AEDSA */
|
|
2341
|
-
aedsa: 24,
|
|
2342
|
-
/** Symmetric authenticated encryption algorithms */
|
|
2343
|
-
aead: 100,
|
|
2344
|
-
/** Authentication using CMAC */
|
|
2345
|
-
hmac: 101
|
|
2346
|
-
},
|
|
2347
|
-
|
|
2348
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
|
|
2349
|
-
* @enum {Integer}
|
|
2350
|
-
* @readonly
|
|
2351
|
-
*/
|
|
2352
|
-
symmetric: {
|
|
2353
|
-
plaintext: 0,
|
|
2354
|
-
/** Not implemented! */
|
|
2355
|
-
idea: 1,
|
|
2356
|
-
tripledes: 2,
|
|
2357
|
-
cast5: 3,
|
|
2358
|
-
blowfish: 4,
|
|
2359
|
-
aes128: 7,
|
|
2360
|
-
aes192: 8,
|
|
2361
|
-
aes256: 9,
|
|
2362
|
-
twofish: 10
|
|
2363
|
-
},
|
|
2364
|
-
|
|
2365
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
|
|
2366
|
-
* @enum {Integer}
|
|
2367
|
-
* @readonly
|
|
2368
|
-
*/
|
|
2369
|
-
compression: {
|
|
2370
|
-
uncompressed: 0,
|
|
2371
|
-
/** RFC1951 */
|
|
2372
|
-
zip: 1,
|
|
2373
|
-
/** RFC1950 */
|
|
2374
|
-
zlib: 2,
|
|
2375
|
-
bzip2: 3
|
|
2376
|
-
},
|
|
2377
|
-
|
|
2378
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
|
|
2379
|
-
* @enum {Integer}
|
|
2380
|
-
* @readonly
|
|
2381
|
-
*/
|
|
2382
|
-
hash: {
|
|
2383
|
-
md5: 1,
|
|
2384
|
-
sha1: 2,
|
|
2385
|
-
ripemd: 3,
|
|
2386
|
-
sha256: 8,
|
|
2387
|
-
sha384: 9,
|
|
2388
|
-
sha512: 10,
|
|
2389
|
-
sha224: 11
|
|
2390
|
-
},
|
|
2391
|
-
|
|
2392
|
-
/** A list of hash names as accepted by webCrypto functions.
|
|
2393
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
|
|
2394
|
-
* @enum {String}
|
|
2395
|
-
*/
|
|
2396
|
-
webHash: {
|
|
2397
|
-
'SHA-1': 2,
|
|
2398
|
-
'SHA-256': 8,
|
|
2399
|
-
'SHA-384': 9,
|
|
2400
|
-
'SHA-512': 10
|
|
2401
|
-
},
|
|
2402
|
-
|
|
2403
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
|
|
2404
|
-
* @enum {Integer}
|
|
2405
|
-
* @readonly
|
|
2406
|
-
*/
|
|
2407
|
-
aead: {
|
|
2408
|
-
eax: 1,
|
|
2409
|
-
ocb: 2,
|
|
2410
|
-
experimentalGCM: 100 // Private algorithm
|
|
2411
|
-
},
|
|
2412
|
-
|
|
2413
|
-
/** A list of packet types and numeric tags associated with them.
|
|
2414
|
-
* @enum {Integer}
|
|
2415
|
-
* @readonly
|
|
2416
|
-
*/
|
|
2417
|
-
packet: {
|
|
2418
|
-
publicKeyEncryptedSessionKey: 1,
|
|
2419
|
-
signature: 2,
|
|
2420
|
-
symEncryptedSessionKey: 3,
|
|
2421
|
-
onePassSignature: 4,
|
|
2422
|
-
secretKey: 5,
|
|
2423
|
-
publicKey: 6,
|
|
2424
|
-
secretSubkey: 7,
|
|
2425
|
-
compressedData: 8,
|
|
2426
|
-
symmetricallyEncryptedData: 9,
|
|
2427
|
-
marker: 10,
|
|
2428
|
-
literalData: 11,
|
|
2429
|
-
trust: 12,
|
|
2430
|
-
userID: 13,
|
|
2431
|
-
publicSubkey: 14,
|
|
2432
|
-
userAttribute: 17,
|
|
2433
|
-
symEncryptedIntegrityProtectedData: 18,
|
|
2434
|
-
modificationDetectionCode: 19,
|
|
2435
|
-
aeadEncryptedData: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
|
|
2436
|
-
},
|
|
2437
|
-
|
|
2438
|
-
/** Data types in the literal packet
|
|
2439
|
-
* @enum {Integer}
|
|
2440
|
-
* @readonly
|
|
2441
|
-
*/
|
|
2442
|
-
literal: {
|
|
2443
|
-
/** Binary data 'b' */
|
|
2444
|
-
binary: 'b'.charCodeAt(),
|
|
2445
|
-
/** Text data 't' */
|
|
2446
|
-
text: 't'.charCodeAt(),
|
|
2447
|
-
/** Utf8 data 'u' */
|
|
2448
|
-
utf8: 'u'.charCodeAt(),
|
|
2449
|
-
/** MIME message body part 'm' */
|
|
2450
|
-
mime: 'm'.charCodeAt()
|
|
2451
|
-
},
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
/** One pass signature packet type
|
|
2455
|
-
* @enum {Integer}
|
|
2456
|
-
* @readonly
|
|
2457
|
-
*/
|
|
2458
|
-
signature: {
|
|
2459
|
-
/** 0x00: Signature of a binary document. */
|
|
2460
|
-
binary: 0,
|
|
2461
|
-
/** 0x01: Signature of a canonical text document.
|
|
2462
|
-
*
|
|
2463
|
-
* Canonicalyzing the document by converting line endings. */
|
|
2464
|
-
text: 1,
|
|
2465
|
-
/** 0x02: Standalone signature.
|
|
2466
|
-
*
|
|
2467
|
-
* This signature is a signature of only its own subpacket contents.
|
|
2468
|
-
* It is calculated identically to a signature over a zero-lengh
|
|
2469
|
-
* binary document. Note that it doesn't make sense to have a V3
|
|
2470
|
-
* standalone signature. */
|
|
2471
|
-
standalone: 2,
|
|
2472
|
-
/** 0x10: Generic certification of a User ID and Public-Key packet.
|
|
2473
|
-
*
|
|
2474
|
-
* The issuer of this certification does not make any particular
|
|
2475
|
-
* assertion as to how well the certifier has checked that the owner
|
|
2476
|
-
* of the key is in fact the person described by the User ID. */
|
|
2477
|
-
certGeneric: 16,
|
|
2478
|
-
/** 0x11: Persona certification of a User ID and Public-Key packet.
|
|
2479
|
-
*
|
|
2480
|
-
* The issuer of this certification has not done any verification of
|
|
2481
|
-
* the claim that the owner of this key is the User ID specified. */
|
|
2482
|
-
certPersona: 17,
|
|
2483
|
-
/** 0x12: Casual certification of a User ID and Public-Key packet.
|
|
2484
|
-
*
|
|
2485
|
-
* The issuer of this certification has done some casual
|
|
2486
|
-
* verification of the claim of identity. */
|
|
2487
|
-
certCasual: 18,
|
|
2488
|
-
/** 0x13: Positive certification of a User ID and Public-Key packet.
|
|
2489
|
-
*
|
|
2490
|
-
* The issuer of this certification has done substantial
|
|
2491
|
-
* verification of the claim of identity.
|
|
2492
|
-
*
|
|
2493
|
-
* Most OpenPGP implementations make their "key signatures" as 0x10
|
|
2494
|
-
* certifications. Some implementations can issue 0x11-0x13
|
|
2495
|
-
* certifications, but few differentiate between the types. */
|
|
2496
|
-
certPositive: 19,
|
|
2497
|
-
/** 0x30: Certification revocation signature
|
|
2498
|
-
*
|
|
2499
|
-
* This signature revokes an earlier User ID certification signature
|
|
2500
|
-
* (signature class 0x10 through 0x13) or direct-key signature
|
|
2501
|
-
* (0x1F). It should be issued by the same key that issued the
|
|
2502
|
-
* revoked signature or an authorized revocation key. The signature
|
|
2503
|
-
* is computed over the same data as the certificate that it
|
|
2504
|
-
* revokes, and should have a later creation date than that
|
|
2505
|
-
* certificate. */
|
|
2506
|
-
certRevocation: 48,
|
|
2507
|
-
/** 0x18: Subkey Binding Signature
|
|
2508
|
-
*
|
|
2509
|
-
* This signature is a statement by the top-level signing key that
|
|
2510
|
-
* indicates that it owns the subkey. This signature is calculated
|
|
2511
|
-
* directly on the primary key and subkey, and not on any User ID or
|
|
2512
|
-
* other packets. A signature that binds a signing subkey MUST have
|
|
2513
|
-
* an Embedded Signature subpacket in this binding signature that
|
|
2514
|
-
* contains a 0x19 signature made by the signing subkey on the
|
|
2515
|
-
* primary key and subkey. */
|
|
2516
|
-
subkeyBinding: 24,
|
|
2517
|
-
/** 0x19: Primary Key Binding Signature
|
|
2518
|
-
*
|
|
2519
|
-
* This signature is a statement by a signing subkey, indicating
|
|
2520
|
-
* that it is owned by the primary key and subkey. This signature
|
|
2521
|
-
* is calculated the same way as a 0x18 signature: directly on the
|
|
2522
|
-
* primary key and subkey, and not on any User ID or other packets.
|
|
2523
|
-
*
|
|
2524
|
-
* When a signature is made over a key, the hash data starts with the
|
|
2525
|
-
* octet 0x99, followed by a two-octet length of the key, and then body
|
|
2526
|
-
* of the key packet. (Note that this is an old-style packet header for
|
|
2527
|
-
* a key packet with two-octet length.) A subkey binding signature
|
|
2528
|
-
* (type 0x18) or primary key binding signature (type 0x19) then hashes
|
|
2529
|
-
* the subkey using the same format as the main key (also using 0x99 as
|
|
2530
|
-
* the first octet). */
|
|
2531
|
-
keyBinding: 25,
|
|
2532
|
-
/** 0x1F: Signature directly on a key
|
|
2533
|
-
*
|
|
2534
|
-
* This signature is calculated directly on a key. It binds the
|
|
2535
|
-
* information in the Signature subpackets to the key, and is
|
|
2536
|
-
* appropriate to be used for subpackets that provide information
|
|
2537
|
-
* about the key, such as the Revocation Key subpacket. It is also
|
|
2538
|
-
* appropriate for statements that non-self certifiers want to make
|
|
2539
|
-
* about the key itself, rather than the binding between a key and a
|
|
2540
|
-
* name. */
|
|
2541
|
-
key: 31,
|
|
2542
|
-
/** 0x20: Key revocation signature
|
|
2543
|
-
*
|
|
2544
|
-
* The signature is calculated directly on the key being revoked. A
|
|
2545
|
-
* revoked key is not to be used. Only revocation signatures by the
|
|
2546
|
-
* key being revoked, or by an authorized revocation key, should be
|
|
2547
|
-
* considered valid revocation signatures.a */
|
|
2548
|
-
keyRevocation: 32,
|
|
2549
|
-
/** 0x28: Subkey revocation signature
|
|
2550
|
-
*
|
|
2551
|
-
* The signature is calculated directly on the subkey being revoked.
|
|
2552
|
-
* A revoked subkey is not to be used. Only revocation signatures
|
|
2553
|
-
* by the top-level signature key that is bound to this subkey, or
|
|
2554
|
-
* by an authorized revocation key, should be considered valid
|
|
2555
|
-
* revocation signatures.
|
|
2556
|
-
*
|
|
2557
|
-
* Key revocation signatures (types 0x20 and 0x28)
|
|
2558
|
-
* hash only the key being revoked. */
|
|
2559
|
-
subkeyRevocation: 40,
|
|
2560
|
-
/** 0x40: Timestamp signature.
|
|
2561
|
-
* This signature is only meaningful for the timestamp contained in
|
|
2562
|
-
* it. */
|
|
2563
|
-
timestamp: 64,
|
|
2564
|
-
/** 0x50: Third-Party Confirmation signature.
|
|
2565
|
-
*
|
|
2566
|
-
* This signature is a signature over some other OpenPGP Signature
|
|
2567
|
-
* packet(s). It is analogous to a notary seal on the signed data.
|
|
2568
|
-
* A third-party signature SHOULD include Signature Target
|
|
2569
|
-
* subpacket(s) to give easy identification. Note that we really do
|
|
2570
|
-
* mean SHOULD. There are plausible uses for this (such as a blind
|
|
2571
|
-
* party that only sees the signature, not the key or source
|
|
2572
|
-
* document) that cannot include a target subpacket. */
|
|
2573
|
-
thirdParty: 80
|
|
2574
|
-
},
|
|
2575
|
-
|
|
2576
|
-
/** Signature subpacket type
|
|
2577
|
-
* @enum {Integer}
|
|
2578
|
-
* @readonly
|
|
2579
|
-
*/
|
|
2580
|
-
signatureSubpacket: {
|
|
2581
|
-
signatureCreationTime: 2,
|
|
2582
|
-
signatureExpirationTime: 3,
|
|
2583
|
-
exportableCertification: 4,
|
|
2584
|
-
trustSignature: 5,
|
|
2585
|
-
regularExpression: 6,
|
|
2586
|
-
revocable: 7,
|
|
2587
|
-
keyExpirationTime: 9,
|
|
2588
|
-
placeholderBackwardsCompatibility: 10,
|
|
2589
|
-
preferredSymmetricAlgorithms: 11,
|
|
2590
|
-
revocationKey: 12,
|
|
2591
|
-
issuer: 16,
|
|
2592
|
-
notationData: 20,
|
|
2593
|
-
preferredHashAlgorithms: 21,
|
|
2594
|
-
preferredCompressionAlgorithms: 22,
|
|
2595
|
-
keyServerPreferences: 23,
|
|
2596
|
-
preferredKeyServer: 24,
|
|
2597
|
-
primaryUserID: 25,
|
|
2598
|
-
policyURI: 26,
|
|
2599
|
-
keyFlags: 27,
|
|
2600
|
-
signersUserID: 28,
|
|
2601
|
-
reasonForRevocation: 29,
|
|
2602
|
-
features: 30,
|
|
2603
|
-
signatureTarget: 31,
|
|
2604
|
-
embeddedSignature: 32,
|
|
2605
|
-
issuerFingerprint: 33,
|
|
2606
|
-
preferredAEADAlgorithms: 34
|
|
2607
|
-
},
|
|
2608
|
-
|
|
2609
|
-
/** Key flags
|
|
2610
|
-
* @enum {Integer}
|
|
2611
|
-
* @readonly
|
|
2612
|
-
*/
|
|
2613
|
-
keyFlags: {
|
|
2614
|
-
/** 0x01 - This key may be used to certify other keys. */
|
|
2615
|
-
certifyKeys: 1,
|
|
2616
|
-
/** 0x02 - This key may be used to sign data. */
|
|
2617
|
-
signData: 2,
|
|
2618
|
-
/** 0x04 - This key may be used to encrypt communications. */
|
|
2619
|
-
encryptCommunication: 4,
|
|
2620
|
-
/** 0x08 - This key may be used to encrypt storage. */
|
|
2621
|
-
encryptStorage: 8,
|
|
2622
|
-
/** 0x10 - The private component of this key may have been split
|
|
2623
|
-
* by a secret-sharing mechanism. */
|
|
2624
|
-
splitPrivateKey: 16,
|
|
2625
|
-
/** 0x20 - This key may be used for authentication. */
|
|
2626
|
-
authentication: 32,
|
|
2627
|
-
/** This key may be used for forwarded communications */
|
|
2628
|
-
forwardedCommunication: 64,
|
|
2629
|
-
/** 0x80 - The private component of this key may be in the
|
|
2630
|
-
* possession of more than one person. */
|
|
2631
|
-
sharedPrivateKey: 128
|
|
2632
|
-
},
|
|
2633
|
-
|
|
2634
|
-
/** Armor type
|
|
2635
|
-
* @enum {Integer}
|
|
2636
|
-
* @readonly
|
|
2637
|
-
*/
|
|
2638
|
-
armor: {
|
|
2639
|
-
multipartSection: 0,
|
|
2640
|
-
multipartLast: 1,
|
|
2641
|
-
signed: 2,
|
|
2642
|
-
message: 3,
|
|
2643
|
-
publicKey: 4,
|
|
2644
|
-
privateKey: 5,
|
|
2645
|
-
signature: 6
|
|
2646
|
-
},
|
|
2647
|
-
|
|
2648
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
|
|
2649
|
-
* @enum {Integer}
|
|
2650
|
-
* @readonly
|
|
2651
|
-
*/
|
|
2652
|
-
reasonForRevocation: {
|
|
2653
|
-
/** No reason specified (key revocations or cert revocations) */
|
|
2654
|
-
noReason: 0,
|
|
2655
|
-
/** Key is superseded (key revocations) */
|
|
2656
|
-
keySuperseded: 1,
|
|
2657
|
-
/** Key material has been compromised (key revocations) */
|
|
2658
|
-
keyCompromised: 2,
|
|
2659
|
-
/** Key is retired and no longer used (key revocations) */
|
|
2660
|
-
keyRetired: 3,
|
|
2661
|
-
/** User ID information is no longer valid (cert revocations) */
|
|
2662
|
-
userIDInvalid: 32
|
|
2663
|
-
},
|
|
2664
|
-
|
|
2665
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
|
|
2666
|
-
* @enum {Integer}
|
|
2667
|
-
* @readonly
|
|
2668
|
-
*/
|
|
2669
|
-
features: {
|
|
2670
|
-
/** 0x01 - Modification Detection (packets 18 and 19) */
|
|
2671
|
-
modificationDetection: 1,
|
|
2672
|
-
/** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
|
|
2673
|
-
* Symmetric-Key Encrypted Session Key Packets (packet 3) */
|
|
2674
|
-
aead: 2,
|
|
2675
|
-
/** 0x04 - Version 5 Public-Key Packet format and corresponding new
|
|
2676
|
-
* fingerprint format */
|
|
2677
|
-
v5Keys: 4
|
|
2678
|
-
},
|
|
2679
|
-
|
|
2680
|
-
/**
|
|
2681
|
-
* Asserts validity of given value and converts from string/integer to integer.
|
|
2682
|
-
* @param {Object} type target enum type
|
|
2683
|
-
* @param {String|Integer} e value to check and/or convert
|
|
2684
|
-
* @returns {Integer} enum value if it exists
|
|
2685
|
-
* @throws {Error} if the value is invalid
|
|
2686
|
-
*/
|
|
2687
|
-
write: function(type, e) {
|
|
2688
|
-
if (typeof e === 'number') {
|
|
2689
|
-
e = this.read(type, e);
|
|
2690
|
-
}
|
|
2691
|
-
|
|
2692
|
-
if (type[e] !== undefined) {
|
|
2693
|
-
return type[e];
|
|
2694
|
-
}
|
|
2695
|
-
|
|
2696
|
-
throw new Error('Invalid enum value.');
|
|
2697
|
-
},
|
|
2698
|
-
|
|
2699
|
-
/**
|
|
2700
|
-
* Converts enum integer value to the corresponding string, if it exists.
|
|
2701
|
-
* @param {Object} type target enum type
|
|
2702
|
-
* @param {Integer} e value to convert
|
|
2703
|
-
* @returns {String} name of enum value if it exists
|
|
2704
|
-
* @throws {Error} if the value is invalid
|
|
2705
|
-
*/
|
|
2706
|
-
read: function(type, e) {
|
|
2707
|
-
if (!type[byValue]) {
|
|
2708
|
-
type[byValue] = [];
|
|
2709
|
-
Object.entries(type).forEach(([key, value]) => {
|
|
2710
|
-
type[byValue][value] = key;
|
|
2711
|
-
});
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
if (type[byValue][e] !== undefined) {
|
|
2715
|
-
return type[byValue][e];
|
|
2716
|
-
}
|
|
2717
|
-
|
|
2718
|
-
throw new Error('Invalid enum value.');
|
|
2719
|
-
}
|
|
2720
|
-
};
|
|
2721
|
-
|
|
2722
2737
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
2723
2738
|
|
|
2724
2739
|
var config = {
|
|
@@ -2935,7 +2950,7 @@ var config = {
|
|
|
2935
2950
|
* @memberof module:config
|
|
2936
2951
|
* @property {String} versionString A version string to be included in armored messages
|
|
2937
2952
|
*/
|
|
2938
|
-
versionString: 'OpenPGP.js 5.
|
|
2953
|
+
versionString: 'OpenPGP.js 5.10.2',
|
|
2939
2954
|
/**
|
|
2940
2955
|
* @memberof module:config
|
|
2941
2956
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -3427,6 +3442,7 @@ class KeyID {
|
|
|
3427
3442
|
*/
|
|
3428
3443
|
read(bytes) {
|
|
3429
3444
|
this.bytes = util.uint8ArrayToString(bytes.subarray(0, 8));
|
|
3445
|
+
return this.bytes.length;
|
|
3430
3446
|
}
|
|
3431
3447
|
|
|
3432
3448
|
/**
|
|
@@ -9983,7 +9999,7 @@ async function encrypt(algo, key, plaintext, iv, config) {
|
|
|
9983
9999
|
if (util.getNodeCrypto() && nodeAlgos[algoName]) { // Node crypto library.
|
|
9984
10000
|
return nodeEncrypt(algo, key, plaintext, iv);
|
|
9985
10001
|
}
|
|
9986
|
-
if (
|
|
10002
|
+
if (util.isAES(algo)) {
|
|
9987
10003
|
return aesEncrypt(algo, key, plaintext, iv, config);
|
|
9988
10004
|
}
|
|
9989
10005
|
|
|
@@ -10026,7 +10042,7 @@ async function decrypt(algo, key, ciphertext, iv) {
|
|
|
10026
10042
|
if (util.getNodeCrypto() && nodeAlgos[algoName]) { // Node crypto library.
|
|
10027
10043
|
return nodeDecrypt(algo, key, ciphertext, iv);
|
|
10028
10044
|
}
|
|
10029
|
-
if (
|
|
10045
|
+
if (util.isAES(algo)) {
|
|
10030
10046
|
return aesDecrypt(algo, key, ciphertext, iv);
|
|
10031
10047
|
}
|
|
10032
10048
|
|
|
@@ -10045,7 +10061,7 @@ async function decrypt(algo, key, ciphertext, iv) {
|
|
|
10045
10061
|
let j = 0;
|
|
10046
10062
|
while (chunk ? ct.length >= block_size : ct.length) {
|
|
10047
10063
|
const decblock = cipherfn.encrypt(blockp);
|
|
10048
|
-
blockp = ct;
|
|
10064
|
+
blockp = ct.subarray(0, block_size);
|
|
10049
10065
|
for (i = 0; i < block_size; i++) {
|
|
10050
10066
|
plaintext[j++] = blockp[i] ^ decblock[i];
|
|
10051
10067
|
}
|
|
@@ -13612,7 +13628,7 @@ const curves = {
|
|
|
13612
13628
|
}
|
|
13613
13629
|
};
|
|
13614
13630
|
|
|
13615
|
-
class
|
|
13631
|
+
class CurveWithOID {
|
|
13616
13632
|
constructor(oidOrName, params) {
|
|
13617
13633
|
try {
|
|
13618
13634
|
if (util.isArray(oidOrName) ||
|
|
@@ -13689,7 +13705,7 @@ class Curve {
|
|
|
13689
13705
|
async function generate$1(curve) {
|
|
13690
13706
|
const BigInteger = await util.getBigInteger();
|
|
13691
13707
|
|
|
13692
|
-
curve = new
|
|
13708
|
+
curve = new CurveWithOID(curve);
|
|
13693
13709
|
const keyPair = await curve.genKeyPair();
|
|
13694
13710
|
const Q = new BigInteger(keyPair.publicKey).toUint8Array();
|
|
13695
13711
|
const secret = new BigInteger(keyPair.privateKey).toUint8Array('be', curve.payloadSize);
|
|
@@ -13878,7 +13894,7 @@ const nodeCrypto$8 = util.getNodeCrypto();
|
|
|
13878
13894
|
* @async
|
|
13879
13895
|
*/
|
|
13880
13896
|
async function sign$1(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
13881
|
-
const curve = new
|
|
13897
|
+
const curve = new CurveWithOID(oid);
|
|
13882
13898
|
if (message && !util.isStream(message)) {
|
|
13883
13899
|
const keyPair = { publicKey, privateKey };
|
|
13884
13900
|
switch (curve.type) {
|
|
@@ -13923,7 +13939,7 @@ async function sign$1(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
13923
13939
|
* @async
|
|
13924
13940
|
*/
|
|
13925
13941
|
async function verify$1(oid, hashAlgo, signature, message, publicKey, hashed) {
|
|
13926
|
-
const curve = new
|
|
13942
|
+
const curve = new CurveWithOID(oid);
|
|
13927
13943
|
if (message && !util.isStream(message)) {
|
|
13928
13944
|
switch (curve.type) {
|
|
13929
13945
|
case 'web':
|
|
@@ -13957,7 +13973,7 @@ async function verify$1(oid, hashAlgo, signature, message, publicKey, hashed) {
|
|
|
13957
13973
|
* @async
|
|
13958
13974
|
*/
|
|
13959
13975
|
async function validateParams$2(oid, Q, d) {
|
|
13960
|
-
const curve = new
|
|
13976
|
+
const curve = new CurveWithOID(oid);
|
|
13961
13977
|
// Reject curves x25519 and ed25519
|
|
13962
13978
|
if (curve.keyType !== enums.publicKey.ecdsa) {
|
|
13963
13979
|
return false;
|
|
@@ -14160,7 +14176,7 @@ var ecdsa = /*#__PURE__*/Object.freeze({
|
|
|
14160
14176
|
naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
|
|
14161
14177
|
|
|
14162
14178
|
/**
|
|
14163
|
-
* Sign a message using the provided key
|
|
14179
|
+
* Sign a message using the provided legacy EdDSA key
|
|
14164
14180
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14165
14181
|
* @param {module:enums.hash} hashAlgo - Hash algorithm used to sign (must be sha256 or stronger)
|
|
14166
14182
|
* @param {Uint8Array} message - Message to sign
|
|
@@ -14188,7 +14204,7 @@ async function sign$2(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
14188
14204
|
}
|
|
14189
14205
|
|
|
14190
14206
|
/**
|
|
14191
|
-
* Verifies if a signature is valid for a message
|
|
14207
|
+
* Verifies if a legacy EdDSA signature is valid for a message
|
|
14192
14208
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14193
14209
|
* @param {module:enums.hash} hashAlgo - Hash algorithm used in the signature
|
|
14194
14210
|
* @param {{r: Uint8Array,
|
|
@@ -14204,7 +14220,7 @@ async function verify$2(oid, hashAlgo, { r, s }, m, publicKey, hashed) {
|
|
|
14204
14220
|
return naclFastLight.sign.detached.verify(hashed, signature, publicKey.subarray(1));
|
|
14205
14221
|
}
|
|
14206
14222
|
/**
|
|
14207
|
-
* Validate EdDSA parameters
|
|
14223
|
+
* Validate legacy EdDSA parameters
|
|
14208
14224
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14209
14225
|
* @param {Uint8Array} Q - EdDSA public point
|
|
14210
14226
|
* @param {Uint8Array} k - EdDSA secret seed
|
|
@@ -14224,9 +14240,10 @@ async function validateParams$3(oid, Q, k) {
|
|
|
14224
14240
|
const { publicKey } = naclFastLight.sign.keyPair.fromSeed(k);
|
|
14225
14241
|
const dG = new Uint8Array([0x40, ...publicKey]); // Add public key prefix
|
|
14226
14242
|
return util.equalsUint8Array(Q, dG);
|
|
14243
|
+
|
|
14227
14244
|
}
|
|
14228
14245
|
|
|
14229
|
-
var
|
|
14246
|
+
var eddsa_legacy = /*#__PURE__*/Object.freeze({
|
|
14230
14247
|
__proto__: null,
|
|
14231
14248
|
sign: sign$2,
|
|
14232
14249
|
verify: verify$2,
|
|
@@ -14235,6 +14252,113 @@ var eddsa = /*#__PURE__*/Object.freeze({
|
|
|
14235
14252
|
|
|
14236
14253
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14237
14254
|
|
|
14255
|
+
naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
|
|
14256
|
+
|
|
14257
|
+
/**
|
|
14258
|
+
* Generate (non-legacy) EdDSA key
|
|
14259
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14260
|
+
* @returns {Promise<{ A: Uint8Array, seed: Uint8Array }>}
|
|
14261
|
+
*/
|
|
14262
|
+
async function generate$2(algo) {
|
|
14263
|
+
switch (algo) {
|
|
14264
|
+
case enums.publicKey.ed25519: {
|
|
14265
|
+
const seed = getRandomBytes(32);
|
|
14266
|
+
const { publicKey: A } = naclFastLight.sign.keyPair.fromSeed(seed);
|
|
14267
|
+
return { A, seed };
|
|
14268
|
+
}
|
|
14269
|
+
default:
|
|
14270
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14271
|
+
}
|
|
14272
|
+
}
|
|
14273
|
+
|
|
14274
|
+
/**
|
|
14275
|
+
* Sign a message using the provided key
|
|
14276
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14277
|
+
* @param {module:enums.hash} hashAlgo - Hash algorithm used to sign (must be sha256 or stronger)
|
|
14278
|
+
* @param {Uint8Array} message - Message to sign
|
|
14279
|
+
* @param {Uint8Array} publicKey - Public key
|
|
14280
|
+
* @param {Uint8Array} privateKey - Private key used to sign the message
|
|
14281
|
+
* @param {Uint8Array} hashed - The hashed message
|
|
14282
|
+
* @returns {Promise<{
|
|
14283
|
+
* RS: Uint8Array
|
|
14284
|
+
* }>} Signature of the message
|
|
14285
|
+
* @async
|
|
14286
|
+
*/
|
|
14287
|
+
async function sign$3(algo, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
14288
|
+
if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(enums.hash.sha256)) {
|
|
14289
|
+
// see https://tools.ietf.org/id/draft-ietf-openpgp-rfc4880bis-10.html#section-15-7.2
|
|
14290
|
+
throw new Error('Hash algorithm too weak: sha256 or stronger is required for EdDSA.');
|
|
14291
|
+
}
|
|
14292
|
+
switch (algo) {
|
|
14293
|
+
case enums.publicKey.ed25519: {
|
|
14294
|
+
const secretKey = util.concatUint8Array([privateKey, publicKey]);
|
|
14295
|
+
const signature = naclFastLight.sign.detached(hashed, secretKey);
|
|
14296
|
+
return { RS: signature };
|
|
14297
|
+
}
|
|
14298
|
+
case enums.publicKey.ed448:
|
|
14299
|
+
default:
|
|
14300
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14301
|
+
}
|
|
14302
|
+
|
|
14303
|
+
}
|
|
14304
|
+
|
|
14305
|
+
/**
|
|
14306
|
+
* Verifies if a signature is valid for a message
|
|
14307
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14308
|
+
* @param {module:enums.hash} hashAlgo - Hash algorithm used in the signature
|
|
14309
|
+
* @param {{ RS: Uint8Array }} signature Signature to verify the message
|
|
14310
|
+
* @param {Uint8Array} m - Message to verify
|
|
14311
|
+
* @param {Uint8Array} publicKey - Public key used to verify the message
|
|
14312
|
+
* @param {Uint8Array} hashed - The hashed message
|
|
14313
|
+
* @returns {Boolean}
|
|
14314
|
+
* @async
|
|
14315
|
+
*/
|
|
14316
|
+
async function verify$3(algo, hashAlgo, { RS }, m, publicKey, hashed) {
|
|
14317
|
+
switch (algo) {
|
|
14318
|
+
case enums.publicKey.ed25519: {
|
|
14319
|
+
return naclFastLight.sign.detached.verify(hashed, RS, publicKey);
|
|
14320
|
+
}
|
|
14321
|
+
case enums.publicKey.ed448:
|
|
14322
|
+
default:
|
|
14323
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14324
|
+
}
|
|
14325
|
+
}
|
|
14326
|
+
/**
|
|
14327
|
+
* Validate (non-legacy) EdDSA parameters
|
|
14328
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14329
|
+
* @param {Uint8Array} A - EdDSA public point
|
|
14330
|
+
* @param {Uint8Array} seed - EdDSA secret seed
|
|
14331
|
+
* @param {Uint8Array} oid - (legacy only) EdDSA OID
|
|
14332
|
+
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14333
|
+
* @async
|
|
14334
|
+
*/
|
|
14335
|
+
async function validateParams$4(algo, A, seed) {
|
|
14336
|
+
switch (algo) {
|
|
14337
|
+
case enums.publicKey.ed25519: {
|
|
14338
|
+
/**
|
|
14339
|
+
* Derive public point A' from private key
|
|
14340
|
+
* and expect A == A'
|
|
14341
|
+
*/
|
|
14342
|
+
const { publicKey } = naclFastLight.sign.keyPair.fromSeed(seed);
|
|
14343
|
+
return util.equalsUint8Array(A, publicKey);
|
|
14344
|
+
}
|
|
14345
|
+
|
|
14346
|
+
case enums.publicKey.ed448: // unsupported
|
|
14347
|
+
default:
|
|
14348
|
+
return false;
|
|
14349
|
+
}
|
|
14350
|
+
}
|
|
14351
|
+
|
|
14352
|
+
var eddsa = /*#__PURE__*/Object.freeze({
|
|
14353
|
+
__proto__: null,
|
|
14354
|
+
generate: generate$2,
|
|
14355
|
+
sign: sign$3,
|
|
14356
|
+
verify: verify$3,
|
|
14357
|
+
validateParams: validateParams$4
|
|
14358
|
+
});
|
|
14359
|
+
|
|
14360
|
+
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14361
|
+
|
|
14238
14362
|
/**
|
|
14239
14363
|
* AES key wrap
|
|
14240
14364
|
* @function
|
|
@@ -14422,7 +14546,7 @@ const nodeCrypto$9 = util.getNodeCrypto();
|
|
|
14422
14546
|
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14423
14547
|
* @async
|
|
14424
14548
|
*/
|
|
14425
|
-
async function validateParams$
|
|
14549
|
+
async function validateParams$5(oid, Q, d) {
|
|
14426
14550
|
return validateStandardParams(enums.publicKey.ecdh, oid, Q, d);
|
|
14427
14551
|
}
|
|
14428
14552
|
|
|
@@ -14464,7 +14588,7 @@ async function kdf(hashAlgo, X, length, param, stripLeading = false, stripTraili
|
|
|
14464
14588
|
/**
|
|
14465
14589
|
* Generate ECDHE ephemeral key and secret from public key
|
|
14466
14590
|
*
|
|
14467
|
-
* @param {
|
|
14591
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14468
14592
|
* @param {Uint8Array} Q - Recipient public key
|
|
14469
14593
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14470
14594
|
* @async
|
|
@@ -14507,7 +14631,7 @@ async function genPublicEphemeralKey(curve, Q) {
|
|
|
14507
14631
|
async function encrypt$3(oid, kdfParams, data, Q, fingerprint) {
|
|
14508
14632
|
const m = encode$1(data);
|
|
14509
14633
|
|
|
14510
|
-
const curve = new
|
|
14634
|
+
const curve = new CurveWithOID(oid);
|
|
14511
14635
|
const { publicKey, sharedKey } = await genPublicEphemeralKey(curve, Q);
|
|
14512
14636
|
const param = buildEcdhParam(enums.publicKey.ecdh, oid, kdfParams, fingerprint);
|
|
14513
14637
|
const { keySize } = getCipher(kdfParams.cipher);
|
|
@@ -14519,7 +14643,7 @@ async function encrypt$3(oid, kdfParams, data, Q, fingerprint) {
|
|
|
14519
14643
|
/**
|
|
14520
14644
|
* Generate ECDHE secret from private key and public part of ephemeral key
|
|
14521
14645
|
*
|
|
14522
|
-
* @param {
|
|
14646
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14523
14647
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14524
14648
|
* @param {Uint8Array} Q - Recipient public key
|
|
14525
14649
|
* @param {Uint8Array} d - Recipient private key
|
|
@@ -14567,7 +14691,7 @@ async function genPrivateEphemeralKey(curve, V, Q, d) {
|
|
|
14567
14691
|
* @async
|
|
14568
14692
|
*/
|
|
14569
14693
|
async function decrypt$3(oid, kdfParams, V, C, Q, d, fingerprint) {
|
|
14570
|
-
const curve = new
|
|
14694
|
+
const curve = new CurveWithOID(oid);
|
|
14571
14695
|
const { sharedKey } = await genPrivateEphemeralKey(curve, V, Q, d);
|
|
14572
14696
|
const param = buildEcdhParam(enums.publicKey.ecdh, oid, kdfParams, fingerprint);
|
|
14573
14697
|
const { keySize } = getCipher(kdfParams.cipher);
|
|
@@ -14587,7 +14711,7 @@ async function decrypt$3(oid, kdfParams, V, C, Q, d, fingerprint) {
|
|
|
14587
14711
|
/**
|
|
14588
14712
|
* Generate ECDHE secret from private key and public part of ephemeral key using webCrypto
|
|
14589
14713
|
*
|
|
14590
|
-
* @param {
|
|
14714
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14591
14715
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14592
14716
|
* @param {Uint8Array} Q - Recipient public key
|
|
14593
14717
|
* @param {Uint8Array} d - Recipient private key
|
|
@@ -14640,7 +14764,7 @@ async function webPrivateEphemeralKey(curve, V, Q, d) {
|
|
|
14640
14764
|
/**
|
|
14641
14765
|
* Generate ECDHE ephemeral key and secret from public key using webCrypto
|
|
14642
14766
|
*
|
|
14643
|
-
* @param {
|
|
14767
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14644
14768
|
* @param {Uint8Array} Q - Recipient public key
|
|
14645
14769
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14646
14770
|
* @async
|
|
@@ -14688,7 +14812,7 @@ async function webPublicEphemeralKey(curve, Q) {
|
|
|
14688
14812
|
/**
|
|
14689
14813
|
* Generate ECDHE secret from private key and public part of ephemeral key using indutny/elliptic
|
|
14690
14814
|
*
|
|
14691
|
-
* @param {
|
|
14815
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14692
14816
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14693
14817
|
* @param {Uint8Array} d - Recipient private key
|
|
14694
14818
|
* @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
@@ -14708,7 +14832,7 @@ async function ellipticPrivateEphemeralKey(curve, V, d) {
|
|
|
14708
14832
|
/**
|
|
14709
14833
|
* Generate ECDHE ephemeral key and secret from public key using indutny/elliptic
|
|
14710
14834
|
*
|
|
14711
|
-
* @param {
|
|
14835
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14712
14836
|
* @param {Uint8Array} Q - Recipient public key
|
|
14713
14837
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14714
14838
|
* @async
|
|
@@ -14728,7 +14852,7 @@ async function ellipticPublicEphemeralKey(curve, Q) {
|
|
|
14728
14852
|
/**
|
|
14729
14853
|
* Generate ECDHE secret from private key and public part of ephemeral key using nodeCrypto
|
|
14730
14854
|
*
|
|
14731
|
-
* @param {
|
|
14855
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14732
14856
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14733
14857
|
* @param {Uint8Array} d - Recipient private key
|
|
14734
14858
|
* @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
@@ -14745,7 +14869,7 @@ async function nodePrivateEphemeralKey(curve, V, d) {
|
|
|
14745
14869
|
/**
|
|
14746
14870
|
* Generate ECDHE ephemeral key and secret from public key using nodeCrypto
|
|
14747
14871
|
*
|
|
14748
|
-
* @param {
|
|
14872
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14749
14873
|
* @param {Uint8Array} Q - Recipient public key
|
|
14750
14874
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14751
14875
|
* @async
|
|
@@ -14760,18 +14884,204 @@ async function nodePublicEphemeralKey(curve, Q) {
|
|
|
14760
14884
|
|
|
14761
14885
|
var ecdh = /*#__PURE__*/Object.freeze({
|
|
14762
14886
|
__proto__: null,
|
|
14763
|
-
validateParams: validateParams$
|
|
14887
|
+
validateParams: validateParams$5,
|
|
14764
14888
|
encrypt: encrypt$3,
|
|
14765
14889
|
decrypt: decrypt$3
|
|
14766
14890
|
});
|
|
14767
14891
|
|
|
14892
|
+
/**
|
|
14893
|
+
* @fileoverview This module implements HKDF using either the WebCrypto API or Node.js' crypto API.
|
|
14894
|
+
* @module crypto/hkdf
|
|
14895
|
+
* @private
|
|
14896
|
+
*/
|
|
14897
|
+
|
|
14898
|
+
const webCrypto$9 = util.getWebCrypto();
|
|
14899
|
+
const nodeCrypto$a = util.getNodeCrypto();
|
|
14900
|
+
const nodeSubtleCrypto = nodeCrypto$a && nodeCrypto$a.webcrypto && nodeCrypto$a.webcrypto.subtle;
|
|
14901
|
+
|
|
14902
|
+
async function HKDF(hashAlgo, inputKey, salt, info, outLen) {
|
|
14903
|
+
const hash = enums.read(enums.webHash, hashAlgo);
|
|
14904
|
+
if (!hash) throw new Error('Hash algo not supported with HKDF');
|
|
14905
|
+
|
|
14906
|
+
if (webCrypto$9 || nodeSubtleCrypto) {
|
|
14907
|
+
const crypto = webCrypto$9 || nodeSubtleCrypto;
|
|
14908
|
+
const importedKey = await crypto.importKey('raw', inputKey, 'HKDF', false, ['deriveBits']);
|
|
14909
|
+
const bits = await crypto.deriveBits({ name: 'HKDF', hash, salt, info }, importedKey, outLen * 8);
|
|
14910
|
+
return new Uint8Array(bits);
|
|
14911
|
+
}
|
|
14912
|
+
|
|
14913
|
+
if (nodeCrypto$a) {
|
|
14914
|
+
const hashAlgoName = enums.read(enums.hash, hashAlgo);
|
|
14915
|
+
// Node-only HKDF implementation based on https://www.rfc-editor.org/rfc/rfc5869
|
|
14916
|
+
|
|
14917
|
+
const computeHMAC = (hmacKey, hmacMessage) => nodeCrypto$a.createHmac(hashAlgoName, hmacKey).update(hmacMessage).digest();
|
|
14918
|
+
// Step 1: Extract
|
|
14919
|
+
// PRK = HMAC-Hash(salt, IKM)
|
|
14920
|
+
const pseudoRandomKey = computeHMAC(salt, inputKey);
|
|
14921
|
+
|
|
14922
|
+
const hashLen = pseudoRandomKey.length;
|
|
14923
|
+
|
|
14924
|
+
// Step 2: Expand
|
|
14925
|
+
// HKDF-Expand(PRK, info, L) -> OKM
|
|
14926
|
+
const n = Math.ceil(outLen / hashLen);
|
|
14927
|
+
const outputKeyingMaterial = new Uint8Array(n * hashLen);
|
|
14928
|
+
|
|
14929
|
+
// HMAC input buffer updated at each iteration
|
|
14930
|
+
const roundInput = new Uint8Array(hashLen + info.length + 1);
|
|
14931
|
+
// T_i and last byte are updated at each iteration, but `info` remains constant
|
|
14932
|
+
roundInput.set(info, hashLen);
|
|
14933
|
+
|
|
14934
|
+
for (let i = 0; i < n; i++) {
|
|
14935
|
+
// T(0) = empty string (zero length)
|
|
14936
|
+
// T(i) = HMAC-Hash(PRK, T(i-1) | info | i)
|
|
14937
|
+
roundInput[roundInput.length - 1] = i + 1;
|
|
14938
|
+
// t = T(i+1)
|
|
14939
|
+
const t = computeHMAC(pseudoRandomKey, i > 0 ? roundInput : roundInput.subarray(hashLen));
|
|
14940
|
+
roundInput.set(t, 0);
|
|
14941
|
+
|
|
14942
|
+
outputKeyingMaterial.set(t, i * hashLen);
|
|
14943
|
+
}
|
|
14944
|
+
|
|
14945
|
+
return outputKeyingMaterial.subarray(0, outLen);
|
|
14946
|
+
}
|
|
14947
|
+
|
|
14948
|
+
throw new Error('No HKDF implementation available');
|
|
14949
|
+
}
|
|
14950
|
+
|
|
14951
|
+
/**
|
|
14952
|
+
* @fileoverview Key encryption and decryption for RFC 6637 ECDH
|
|
14953
|
+
* @module crypto/public_key/elliptic/ecdh
|
|
14954
|
+
* @private
|
|
14955
|
+
*/
|
|
14956
|
+
|
|
14957
|
+
const HKDF_INFO = {
|
|
14958
|
+
x25519: util.encodeUTF8('OpenPGP X25519')
|
|
14959
|
+
};
|
|
14960
|
+
|
|
14961
|
+
/**
|
|
14962
|
+
* Generate ECDH key for Montgomery curves
|
|
14963
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14964
|
+
* @returns {Promise<{ A: Uint8Array, k: Uint8Array }>}
|
|
14965
|
+
*/
|
|
14966
|
+
async function generate$3(algo) {
|
|
14967
|
+
switch (algo) {
|
|
14968
|
+
case enums.publicKey.x25519: {
|
|
14969
|
+
// k stays in little-endian, unlike legacy ECDH over curve25519
|
|
14970
|
+
const k = getRandomBytes(32);
|
|
14971
|
+
k[0] &= 248;
|
|
14972
|
+
k[31] = (k[31] & 127) | 64;
|
|
14973
|
+
const { publicKey: A } = naclFastLight.box.keyPair.fromSecretKey(k);
|
|
14974
|
+
return { A, k };
|
|
14975
|
+
}
|
|
14976
|
+
default:
|
|
14977
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
14978
|
+
}
|
|
14979
|
+
}
|
|
14980
|
+
|
|
14981
|
+
/**
|
|
14982
|
+
* Validate ECDH parameters
|
|
14983
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14984
|
+
* @param {Uint8Array} A - ECDH public point
|
|
14985
|
+
* @param {Uint8Array} k - ECDH secret scalar
|
|
14986
|
+
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14987
|
+
* @async
|
|
14988
|
+
*/
|
|
14989
|
+
async function validateParams$6(algo, A, k) {
|
|
14990
|
+
switch (algo) {
|
|
14991
|
+
case enums.publicKey.x25519: {
|
|
14992
|
+
/**
|
|
14993
|
+
* Derive public point A' from private key
|
|
14994
|
+
* and expect A == A'
|
|
14995
|
+
*/
|
|
14996
|
+
const { publicKey } = naclFastLight.box.keyPair.fromSecretKey(k);
|
|
14997
|
+
return util.equalsUint8Array(A, publicKey);
|
|
14998
|
+
}
|
|
14999
|
+
|
|
15000
|
+
default:
|
|
15001
|
+
return false;
|
|
15002
|
+
}
|
|
15003
|
+
}
|
|
15004
|
+
|
|
15005
|
+
/**
|
|
15006
|
+
* Wrap and encrypt a session key
|
|
15007
|
+
*
|
|
15008
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
15009
|
+
* @param {Uint8Array} data - session key data to be encrypted
|
|
15010
|
+
* @param {Uint8Array} recipientA - Recipient public key (K_B)
|
|
15011
|
+
* @returns {Promise<{
|
|
15012
|
+
* ephemeralPublicKey: Uint8Array,
|
|
15013
|
+
* wrappedKey: Uint8Array
|
|
15014
|
+
* }>} ephemeral public key (K_A) and encrypted key
|
|
15015
|
+
* @async
|
|
15016
|
+
*/
|
|
15017
|
+
async function encrypt$4(algo, data, recipientA) {
|
|
15018
|
+
switch (algo) {
|
|
15019
|
+
case enums.publicKey.x25519: {
|
|
15020
|
+
const ephemeralSecretKey = getRandomBytes(32);
|
|
15021
|
+
const sharedSecret = naclFastLight.scalarMult(ephemeralSecretKey, recipientA);
|
|
15022
|
+
const { publicKey: ephemeralPublicKey } = naclFastLight.box.keyPair.fromSecretKey(ephemeralSecretKey);
|
|
15023
|
+
const hkdfInput = util.concatUint8Array([
|
|
15024
|
+
ephemeralPublicKey,
|
|
15025
|
+
recipientA,
|
|
15026
|
+
sharedSecret
|
|
15027
|
+
]);
|
|
15028
|
+
const { keySize } = getCipher(enums.symmetric.aes128);
|
|
15029
|
+
const encryptionKey = await HKDF(enums.hash.sha256, hkdfInput, new Uint8Array(), HKDF_INFO.x25519, keySize);
|
|
15030
|
+
const wrappedKey = wrap(encryptionKey, data);
|
|
15031
|
+
return { ephemeralPublicKey, wrappedKey };
|
|
15032
|
+
}
|
|
15033
|
+
|
|
15034
|
+
default:
|
|
15035
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
15036
|
+
}
|
|
15037
|
+
}
|
|
15038
|
+
|
|
15039
|
+
/**
|
|
15040
|
+
* Decrypt and unwrap the session key
|
|
15041
|
+
*
|
|
15042
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
15043
|
+
* @param {Uint8Array} ephemeralPublicKey - (K_A)
|
|
15044
|
+
* @param {Uint8Array} wrappedKey,
|
|
15045
|
+
* @param {Uint8Array} A - Recipient public key (K_b), needed for KDF
|
|
15046
|
+
* @param {Uint8Array} k - Recipient secret key (b)
|
|
15047
|
+
* @returns {Promise<Uint8Array>} decrypted session key data
|
|
15048
|
+
* @async
|
|
15049
|
+
*/
|
|
15050
|
+
async function decrypt$4(algo, ephemeralPublicKey, wrappedKey, A, k) {
|
|
15051
|
+
switch (algo) {
|
|
15052
|
+
case enums.publicKey.x25519: {
|
|
15053
|
+
const sharedSecret = naclFastLight.scalarMult(k, ephemeralPublicKey);
|
|
15054
|
+
const hkdfInput = util.concatUint8Array([
|
|
15055
|
+
ephemeralPublicKey,
|
|
15056
|
+
A,
|
|
15057
|
+
sharedSecret
|
|
15058
|
+
]);
|
|
15059
|
+
const { keySize } = getCipher(enums.symmetric.aes128);
|
|
15060
|
+
const encryptionKey = await HKDF(enums.hash.sha256, hkdfInput, new Uint8Array(), HKDF_INFO.x25519, keySize);
|
|
15061
|
+
return unwrap(encryptionKey, wrappedKey);
|
|
15062
|
+
}
|
|
15063
|
+
default:
|
|
15064
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
15065
|
+
}
|
|
15066
|
+
}
|
|
15067
|
+
|
|
15068
|
+
var ecdh_x = /*#__PURE__*/Object.freeze({
|
|
15069
|
+
__proto__: null,
|
|
15070
|
+
generate: generate$3,
|
|
15071
|
+
validateParams: validateParams$6,
|
|
15072
|
+
encrypt: encrypt$4,
|
|
15073
|
+
decrypt: decrypt$4
|
|
15074
|
+
});
|
|
15075
|
+
|
|
14768
15076
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14769
15077
|
|
|
14770
15078
|
var elliptic = /*#__PURE__*/Object.freeze({
|
|
14771
15079
|
__proto__: null,
|
|
14772
|
-
|
|
15080
|
+
CurveWithOID: CurveWithOID,
|
|
14773
15081
|
ecdh: ecdh,
|
|
15082
|
+
ecdhX: ecdh_x,
|
|
14774
15083
|
ecdsa: ecdsa,
|
|
15084
|
+
eddsaLegacy: eddsa_legacy,
|
|
14775
15085
|
eddsa: eddsa,
|
|
14776
15086
|
generate: generate$1,
|
|
14777
15087
|
getPreferredHashAlgo: getPreferredHashAlgo
|
|
@@ -14796,7 +15106,7 @@ var elliptic = /*#__PURE__*/Object.freeze({
|
|
|
14796
15106
|
* @returns {Promise<{ r: Uint8Array, s: Uint8Array }>}
|
|
14797
15107
|
* @async
|
|
14798
15108
|
*/
|
|
14799
|
-
async function sign$
|
|
15109
|
+
async function sign$4(hashAlgo, hashed, g, p, q, x) {
|
|
14800
15110
|
const BigInteger = await util.getBigInteger();
|
|
14801
15111
|
const one = new BigInteger(1);
|
|
14802
15112
|
p = new BigInteger(p);
|
|
@@ -14855,7 +15165,7 @@ async function sign$3(hashAlgo, hashed, g, p, q, x) {
|
|
|
14855
15165
|
* @returns {boolean}
|
|
14856
15166
|
* @async
|
|
14857
15167
|
*/
|
|
14858
|
-
async function verify$
|
|
15168
|
+
async function verify$4(hashAlgo, r, s, hashed, g, p, q, y) {
|
|
14859
15169
|
const BigInteger = await util.getBigInteger();
|
|
14860
15170
|
const zero = new BigInteger(0);
|
|
14861
15171
|
r = new BigInteger(r);
|
|
@@ -14898,7 +15208,7 @@ async function verify$3(hashAlgo, r, s, hashed, g, p, q, y) {
|
|
|
14898
15208
|
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14899
15209
|
* @async
|
|
14900
15210
|
*/
|
|
14901
|
-
async function validateParams$
|
|
15211
|
+
async function validateParams$7(p, q, g, y, x) {
|
|
14902
15212
|
const BigInteger = await util.getBigInteger();
|
|
14903
15213
|
p = new BigInteger(p);
|
|
14904
15214
|
q = new BigInteger(q);
|
|
@@ -14953,9 +15263,9 @@ async function validateParams$5(p, q, g, y, x) {
|
|
|
14953
15263
|
|
|
14954
15264
|
var dsa = /*#__PURE__*/Object.freeze({
|
|
14955
15265
|
__proto__: null,
|
|
14956
|
-
sign: sign$
|
|
14957
|
-
verify: verify$
|
|
14958
|
-
validateParams: validateParams$
|
|
15266
|
+
sign: sign$4,
|
|
15267
|
+
verify: verify$4,
|
|
15268
|
+
validateParams: validateParams$7
|
|
14959
15269
|
});
|
|
14960
15270
|
|
|
14961
15271
|
/**
|
|
@@ -15091,10 +15401,11 @@ function parseSignatureParams(algo, signature) {
|
|
|
15091
15401
|
const s = util.readMPI(signature.subarray(read));
|
|
15092
15402
|
return { r, s };
|
|
15093
15403
|
}
|
|
15094
|
-
// Algorithm-Specific Fields for EdDSA signatures:
|
|
15404
|
+
// Algorithm-Specific Fields for legacy EdDSA signatures:
|
|
15095
15405
|
// - MPI of an EC point r.
|
|
15096
15406
|
// - EdDSA value s, in MPI, in the little endian representation
|
|
15097
|
-
case enums.publicKey.eddsa:
|
|
15407
|
+
case enums.publicKey.eddsa:
|
|
15408
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15098
15409
|
// When parsing little-endian MPI data, we always need to left-pad it, as done with big-endian values:
|
|
15099
15410
|
// https://www.ietf.org/archive/id/draft-ietf-openpgp-rfc4880bis-10.html#section-3.2-9
|
|
15100
15411
|
let r = util.readMPI(signature.subarray(read)); read += r.length + 2;
|
|
@@ -15103,7 +15414,12 @@ function parseSignatureParams(algo, signature) {
|
|
|
15103
15414
|
s = util.leftPad(s, 32);
|
|
15104
15415
|
return { r, s };
|
|
15105
15416
|
}
|
|
15106
|
-
|
|
15417
|
+
// Algorithm-Specific Fields for Ed25519 signatures:
|
|
15418
|
+
// - 64 octets of the native signature
|
|
15419
|
+
case enums.publicKey.ed25519: {
|
|
15420
|
+
const RS = signature.subarray(read, read + 64); read += RS.length;
|
|
15421
|
+
return { RS };
|
|
15422
|
+
}
|
|
15107
15423
|
case enums.publicKey.hmac: {
|
|
15108
15424
|
const mac = new ShortByteString(); mac.read(signature.subarray(read));
|
|
15109
15425
|
return { mac };
|
|
@@ -15128,7 +15444,7 @@ function parseSignatureParams(algo, signature) {
|
|
|
15128
15444
|
* @returns {Promise<Boolean>} True if signature is valid.
|
|
15129
15445
|
* @async
|
|
15130
15446
|
*/
|
|
15131
|
-
async function verify$
|
|
15447
|
+
async function verify$5(algo, hashAlgo, signature, publicParams, privateParams, data, hashed) {
|
|
15132
15448
|
switch (algo) {
|
|
15133
15449
|
case enums.publicKey.rsaEncryptSign:
|
|
15134
15450
|
case enums.publicKey.rsaEncrypt:
|
|
@@ -15144,16 +15460,21 @@ async function verify$4(algo, hashAlgo, signature, publicParams, privateParams,
|
|
|
15144
15460
|
}
|
|
15145
15461
|
case enums.publicKey.ecdsa: {
|
|
15146
15462
|
const { oid, Q } = publicParams;
|
|
15147
|
-
const curveSize = new publicKey.elliptic.
|
|
15463
|
+
const curveSize = new publicKey.elliptic.CurveWithOID(oid).payloadSize;
|
|
15148
15464
|
// padding needed for webcrypto
|
|
15149
15465
|
const r = util.leftPad(signature.r, curveSize);
|
|
15150
15466
|
const s = util.leftPad(signature.s, curveSize);
|
|
15151
15467
|
return publicKey.elliptic.ecdsa.verify(oid, hashAlgo, { r, s }, data, Q, hashed);
|
|
15152
15468
|
}
|
|
15153
|
-
case enums.publicKey.eddsa:
|
|
15469
|
+
case enums.publicKey.eddsa:
|
|
15470
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15154
15471
|
const { oid, Q } = publicParams;
|
|
15155
15472
|
// signature already padded on parsing
|
|
15156
|
-
return publicKey.elliptic.
|
|
15473
|
+
return publicKey.elliptic.eddsaLegacy.verify(oid, hashAlgo, signature, data, Q, hashed);
|
|
15474
|
+
}
|
|
15475
|
+
case enums.publicKey.ed25519: {
|
|
15476
|
+
const { A } = publicParams;
|
|
15477
|
+
return publicKey.elliptic.eddsa.verify(algo, hashAlgo, signature, data, A, hashed);
|
|
15157
15478
|
}
|
|
15158
15479
|
case enums.publicKey.hmac: {
|
|
15159
15480
|
if (!privateParams) {
|
|
@@ -15183,7 +15504,7 @@ async function verify$4(algo, hashAlgo, signature, publicParams, privateParams,
|
|
|
15183
15504
|
* @returns {Promise<Object>} Signature Object containing named signature parameters.
|
|
15184
15505
|
* @async
|
|
15185
15506
|
*/
|
|
15186
|
-
async function sign$
|
|
15507
|
+
async function sign$5(algo, hashAlgo, publicKeyParams, privateKeyParams, data, hashed) {
|
|
15187
15508
|
if (!publicKeyParams || !privateKeyParams) {
|
|
15188
15509
|
throw new Error('Missing key parameters');
|
|
15189
15510
|
}
|
|
@@ -15209,10 +15530,16 @@ async function sign$4(algo, hashAlgo, publicKeyParams, privateKeyParams, data, h
|
|
|
15209
15530
|
const { d } = privateKeyParams;
|
|
15210
15531
|
return publicKey.elliptic.ecdsa.sign(oid, hashAlgo, data, Q, d, hashed);
|
|
15211
15532
|
}
|
|
15212
|
-
case enums.publicKey.eddsa:
|
|
15533
|
+
case enums.publicKey.eddsa:
|
|
15534
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15213
15535
|
const { oid, Q } = publicKeyParams;
|
|
15214
15536
|
const { seed } = privateKeyParams;
|
|
15215
|
-
return publicKey.elliptic.
|
|
15537
|
+
return publicKey.elliptic.eddsaLegacy.sign(oid, hashAlgo, data, Q, seed, hashed);
|
|
15538
|
+
}
|
|
15539
|
+
case enums.publicKey.ed25519: {
|
|
15540
|
+
const { A } = publicKeyParams;
|
|
15541
|
+
const { seed } = privateKeyParams;
|
|
15542
|
+
return publicKey.elliptic.eddsa.sign(algo, hashAlgo, data, A, seed, hashed);
|
|
15216
15543
|
}
|
|
15217
15544
|
case enums.publicKey.hmac: {
|
|
15218
15545
|
const { cipher: algo } = publicKeyParams;
|
|
@@ -15228,34 +15555,31 @@ async function sign$4(algo, hashAlgo, publicKeyParams, privateKeyParams, data, h
|
|
|
15228
15555
|
var signature = /*#__PURE__*/Object.freeze({
|
|
15229
15556
|
__proto__: null,
|
|
15230
15557
|
parseSignatureParams: parseSignatureParams,
|
|
15231
|
-
verify: verify$
|
|
15232
|
-
sign: sign$
|
|
15558
|
+
verify: verify$5,
|
|
15559
|
+
sign: sign$5
|
|
15233
15560
|
});
|
|
15234
15561
|
|
|
15235
15562
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
15236
15563
|
|
|
15237
15564
|
class ECDHSymmetricKey {
|
|
15238
15565
|
constructor(data) {
|
|
15239
|
-
if (
|
|
15240
|
-
data =
|
|
15241
|
-
} else if (util.isString(data)) {
|
|
15242
|
-
data = util.stringToUint8Array(data);
|
|
15243
|
-
} else {
|
|
15244
|
-
data = new Uint8Array(data);
|
|
15566
|
+
if (data) {
|
|
15567
|
+
this.data = data;
|
|
15245
15568
|
}
|
|
15246
|
-
this.data = data;
|
|
15247
15569
|
}
|
|
15248
15570
|
|
|
15249
15571
|
/**
|
|
15250
|
-
* Read an ECDHSymmetricKey from an Uint8Array
|
|
15251
|
-
*
|
|
15572
|
+
* Read an ECDHSymmetricKey from an Uint8Array:
|
|
15573
|
+
* - 1 octect for the length `l`
|
|
15574
|
+
* - `l` octects of encoded session key data
|
|
15575
|
+
* @param {Uint8Array} bytes
|
|
15252
15576
|
* @returns {Number} Number of read bytes.
|
|
15253
15577
|
*/
|
|
15254
|
-
read(
|
|
15255
|
-
if (
|
|
15256
|
-
const length =
|
|
15257
|
-
if (
|
|
15258
|
-
this.data =
|
|
15578
|
+
read(bytes) {
|
|
15579
|
+
if (bytes.length >= 1) {
|
|
15580
|
+
const length = bytes[0];
|
|
15581
|
+
if (bytes.length >= 1 + length) {
|
|
15582
|
+
this.data = bytes.subarray(1, 1 + length);
|
|
15259
15583
|
return 1 + this.data.length;
|
|
15260
15584
|
}
|
|
15261
15585
|
}
|
|
@@ -15264,7 +15588,7 @@ class ECDHSymmetricKey {
|
|
|
15264
15588
|
|
|
15265
15589
|
/**
|
|
15266
15590
|
* Write an ECDHSymmetricKey as an Uint8Array
|
|
15267
|
-
* @returns {Uint8Array}
|
|
15591
|
+
* @returns {Uint8Array} Serialised data
|
|
15268
15592
|
*/
|
|
15269
15593
|
write() {
|
|
15270
15594
|
return util.concatUint8Array([new Uint8Array([this.data.length]), this.data]);
|
|
@@ -15304,6 +15628,9 @@ class KDFParams {
|
|
|
15304
15628
|
* @returns {Number} Number of read bytes.
|
|
15305
15629
|
*/
|
|
15306
15630
|
read(input) {
|
|
15631
|
+
if (input.length < 4 || (input[1] !== 1 && input[1] !== VERSION_FORWARDING)) {
|
|
15632
|
+
throw new UnsupportedError('Cannot read KDFParams');
|
|
15633
|
+
}
|
|
15307
15634
|
const totalBytes = input[0];
|
|
15308
15635
|
this.version = input[1];
|
|
15309
15636
|
this.hash = input[2];
|
|
@@ -15391,12 +15718,57 @@ const AEADEnum = type_enum(enums.aead);
|
|
|
15391
15718
|
const SymAlgoEnum = type_enum(enums.symmetric);
|
|
15392
15719
|
const HashEnum = type_enum(enums.hash);
|
|
15393
15720
|
|
|
15721
|
+
/**
|
|
15722
|
+
* Encoded symmetric key for x25519 and x448
|
|
15723
|
+
* The payload format varies for v3 and v6 PKESK:
|
|
15724
|
+
* the former includes an algorithm byte preceeding the encrypted session key.
|
|
15725
|
+
*
|
|
15726
|
+
* @module type/x25519x448_symkey
|
|
15727
|
+
*/
|
|
15728
|
+
|
|
15729
|
+
class ECDHXSymmetricKey {
|
|
15730
|
+
static fromObject({ wrappedKey, algorithm }) {
|
|
15731
|
+
const instance = new ECDHXSymmetricKey();
|
|
15732
|
+
instance.wrappedKey = wrappedKey;
|
|
15733
|
+
instance.algorithm = algorithm;
|
|
15734
|
+
return instance;
|
|
15735
|
+
}
|
|
15736
|
+
|
|
15737
|
+
/**
|
|
15738
|
+
* - 1 octect for the length `l`
|
|
15739
|
+
* - `l` octects of encoded session key data (with optional leading algorithm byte)
|
|
15740
|
+
* @param {Uint8Array} bytes
|
|
15741
|
+
* @returns {Number} Number of read bytes.
|
|
15742
|
+
*/
|
|
15743
|
+
read(bytes) {
|
|
15744
|
+
let read = 0;
|
|
15745
|
+
let followLength = bytes[read++];
|
|
15746
|
+
this.algorithm = followLength % 2 ? bytes[read++] : null; // session key size is always even
|
|
15747
|
+
followLength -= followLength % 2;
|
|
15748
|
+
this.wrappedKey = bytes.subarray(read, read + followLength); read += followLength;
|
|
15749
|
+
}
|
|
15750
|
+
|
|
15751
|
+
/**
|
|
15752
|
+
* Write an MontgomerySymmetricKey as an Uint8Array
|
|
15753
|
+
* @returns {Uint8Array} Serialised data
|
|
15754
|
+
*/
|
|
15755
|
+
write() {
|
|
15756
|
+
return util.concatUint8Array([
|
|
15757
|
+
this.algorithm ?
|
|
15758
|
+
new Uint8Array([this.wrappedKey.length + 1, this.algorithm]) :
|
|
15759
|
+
new Uint8Array([this.wrappedKey.length]),
|
|
15760
|
+
this.wrappedKey
|
|
15761
|
+
]);
|
|
15762
|
+
}
|
|
15763
|
+
}
|
|
15764
|
+
|
|
15394
15765
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
15395
15766
|
|
|
15396
15767
|
/**
|
|
15397
15768
|
* Encrypts data using specified algorithm and public key parameters.
|
|
15398
15769
|
* See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1} for public key algorithms.
|
|
15399
|
-
* @param {module:enums.publicKey}
|
|
15770
|
+
* @param {module:enums.publicKey} keyAlgo - Public key algorithm
|
|
15771
|
+
* @param {module:enums.symmetric} symmetricAlgo - Cipher algorithm
|
|
15400
15772
|
* @param {Object} publicParams - Algorithm-specific public key parameters
|
|
15401
15773
|
* @param {Object} privateParams - Algorithm-specific private key parameters
|
|
15402
15774
|
* @param {Uint8Array} data - Data to be encrypted
|
|
@@ -15404,8 +15776,8 @@ const HashEnum = type_enum(enums.hash);
|
|
|
15404
15776
|
* @returns {Promise<Object>} Encrypted session key parameters.
|
|
15405
15777
|
* @async
|
|
15406
15778
|
*/
|
|
15407
|
-
async function publicKeyEncrypt(
|
|
15408
|
-
switch (
|
|
15779
|
+
async function publicKeyEncrypt(keyAlgo, symmetricAlgo, publicParams, privateParams, data, fingerprint) {
|
|
15780
|
+
switch (keyAlgo) {
|
|
15409
15781
|
case enums.publicKey.rsaEncrypt:
|
|
15410
15782
|
case enums.publicKey.rsaEncryptSign: {
|
|
15411
15783
|
const { n, e } = publicParams;
|
|
@@ -15422,6 +15794,17 @@ async function publicKeyEncrypt(algo, publicParams, privateParams, data, fingerp
|
|
|
15422
15794
|
oid, kdfParams, data, Q, fingerprint);
|
|
15423
15795
|
return { V, C: new ECDHSymmetricKey(C) };
|
|
15424
15796
|
}
|
|
15797
|
+
case enums.publicKey.x25519: {
|
|
15798
|
+
if (!util.isAES(symmetricAlgo)) {
|
|
15799
|
+
// see https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/276
|
|
15800
|
+
throw new Error('X25519 keys can only encrypt AES session keys');
|
|
15801
|
+
}
|
|
15802
|
+
const { A } = publicParams;
|
|
15803
|
+
const { ephemeralPublicKey, wrappedKey } = await publicKey.elliptic.ecdhX.encrypt(
|
|
15804
|
+
keyAlgo, data, A);
|
|
15805
|
+
const C = ECDHXSymmetricKey.fromObject({ algorithm: symmetricAlgo, wrappedKey });
|
|
15806
|
+
return { ephemeralPublicKey, C };
|
|
15807
|
+
}
|
|
15425
15808
|
case enums.publicKey.aead: {
|
|
15426
15809
|
if (!privateParams) {
|
|
15427
15810
|
throw new Error('Cannot encrypt with symmetric key missing private parameters');
|
|
@@ -15478,6 +15861,16 @@ async function publicKeyDecrypt(algo, publicKeyParams, privateKeyParams, session
|
|
|
15478
15861
|
return publicKey.elliptic.ecdh.decrypt(
|
|
15479
15862
|
oid, kdfParams, V, C.data, Q, d, fingerprint);
|
|
15480
15863
|
}
|
|
15864
|
+
case enums.publicKey.x25519: {
|
|
15865
|
+
const { A } = publicKeyParams;
|
|
15866
|
+
const { k } = privateKeyParams;
|
|
15867
|
+
const { ephemeralPublicKey, C } = sessionKeyParams;
|
|
15868
|
+
if (!util.isAES(C.algorithm)) {
|
|
15869
|
+
throw new Error('AES session key expected');
|
|
15870
|
+
}
|
|
15871
|
+
return publicKey.elliptic.ecdhX.decrypt(
|
|
15872
|
+
algo, ephemeralPublicKey, C.wrappedKey, A, k);
|
|
15873
|
+
}
|
|
15481
15874
|
case enums.publicKey.aead: {
|
|
15482
15875
|
const { cipher: algo } = publicKeyParams;
|
|
15483
15876
|
const algoValue = algo.getValue();
|
|
@@ -15529,7 +15922,8 @@ function parsePublicKeyParams(algo, bytes) {
|
|
|
15529
15922
|
const Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
|
15530
15923
|
return { read: read, publicParams: { oid, Q } };
|
|
15531
15924
|
}
|
|
15532
|
-
case enums.publicKey.eddsa:
|
|
15925
|
+
case enums.publicKey.eddsa:
|
|
15926
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15533
15927
|
const oid = new OID(); read += oid.read(bytes);
|
|
15534
15928
|
checkSupportedCurve(oid);
|
|
15535
15929
|
let Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
|
@@ -15543,6 +15937,11 @@ function parsePublicKeyParams(algo, bytes) {
|
|
|
15543
15937
|
const kdfParams = new KDFParams(); read += kdfParams.read(bytes.subarray(read));
|
|
15544
15938
|
return { read: read, publicParams: { oid, Q, kdfParams } };
|
|
15545
15939
|
}
|
|
15940
|
+
case enums.publicKey.ed25519:
|
|
15941
|
+
case enums.publicKey.x25519: {
|
|
15942
|
+
const A = bytes.subarray(read, read + 32); read += A.length;
|
|
15943
|
+
return { read, publicParams: { A } };
|
|
15944
|
+
}
|
|
15546
15945
|
case enums.publicKey.hmac:
|
|
15547
15946
|
case enums.publicKey.aead: {
|
|
15548
15947
|
const algo = new SymAlgoEnum(); read += algo.read(bytes);
|
|
@@ -15581,17 +15980,26 @@ function parsePrivateKeyParams(algo, bytes, publicParams) {
|
|
|
15581
15980
|
}
|
|
15582
15981
|
case enums.publicKey.ecdsa:
|
|
15583
15982
|
case enums.publicKey.ecdh: {
|
|
15584
|
-
const curve = new
|
|
15983
|
+
const curve = new CurveWithOID(publicParams.oid);
|
|
15585
15984
|
let d = util.readMPI(bytes.subarray(read)); read += d.length + 2;
|
|
15586
15985
|
d = util.leftPad(d, curve.payloadSize);
|
|
15587
15986
|
return { read, privateParams: { d } };
|
|
15588
15987
|
}
|
|
15589
|
-
case enums.publicKey.eddsa:
|
|
15590
|
-
|
|
15988
|
+
case enums.publicKey.eddsa:
|
|
15989
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15990
|
+
const curve = new CurveWithOID(publicParams.oid);
|
|
15591
15991
|
let seed = util.readMPI(bytes.subarray(read)); read += seed.length + 2;
|
|
15592
15992
|
seed = util.leftPad(seed, curve.payloadSize);
|
|
15593
15993
|
return { read, privateParams: { seed } };
|
|
15594
15994
|
}
|
|
15995
|
+
case enums.publicKey.ed25519: {
|
|
15996
|
+
const seed = bytes.subarray(read, read + 32); read += seed.length;
|
|
15997
|
+
return { read, privateParams: { seed } };
|
|
15998
|
+
}
|
|
15999
|
+
case enums.publicKey.x25519: {
|
|
16000
|
+
const k = bytes.subarray(read, read + 32); read += k.length;
|
|
16001
|
+
return { read, privateParams: { k } };
|
|
16002
|
+
}
|
|
15595
16003
|
case enums.publicKey.hmac: {
|
|
15596
16004
|
const { cipher: algo } = publicParams;
|
|
15597
16005
|
const keySize = hash.getHashByteLength(algo.getValue());
|
|
@@ -15643,6 +16051,16 @@ function parseEncSessionKeyParams(algo, bytes) {
|
|
|
15643
16051
|
const C = new ECDHSymmetricKey(); C.read(bytes.subarray(read));
|
|
15644
16052
|
return { V, C };
|
|
15645
16053
|
}
|
|
16054
|
+
// Algorithm-Specific Fields for X25519 encrypted session keys:
|
|
16055
|
+
// - 32 octets representing an ephemeral X25519 public key.
|
|
16056
|
+
// - A one-octet size of the following fields.
|
|
16057
|
+
// - The one-octet algorithm identifier, if it was passed (in the case of a v3 PKESK packet).
|
|
16058
|
+
// - The encrypted session key.
|
|
16059
|
+
case enums.publicKey.x25519: {
|
|
16060
|
+
const ephemeralPublicKey = bytes.subarray(read, read + 32); read += ephemeralPublicKey.length;
|
|
16061
|
+
const C = new ECDHXSymmetricKey(); C.read(bytes.subarray(read));
|
|
16062
|
+
return { ephemeralPublicKey, C };
|
|
16063
|
+
}
|
|
15646
16064
|
// Algorithm-Specific Fields for symmetric AEAD encryption:
|
|
15647
16065
|
// - AEAD algorithm
|
|
15648
16066
|
// - Starting initialization vector
|
|
@@ -15669,22 +16087,13 @@ function parseEncSessionKeyParams(algo, bytes) {
|
|
|
15669
16087
|
* @returns {Uint8Array} The array containing the MPIs.
|
|
15670
16088
|
*/
|
|
15671
16089
|
function serializeParams(algo, params) {
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15678
|
-
|
|
15679
|
-
});
|
|
15680
|
-
break;
|
|
15681
|
-
}
|
|
15682
|
-
default:
|
|
15683
|
-
orderedParams = Object.keys(params).map(name => {
|
|
15684
|
-
const param = params[name];
|
|
15685
|
-
return util.isUint8Array(param) ? util.uint8ArrayToMPI(param) : param.write();
|
|
15686
|
-
});
|
|
15687
|
-
}
|
|
16090
|
+
// Some algorithms do not rely on MPIs to store the binary params
|
|
16091
|
+
const algosWithNativeRepresentation = new Set([enums.publicKey.ed25519, enums.publicKey.x25519, enums.publicKey.aead, enums.publicKey.hmac]);
|
|
16092
|
+
const orderedParams = Object.keys(params).map(name => {
|
|
16093
|
+
const param = params[name];
|
|
16094
|
+
if (!util.isUint8Array(param)) return param.write();
|
|
16095
|
+
return algosWithNativeRepresentation.has(algo) ? param : util.uint8ArrayToMPI(param);
|
|
16096
|
+
});
|
|
15688
16097
|
return util.concatUint8Array(orderedParams);
|
|
15689
16098
|
}
|
|
15690
16099
|
|
|
@@ -15713,6 +16122,7 @@ function generateParams(algo, bits, oid, symmetric) {
|
|
|
15713
16122
|
publicParams: { oid: new OID(oid), Q }
|
|
15714
16123
|
}));
|
|
15715
16124
|
case enums.publicKey.eddsa:
|
|
16125
|
+
case enums.publicKey.ed25519Legacy:
|
|
15716
16126
|
return publicKey.elliptic.generate(oid).then(({ oid, Q, secret }) => ({
|
|
15717
16127
|
privateParams: { seed: secret },
|
|
15718
16128
|
publicParams: { oid: new OID(oid), Q }
|
|
@@ -15726,6 +16136,16 @@ function generateParams(algo, bits, oid, symmetric) {
|
|
|
15726
16136
|
kdfParams: new KDFParams({ hash, cipher })
|
|
15727
16137
|
}
|
|
15728
16138
|
}));
|
|
16139
|
+
case enums.publicKey.ed25519:
|
|
16140
|
+
return publicKey.elliptic.eddsa.generate(algo).then(({ A, seed }) => ({
|
|
16141
|
+
privateParams: { seed },
|
|
16142
|
+
publicParams: { A }
|
|
16143
|
+
}));
|
|
16144
|
+
case enums.publicKey.x25519:
|
|
16145
|
+
return publicKey.elliptic.ecdhX.generate(algo).then(({ A, k }) => ({
|
|
16146
|
+
privateParams: { k },
|
|
16147
|
+
publicParams: { A }
|
|
16148
|
+
}));
|
|
15729
16149
|
case enums.publicKey.hmac: {
|
|
15730
16150
|
const symAlgo = enums.write(enums.hash, symmetric);
|
|
15731
16151
|
const keyMaterial = getRandomBytes(hash.getHashByteLength(symAlgo));
|
|
@@ -15767,7 +16187,7 @@ async function createSymmetricParams(key, algo) {
|
|
|
15767
16187
|
* @returns {Promise<Boolean>} Whether the parameters are valid.
|
|
15768
16188
|
* @async
|
|
15769
16189
|
*/
|
|
15770
|
-
async function validateParams$
|
|
16190
|
+
async function validateParams$8(algo, publicParams, privateParams) {
|
|
15771
16191
|
if (!publicParams || !privateParams) {
|
|
15772
16192
|
throw new Error('Missing key parameters');
|
|
15773
16193
|
}
|
|
@@ -15796,10 +16216,21 @@ async function validateParams$6(algo, publicParams, privateParams) {
|
|
|
15796
16216
|
const { d } = privateParams;
|
|
15797
16217
|
return algoModule.validateParams(oid, Q, d);
|
|
15798
16218
|
}
|
|
15799
|
-
case enums.publicKey.eddsa:
|
|
15800
|
-
|
|
16219
|
+
case enums.publicKey.eddsa:
|
|
16220
|
+
case enums.publicKey.ed25519Legacy: {
|
|
16221
|
+
const { Q, oid } = publicParams;
|
|
15801
16222
|
const { seed } = privateParams;
|
|
15802
|
-
return publicKey.elliptic.
|
|
16223
|
+
return publicKey.elliptic.eddsaLegacy.validateParams(oid, Q, seed);
|
|
16224
|
+
}
|
|
16225
|
+
case enums.publicKey.ed25519: {
|
|
16226
|
+
const { A } = publicParams;
|
|
16227
|
+
const { seed } = privateParams;
|
|
16228
|
+
return publicKey.elliptic.eddsa.validateParams(algo, A, seed);
|
|
16229
|
+
}
|
|
16230
|
+
case enums.publicKey.x25519: {
|
|
16231
|
+
const { A } = publicParams;
|
|
16232
|
+
const { k } = privateParams;
|
|
16233
|
+
return publicKey.elliptic.ecdhX.validateParams(algo, A, k);
|
|
15803
16234
|
}
|
|
15804
16235
|
case enums.publicKey.hmac: {
|
|
15805
16236
|
const { cipher: algo, digest } = publicParams;
|
|
@@ -15878,7 +16309,7 @@ var crypto$1 = /*#__PURE__*/Object.freeze({
|
|
|
15878
16309
|
parseEncSessionKeyParams: parseEncSessionKeyParams,
|
|
15879
16310
|
serializeParams: serializeParams,
|
|
15880
16311
|
generateParams: generateParams,
|
|
15881
|
-
validateParams: validateParams$
|
|
16312
|
+
validateParams: validateParams$8,
|
|
15882
16313
|
getPrefixRandom: getPrefixRandom,
|
|
15883
16314
|
generateSessionKey: generateSessionKey,
|
|
15884
16315
|
getAEADMode: getAEADMode,
|
|
@@ -16125,15 +16556,15 @@ class GenericS2K {
|
|
|
16125
16556
|
this.type = 'gnu-dummy';
|
|
16126
16557
|
// GnuPG extension mode 1001 -- don't write secret key at all
|
|
16127
16558
|
} else {
|
|
16128
|
-
throw new
|
|
16559
|
+
throw new UnsupportedError('Unknown s2k gnu protection mode.');
|
|
16129
16560
|
}
|
|
16130
16561
|
} else {
|
|
16131
|
-
throw new
|
|
16562
|
+
throw new UnsupportedError('Unknown s2k type.');
|
|
16132
16563
|
}
|
|
16133
16564
|
break;
|
|
16134
16565
|
|
|
16135
16566
|
default:
|
|
16136
|
-
throw new
|
|
16567
|
+
throw new UnsupportedError('Unknown s2k type.'); // unreachable
|
|
16137
16568
|
}
|
|
16138
16569
|
|
|
16139
16570
|
return i;
|
|
@@ -16237,7 +16668,7 @@ function newS2KFromType(type, config$1 = config) {
|
|
|
16237
16668
|
case enums.s2k.simple:
|
|
16238
16669
|
return new GenericS2K(type, config$1);
|
|
16239
16670
|
default:
|
|
16240
|
-
throw new
|
|
16671
|
+
throw new UnsupportedError(`Unsupported S2K type ${type}`);
|
|
16241
16672
|
}
|
|
16242
16673
|
}
|
|
16243
16674
|
|
|
@@ -24991,13 +25422,17 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
24991
25422
|
* @param {Uint8Array} bytes - Payload of a tag 1 packet
|
|
24992
25423
|
*/
|
|
24993
25424
|
read(bytes) {
|
|
24994
|
-
|
|
25425
|
+
let i = 0;
|
|
25426
|
+
this.version = bytes[i++];
|
|
24995
25427
|
if (this.version !== VERSION$3) {
|
|
24996
25428
|
throw new UnsupportedError(`Version ${this.version} of the PKESK packet is unsupported.`);
|
|
24997
25429
|
}
|
|
24998
|
-
this.publicKeyID.read(bytes.subarray(
|
|
24999
|
-
this.publicKeyAlgorithm = bytes[
|
|
25000
|
-
this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(
|
|
25430
|
+
i += this.publicKeyID.read(bytes.subarray(i));
|
|
25431
|
+
this.publicKeyAlgorithm = bytes[i++];
|
|
25432
|
+
this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(i), this.version);
|
|
25433
|
+
if (this.publicKeyAlgorithm === enums.publicKey.x25519) {
|
|
25434
|
+
this.sessionKeyAlgorithm = enums.write(enums.symmetric, this.encrypted.C.algorithm);
|
|
25435
|
+
}
|
|
25001
25436
|
}
|
|
25002
25437
|
|
|
25003
25438
|
/**
|
|
@@ -25023,15 +25458,11 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
25023
25458
|
* @async
|
|
25024
25459
|
*/
|
|
25025
25460
|
async encrypt(key) {
|
|
25026
|
-
const data = util.concatUint8Array([
|
|
25027
|
-
new Uint8Array([enums.write(enums.symmetric, this.sessionKeyAlgorithm)]),
|
|
25028
|
-
this.sessionKey,
|
|
25029
|
-
util.writeChecksum(this.sessionKey)
|
|
25030
|
-
]);
|
|
25031
25461
|
const algo = enums.write(enums.publicKey, this.publicKeyAlgorithm);
|
|
25462
|
+
const encoded = encodeSessionKey(this.version, algo, this.sessionKeyAlgorithm, this.sessionKey);
|
|
25032
25463
|
const privateParams = algo === enums.publicKey.aead ? key.privateParams : null;
|
|
25033
25464
|
this.encrypted = await mod.publicKeyEncrypt(
|
|
25034
|
-
algo, key.publicParams, privateParams,
|
|
25465
|
+
algo, this.sessionKeyAlgorithm, key.publicParams, privateParams, encoded, key.getFingerprintBytes());
|
|
25035
25466
|
}
|
|
25036
25467
|
|
|
25037
25468
|
/**
|
|
@@ -25048,34 +25479,86 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
25048
25479
|
throw new Error('Decryption error');
|
|
25049
25480
|
}
|
|
25050
25481
|
|
|
25051
|
-
const randomPayload = randomSessionKey ?
|
|
25052
|
-
|
|
25053
|
-
|
|
25054
|
-
|
|
25055
|
-
]) : null;
|
|
25056
|
-
const decoded = await mod.publicKeyDecrypt(this.publicKeyAlgorithm, key.publicParams, key.privateParams, this.encrypted, key.getFingerprintBytes(), randomPayload);
|
|
25057
|
-
const symmetricAlgoByte = decoded[0];
|
|
25058
|
-
const sessionKey = decoded.subarray(1, decoded.length - 2);
|
|
25059
|
-
const checksum = decoded.subarray(decoded.length - 2);
|
|
25060
|
-
const computedChecksum = util.writeChecksum(sessionKey);
|
|
25061
|
-
const isValidChecksum = computedChecksum[0] === checksum[0] & computedChecksum[1] === checksum[1];
|
|
25062
|
-
|
|
25063
|
-
if (randomSessionKey) {
|
|
25064
|
-
// We must not leak info about the validity of the decrypted checksum or cipher algo.
|
|
25065
|
-
// 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.
|
|
25066
|
-
const isValidPayload = isValidChecksum & symmetricAlgoByte === randomSessionKey.sessionKeyAlgorithm & sessionKey.length === randomSessionKey.sessionKey.length;
|
|
25067
|
-
this.sessionKeyAlgorithm = util.selectUint8(isValidPayload, symmetricAlgoByte, randomSessionKey.sessionKeyAlgorithm);
|
|
25068
|
-
this.sessionKey = util.selectUint8Array(isValidPayload, sessionKey, randomSessionKey.sessionKey);
|
|
25482
|
+
const randomPayload = randomSessionKey ?
|
|
25483
|
+
encodeSessionKey(this.version, this.publicKeyAlgorithm, randomSessionKey.sessionKeyAlgorithm, randomSessionKey.sessionKey) :
|
|
25484
|
+
null;
|
|
25485
|
+
const decryptedData = await mod.publicKeyDecrypt(this.publicKeyAlgorithm, key.publicParams, key.privateParams, this.encrypted, key.getFingerprintBytes(), randomPayload);
|
|
25069
25486
|
|
|
25070
|
-
}
|
|
25071
|
-
|
|
25072
|
-
|
|
25073
|
-
|
|
25074
|
-
|
|
25487
|
+
const { sessionKey, sessionKeyAlgorithm } = decodeSessionKey(this.version, this.publicKeyAlgorithm, decryptedData, randomSessionKey);
|
|
25488
|
+
|
|
25489
|
+
// v3 Montgomery curves have cleartext cipher algo
|
|
25490
|
+
if (this.publicKeyAlgorithm !== enums.publicKey.x25519) {
|
|
25491
|
+
this.sessionKeyAlgorithm = sessionKeyAlgorithm;
|
|
25492
|
+
}
|
|
25493
|
+
this.sessionKey = sessionKey;
|
|
25494
|
+
}
|
|
25495
|
+
}
|
|
25496
|
+
|
|
25497
|
+
|
|
25498
|
+
function encodeSessionKey(version, keyAlgo, cipherAlgo, sessionKeyData) {
|
|
25499
|
+
switch (keyAlgo) {
|
|
25500
|
+
case enums.publicKey.rsaEncrypt:
|
|
25501
|
+
case enums.publicKey.rsaEncryptSign:
|
|
25502
|
+
case enums.publicKey.elgamal:
|
|
25503
|
+
case enums.publicKey.ecdh:
|
|
25504
|
+
case enums.publicKey.aead: {
|
|
25505
|
+
// add checksum
|
|
25506
|
+
return util.concatUint8Array([
|
|
25507
|
+
new Uint8Array([cipherAlgo]),
|
|
25508
|
+
sessionKeyData,
|
|
25509
|
+
util.writeChecksum(sessionKeyData.subarray(sessionKeyData.length % 8))
|
|
25510
|
+
]);
|
|
25511
|
+
}
|
|
25512
|
+
case enums.publicKey.x25519:
|
|
25513
|
+
return sessionKeyData;
|
|
25514
|
+
default:
|
|
25515
|
+
throw new Error('Unsupported public key algorithm');
|
|
25516
|
+
}
|
|
25517
|
+
}
|
|
25518
|
+
|
|
25519
|
+
|
|
25520
|
+
function decodeSessionKey(version, keyAlgo, decryptedData, randomSessionKey) {
|
|
25521
|
+
switch (keyAlgo) {
|
|
25522
|
+
case enums.publicKey.rsaEncrypt:
|
|
25523
|
+
case enums.publicKey.rsaEncryptSign:
|
|
25524
|
+
case enums.publicKey.elgamal:
|
|
25525
|
+
case enums.publicKey.ecdh:
|
|
25526
|
+
case enums.publicKey.aead: {
|
|
25527
|
+
// verify checksum in constant time
|
|
25528
|
+
const result = decryptedData.subarray(0, decryptedData.length - 2);
|
|
25529
|
+
const checksum = decryptedData.subarray(decryptedData.length - 2);
|
|
25530
|
+
const computedChecksum = util.writeChecksum(result.subarray(result.length % 8));
|
|
25531
|
+
const isValidChecksum = computedChecksum[0] === checksum[0] & computedChecksum[1] === checksum[1];
|
|
25532
|
+
const decryptedSessionKey = { sessionKeyAlgorithm: result[0], sessionKey: result.subarray(1) };
|
|
25533
|
+
if (randomSessionKey) {
|
|
25534
|
+
// We must not leak info about the validity of the decrypted checksum or cipher algo.
|
|
25535
|
+
// 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.
|
|
25536
|
+
const isValidPayload = isValidChecksum &
|
|
25537
|
+
decryptedSessionKey.sessionKeyAlgorithm === randomSessionKey.sessionKeyAlgorithm &
|
|
25538
|
+
decryptedSessionKey.sessionKey.length === randomSessionKey.sessionKey.length;
|
|
25539
|
+
return {
|
|
25540
|
+
sessionKey: util.selectUint8Array(isValidPayload, decryptedSessionKey.sessionKey, randomSessionKey.sessionKey),
|
|
25541
|
+
sessionKeyAlgorithm: util.selectUint8(
|
|
25542
|
+
isValidPayload,
|
|
25543
|
+
decryptedSessionKey.sessionKeyAlgorithm,
|
|
25544
|
+
randomSessionKey.sessionKeyAlgorithm
|
|
25545
|
+
)
|
|
25546
|
+
};
|
|
25075
25547
|
} else {
|
|
25076
|
-
|
|
25548
|
+
const isValidPayload = isValidChecksum && enums.read(enums.symmetric, decryptedSessionKey.sessionKeyAlgorithm);
|
|
25549
|
+
if (isValidPayload) {
|
|
25550
|
+
return decryptedSessionKey;
|
|
25551
|
+
} else {
|
|
25552
|
+
throw new Error('Decryption error');
|
|
25553
|
+
}
|
|
25077
25554
|
}
|
|
25078
25555
|
}
|
|
25556
|
+
case enums.publicKey.x25519:
|
|
25557
|
+
return {
|
|
25558
|
+
sessionKey: decryptedData
|
|
25559
|
+
};
|
|
25560
|
+
default:
|
|
25561
|
+
throw new Error('Unsupported public key algorithm');
|
|
25079
25562
|
}
|
|
25080
25563
|
}
|
|
25081
25564
|
|
|
@@ -25506,7 +25989,7 @@ class PublicKeyPacket {
|
|
|
25506
25989
|
result.bits = util.uint8ArrayBitLength(modulo);
|
|
25507
25990
|
} else if (this.publicParams.oid) {
|
|
25508
25991
|
result.curve = this.publicParams.oid.getName();
|
|
25509
|
-
} else {
|
|
25992
|
+
} else if (this.publicParams.cipher) {
|
|
25510
25993
|
result.symmetric = this.publicParams.cipher.getName();
|
|
25511
25994
|
}
|
|
25512
25995
|
return result;
|
|
@@ -25838,6 +26321,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25838
26321
|
async read(bytes) {
|
|
25839
26322
|
// - A Public-Key or Public-Subkey packet, as described above.
|
|
25840
26323
|
let i = await this.readPublicKey(bytes);
|
|
26324
|
+
const startOfSecretKeyData = i;
|
|
25841
26325
|
|
|
25842
26326
|
// - One octet indicating string-to-key usage conventions. Zero
|
|
25843
26327
|
// indicates that the secret-key data is not encrypted. 255 or 254
|
|
@@ -25851,41 +26335,48 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25851
26335
|
i++;
|
|
25852
26336
|
}
|
|
25853
26337
|
|
|
25854
|
-
|
|
25855
|
-
|
|
25856
|
-
|
|
25857
|
-
this.
|
|
26338
|
+
try {
|
|
26339
|
+
// - [Optional] If string-to-key usage octet was 255, 254, or 253, a
|
|
26340
|
+
// one-octet symmetric encryption algorithm.
|
|
26341
|
+
if (this.s2kUsage === 255 || this.s2kUsage === 254 || this.s2kUsage === 253) {
|
|
26342
|
+
this.symmetric = bytes[i++];
|
|
25858
26343
|
|
|
25859
|
-
|
|
25860
|
-
|
|
25861
|
-
|
|
25862
|
-
|
|
25863
|
-
|
|
26344
|
+
// - [Optional] If string-to-key usage octet was 253, a one-octet
|
|
26345
|
+
// AEAD algorithm.
|
|
26346
|
+
if (this.s2kUsage === 253) {
|
|
26347
|
+
this.aead = bytes[i++];
|
|
26348
|
+
}
|
|
25864
26349
|
|
|
25865
|
-
|
|
25866
|
-
|
|
25867
|
-
|
|
25868
|
-
|
|
25869
|
-
|
|
25870
|
-
|
|
26350
|
+
// - [Optional] If string-to-key usage octet was 255, 254, or 253, a
|
|
26351
|
+
// string-to-key specifier. The length of the string-to-key
|
|
26352
|
+
// specifier is implied by its type, as described above.
|
|
26353
|
+
const s2kType = bytes[i++];
|
|
26354
|
+
this.s2k = newS2KFromType(s2kType);
|
|
26355
|
+
i += this.s2k.read(bytes.subarray(i, bytes.length));
|
|
25871
26356
|
|
|
25872
|
-
|
|
25873
|
-
|
|
26357
|
+
if (this.s2k.type === 'gnu-dummy') {
|
|
26358
|
+
return;
|
|
26359
|
+
}
|
|
26360
|
+
} else if (this.s2kUsage) {
|
|
26361
|
+
this.symmetric = this.s2kUsage;
|
|
25874
26362
|
}
|
|
25875
|
-
} else if (this.s2kUsage) {
|
|
25876
|
-
this.symmetric = this.s2kUsage;
|
|
25877
|
-
}
|
|
25878
26363
|
|
|
25879
|
-
|
|
25880
|
-
|
|
25881
|
-
|
|
25882
|
-
|
|
25883
|
-
|
|
25884
|
-
|
|
25885
|
-
|
|
25886
|
-
|
|
26364
|
+
// - [Optional] If secret data is encrypted (string-to-key usage octet
|
|
26365
|
+
// not zero), an Initial Vector (IV) of the same length as the
|
|
26366
|
+
// cipher's block size.
|
|
26367
|
+
if (this.s2kUsage) {
|
|
26368
|
+
this.iv = bytes.subarray(
|
|
26369
|
+
i,
|
|
26370
|
+
i + mod.getCipher(this.symmetric).blockSize
|
|
26371
|
+
);
|
|
25887
26372
|
|
|
25888
|
-
|
|
26373
|
+
i += this.iv.length;
|
|
26374
|
+
}
|
|
26375
|
+
} catch (e) {
|
|
26376
|
+
// if the s2k is unsupported, we still want to support encrypting and verifying with the given key
|
|
26377
|
+
if (!this.s2kUsage) throw e; // always throw for decrypted keys
|
|
26378
|
+
this.unparseableKeyMaterial = bytes.subarray(startOfSecretKeyData);
|
|
26379
|
+
this.isEncrypted = true;
|
|
25889
26380
|
}
|
|
25890
26381
|
|
|
25891
26382
|
// - Only for a version 5 packet, a four-octet scalar octet count for
|
|
@@ -25921,8 +26412,15 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25921
26412
|
* @returns {Uint8Array} A string of bytes containing the secret key OpenPGP packet.
|
|
25922
26413
|
*/
|
|
25923
26414
|
write() {
|
|
25924
|
-
const
|
|
26415
|
+
const serializedPublicKey = this.writePublicKey();
|
|
26416
|
+
if (this.unparseableKeyMaterial) {
|
|
26417
|
+
return util.concatUint8Array([
|
|
26418
|
+
serializedPublicKey,
|
|
26419
|
+
this.unparseableKeyMaterial
|
|
26420
|
+
]);
|
|
26421
|
+
}
|
|
25925
26422
|
|
|
26423
|
+
const arr = [serializedPublicKey];
|
|
25926
26424
|
arr.push(new Uint8Array([this.s2kUsage]));
|
|
25927
26425
|
|
|
25928
26426
|
const optionalFieldsArr = [];
|
|
@@ -25982,6 +26480,18 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25982
26480
|
return this.isEncrypted === false;
|
|
25983
26481
|
}
|
|
25984
26482
|
|
|
26483
|
+
/**
|
|
26484
|
+
* Check whether the key includes secret key material.
|
|
26485
|
+
* Some secret keys do not include it, and can thus only be used
|
|
26486
|
+
* for public-key operations (encryption and verification).
|
|
26487
|
+
* Such keys are:
|
|
26488
|
+
* - GNU-dummy keys, where the secret material has been stripped away
|
|
26489
|
+
* - encrypted keys with unsupported S2K or cipher
|
|
26490
|
+
*/
|
|
26491
|
+
isMissingSecretKeyMaterial() {
|
|
26492
|
+
return this.unparseableKeyMaterial !== undefined || this.isDummy();
|
|
26493
|
+
}
|
|
26494
|
+
|
|
25985
26495
|
/**
|
|
25986
26496
|
* Check whether this is a gnu-dummy key
|
|
25987
26497
|
* @returns {Boolean}
|
|
@@ -26002,6 +26512,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
26002
26512
|
if (this.isDecrypted()) {
|
|
26003
26513
|
this.clearPrivateParams();
|
|
26004
26514
|
}
|
|
26515
|
+
delete this.unparseableKeyMaterial;
|
|
26005
26516
|
this.isEncrypted = null;
|
|
26006
26517
|
this.keyMaterial = null;
|
|
26007
26518
|
this.s2k = newS2KFromType(enums.s2k.gnu, config$1);
|
|
@@ -26073,6 +26584,10 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
26073
26584
|
return false;
|
|
26074
26585
|
}
|
|
26075
26586
|
|
|
26587
|
+
if (this.unparseableKeyMaterial) {
|
|
26588
|
+
throw new Error('Key packet cannot be decrypted: unsupported S2K or cipher algo');
|
|
26589
|
+
}
|
|
26590
|
+
|
|
26076
26591
|
if (this.isDecrypted()) {
|
|
26077
26592
|
throw new Error('Key packet is already decrypted.');
|
|
26078
26593
|
}
|
|
@@ -26157,7 +26672,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
26157
26672
|
* Clear private key parameters
|
|
26158
26673
|
*/
|
|
26159
26674
|
clearPrivateParams() {
|
|
26160
|
-
if (this.
|
|
26675
|
+
if (this.isMissingSecretKeyMaterial()) {
|
|
26161
26676
|
return;
|
|
26162
26677
|
}
|
|
26163
26678
|
|
|
@@ -27566,7 +28081,9 @@ async function createBindingSignature(subkey, primaryKey, options, config) {
|
|
|
27566
28081
|
signatureType: enums.signature.keyBinding
|
|
27567
28082
|
}, options.date, undefined, undefined, undefined, config);
|
|
27568
28083
|
} else {
|
|
27569
|
-
subkeySignaturePacket.keyFlags =
|
|
28084
|
+
subkeySignaturePacket.keyFlags = options.forwarding ?
|
|
28085
|
+
[enums.keyFlags.forwardedCommunication] :
|
|
28086
|
+
[enums.keyFlags.encryptCommunication | enums.keyFlags.encryptStorage];
|
|
27570
28087
|
}
|
|
27571
28088
|
if (options.keyExpirationTime > 0) {
|
|
27572
28089
|
subkeySignaturePacket.keyExpirationTime = options.keyExpirationTime;
|
|
@@ -27804,6 +28321,10 @@ function sanitizeKeyOptions(options, subkeyDefaults = {}) {
|
|
|
27804
28321
|
options.date = options.date || subkeyDefaults.date;
|
|
27805
28322
|
|
|
27806
28323
|
options.sign = options.sign || false;
|
|
28324
|
+
options.forwarding = options.forwarding || false;
|
|
28325
|
+
if (options.sign && options.forwarding) {
|
|
28326
|
+
throw new Error('Incompatible options: "sign" and "forwarding" cannot be set together');
|
|
28327
|
+
}
|
|
27807
28328
|
|
|
27808
28329
|
switch (options.type) {
|
|
27809
28330
|
case 'ecc':
|
|
@@ -27844,6 +28365,7 @@ function isValidSigningKeyPacket(keyPacket, signature) {
|
|
|
27844
28365
|
return keyAlgo !== enums.publicKey.rsaEncrypt &&
|
|
27845
28366
|
keyAlgo !== enums.publicKey.elgamal &&
|
|
27846
28367
|
keyAlgo !== enums.publicKey.ecdh &&
|
|
28368
|
+
keyAlgo !== enums.publicKey.x25519 &&
|
|
27847
28369
|
(!signature.keyFlags ||
|
|
27848
28370
|
(signature.keyFlags[0] & enums.keyFlags.signData) !== 0);
|
|
27849
28371
|
}
|
|
@@ -27854,13 +28376,19 @@ function isValidEncryptionKeyPacket(keyPacket, signature) {
|
|
|
27854
28376
|
keyAlgo !== enums.publicKey.rsaSign &&
|
|
27855
28377
|
keyAlgo !== enums.publicKey.ecdsa &&
|
|
27856
28378
|
keyAlgo !== enums.publicKey.eddsa &&
|
|
28379
|
+
keyAlgo !== enums.publicKey.ed25519 &&
|
|
27857
28380
|
(!signature.keyFlags ||
|
|
27858
28381
|
(signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
|
|
27859
28382
|
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0);
|
|
27860
28383
|
}
|
|
27861
28384
|
|
|
27862
28385
|
function isValidDecryptionKeyPacket(signature, config) {
|
|
27863
|
-
|
|
28386
|
+
const isSigningKey = !signature.keyFlags ||
|
|
28387
|
+
(signature.keyFlags[0] & enums.keyFlags.sign) !== 0 ||
|
|
28388
|
+
(signature.keyFlags[0] & enums.keyFlags.certifyKeys) !== 0 ||
|
|
28389
|
+
(signature.keyFlags[0] & enums.keyFlags.authentication) !== 0;
|
|
28390
|
+
|
|
28391
|
+
if (isSigningKey && config.allowInsecureDecryptionWithSigningKeys) {
|
|
27864
28392
|
// This is only relevant for RSA keys, all other signing algorithms cannot decrypt
|
|
27865
28393
|
return true;
|
|
27866
28394
|
}
|
|
@@ -29403,7 +29931,7 @@ function createKey(packetlist) {
|
|
|
29403
29931
|
* @static
|
|
29404
29932
|
* @private
|
|
29405
29933
|
*/
|
|
29406
|
-
async function generate$
|
|
29934
|
+
async function generate$4(options, config) {
|
|
29407
29935
|
options.sign = true; // primary key is always a signing key
|
|
29408
29936
|
options = sanitizeKeyOptions(options);
|
|
29409
29937
|
options.subkeys = options.subkeys.map((subkey, index) => sanitizeKeyOptions(options.subkeys[index], options));
|
|
@@ -29459,7 +29987,8 @@ async function reformat(options, config) {
|
|
|
29459
29987
|
getLatestValidSignature(subkey.bindingSignatures, secretKeyPacket, enums.signature.subkeyBinding, dataToVerify, null, config)
|
|
29460
29988
|
).catch(() => ({}));
|
|
29461
29989
|
return {
|
|
29462
|
-
sign: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.signData)
|
|
29990
|
+
sign: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.signData),
|
|
29991
|
+
forwarding: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.forwardedCommunication)
|
|
29463
29992
|
};
|
|
29464
29993
|
}));
|
|
29465
29994
|
}
|
|
@@ -30081,6 +30610,15 @@ class Message {
|
|
|
30081
30610
|
enums.read(enums.aead, await getPreferredAlgo('aead', encryptionKeys, date, userIDs, config$1)) :
|
|
30082
30611
|
undefined;
|
|
30083
30612
|
|
|
30613
|
+
await Promise.all(encryptionKeys.map(key => key.getEncryptionKey()
|
|
30614
|
+
.catch(() => null) // ignore key strength requirements
|
|
30615
|
+
.then(maybeKey => {
|
|
30616
|
+
if (maybeKey && (maybeKey.keyPacket.algorithm === enums.publicKey.x25519) && !util.isAES(algo)) {
|
|
30617
|
+
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.');
|
|
30618
|
+
}
|
|
30619
|
+
})
|
|
30620
|
+
));
|
|
30621
|
+
|
|
30084
30622
|
const sessionKeyData = mod.generateSessionKey(algo);
|
|
30085
30623
|
return { data: sessionKeyData, algorithm: algorithmName, aeadAlgorithm: aeadAlgorithmName };
|
|
30086
30624
|
}
|
|
@@ -30388,7 +30926,7 @@ class Message {
|
|
|
30388
30926
|
if (literalDataList.length !== 1) {
|
|
30389
30927
|
throw new Error('Can only verify message with one literal data packet.');
|
|
30390
30928
|
}
|
|
30391
|
-
const signatureList = signature.packets;
|
|
30929
|
+
const signatureList = signature.packets.filterByTag(enums.packet.signature); // drop UnparsablePackets
|
|
30392
30930
|
return createVerificationObjects(signatureList, literalDataList, verificationKeys, date, true, config$1);
|
|
30393
30931
|
}
|
|
30394
30932
|
|
|
@@ -30735,7 +31273,7 @@ class CleartextMessage {
|
|
|
30735
31273
|
* @async
|
|
30736
31274
|
*/
|
|
30737
31275
|
verify(keys, date = new Date(), config$1 = config) {
|
|
30738
|
-
const signatureList = this.signature.packets;
|
|
31276
|
+
const signatureList = this.signature.packets.filterByTag(enums.packet.signature); // drop UnparsablePackets
|
|
30739
31277
|
const literalDataPacket = new LiteralDataPacket();
|
|
30740
31278
|
// we assume that cleartext signature is generated based on UTF8 cleartext
|
|
30741
31279
|
literalDataPacket.setText(this.text);
|
|
@@ -30820,7 +31358,7 @@ function verifyHeaders$1(headers, packetlist) {
|
|
|
30820
31358
|
let oneHeader = null;
|
|
30821
31359
|
let hashAlgos = [];
|
|
30822
31360
|
headers.forEach(function(header) {
|
|
30823
|
-
oneHeader = header.match(
|
|
31361
|
+
oneHeader = header.match(/^Hash: (.+)$/); // get header value
|
|
30824
31362
|
if (oneHeader) {
|
|
30825
31363
|
oneHeader = oneHeader[1].replace(/\s/g, ''); // remove whitespace
|
|
30826
31364
|
oneHeader = oneHeader.split(',');
|
|
@@ -30912,7 +31450,7 @@ async function generateKey({ userIDs = [], passphrase, type = 'ecc', rsaBits = 4
|
|
|
30912
31450
|
const options = { userIDs, passphrase, type, rsaBits, curve, keyExpirationTime, date, subkeys, symmetricHash, symmetricCipher };
|
|
30913
31451
|
|
|
30914
31452
|
try {
|
|
30915
|
-
const { key, revocationCertificate } = await generate$
|
|
31453
|
+
const { key, revocationCertificate } = await generate$4(options, config$1);
|
|
30916
31454
|
key.getKeys().forEach(({ keyPacket }) => checkKeyRequirements(keyPacket, config$1));
|
|
30917
31455
|
|
|
30918
31456
|
return {
|
|
@@ -31106,7 +31644,7 @@ async function encryptKey({ privateKey, passphrase, config: config$1, ...rest })
|
|
|
31106
31644
|
* @async
|
|
31107
31645
|
* @static
|
|
31108
31646
|
*/
|
|
31109
|
-
async function encrypt$
|
|
31647
|
+
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 }) {
|
|
31110
31648
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31111
31649
|
checkMessage(message); checkOutputMessageFormat(format);
|
|
31112
31650
|
encryptionKeys = toArray$1(encryptionKeys); signingKeys = toArray$1(signingKeys); passwords = toArray$1(passwords);
|
|
@@ -31175,7 +31713,7 @@ async function encrypt$4({ message, encryptionKeys, signingKeys, passwords, sess
|
|
|
31175
31713
|
* @async
|
|
31176
31714
|
* @static
|
|
31177
31715
|
*/
|
|
31178
|
-
async function decrypt$
|
|
31716
|
+
async function decrypt$5({ message, decryptionKeys, passwords, sessionKeys, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
|
|
31179
31717
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31180
31718
|
checkMessage(message); verificationKeys = toArray$1(verificationKeys); decryptionKeys = toArray$1(decryptionKeys); passwords = toArray$1(passwords); sessionKeys = toArray$1(sessionKeys);
|
|
31181
31719
|
if (rest.privateKeys) throw new Error('The `privateKeys` option has been removed from openpgp.decrypt, pass `decryptionKeys` instead');
|
|
@@ -31238,7 +31776,7 @@ async function decrypt$4({ message, decryptionKeys, passwords, sessionKeys, veri
|
|
|
31238
31776
|
* @async
|
|
31239
31777
|
* @static
|
|
31240
31778
|
*/
|
|
31241
|
-
async function sign$
|
|
31779
|
+
async function sign$6({ message, signingKeys, format = 'armored', detached = false, signingKeyIDs = [], date = new Date(), signingUserIDs = [], signatureNotations = [], config: config$1, ...rest }) {
|
|
31242
31780
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31243
31781
|
checkCleartextOrMessage(message); checkOutputMessageFormat(format);
|
|
31244
31782
|
signingKeys = toArray$1(signingKeys); signingKeyIDs = toArray$1(signingKeyIDs); signingUserIDs = toArray$1(signingUserIDs); signatureNotations = toArray$1(signatureNotations);
|
|
@@ -31307,7 +31845,7 @@ async function sign$5({ message, signingKeys, format = 'armored', detached = fal
|
|
|
31307
31845
|
* @async
|
|
31308
31846
|
* @static
|
|
31309
31847
|
*/
|
|
31310
|
-
async function verify$
|
|
31848
|
+
async function verify$6({ message, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
|
|
31311
31849
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31312
31850
|
checkCleartextOrMessage(message); verificationKeys = toArray$1(verificationKeys);
|
|
31313
31851
|
if (rest.publicKeys) throw new Error('The `publicKeys` option has been removed from openpgp.verify, pass `verificationKeys` instead');
|
|
@@ -44476,7 +45014,7 @@ function* makePRNG(wasmContext, pass, lane, slice, m_, totalPasses, segmentLengt
|
|
|
44476
45014
|
return [];
|
|
44477
45015
|
}
|
|
44478
45016
|
|
|
44479
|
-
function validateParams$
|
|
45017
|
+
function validateParams$9({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {
|
|
44480
45018
|
const assertLength = (name, value, min, max) => {
|
|
44481
45019
|
if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }
|
|
44482
45020
|
};
|
|
@@ -44499,7 +45037,7 @@ const WASM_PAGE_SIZE = 64 * KB;
|
|
|
44499
45037
|
function argon2id(params, { memory, instance: wasmInstance }) {
|
|
44500
45038
|
if (!isLittleEndian$1) throw new Error('BigEndian system not supported'); // optmisations assume LE system
|
|
44501
45039
|
|
|
44502
|
-
const ctx = validateParams$
|
|
45040
|
+
const ctx = validateParams$9({ type: TYPE$2, version: VERSION$4, ...params });
|
|
44503
45041
|
|
|
44504
45042
|
const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;
|
|
44505
45043
|
const wasmRefs = {};
|
|
@@ -44779,4 +45317,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
44779
45317
|
'default': loadWasm
|
|
44780
45318
|
});
|
|
44781
45319
|
|
|
44782
|
-
export { AEADEncryptedDataPacket, CleartextMessage, CompressedDataPacket, KDFParams, LiteralDataPacket, MarkerPacket, Message, OnePassSignaturePacket, PacketList, PrivateKey, PublicKey, PublicKeyEncryptedSessionKeyPacket, PublicKeyPacket, PublicSubkeyPacket, SecretKeyPacket, SecretSubkeyPacket, Signature, SignaturePacket, Subkey, SymEncryptedIntegrityProtectedDataPacket, SymEncryptedSessionKeyPacket, SymmetricallyEncryptedDataPacket, TrustPacket, UnparseablePacket, UserAttributePacket, UserIDPacket, armor, config, createCleartextMessage, createMessage, decrypt$
|
|
45320
|
+
export { AEADEncryptedDataPacket, CleartextMessage, CompressedDataPacket, KDFParams, LiteralDataPacket, MarkerPacket, Message, OnePassSignaturePacket, PacketList, PrivateKey, PublicKey, PublicKeyEncryptedSessionKeyPacket, PublicKeyPacket, PublicSubkeyPacket, SecretKeyPacket, SecretSubkeyPacket, Signature, SignaturePacket, Subkey, SymEncryptedIntegrityProtectedDataPacket, SymEncryptedSessionKeyPacket, SymmetricallyEncryptedDataPacket, TrustPacket, UnparseablePacket, UserAttributePacket, UserIDPacket, armor, config, createCleartextMessage, createMessage, decrypt$5 as decrypt, decryptKey, decryptSessionKeys, encrypt$5 as encrypt, encryptKey, encryptSessionKey, enums, generateKey, generateSessionKey$1 as generateSessionKey, readCleartextMessage, readKey, readKeys, readMessage, readPrivateKey, readPrivateKeys, readSignature, reformatKey, revokeKey, sign$6 as sign, unarmor, verify$6 as verify };
|