@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/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
|
const doneWritingPromise = Symbol('doneWritingPromise');
|
|
@@ -1507,6 +1507,526 @@ async function getBigInteger() {
|
|
|
1507
1507
|
}
|
|
1508
1508
|
}
|
|
1509
1509
|
|
|
1510
|
+
/**
|
|
1511
|
+
* @module enums
|
|
1512
|
+
*/
|
|
1513
|
+
|
|
1514
|
+
const byValue = Symbol('byValue');
|
|
1515
|
+
|
|
1516
|
+
var enums = {
|
|
1517
|
+
|
|
1518
|
+
/** Maps curve names under various standards to one
|
|
1519
|
+
* @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
|
|
1520
|
+
* @enum {String}
|
|
1521
|
+
* @readonly
|
|
1522
|
+
*/
|
|
1523
|
+
curve: {
|
|
1524
|
+
/** NIST P-256 Curve */
|
|
1525
|
+
'p256': 'p256',
|
|
1526
|
+
'P-256': 'p256',
|
|
1527
|
+
'secp256r1': 'p256',
|
|
1528
|
+
'prime256v1': 'p256',
|
|
1529
|
+
'1.2.840.10045.3.1.7': 'p256',
|
|
1530
|
+
'2a8648ce3d030107': 'p256',
|
|
1531
|
+
'2A8648CE3D030107': 'p256',
|
|
1532
|
+
|
|
1533
|
+
/** NIST P-384 Curve */
|
|
1534
|
+
'p384': 'p384',
|
|
1535
|
+
'P-384': 'p384',
|
|
1536
|
+
'secp384r1': 'p384',
|
|
1537
|
+
'1.3.132.0.34': 'p384',
|
|
1538
|
+
'2b81040022': 'p384',
|
|
1539
|
+
'2B81040022': 'p384',
|
|
1540
|
+
|
|
1541
|
+
/** NIST P-521 Curve */
|
|
1542
|
+
'p521': 'p521',
|
|
1543
|
+
'P-521': 'p521',
|
|
1544
|
+
'secp521r1': 'p521',
|
|
1545
|
+
'1.3.132.0.35': 'p521',
|
|
1546
|
+
'2b81040023': 'p521',
|
|
1547
|
+
'2B81040023': 'p521',
|
|
1548
|
+
|
|
1549
|
+
/** SECG SECP256k1 Curve */
|
|
1550
|
+
'secp256k1': 'secp256k1',
|
|
1551
|
+
'1.3.132.0.10': 'secp256k1',
|
|
1552
|
+
'2b8104000a': 'secp256k1',
|
|
1553
|
+
'2B8104000A': 'secp256k1',
|
|
1554
|
+
|
|
1555
|
+
/** Ed25519 */
|
|
1556
|
+
'ED25519': 'ed25519',
|
|
1557
|
+
'ed25519': 'ed25519',
|
|
1558
|
+
'Ed25519': 'ed25519',
|
|
1559
|
+
'1.3.6.1.4.1.11591.15.1': 'ed25519',
|
|
1560
|
+
'2b06010401da470f01': 'ed25519',
|
|
1561
|
+
'2B06010401DA470F01': 'ed25519',
|
|
1562
|
+
|
|
1563
|
+
/** Curve25519 */
|
|
1564
|
+
'X25519': 'curve25519',
|
|
1565
|
+
'cv25519': 'curve25519',
|
|
1566
|
+
'curve25519': 'curve25519',
|
|
1567
|
+
'Curve25519': 'curve25519',
|
|
1568
|
+
'1.3.6.1.4.1.3029.1.5.1': 'curve25519',
|
|
1569
|
+
'2b060104019755010501': 'curve25519',
|
|
1570
|
+
'2B060104019755010501': 'curve25519',
|
|
1571
|
+
|
|
1572
|
+
/** BrainpoolP256r1 Curve */
|
|
1573
|
+
'brainpoolP256r1': 'brainpoolP256r1',
|
|
1574
|
+
'1.3.36.3.3.2.8.1.1.7': 'brainpoolP256r1',
|
|
1575
|
+
'2b2403030208010107': 'brainpoolP256r1',
|
|
1576
|
+
'2B2403030208010107': 'brainpoolP256r1',
|
|
1577
|
+
|
|
1578
|
+
/** BrainpoolP384r1 Curve */
|
|
1579
|
+
'brainpoolP384r1': 'brainpoolP384r1',
|
|
1580
|
+
'1.3.36.3.3.2.8.1.1.11': 'brainpoolP384r1',
|
|
1581
|
+
'2b240303020801010b': 'brainpoolP384r1',
|
|
1582
|
+
'2B240303020801010B': 'brainpoolP384r1',
|
|
1583
|
+
|
|
1584
|
+
/** BrainpoolP512r1 Curve */
|
|
1585
|
+
'brainpoolP512r1': 'brainpoolP512r1',
|
|
1586
|
+
'1.3.36.3.3.2.8.1.1.13': 'brainpoolP512r1',
|
|
1587
|
+
'2b240303020801010d': 'brainpoolP512r1',
|
|
1588
|
+
'2B240303020801010D': 'brainpoolP512r1'
|
|
1589
|
+
},
|
|
1590
|
+
|
|
1591
|
+
/** KDF parameters flags
|
|
1592
|
+
* Non-standard extensions (for now) to allow email forwarding
|
|
1593
|
+
* @enum {Integer}
|
|
1594
|
+
* @readonly
|
|
1595
|
+
*/
|
|
1596
|
+
kdfFlags: {
|
|
1597
|
+
/** Specify fingerprint to use instead of the recipient's */
|
|
1598
|
+
replace_fingerprint: 0x01,
|
|
1599
|
+
/** Specify custom parameters to use in the KDF digest computation */
|
|
1600
|
+
replace_kdf_params: 0x02
|
|
1601
|
+
},
|
|
1602
|
+
|
|
1603
|
+
/** A string to key specifier type
|
|
1604
|
+
* @enum {Integer}
|
|
1605
|
+
* @readonly
|
|
1606
|
+
*/
|
|
1607
|
+
s2k: {
|
|
1608
|
+
simple: 0,
|
|
1609
|
+
salted: 1,
|
|
1610
|
+
iterated: 3,
|
|
1611
|
+
argon2: 4,
|
|
1612
|
+
gnu: 101
|
|
1613
|
+
},
|
|
1614
|
+
|
|
1615
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-crypto-refresh-08.html#section-9.1|crypto-refresh RFC, section 9.1}
|
|
1616
|
+
* @enum {Integer}
|
|
1617
|
+
* @readonly
|
|
1618
|
+
*/
|
|
1619
|
+
publicKey: {
|
|
1620
|
+
/** RSA (Encrypt or Sign) [HAC] */
|
|
1621
|
+
rsaEncryptSign: 1,
|
|
1622
|
+
/** RSA (Encrypt only) [HAC] */
|
|
1623
|
+
rsaEncrypt: 2,
|
|
1624
|
+
/** RSA (Sign only) [HAC] */
|
|
1625
|
+
rsaSign: 3,
|
|
1626
|
+
/** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
|
|
1627
|
+
elgamal: 16,
|
|
1628
|
+
/** DSA (Sign only) [FIPS186] [HAC] */
|
|
1629
|
+
dsa: 17,
|
|
1630
|
+
/** ECDH (Encrypt only) [RFC6637] */
|
|
1631
|
+
ecdh: 18,
|
|
1632
|
+
/** ECDSA (Sign only) [RFC6637] */
|
|
1633
|
+
ecdsa: 19,
|
|
1634
|
+
/** EdDSA (Sign only) - deprecated by crypto-refresh (replaced by `ed25519` identifier below)
|
|
1635
|
+
* [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
|
|
1636
|
+
ed25519Legacy: 22, // NB: this is declared before `eddsa` to translate 22 to 'eddsa' for backwards compatibility
|
|
1637
|
+
eddsa: 22, // to be deprecated in v6
|
|
1638
|
+
/** Reserved for AEDH */
|
|
1639
|
+
aedh: 23,
|
|
1640
|
+
/** Reserved for AEDSA */
|
|
1641
|
+
aedsa: 24,
|
|
1642
|
+
/** X25519 (Encrypt only) */
|
|
1643
|
+
x25519: 25,
|
|
1644
|
+
/** X448 (Encrypt only) */
|
|
1645
|
+
x448: 26,
|
|
1646
|
+
/** Ed25519 (Sign only) */
|
|
1647
|
+
ed25519: 27,
|
|
1648
|
+
/** Ed448 (Sign only) */
|
|
1649
|
+
ed448: 28,
|
|
1650
|
+
/** Symmetric authenticated encryption algorithms */
|
|
1651
|
+
aead: 100,
|
|
1652
|
+
/** Authentication using CMAC */
|
|
1653
|
+
hmac: 101
|
|
1654
|
+
},
|
|
1655
|
+
|
|
1656
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
|
|
1657
|
+
* @enum {Integer}
|
|
1658
|
+
* @readonly
|
|
1659
|
+
*/
|
|
1660
|
+
symmetric: {
|
|
1661
|
+
plaintext: 0,
|
|
1662
|
+
/** Not implemented! */
|
|
1663
|
+
idea: 1,
|
|
1664
|
+
tripledes: 2,
|
|
1665
|
+
cast5: 3,
|
|
1666
|
+
blowfish: 4,
|
|
1667
|
+
aes128: 7,
|
|
1668
|
+
aes192: 8,
|
|
1669
|
+
aes256: 9,
|
|
1670
|
+
twofish: 10
|
|
1671
|
+
},
|
|
1672
|
+
|
|
1673
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
|
|
1674
|
+
* @enum {Integer}
|
|
1675
|
+
* @readonly
|
|
1676
|
+
*/
|
|
1677
|
+
compression: {
|
|
1678
|
+
uncompressed: 0,
|
|
1679
|
+
/** RFC1951 */
|
|
1680
|
+
zip: 1,
|
|
1681
|
+
/** RFC1950 */
|
|
1682
|
+
zlib: 2,
|
|
1683
|
+
bzip2: 3
|
|
1684
|
+
},
|
|
1685
|
+
|
|
1686
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
|
|
1687
|
+
* @enum {Integer}
|
|
1688
|
+
* @readonly
|
|
1689
|
+
*/
|
|
1690
|
+
hash: {
|
|
1691
|
+
md5: 1,
|
|
1692
|
+
sha1: 2,
|
|
1693
|
+
ripemd: 3,
|
|
1694
|
+
sha256: 8,
|
|
1695
|
+
sha384: 9,
|
|
1696
|
+
sha512: 10,
|
|
1697
|
+
sha224: 11
|
|
1698
|
+
},
|
|
1699
|
+
|
|
1700
|
+
/** A list of hash names as accepted by webCrypto functions.
|
|
1701
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
|
|
1702
|
+
* @enum {String}
|
|
1703
|
+
*/
|
|
1704
|
+
webHash: {
|
|
1705
|
+
'SHA-1': 2,
|
|
1706
|
+
'SHA-256': 8,
|
|
1707
|
+
'SHA-384': 9,
|
|
1708
|
+
'SHA-512': 10
|
|
1709
|
+
},
|
|
1710
|
+
|
|
1711
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
|
|
1712
|
+
* @enum {Integer}
|
|
1713
|
+
* @readonly
|
|
1714
|
+
*/
|
|
1715
|
+
aead: {
|
|
1716
|
+
eax: 1,
|
|
1717
|
+
ocb: 2,
|
|
1718
|
+
experimentalGCM: 100 // Private algorithm
|
|
1719
|
+
},
|
|
1720
|
+
|
|
1721
|
+
/** A list of packet types and numeric tags associated with them.
|
|
1722
|
+
* @enum {Integer}
|
|
1723
|
+
* @readonly
|
|
1724
|
+
*/
|
|
1725
|
+
packet: {
|
|
1726
|
+
publicKeyEncryptedSessionKey: 1,
|
|
1727
|
+
signature: 2,
|
|
1728
|
+
symEncryptedSessionKey: 3,
|
|
1729
|
+
onePassSignature: 4,
|
|
1730
|
+
secretKey: 5,
|
|
1731
|
+
publicKey: 6,
|
|
1732
|
+
secretSubkey: 7,
|
|
1733
|
+
compressedData: 8,
|
|
1734
|
+
symmetricallyEncryptedData: 9,
|
|
1735
|
+
marker: 10,
|
|
1736
|
+
literalData: 11,
|
|
1737
|
+
trust: 12,
|
|
1738
|
+
userID: 13,
|
|
1739
|
+
publicSubkey: 14,
|
|
1740
|
+
userAttribute: 17,
|
|
1741
|
+
symEncryptedIntegrityProtectedData: 18,
|
|
1742
|
+
modificationDetectionCode: 19,
|
|
1743
|
+
aeadEncryptedData: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
|
|
1744
|
+
},
|
|
1745
|
+
|
|
1746
|
+
/** Data types in the literal packet
|
|
1747
|
+
* @enum {Integer}
|
|
1748
|
+
* @readonly
|
|
1749
|
+
*/
|
|
1750
|
+
literal: {
|
|
1751
|
+
/** Binary data 'b' */
|
|
1752
|
+
binary: 'b'.charCodeAt(),
|
|
1753
|
+
/** Text data 't' */
|
|
1754
|
+
text: 't'.charCodeAt(),
|
|
1755
|
+
/** Utf8 data 'u' */
|
|
1756
|
+
utf8: 'u'.charCodeAt(),
|
|
1757
|
+
/** MIME message body part 'm' */
|
|
1758
|
+
mime: 'm'.charCodeAt()
|
|
1759
|
+
},
|
|
1760
|
+
|
|
1761
|
+
|
|
1762
|
+
/** One pass signature packet type
|
|
1763
|
+
* @enum {Integer}
|
|
1764
|
+
* @readonly
|
|
1765
|
+
*/
|
|
1766
|
+
signature: {
|
|
1767
|
+
/** 0x00: Signature of a binary document. */
|
|
1768
|
+
binary: 0,
|
|
1769
|
+
/** 0x01: Signature of a canonical text document.
|
|
1770
|
+
*
|
|
1771
|
+
* Canonicalyzing the document by converting line endings. */
|
|
1772
|
+
text: 1,
|
|
1773
|
+
/** 0x02: Standalone signature.
|
|
1774
|
+
*
|
|
1775
|
+
* This signature is a signature of only its own subpacket contents.
|
|
1776
|
+
* It is calculated identically to a signature over a zero-lengh
|
|
1777
|
+
* binary document. Note that it doesn't make sense to have a V3
|
|
1778
|
+
* standalone signature. */
|
|
1779
|
+
standalone: 2,
|
|
1780
|
+
/** 0x10: Generic certification of a User ID and Public-Key packet.
|
|
1781
|
+
*
|
|
1782
|
+
* The issuer of this certification does not make any particular
|
|
1783
|
+
* assertion as to how well the certifier has checked that the owner
|
|
1784
|
+
* of the key is in fact the person described by the User ID. */
|
|
1785
|
+
certGeneric: 16,
|
|
1786
|
+
/** 0x11: Persona certification of a User ID and Public-Key packet.
|
|
1787
|
+
*
|
|
1788
|
+
* The issuer of this certification has not done any verification of
|
|
1789
|
+
* the claim that the owner of this key is the User ID specified. */
|
|
1790
|
+
certPersona: 17,
|
|
1791
|
+
/** 0x12: Casual certification of a User ID and Public-Key packet.
|
|
1792
|
+
*
|
|
1793
|
+
* The issuer of this certification has done some casual
|
|
1794
|
+
* verification of the claim of identity. */
|
|
1795
|
+
certCasual: 18,
|
|
1796
|
+
/** 0x13: Positive certification of a User ID and Public-Key packet.
|
|
1797
|
+
*
|
|
1798
|
+
* The issuer of this certification has done substantial
|
|
1799
|
+
* verification of the claim of identity.
|
|
1800
|
+
*
|
|
1801
|
+
* Most OpenPGP implementations make their "key signatures" as 0x10
|
|
1802
|
+
* certifications. Some implementations can issue 0x11-0x13
|
|
1803
|
+
* certifications, but few differentiate between the types. */
|
|
1804
|
+
certPositive: 19,
|
|
1805
|
+
/** 0x30: Certification revocation signature
|
|
1806
|
+
*
|
|
1807
|
+
* This signature revokes an earlier User ID certification signature
|
|
1808
|
+
* (signature class 0x10 through 0x13) or direct-key signature
|
|
1809
|
+
* (0x1F). It should be issued by the same key that issued the
|
|
1810
|
+
* revoked signature or an authorized revocation key. The signature
|
|
1811
|
+
* is computed over the same data as the certificate that it
|
|
1812
|
+
* revokes, and should have a later creation date than that
|
|
1813
|
+
* certificate. */
|
|
1814
|
+
certRevocation: 48,
|
|
1815
|
+
/** 0x18: Subkey Binding Signature
|
|
1816
|
+
*
|
|
1817
|
+
* This signature is a statement by the top-level signing key that
|
|
1818
|
+
* indicates that it owns the subkey. This signature is calculated
|
|
1819
|
+
* directly on the primary key and subkey, and not on any User ID or
|
|
1820
|
+
* other packets. A signature that binds a signing subkey MUST have
|
|
1821
|
+
* an Embedded Signature subpacket in this binding signature that
|
|
1822
|
+
* contains a 0x19 signature made by the signing subkey on the
|
|
1823
|
+
* primary key and subkey. */
|
|
1824
|
+
subkeyBinding: 24,
|
|
1825
|
+
/** 0x19: Primary Key Binding Signature
|
|
1826
|
+
*
|
|
1827
|
+
* This signature is a statement by a signing subkey, indicating
|
|
1828
|
+
* that it is owned by the primary key and subkey. This signature
|
|
1829
|
+
* is calculated the same way as a 0x18 signature: directly on the
|
|
1830
|
+
* primary key and subkey, and not on any User ID or other packets.
|
|
1831
|
+
*
|
|
1832
|
+
* When a signature is made over a key, the hash data starts with the
|
|
1833
|
+
* octet 0x99, followed by a two-octet length of the key, and then body
|
|
1834
|
+
* of the key packet. (Note that this is an old-style packet header for
|
|
1835
|
+
* a key packet with two-octet length.) A subkey binding signature
|
|
1836
|
+
* (type 0x18) or primary key binding signature (type 0x19) then hashes
|
|
1837
|
+
* the subkey using the same format as the main key (also using 0x99 as
|
|
1838
|
+
* the first octet). */
|
|
1839
|
+
keyBinding: 25,
|
|
1840
|
+
/** 0x1F: Signature directly on a key
|
|
1841
|
+
*
|
|
1842
|
+
* This signature is calculated directly on a key. It binds the
|
|
1843
|
+
* information in the Signature subpackets to the key, and is
|
|
1844
|
+
* appropriate to be used for subpackets that provide information
|
|
1845
|
+
* about the key, such as the Revocation Key subpacket. It is also
|
|
1846
|
+
* appropriate for statements that non-self certifiers want to make
|
|
1847
|
+
* about the key itself, rather than the binding between a key and a
|
|
1848
|
+
* name. */
|
|
1849
|
+
key: 31,
|
|
1850
|
+
/** 0x20: Key revocation signature
|
|
1851
|
+
*
|
|
1852
|
+
* The signature is calculated directly on the key being revoked. A
|
|
1853
|
+
* revoked key is not to be used. Only revocation signatures by the
|
|
1854
|
+
* key being revoked, or by an authorized revocation key, should be
|
|
1855
|
+
* considered valid revocation signatures.a */
|
|
1856
|
+
keyRevocation: 32,
|
|
1857
|
+
/** 0x28: Subkey revocation signature
|
|
1858
|
+
*
|
|
1859
|
+
* The signature is calculated directly on the subkey being revoked.
|
|
1860
|
+
* A revoked subkey is not to be used. Only revocation signatures
|
|
1861
|
+
* by the top-level signature key that is bound to this subkey, or
|
|
1862
|
+
* by an authorized revocation key, should be considered valid
|
|
1863
|
+
* revocation signatures.
|
|
1864
|
+
*
|
|
1865
|
+
* Key revocation signatures (types 0x20 and 0x28)
|
|
1866
|
+
* hash only the key being revoked. */
|
|
1867
|
+
subkeyRevocation: 40,
|
|
1868
|
+
/** 0x40: Timestamp signature.
|
|
1869
|
+
* This signature is only meaningful for the timestamp contained in
|
|
1870
|
+
* it. */
|
|
1871
|
+
timestamp: 64,
|
|
1872
|
+
/** 0x50: Third-Party Confirmation signature.
|
|
1873
|
+
*
|
|
1874
|
+
* This signature is a signature over some other OpenPGP Signature
|
|
1875
|
+
* packet(s). It is analogous to a notary seal on the signed data.
|
|
1876
|
+
* A third-party signature SHOULD include Signature Target
|
|
1877
|
+
* subpacket(s) to give easy identification. Note that we really do
|
|
1878
|
+
* mean SHOULD. There are plausible uses for this (such as a blind
|
|
1879
|
+
* party that only sees the signature, not the key or source
|
|
1880
|
+
* document) that cannot include a target subpacket. */
|
|
1881
|
+
thirdParty: 80
|
|
1882
|
+
},
|
|
1883
|
+
|
|
1884
|
+
/** Signature subpacket type
|
|
1885
|
+
* @enum {Integer}
|
|
1886
|
+
* @readonly
|
|
1887
|
+
*/
|
|
1888
|
+
signatureSubpacket: {
|
|
1889
|
+
signatureCreationTime: 2,
|
|
1890
|
+
signatureExpirationTime: 3,
|
|
1891
|
+
exportableCertification: 4,
|
|
1892
|
+
trustSignature: 5,
|
|
1893
|
+
regularExpression: 6,
|
|
1894
|
+
revocable: 7,
|
|
1895
|
+
keyExpirationTime: 9,
|
|
1896
|
+
placeholderBackwardsCompatibility: 10,
|
|
1897
|
+
preferredSymmetricAlgorithms: 11,
|
|
1898
|
+
revocationKey: 12,
|
|
1899
|
+
issuer: 16,
|
|
1900
|
+
notationData: 20,
|
|
1901
|
+
preferredHashAlgorithms: 21,
|
|
1902
|
+
preferredCompressionAlgorithms: 22,
|
|
1903
|
+
keyServerPreferences: 23,
|
|
1904
|
+
preferredKeyServer: 24,
|
|
1905
|
+
primaryUserID: 25,
|
|
1906
|
+
policyURI: 26,
|
|
1907
|
+
keyFlags: 27,
|
|
1908
|
+
signersUserID: 28,
|
|
1909
|
+
reasonForRevocation: 29,
|
|
1910
|
+
features: 30,
|
|
1911
|
+
signatureTarget: 31,
|
|
1912
|
+
embeddedSignature: 32,
|
|
1913
|
+
issuerFingerprint: 33,
|
|
1914
|
+
preferredAEADAlgorithms: 34
|
|
1915
|
+
},
|
|
1916
|
+
|
|
1917
|
+
/** Key flags
|
|
1918
|
+
* @enum {Integer}
|
|
1919
|
+
* @readonly
|
|
1920
|
+
*/
|
|
1921
|
+
keyFlags: {
|
|
1922
|
+
/** 0x01 - This key may be used to certify other keys. */
|
|
1923
|
+
certifyKeys: 1,
|
|
1924
|
+
/** 0x02 - This key may be used to sign data. */
|
|
1925
|
+
signData: 2,
|
|
1926
|
+
/** 0x04 - This key may be used to encrypt communications. */
|
|
1927
|
+
encryptCommunication: 4,
|
|
1928
|
+
/** 0x08 - This key may be used to encrypt storage. */
|
|
1929
|
+
encryptStorage: 8,
|
|
1930
|
+
/** 0x10 - The private component of this key may have been split
|
|
1931
|
+
* by a secret-sharing mechanism. */
|
|
1932
|
+
splitPrivateKey: 16,
|
|
1933
|
+
/** 0x20 - This key may be used for authentication. */
|
|
1934
|
+
authentication: 32,
|
|
1935
|
+
/** This key may be used for forwarded communications */
|
|
1936
|
+
forwardedCommunication: 64,
|
|
1937
|
+
/** 0x80 - The private component of this key may be in the
|
|
1938
|
+
* possession of more than one person. */
|
|
1939
|
+
sharedPrivateKey: 128
|
|
1940
|
+
},
|
|
1941
|
+
|
|
1942
|
+
/** Armor type
|
|
1943
|
+
* @enum {Integer}
|
|
1944
|
+
* @readonly
|
|
1945
|
+
*/
|
|
1946
|
+
armor: {
|
|
1947
|
+
multipartSection: 0,
|
|
1948
|
+
multipartLast: 1,
|
|
1949
|
+
signed: 2,
|
|
1950
|
+
message: 3,
|
|
1951
|
+
publicKey: 4,
|
|
1952
|
+
privateKey: 5,
|
|
1953
|
+
signature: 6
|
|
1954
|
+
},
|
|
1955
|
+
|
|
1956
|
+
/** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
|
|
1957
|
+
* @enum {Integer}
|
|
1958
|
+
* @readonly
|
|
1959
|
+
*/
|
|
1960
|
+
reasonForRevocation: {
|
|
1961
|
+
/** No reason specified (key revocations or cert revocations) */
|
|
1962
|
+
noReason: 0,
|
|
1963
|
+
/** Key is superseded (key revocations) */
|
|
1964
|
+
keySuperseded: 1,
|
|
1965
|
+
/** Key material has been compromised (key revocations) */
|
|
1966
|
+
keyCompromised: 2,
|
|
1967
|
+
/** Key is retired and no longer used (key revocations) */
|
|
1968
|
+
keyRetired: 3,
|
|
1969
|
+
/** User ID information is no longer valid (cert revocations) */
|
|
1970
|
+
userIDInvalid: 32
|
|
1971
|
+
},
|
|
1972
|
+
|
|
1973
|
+
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
|
|
1974
|
+
* @enum {Integer}
|
|
1975
|
+
* @readonly
|
|
1976
|
+
*/
|
|
1977
|
+
features: {
|
|
1978
|
+
/** 0x01 - Modification Detection (packets 18 and 19) */
|
|
1979
|
+
modificationDetection: 1,
|
|
1980
|
+
/** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
|
|
1981
|
+
* Symmetric-Key Encrypted Session Key Packets (packet 3) */
|
|
1982
|
+
aead: 2,
|
|
1983
|
+
/** 0x04 - Version 5 Public-Key Packet format and corresponding new
|
|
1984
|
+
* fingerprint format */
|
|
1985
|
+
v5Keys: 4
|
|
1986
|
+
},
|
|
1987
|
+
|
|
1988
|
+
/**
|
|
1989
|
+
* Asserts validity of given value and converts from string/integer to integer.
|
|
1990
|
+
* @param {Object} type target enum type
|
|
1991
|
+
* @param {String|Integer} e value to check and/or convert
|
|
1992
|
+
* @returns {Integer} enum value if it exists
|
|
1993
|
+
* @throws {Error} if the value is invalid
|
|
1994
|
+
*/
|
|
1995
|
+
write: function(type, e) {
|
|
1996
|
+
if (typeof e === 'number') {
|
|
1997
|
+
e = this.read(type, e);
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
if (type[e] !== undefined) {
|
|
2001
|
+
return type[e];
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
throw new Error('Invalid enum value.');
|
|
2005
|
+
},
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Converts enum integer value to the corresponding string, if it exists.
|
|
2009
|
+
* @param {Object} type target enum type
|
|
2010
|
+
* @param {Integer} e value to convert
|
|
2011
|
+
* @returns {String} name of enum value if it exists
|
|
2012
|
+
* @throws {Error} if the value is invalid
|
|
2013
|
+
*/
|
|
2014
|
+
read: function(type, e) {
|
|
2015
|
+
if (!type[byValue]) {
|
|
2016
|
+
type[byValue] = [];
|
|
2017
|
+
Object.entries(type).forEach(([key, value]) => {
|
|
2018
|
+
type[byValue][value] = key;
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
if (type[byValue][e] !== undefined) {
|
|
2023
|
+
return type[byValue][e];
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
throw new Error('Invalid enum value.');
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
|
|
1510
2030
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
1511
2031
|
|
|
1512
2032
|
const debugMode = (() => {
|
|
@@ -2088,6 +2608,12 @@ const util = {
|
|
|
2088
2608
|
*/
|
|
2089
2609
|
selectUint8: function(cond, a, b) {
|
|
2090
2610
|
return (a & (256 - cond)) | (b & (255 + cond));
|
|
2611
|
+
},
|
|
2612
|
+
/**
|
|
2613
|
+
* @param {module:enums.symmetric} cipherAlgo
|
|
2614
|
+
*/
|
|
2615
|
+
isAES: function(cipherAlgo) {
|
|
2616
|
+
return cipherAlgo === enums.symmetric.aes128 || cipherAlgo === enums.symmetric.aes192 || cipherAlgo === enums.symmetric.aes256;
|
|
2091
2617
|
}
|
|
2092
2618
|
};
|
|
2093
2619
|
|
|
@@ -2202,517 +2728,6 @@ function uint8ArrayToB64(bytes, url) {
|
|
|
2202
2728
|
return encoded;
|
|
2203
2729
|
}
|
|
2204
2730
|
|
|
2205
|
-
/**
|
|
2206
|
-
* @module enums
|
|
2207
|
-
*/
|
|
2208
|
-
|
|
2209
|
-
const byValue = Symbol('byValue');
|
|
2210
|
-
|
|
2211
|
-
var enums = {
|
|
2212
|
-
|
|
2213
|
-
/** Maps curve names under various standards to one
|
|
2214
|
-
* @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
|
|
2215
|
-
* @enum {String}
|
|
2216
|
-
* @readonly
|
|
2217
|
-
*/
|
|
2218
|
-
curve: {
|
|
2219
|
-
/** NIST P-256 Curve */
|
|
2220
|
-
'p256': 'p256',
|
|
2221
|
-
'P-256': 'p256',
|
|
2222
|
-
'secp256r1': 'p256',
|
|
2223
|
-
'prime256v1': 'p256',
|
|
2224
|
-
'1.2.840.10045.3.1.7': 'p256',
|
|
2225
|
-
'2a8648ce3d030107': 'p256',
|
|
2226
|
-
'2A8648CE3D030107': 'p256',
|
|
2227
|
-
|
|
2228
|
-
/** NIST P-384 Curve */
|
|
2229
|
-
'p384': 'p384',
|
|
2230
|
-
'P-384': 'p384',
|
|
2231
|
-
'secp384r1': 'p384',
|
|
2232
|
-
'1.3.132.0.34': 'p384',
|
|
2233
|
-
'2b81040022': 'p384',
|
|
2234
|
-
'2B81040022': 'p384',
|
|
2235
|
-
|
|
2236
|
-
/** NIST P-521 Curve */
|
|
2237
|
-
'p521': 'p521',
|
|
2238
|
-
'P-521': 'p521',
|
|
2239
|
-
'secp521r1': 'p521',
|
|
2240
|
-
'1.3.132.0.35': 'p521',
|
|
2241
|
-
'2b81040023': 'p521',
|
|
2242
|
-
'2B81040023': 'p521',
|
|
2243
|
-
|
|
2244
|
-
/** SECG SECP256k1 Curve */
|
|
2245
|
-
'secp256k1': 'secp256k1',
|
|
2246
|
-
'1.3.132.0.10': 'secp256k1',
|
|
2247
|
-
'2b8104000a': 'secp256k1',
|
|
2248
|
-
'2B8104000A': 'secp256k1',
|
|
2249
|
-
|
|
2250
|
-
/** Ed25519 */
|
|
2251
|
-
'ED25519': 'ed25519',
|
|
2252
|
-
'ed25519': 'ed25519',
|
|
2253
|
-
'Ed25519': 'ed25519',
|
|
2254
|
-
'1.3.6.1.4.1.11591.15.1': 'ed25519',
|
|
2255
|
-
'2b06010401da470f01': 'ed25519',
|
|
2256
|
-
'2B06010401DA470F01': 'ed25519',
|
|
2257
|
-
|
|
2258
|
-
/** Curve25519 */
|
|
2259
|
-
'X25519': 'curve25519',
|
|
2260
|
-
'cv25519': 'curve25519',
|
|
2261
|
-
'curve25519': 'curve25519',
|
|
2262
|
-
'Curve25519': 'curve25519',
|
|
2263
|
-
'1.3.6.1.4.1.3029.1.5.1': 'curve25519',
|
|
2264
|
-
'2b060104019755010501': 'curve25519',
|
|
2265
|
-
'2B060104019755010501': 'curve25519',
|
|
2266
|
-
|
|
2267
|
-
/** BrainpoolP256r1 Curve */
|
|
2268
|
-
'brainpoolP256r1': 'brainpoolP256r1',
|
|
2269
|
-
'1.3.36.3.3.2.8.1.1.7': 'brainpoolP256r1',
|
|
2270
|
-
'2b2403030208010107': 'brainpoolP256r1',
|
|
2271
|
-
'2B2403030208010107': 'brainpoolP256r1',
|
|
2272
|
-
|
|
2273
|
-
/** BrainpoolP384r1 Curve */
|
|
2274
|
-
'brainpoolP384r1': 'brainpoolP384r1',
|
|
2275
|
-
'1.3.36.3.3.2.8.1.1.11': 'brainpoolP384r1',
|
|
2276
|
-
'2b240303020801010b': 'brainpoolP384r1',
|
|
2277
|
-
'2B240303020801010B': 'brainpoolP384r1',
|
|
2278
|
-
|
|
2279
|
-
/** BrainpoolP512r1 Curve */
|
|
2280
|
-
'brainpoolP512r1': 'brainpoolP512r1',
|
|
2281
|
-
'1.3.36.3.3.2.8.1.1.13': 'brainpoolP512r1',
|
|
2282
|
-
'2b240303020801010d': 'brainpoolP512r1',
|
|
2283
|
-
'2B240303020801010D': 'brainpoolP512r1'
|
|
2284
|
-
},
|
|
2285
|
-
|
|
2286
|
-
/** KDF parameters flags
|
|
2287
|
-
* Non-standard extensions (for now) to allow email forwarding
|
|
2288
|
-
* @enum {Integer}
|
|
2289
|
-
* @readonly
|
|
2290
|
-
*/
|
|
2291
|
-
kdfFlags: {
|
|
2292
|
-
/** Specify fingerprint to use instead of the recipient's */
|
|
2293
|
-
replace_fingerprint: 0x01,
|
|
2294
|
-
/** Specify custom parameters to use in the KDF digest computation */
|
|
2295
|
-
replace_kdf_params: 0x02
|
|
2296
|
-
},
|
|
2297
|
-
|
|
2298
|
-
/** A string to key specifier type
|
|
2299
|
-
* @enum {Integer}
|
|
2300
|
-
* @readonly
|
|
2301
|
-
*/
|
|
2302
|
-
s2k: {
|
|
2303
|
-
simple: 0,
|
|
2304
|
-
salted: 1,
|
|
2305
|
-
iterated: 3,
|
|
2306
|
-
argon2: 4,
|
|
2307
|
-
gnu: 101
|
|
2308
|
-
},
|
|
2309
|
-
|
|
2310
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.1|RFC4880bis-04, section 9.1}
|
|
2311
|
-
* @enum {Integer}
|
|
2312
|
-
* @readonly
|
|
2313
|
-
*/
|
|
2314
|
-
publicKey: {
|
|
2315
|
-
/** RSA (Encrypt or Sign) [HAC] */
|
|
2316
|
-
rsaEncryptSign: 1,
|
|
2317
|
-
/** RSA (Encrypt only) [HAC] */
|
|
2318
|
-
rsaEncrypt: 2,
|
|
2319
|
-
/** RSA (Sign only) [HAC] */
|
|
2320
|
-
rsaSign: 3,
|
|
2321
|
-
/** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
|
|
2322
|
-
elgamal: 16,
|
|
2323
|
-
/** DSA (Sign only) [FIPS186] [HAC] */
|
|
2324
|
-
dsa: 17,
|
|
2325
|
-
/** ECDH (Encrypt only) [RFC6637] */
|
|
2326
|
-
ecdh: 18,
|
|
2327
|
-
/** ECDSA (Sign only) [RFC6637] */
|
|
2328
|
-
ecdsa: 19,
|
|
2329
|
-
/** EdDSA (Sign only)
|
|
2330
|
-
* [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
|
|
2331
|
-
eddsa: 22,
|
|
2332
|
-
/** Reserved for AEDH */
|
|
2333
|
-
aedh: 23,
|
|
2334
|
-
/** Reserved for AEDSA */
|
|
2335
|
-
aedsa: 24,
|
|
2336
|
-
/** Symmetric authenticated encryption algorithms */
|
|
2337
|
-
aead: 100,
|
|
2338
|
-
/** Authentication using CMAC */
|
|
2339
|
-
hmac: 101
|
|
2340
|
-
},
|
|
2341
|
-
|
|
2342
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
|
|
2343
|
-
* @enum {Integer}
|
|
2344
|
-
* @readonly
|
|
2345
|
-
*/
|
|
2346
|
-
symmetric: {
|
|
2347
|
-
plaintext: 0,
|
|
2348
|
-
/** Not implemented! */
|
|
2349
|
-
idea: 1,
|
|
2350
|
-
tripledes: 2,
|
|
2351
|
-
cast5: 3,
|
|
2352
|
-
blowfish: 4,
|
|
2353
|
-
aes128: 7,
|
|
2354
|
-
aes192: 8,
|
|
2355
|
-
aes256: 9,
|
|
2356
|
-
twofish: 10
|
|
2357
|
-
},
|
|
2358
|
-
|
|
2359
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
|
|
2360
|
-
* @enum {Integer}
|
|
2361
|
-
* @readonly
|
|
2362
|
-
*/
|
|
2363
|
-
compression: {
|
|
2364
|
-
uncompressed: 0,
|
|
2365
|
-
/** RFC1951 */
|
|
2366
|
-
zip: 1,
|
|
2367
|
-
/** RFC1950 */
|
|
2368
|
-
zlib: 2,
|
|
2369
|
-
bzip2: 3
|
|
2370
|
-
},
|
|
2371
|
-
|
|
2372
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
|
|
2373
|
-
* @enum {Integer}
|
|
2374
|
-
* @readonly
|
|
2375
|
-
*/
|
|
2376
|
-
hash: {
|
|
2377
|
-
md5: 1,
|
|
2378
|
-
sha1: 2,
|
|
2379
|
-
ripemd: 3,
|
|
2380
|
-
sha256: 8,
|
|
2381
|
-
sha384: 9,
|
|
2382
|
-
sha512: 10,
|
|
2383
|
-
sha224: 11
|
|
2384
|
-
},
|
|
2385
|
-
|
|
2386
|
-
/** A list of hash names as accepted by webCrypto functions.
|
|
2387
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
|
|
2388
|
-
* @enum {String}
|
|
2389
|
-
*/
|
|
2390
|
-
webHash: {
|
|
2391
|
-
'SHA-1': 2,
|
|
2392
|
-
'SHA-256': 8,
|
|
2393
|
-
'SHA-384': 9,
|
|
2394
|
-
'SHA-512': 10
|
|
2395
|
-
},
|
|
2396
|
-
|
|
2397
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
|
|
2398
|
-
* @enum {Integer}
|
|
2399
|
-
* @readonly
|
|
2400
|
-
*/
|
|
2401
|
-
aead: {
|
|
2402
|
-
eax: 1,
|
|
2403
|
-
ocb: 2,
|
|
2404
|
-
experimentalGCM: 100 // Private algorithm
|
|
2405
|
-
},
|
|
2406
|
-
|
|
2407
|
-
/** A list of packet types and numeric tags associated with them.
|
|
2408
|
-
* @enum {Integer}
|
|
2409
|
-
* @readonly
|
|
2410
|
-
*/
|
|
2411
|
-
packet: {
|
|
2412
|
-
publicKeyEncryptedSessionKey: 1,
|
|
2413
|
-
signature: 2,
|
|
2414
|
-
symEncryptedSessionKey: 3,
|
|
2415
|
-
onePassSignature: 4,
|
|
2416
|
-
secretKey: 5,
|
|
2417
|
-
publicKey: 6,
|
|
2418
|
-
secretSubkey: 7,
|
|
2419
|
-
compressedData: 8,
|
|
2420
|
-
symmetricallyEncryptedData: 9,
|
|
2421
|
-
marker: 10,
|
|
2422
|
-
literalData: 11,
|
|
2423
|
-
trust: 12,
|
|
2424
|
-
userID: 13,
|
|
2425
|
-
publicSubkey: 14,
|
|
2426
|
-
userAttribute: 17,
|
|
2427
|
-
symEncryptedIntegrityProtectedData: 18,
|
|
2428
|
-
modificationDetectionCode: 19,
|
|
2429
|
-
aeadEncryptedData: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
|
|
2430
|
-
},
|
|
2431
|
-
|
|
2432
|
-
/** Data types in the literal packet
|
|
2433
|
-
* @enum {Integer}
|
|
2434
|
-
* @readonly
|
|
2435
|
-
*/
|
|
2436
|
-
literal: {
|
|
2437
|
-
/** Binary data 'b' */
|
|
2438
|
-
binary: 'b'.charCodeAt(),
|
|
2439
|
-
/** Text data 't' */
|
|
2440
|
-
text: 't'.charCodeAt(),
|
|
2441
|
-
/** Utf8 data 'u' */
|
|
2442
|
-
utf8: 'u'.charCodeAt(),
|
|
2443
|
-
/** MIME message body part 'm' */
|
|
2444
|
-
mime: 'm'.charCodeAt()
|
|
2445
|
-
},
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
/** One pass signature packet type
|
|
2449
|
-
* @enum {Integer}
|
|
2450
|
-
* @readonly
|
|
2451
|
-
*/
|
|
2452
|
-
signature: {
|
|
2453
|
-
/** 0x00: Signature of a binary document. */
|
|
2454
|
-
binary: 0,
|
|
2455
|
-
/** 0x01: Signature of a canonical text document.
|
|
2456
|
-
*
|
|
2457
|
-
* Canonicalyzing the document by converting line endings. */
|
|
2458
|
-
text: 1,
|
|
2459
|
-
/** 0x02: Standalone signature.
|
|
2460
|
-
*
|
|
2461
|
-
* This signature is a signature of only its own subpacket contents.
|
|
2462
|
-
* It is calculated identically to a signature over a zero-lengh
|
|
2463
|
-
* binary document. Note that it doesn't make sense to have a V3
|
|
2464
|
-
* standalone signature. */
|
|
2465
|
-
standalone: 2,
|
|
2466
|
-
/** 0x10: Generic certification of a User ID and Public-Key packet.
|
|
2467
|
-
*
|
|
2468
|
-
* The issuer of this certification does not make any particular
|
|
2469
|
-
* assertion as to how well the certifier has checked that the owner
|
|
2470
|
-
* of the key is in fact the person described by the User ID. */
|
|
2471
|
-
certGeneric: 16,
|
|
2472
|
-
/** 0x11: Persona certification of a User ID and Public-Key packet.
|
|
2473
|
-
*
|
|
2474
|
-
* The issuer of this certification has not done any verification of
|
|
2475
|
-
* the claim that the owner of this key is the User ID specified. */
|
|
2476
|
-
certPersona: 17,
|
|
2477
|
-
/** 0x12: Casual certification of a User ID and Public-Key packet.
|
|
2478
|
-
*
|
|
2479
|
-
* The issuer of this certification has done some casual
|
|
2480
|
-
* verification of the claim of identity. */
|
|
2481
|
-
certCasual: 18,
|
|
2482
|
-
/** 0x13: Positive certification of a User ID and Public-Key packet.
|
|
2483
|
-
*
|
|
2484
|
-
* The issuer of this certification has done substantial
|
|
2485
|
-
* verification of the claim of identity.
|
|
2486
|
-
*
|
|
2487
|
-
* Most OpenPGP implementations make their "key signatures" as 0x10
|
|
2488
|
-
* certifications. Some implementations can issue 0x11-0x13
|
|
2489
|
-
* certifications, but few differentiate between the types. */
|
|
2490
|
-
certPositive: 19,
|
|
2491
|
-
/** 0x30: Certification revocation signature
|
|
2492
|
-
*
|
|
2493
|
-
* This signature revokes an earlier User ID certification signature
|
|
2494
|
-
* (signature class 0x10 through 0x13) or direct-key signature
|
|
2495
|
-
* (0x1F). It should be issued by the same key that issued the
|
|
2496
|
-
* revoked signature or an authorized revocation key. The signature
|
|
2497
|
-
* is computed over the same data as the certificate that it
|
|
2498
|
-
* revokes, and should have a later creation date than that
|
|
2499
|
-
* certificate. */
|
|
2500
|
-
certRevocation: 48,
|
|
2501
|
-
/** 0x18: Subkey Binding Signature
|
|
2502
|
-
*
|
|
2503
|
-
* This signature is a statement by the top-level signing key that
|
|
2504
|
-
* indicates that it owns the subkey. This signature is calculated
|
|
2505
|
-
* directly on the primary key and subkey, and not on any User ID or
|
|
2506
|
-
* other packets. A signature that binds a signing subkey MUST have
|
|
2507
|
-
* an Embedded Signature subpacket in this binding signature that
|
|
2508
|
-
* contains a 0x19 signature made by the signing subkey on the
|
|
2509
|
-
* primary key and subkey. */
|
|
2510
|
-
subkeyBinding: 24,
|
|
2511
|
-
/** 0x19: Primary Key Binding Signature
|
|
2512
|
-
*
|
|
2513
|
-
* This signature is a statement by a signing subkey, indicating
|
|
2514
|
-
* that it is owned by the primary key and subkey. This signature
|
|
2515
|
-
* is calculated the same way as a 0x18 signature: directly on the
|
|
2516
|
-
* primary key and subkey, and not on any User ID or other packets.
|
|
2517
|
-
*
|
|
2518
|
-
* When a signature is made over a key, the hash data starts with the
|
|
2519
|
-
* octet 0x99, followed by a two-octet length of the key, and then body
|
|
2520
|
-
* of the key packet. (Note that this is an old-style packet header for
|
|
2521
|
-
* a key packet with two-octet length.) A subkey binding signature
|
|
2522
|
-
* (type 0x18) or primary key binding signature (type 0x19) then hashes
|
|
2523
|
-
* the subkey using the same format as the main key (also using 0x99 as
|
|
2524
|
-
* the first octet). */
|
|
2525
|
-
keyBinding: 25,
|
|
2526
|
-
/** 0x1F: Signature directly on a key
|
|
2527
|
-
*
|
|
2528
|
-
* This signature is calculated directly on a key. It binds the
|
|
2529
|
-
* information in the Signature subpackets to the key, and is
|
|
2530
|
-
* appropriate to be used for subpackets that provide information
|
|
2531
|
-
* about the key, such as the Revocation Key subpacket. It is also
|
|
2532
|
-
* appropriate for statements that non-self certifiers want to make
|
|
2533
|
-
* about the key itself, rather than the binding between a key and a
|
|
2534
|
-
* name. */
|
|
2535
|
-
key: 31,
|
|
2536
|
-
/** 0x20: Key revocation signature
|
|
2537
|
-
*
|
|
2538
|
-
* The signature is calculated directly on the key being revoked. A
|
|
2539
|
-
* revoked key is not to be used. Only revocation signatures by the
|
|
2540
|
-
* key being revoked, or by an authorized revocation key, should be
|
|
2541
|
-
* considered valid revocation signatures.a */
|
|
2542
|
-
keyRevocation: 32,
|
|
2543
|
-
/** 0x28: Subkey revocation signature
|
|
2544
|
-
*
|
|
2545
|
-
* The signature is calculated directly on the subkey being revoked.
|
|
2546
|
-
* A revoked subkey is not to be used. Only revocation signatures
|
|
2547
|
-
* by the top-level signature key that is bound to this subkey, or
|
|
2548
|
-
* by an authorized revocation key, should be considered valid
|
|
2549
|
-
* revocation signatures.
|
|
2550
|
-
*
|
|
2551
|
-
* Key revocation signatures (types 0x20 and 0x28)
|
|
2552
|
-
* hash only the key being revoked. */
|
|
2553
|
-
subkeyRevocation: 40,
|
|
2554
|
-
/** 0x40: Timestamp signature.
|
|
2555
|
-
* This signature is only meaningful for the timestamp contained in
|
|
2556
|
-
* it. */
|
|
2557
|
-
timestamp: 64,
|
|
2558
|
-
/** 0x50: Third-Party Confirmation signature.
|
|
2559
|
-
*
|
|
2560
|
-
* This signature is a signature over some other OpenPGP Signature
|
|
2561
|
-
* packet(s). It is analogous to a notary seal on the signed data.
|
|
2562
|
-
* A third-party signature SHOULD include Signature Target
|
|
2563
|
-
* subpacket(s) to give easy identification. Note that we really do
|
|
2564
|
-
* mean SHOULD. There are plausible uses for this (such as a blind
|
|
2565
|
-
* party that only sees the signature, not the key or source
|
|
2566
|
-
* document) that cannot include a target subpacket. */
|
|
2567
|
-
thirdParty: 80
|
|
2568
|
-
},
|
|
2569
|
-
|
|
2570
|
-
/** Signature subpacket type
|
|
2571
|
-
* @enum {Integer}
|
|
2572
|
-
* @readonly
|
|
2573
|
-
*/
|
|
2574
|
-
signatureSubpacket: {
|
|
2575
|
-
signatureCreationTime: 2,
|
|
2576
|
-
signatureExpirationTime: 3,
|
|
2577
|
-
exportableCertification: 4,
|
|
2578
|
-
trustSignature: 5,
|
|
2579
|
-
regularExpression: 6,
|
|
2580
|
-
revocable: 7,
|
|
2581
|
-
keyExpirationTime: 9,
|
|
2582
|
-
placeholderBackwardsCompatibility: 10,
|
|
2583
|
-
preferredSymmetricAlgorithms: 11,
|
|
2584
|
-
revocationKey: 12,
|
|
2585
|
-
issuer: 16,
|
|
2586
|
-
notationData: 20,
|
|
2587
|
-
preferredHashAlgorithms: 21,
|
|
2588
|
-
preferredCompressionAlgorithms: 22,
|
|
2589
|
-
keyServerPreferences: 23,
|
|
2590
|
-
preferredKeyServer: 24,
|
|
2591
|
-
primaryUserID: 25,
|
|
2592
|
-
policyURI: 26,
|
|
2593
|
-
keyFlags: 27,
|
|
2594
|
-
signersUserID: 28,
|
|
2595
|
-
reasonForRevocation: 29,
|
|
2596
|
-
features: 30,
|
|
2597
|
-
signatureTarget: 31,
|
|
2598
|
-
embeddedSignature: 32,
|
|
2599
|
-
issuerFingerprint: 33,
|
|
2600
|
-
preferredAEADAlgorithms: 34
|
|
2601
|
-
},
|
|
2602
|
-
|
|
2603
|
-
/** Key flags
|
|
2604
|
-
* @enum {Integer}
|
|
2605
|
-
* @readonly
|
|
2606
|
-
*/
|
|
2607
|
-
keyFlags: {
|
|
2608
|
-
/** 0x01 - This key may be used to certify other keys. */
|
|
2609
|
-
certifyKeys: 1,
|
|
2610
|
-
/** 0x02 - This key may be used to sign data. */
|
|
2611
|
-
signData: 2,
|
|
2612
|
-
/** 0x04 - This key may be used to encrypt communications. */
|
|
2613
|
-
encryptCommunication: 4,
|
|
2614
|
-
/** 0x08 - This key may be used to encrypt storage. */
|
|
2615
|
-
encryptStorage: 8,
|
|
2616
|
-
/** 0x10 - The private component of this key may have been split
|
|
2617
|
-
* by a secret-sharing mechanism. */
|
|
2618
|
-
splitPrivateKey: 16,
|
|
2619
|
-
/** 0x20 - This key may be used for authentication. */
|
|
2620
|
-
authentication: 32,
|
|
2621
|
-
/** This key may be used for forwarded communications */
|
|
2622
|
-
forwardedCommunication: 64,
|
|
2623
|
-
/** 0x80 - The private component of this key may be in the
|
|
2624
|
-
* possession of more than one person. */
|
|
2625
|
-
sharedPrivateKey: 128
|
|
2626
|
-
},
|
|
2627
|
-
|
|
2628
|
-
/** Armor type
|
|
2629
|
-
* @enum {Integer}
|
|
2630
|
-
* @readonly
|
|
2631
|
-
*/
|
|
2632
|
-
armor: {
|
|
2633
|
-
multipartSection: 0,
|
|
2634
|
-
multipartLast: 1,
|
|
2635
|
-
signed: 2,
|
|
2636
|
-
message: 3,
|
|
2637
|
-
publicKey: 4,
|
|
2638
|
-
privateKey: 5,
|
|
2639
|
-
signature: 6
|
|
2640
|
-
},
|
|
2641
|
-
|
|
2642
|
-
/** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
|
|
2643
|
-
* @enum {Integer}
|
|
2644
|
-
* @readonly
|
|
2645
|
-
*/
|
|
2646
|
-
reasonForRevocation: {
|
|
2647
|
-
/** No reason specified (key revocations or cert revocations) */
|
|
2648
|
-
noReason: 0,
|
|
2649
|
-
/** Key is superseded (key revocations) */
|
|
2650
|
-
keySuperseded: 1,
|
|
2651
|
-
/** Key material has been compromised (key revocations) */
|
|
2652
|
-
keyCompromised: 2,
|
|
2653
|
-
/** Key is retired and no longer used (key revocations) */
|
|
2654
|
-
keyRetired: 3,
|
|
2655
|
-
/** User ID information is no longer valid (cert revocations) */
|
|
2656
|
-
userIDInvalid: 32
|
|
2657
|
-
},
|
|
2658
|
-
|
|
2659
|
-
/** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
|
|
2660
|
-
* @enum {Integer}
|
|
2661
|
-
* @readonly
|
|
2662
|
-
*/
|
|
2663
|
-
features: {
|
|
2664
|
-
/** 0x01 - Modification Detection (packets 18 and 19) */
|
|
2665
|
-
modificationDetection: 1,
|
|
2666
|
-
/** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
|
|
2667
|
-
* Symmetric-Key Encrypted Session Key Packets (packet 3) */
|
|
2668
|
-
aead: 2,
|
|
2669
|
-
/** 0x04 - Version 5 Public-Key Packet format and corresponding new
|
|
2670
|
-
* fingerprint format */
|
|
2671
|
-
v5Keys: 4
|
|
2672
|
-
},
|
|
2673
|
-
|
|
2674
|
-
/**
|
|
2675
|
-
* Asserts validity of given value and converts from string/integer to integer.
|
|
2676
|
-
* @param {Object} type target enum type
|
|
2677
|
-
* @param {String|Integer} e value to check and/or convert
|
|
2678
|
-
* @returns {Integer} enum value if it exists
|
|
2679
|
-
* @throws {Error} if the value is invalid
|
|
2680
|
-
*/
|
|
2681
|
-
write: function(type, e) {
|
|
2682
|
-
if (typeof e === 'number') {
|
|
2683
|
-
e = this.read(type, e);
|
|
2684
|
-
}
|
|
2685
|
-
|
|
2686
|
-
if (type[e] !== undefined) {
|
|
2687
|
-
return type[e];
|
|
2688
|
-
}
|
|
2689
|
-
|
|
2690
|
-
throw new Error('Invalid enum value.');
|
|
2691
|
-
},
|
|
2692
|
-
|
|
2693
|
-
/**
|
|
2694
|
-
* Converts enum integer value to the corresponding string, if it exists.
|
|
2695
|
-
* @param {Object} type target enum type
|
|
2696
|
-
* @param {Integer} e value to convert
|
|
2697
|
-
* @returns {String} name of enum value if it exists
|
|
2698
|
-
* @throws {Error} if the value is invalid
|
|
2699
|
-
*/
|
|
2700
|
-
read: function(type, e) {
|
|
2701
|
-
if (!type[byValue]) {
|
|
2702
|
-
type[byValue] = [];
|
|
2703
|
-
Object.entries(type).forEach(([key, value]) => {
|
|
2704
|
-
type[byValue][value] = key;
|
|
2705
|
-
});
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
if (type[byValue][e] !== undefined) {
|
|
2709
|
-
return type[byValue][e];
|
|
2710
|
-
}
|
|
2711
|
-
|
|
2712
|
-
throw new Error('Invalid enum value.');
|
|
2713
|
-
}
|
|
2714
|
-
};
|
|
2715
|
-
|
|
2716
2731
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
2717
2732
|
|
|
2718
2733
|
var config = {
|
|
@@ -2929,7 +2944,7 @@ var config = {
|
|
|
2929
2944
|
* @memberof module:config
|
|
2930
2945
|
* @property {String} versionString A version string to be included in armored messages
|
|
2931
2946
|
*/
|
|
2932
|
-
versionString: 'OpenPGP.js 5.
|
|
2947
|
+
versionString: 'OpenPGP.js 5.10.2',
|
|
2933
2948
|
/**
|
|
2934
2949
|
* @memberof module:config
|
|
2935
2950
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -3421,6 +3436,7 @@ class KeyID {
|
|
|
3421
3436
|
*/
|
|
3422
3437
|
read(bytes) {
|
|
3423
3438
|
this.bytes = util.uint8ArrayToString(bytes.subarray(0, 8));
|
|
3439
|
+
return this.bytes.length;
|
|
3424
3440
|
}
|
|
3425
3441
|
|
|
3426
3442
|
/**
|
|
@@ -9967,7 +9983,7 @@ async function encrypt(algo, key, plaintext, iv, config) {
|
|
|
9967
9983
|
if (util.getNodeCrypto() && nodeAlgos[algoName]) { // Node crypto library.
|
|
9968
9984
|
return nodeEncrypt(algo, key, plaintext, iv);
|
|
9969
9985
|
}
|
|
9970
|
-
if (
|
|
9986
|
+
if (util.isAES(algo)) {
|
|
9971
9987
|
return aesEncrypt(algo, key, plaintext, iv, config);
|
|
9972
9988
|
}
|
|
9973
9989
|
|
|
@@ -10010,7 +10026,7 @@ async function decrypt(algo, key, ciphertext, iv) {
|
|
|
10010
10026
|
if (util.getNodeCrypto() && nodeAlgos[algoName]) { // Node crypto library.
|
|
10011
10027
|
return nodeDecrypt(algo, key, ciphertext, iv);
|
|
10012
10028
|
}
|
|
10013
|
-
if (
|
|
10029
|
+
if (util.isAES(algo)) {
|
|
10014
10030
|
return aesDecrypt(algo, key, ciphertext, iv);
|
|
10015
10031
|
}
|
|
10016
10032
|
|
|
@@ -10029,7 +10045,7 @@ async function decrypt(algo, key, ciphertext, iv) {
|
|
|
10029
10045
|
let j = 0;
|
|
10030
10046
|
while (chunk ? ct.length >= block_size : ct.length) {
|
|
10031
10047
|
const decblock = cipherfn.encrypt(blockp);
|
|
10032
|
-
blockp = ct;
|
|
10048
|
+
blockp = ct.subarray(0, block_size);
|
|
10033
10049
|
for (i = 0; i < block_size; i++) {
|
|
10034
10050
|
plaintext[j++] = blockp[i] ^ decblock[i];
|
|
10035
10051
|
}
|
|
@@ -13598,7 +13614,7 @@ const curves = {
|
|
|
13598
13614
|
}
|
|
13599
13615
|
};
|
|
13600
13616
|
|
|
13601
|
-
class
|
|
13617
|
+
class CurveWithOID {
|
|
13602
13618
|
constructor(oidOrName, params) {
|
|
13603
13619
|
try {
|
|
13604
13620
|
if (util.isArray(oidOrName) ||
|
|
@@ -13675,7 +13691,7 @@ class Curve {
|
|
|
13675
13691
|
async function generate$1(curve) {
|
|
13676
13692
|
const BigInteger = await util.getBigInteger();
|
|
13677
13693
|
|
|
13678
|
-
curve = new
|
|
13694
|
+
curve = new CurveWithOID(curve);
|
|
13679
13695
|
const keyPair = await curve.genKeyPair();
|
|
13680
13696
|
const Q = new BigInteger(keyPair.publicKey).toUint8Array();
|
|
13681
13697
|
const secret = new BigInteger(keyPair.privateKey).toUint8Array('be', curve.payloadSize);
|
|
@@ -13866,7 +13882,7 @@ const nodeCrypto$8 = util.getNodeCrypto();
|
|
|
13866
13882
|
* @async
|
|
13867
13883
|
*/
|
|
13868
13884
|
async function sign$1(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
13869
|
-
const curve = new
|
|
13885
|
+
const curve = new CurveWithOID(oid);
|
|
13870
13886
|
if (message && !util.isStream(message)) {
|
|
13871
13887
|
const keyPair = { publicKey, privateKey };
|
|
13872
13888
|
switch (curve.type) {
|
|
@@ -13911,7 +13927,7 @@ async function sign$1(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
13911
13927
|
* @async
|
|
13912
13928
|
*/
|
|
13913
13929
|
async function verify$1(oid, hashAlgo, signature, message, publicKey, hashed) {
|
|
13914
|
-
const curve = new
|
|
13930
|
+
const curve = new CurveWithOID(oid);
|
|
13915
13931
|
if (message && !util.isStream(message)) {
|
|
13916
13932
|
switch (curve.type) {
|
|
13917
13933
|
case 'web':
|
|
@@ -13945,7 +13961,7 @@ async function verify$1(oid, hashAlgo, signature, message, publicKey, hashed) {
|
|
|
13945
13961
|
* @async
|
|
13946
13962
|
*/
|
|
13947
13963
|
async function validateParams$2(oid, Q, d) {
|
|
13948
|
-
const curve = new
|
|
13964
|
+
const curve = new CurveWithOID(oid);
|
|
13949
13965
|
// Reject curves x25519 and ed25519
|
|
13950
13966
|
if (curve.keyType !== enums.publicKey.ecdsa) {
|
|
13951
13967
|
return false;
|
|
@@ -14148,7 +14164,7 @@ var ecdsa = /*#__PURE__*/Object.freeze({
|
|
|
14148
14164
|
naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
|
|
14149
14165
|
|
|
14150
14166
|
/**
|
|
14151
|
-
* Sign a message using the provided key
|
|
14167
|
+
* Sign a message using the provided legacy EdDSA key
|
|
14152
14168
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14153
14169
|
* @param {module:enums.hash} hashAlgo - Hash algorithm used to sign (must be sha256 or stronger)
|
|
14154
14170
|
* @param {Uint8Array} message - Message to sign
|
|
@@ -14176,7 +14192,7 @@ async function sign$2(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
14176
14192
|
}
|
|
14177
14193
|
|
|
14178
14194
|
/**
|
|
14179
|
-
* Verifies if a signature is valid for a message
|
|
14195
|
+
* Verifies if a legacy EdDSA signature is valid for a message
|
|
14180
14196
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14181
14197
|
* @param {module:enums.hash} hashAlgo - Hash algorithm used in the signature
|
|
14182
14198
|
* @param {{r: Uint8Array,
|
|
@@ -14192,7 +14208,7 @@ async function verify$2(oid, hashAlgo, { r, s }, m, publicKey, hashed) {
|
|
|
14192
14208
|
return naclFastLight.sign.detached.verify(hashed, signature, publicKey.subarray(1));
|
|
14193
14209
|
}
|
|
14194
14210
|
/**
|
|
14195
|
-
* Validate EdDSA parameters
|
|
14211
|
+
* Validate legacy EdDSA parameters
|
|
14196
14212
|
* @param {module:type/oid} oid - Elliptic curve object identifier
|
|
14197
14213
|
* @param {Uint8Array} Q - EdDSA public point
|
|
14198
14214
|
* @param {Uint8Array} k - EdDSA secret seed
|
|
@@ -14212,9 +14228,10 @@ async function validateParams$3(oid, Q, k) {
|
|
|
14212
14228
|
const { publicKey } = naclFastLight.sign.keyPair.fromSeed(k);
|
|
14213
14229
|
const dG = new Uint8Array([0x40, ...publicKey]); // Add public key prefix
|
|
14214
14230
|
return util.equalsUint8Array(Q, dG);
|
|
14231
|
+
|
|
14215
14232
|
}
|
|
14216
14233
|
|
|
14217
|
-
var
|
|
14234
|
+
var eddsa_legacy = /*#__PURE__*/Object.freeze({
|
|
14218
14235
|
__proto__: null,
|
|
14219
14236
|
sign: sign$2,
|
|
14220
14237
|
verify: verify$2,
|
|
@@ -14223,6 +14240,113 @@ var eddsa = /*#__PURE__*/Object.freeze({
|
|
|
14223
14240
|
|
|
14224
14241
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14225
14242
|
|
|
14243
|
+
naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
|
|
14244
|
+
|
|
14245
|
+
/**
|
|
14246
|
+
* Generate (non-legacy) EdDSA key
|
|
14247
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14248
|
+
* @returns {Promise<{ A: Uint8Array, seed: Uint8Array }>}
|
|
14249
|
+
*/
|
|
14250
|
+
async function generate$2(algo) {
|
|
14251
|
+
switch (algo) {
|
|
14252
|
+
case enums.publicKey.ed25519: {
|
|
14253
|
+
const seed = getRandomBytes(32);
|
|
14254
|
+
const { publicKey: A } = naclFastLight.sign.keyPair.fromSeed(seed);
|
|
14255
|
+
return { A, seed };
|
|
14256
|
+
}
|
|
14257
|
+
default:
|
|
14258
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14259
|
+
}
|
|
14260
|
+
}
|
|
14261
|
+
|
|
14262
|
+
/**
|
|
14263
|
+
* Sign a message using the provided key
|
|
14264
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14265
|
+
* @param {module:enums.hash} hashAlgo - Hash algorithm used to sign (must be sha256 or stronger)
|
|
14266
|
+
* @param {Uint8Array} message - Message to sign
|
|
14267
|
+
* @param {Uint8Array} publicKey - Public key
|
|
14268
|
+
* @param {Uint8Array} privateKey - Private key used to sign the message
|
|
14269
|
+
* @param {Uint8Array} hashed - The hashed message
|
|
14270
|
+
* @returns {Promise<{
|
|
14271
|
+
* RS: Uint8Array
|
|
14272
|
+
* }>} Signature of the message
|
|
14273
|
+
* @async
|
|
14274
|
+
*/
|
|
14275
|
+
async function sign$3(algo, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
14276
|
+
if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(enums.hash.sha256)) {
|
|
14277
|
+
// see https://tools.ietf.org/id/draft-ietf-openpgp-rfc4880bis-10.html#section-15-7.2
|
|
14278
|
+
throw new Error('Hash algorithm too weak: sha256 or stronger is required for EdDSA.');
|
|
14279
|
+
}
|
|
14280
|
+
switch (algo) {
|
|
14281
|
+
case enums.publicKey.ed25519: {
|
|
14282
|
+
const secretKey = util.concatUint8Array([privateKey, publicKey]);
|
|
14283
|
+
const signature = naclFastLight.sign.detached(hashed, secretKey);
|
|
14284
|
+
return { RS: signature };
|
|
14285
|
+
}
|
|
14286
|
+
case enums.publicKey.ed448:
|
|
14287
|
+
default:
|
|
14288
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14289
|
+
}
|
|
14290
|
+
|
|
14291
|
+
}
|
|
14292
|
+
|
|
14293
|
+
/**
|
|
14294
|
+
* Verifies if a signature is valid for a message
|
|
14295
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14296
|
+
* @param {module:enums.hash} hashAlgo - Hash algorithm used in the signature
|
|
14297
|
+
* @param {{ RS: Uint8Array }} signature Signature to verify the message
|
|
14298
|
+
* @param {Uint8Array} m - Message to verify
|
|
14299
|
+
* @param {Uint8Array} publicKey - Public key used to verify the message
|
|
14300
|
+
* @param {Uint8Array} hashed - The hashed message
|
|
14301
|
+
* @returns {Boolean}
|
|
14302
|
+
* @async
|
|
14303
|
+
*/
|
|
14304
|
+
async function verify$3(algo, hashAlgo, { RS }, m, publicKey, hashed) {
|
|
14305
|
+
switch (algo) {
|
|
14306
|
+
case enums.publicKey.ed25519: {
|
|
14307
|
+
return naclFastLight.sign.detached.verify(hashed, RS, publicKey);
|
|
14308
|
+
}
|
|
14309
|
+
case enums.publicKey.ed448:
|
|
14310
|
+
default:
|
|
14311
|
+
throw new Error('Unsupported EdDSA algorithm');
|
|
14312
|
+
}
|
|
14313
|
+
}
|
|
14314
|
+
/**
|
|
14315
|
+
* Validate (non-legacy) EdDSA parameters
|
|
14316
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14317
|
+
* @param {Uint8Array} A - EdDSA public point
|
|
14318
|
+
* @param {Uint8Array} seed - EdDSA secret seed
|
|
14319
|
+
* @param {Uint8Array} oid - (legacy only) EdDSA OID
|
|
14320
|
+
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14321
|
+
* @async
|
|
14322
|
+
*/
|
|
14323
|
+
async function validateParams$4(algo, A, seed) {
|
|
14324
|
+
switch (algo) {
|
|
14325
|
+
case enums.publicKey.ed25519: {
|
|
14326
|
+
/**
|
|
14327
|
+
* Derive public point A' from private key
|
|
14328
|
+
* and expect A == A'
|
|
14329
|
+
*/
|
|
14330
|
+
const { publicKey } = naclFastLight.sign.keyPair.fromSeed(seed);
|
|
14331
|
+
return util.equalsUint8Array(A, publicKey);
|
|
14332
|
+
}
|
|
14333
|
+
|
|
14334
|
+
case enums.publicKey.ed448: // unsupported
|
|
14335
|
+
default:
|
|
14336
|
+
return false;
|
|
14337
|
+
}
|
|
14338
|
+
}
|
|
14339
|
+
|
|
14340
|
+
var eddsa = /*#__PURE__*/Object.freeze({
|
|
14341
|
+
__proto__: null,
|
|
14342
|
+
generate: generate$2,
|
|
14343
|
+
sign: sign$3,
|
|
14344
|
+
verify: verify$3,
|
|
14345
|
+
validateParams: validateParams$4
|
|
14346
|
+
});
|
|
14347
|
+
|
|
14348
|
+
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14349
|
+
|
|
14226
14350
|
/**
|
|
14227
14351
|
* AES key wrap
|
|
14228
14352
|
* @function
|
|
@@ -14410,7 +14534,7 @@ const nodeCrypto$9 = util.getNodeCrypto();
|
|
|
14410
14534
|
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14411
14535
|
* @async
|
|
14412
14536
|
*/
|
|
14413
|
-
async function validateParams$
|
|
14537
|
+
async function validateParams$5(oid, Q, d) {
|
|
14414
14538
|
return validateStandardParams(enums.publicKey.ecdh, oid, Q, d);
|
|
14415
14539
|
}
|
|
14416
14540
|
|
|
@@ -14452,7 +14576,7 @@ async function kdf(hashAlgo, X, length, param, stripLeading = false, stripTraili
|
|
|
14452
14576
|
/**
|
|
14453
14577
|
* Generate ECDHE ephemeral key and secret from public key
|
|
14454
14578
|
*
|
|
14455
|
-
* @param {
|
|
14579
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14456
14580
|
* @param {Uint8Array} Q - Recipient public key
|
|
14457
14581
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14458
14582
|
* @async
|
|
@@ -14495,7 +14619,7 @@ async function genPublicEphemeralKey(curve, Q) {
|
|
|
14495
14619
|
async function encrypt$3(oid, kdfParams, data, Q, fingerprint) {
|
|
14496
14620
|
const m = encode$1(data);
|
|
14497
14621
|
|
|
14498
|
-
const curve = new
|
|
14622
|
+
const curve = new CurveWithOID(oid);
|
|
14499
14623
|
const { publicKey, sharedKey } = await genPublicEphemeralKey(curve, Q);
|
|
14500
14624
|
const param = buildEcdhParam(enums.publicKey.ecdh, oid, kdfParams, fingerprint);
|
|
14501
14625
|
const { keySize } = getCipher(kdfParams.cipher);
|
|
@@ -14507,7 +14631,7 @@ async function encrypt$3(oid, kdfParams, data, Q, fingerprint) {
|
|
|
14507
14631
|
/**
|
|
14508
14632
|
* Generate ECDHE secret from private key and public part of ephemeral key
|
|
14509
14633
|
*
|
|
14510
|
-
* @param {
|
|
14634
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14511
14635
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14512
14636
|
* @param {Uint8Array} Q - Recipient public key
|
|
14513
14637
|
* @param {Uint8Array} d - Recipient private key
|
|
@@ -14555,7 +14679,7 @@ async function genPrivateEphemeralKey(curve, V, Q, d) {
|
|
|
14555
14679
|
* @async
|
|
14556
14680
|
*/
|
|
14557
14681
|
async function decrypt$3(oid, kdfParams, V, C, Q, d, fingerprint) {
|
|
14558
|
-
const curve = new
|
|
14682
|
+
const curve = new CurveWithOID(oid);
|
|
14559
14683
|
const { sharedKey } = await genPrivateEphemeralKey(curve, V, Q, d);
|
|
14560
14684
|
const param = buildEcdhParam(enums.publicKey.ecdh, oid, kdfParams, fingerprint);
|
|
14561
14685
|
const { keySize } = getCipher(kdfParams.cipher);
|
|
@@ -14575,7 +14699,7 @@ async function decrypt$3(oid, kdfParams, V, C, Q, d, fingerprint) {
|
|
|
14575
14699
|
/**
|
|
14576
14700
|
* Generate ECDHE secret from private key and public part of ephemeral key using webCrypto
|
|
14577
14701
|
*
|
|
14578
|
-
* @param {
|
|
14702
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14579
14703
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14580
14704
|
* @param {Uint8Array} Q - Recipient public key
|
|
14581
14705
|
* @param {Uint8Array} d - Recipient private key
|
|
@@ -14628,7 +14752,7 @@ async function webPrivateEphemeralKey(curve, V, Q, d) {
|
|
|
14628
14752
|
/**
|
|
14629
14753
|
* Generate ECDHE ephemeral key and secret from public key using webCrypto
|
|
14630
14754
|
*
|
|
14631
|
-
* @param {
|
|
14755
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14632
14756
|
* @param {Uint8Array} Q - Recipient public key
|
|
14633
14757
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14634
14758
|
* @async
|
|
@@ -14676,7 +14800,7 @@ async function webPublicEphemeralKey(curve, Q) {
|
|
|
14676
14800
|
/**
|
|
14677
14801
|
* Generate ECDHE secret from private key and public part of ephemeral key using indutny/elliptic
|
|
14678
14802
|
*
|
|
14679
|
-
* @param {
|
|
14803
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14680
14804
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14681
14805
|
* @param {Uint8Array} d - Recipient private key
|
|
14682
14806
|
* @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
@@ -14696,7 +14820,7 @@ async function ellipticPrivateEphemeralKey(curve, V, d) {
|
|
|
14696
14820
|
/**
|
|
14697
14821
|
* Generate ECDHE ephemeral key and secret from public key using indutny/elliptic
|
|
14698
14822
|
*
|
|
14699
|
-
* @param {
|
|
14823
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14700
14824
|
* @param {Uint8Array} Q - Recipient public key
|
|
14701
14825
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14702
14826
|
* @async
|
|
@@ -14716,7 +14840,7 @@ async function ellipticPublicEphemeralKey(curve, Q) {
|
|
|
14716
14840
|
/**
|
|
14717
14841
|
* Generate ECDHE secret from private key and public part of ephemeral key using nodeCrypto
|
|
14718
14842
|
*
|
|
14719
|
-
* @param {
|
|
14843
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14720
14844
|
* @param {Uint8Array} V - Public part of ephemeral key
|
|
14721
14845
|
* @param {Uint8Array} d - Recipient private key
|
|
14722
14846
|
* @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
@@ -14733,7 +14857,7 @@ async function nodePrivateEphemeralKey(curve, V, d) {
|
|
|
14733
14857
|
/**
|
|
14734
14858
|
* Generate ECDHE ephemeral key and secret from public key using nodeCrypto
|
|
14735
14859
|
*
|
|
14736
|
-
* @param {
|
|
14860
|
+
* @param {CurveWithOID} curve - Elliptic curve object
|
|
14737
14861
|
* @param {Uint8Array} Q - Recipient public key
|
|
14738
14862
|
* @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>}
|
|
14739
14863
|
* @async
|
|
@@ -14748,18 +14872,204 @@ async function nodePublicEphemeralKey(curve, Q) {
|
|
|
14748
14872
|
|
|
14749
14873
|
var ecdh = /*#__PURE__*/Object.freeze({
|
|
14750
14874
|
__proto__: null,
|
|
14751
|
-
validateParams: validateParams$
|
|
14875
|
+
validateParams: validateParams$5,
|
|
14752
14876
|
encrypt: encrypt$3,
|
|
14753
14877
|
decrypt: decrypt$3
|
|
14754
14878
|
});
|
|
14755
14879
|
|
|
14880
|
+
/**
|
|
14881
|
+
* @fileoverview This module implements HKDF using either the WebCrypto API or Node.js' crypto API.
|
|
14882
|
+
* @module crypto/hkdf
|
|
14883
|
+
* @private
|
|
14884
|
+
*/
|
|
14885
|
+
|
|
14886
|
+
const webCrypto$9 = util.getWebCrypto();
|
|
14887
|
+
const nodeCrypto$a = util.getNodeCrypto();
|
|
14888
|
+
const nodeSubtleCrypto = nodeCrypto$a && nodeCrypto$a.webcrypto && nodeCrypto$a.webcrypto.subtle;
|
|
14889
|
+
|
|
14890
|
+
async function HKDF(hashAlgo, inputKey, salt, info, outLen) {
|
|
14891
|
+
const hash = enums.read(enums.webHash, hashAlgo);
|
|
14892
|
+
if (!hash) throw new Error('Hash algo not supported with HKDF');
|
|
14893
|
+
|
|
14894
|
+
if (webCrypto$9 || nodeSubtleCrypto) {
|
|
14895
|
+
const crypto = webCrypto$9 || nodeSubtleCrypto;
|
|
14896
|
+
const importedKey = await crypto.importKey('raw', inputKey, 'HKDF', false, ['deriveBits']);
|
|
14897
|
+
const bits = await crypto.deriveBits({ name: 'HKDF', hash, salt, info }, importedKey, outLen * 8);
|
|
14898
|
+
return new Uint8Array(bits);
|
|
14899
|
+
}
|
|
14900
|
+
|
|
14901
|
+
if (nodeCrypto$a) {
|
|
14902
|
+
const hashAlgoName = enums.read(enums.hash, hashAlgo);
|
|
14903
|
+
// Node-only HKDF implementation based on https://www.rfc-editor.org/rfc/rfc5869
|
|
14904
|
+
|
|
14905
|
+
const computeHMAC = (hmacKey, hmacMessage) => nodeCrypto$a.createHmac(hashAlgoName, hmacKey).update(hmacMessage).digest();
|
|
14906
|
+
// Step 1: Extract
|
|
14907
|
+
// PRK = HMAC-Hash(salt, IKM)
|
|
14908
|
+
const pseudoRandomKey = computeHMAC(salt, inputKey);
|
|
14909
|
+
|
|
14910
|
+
const hashLen = pseudoRandomKey.length;
|
|
14911
|
+
|
|
14912
|
+
// Step 2: Expand
|
|
14913
|
+
// HKDF-Expand(PRK, info, L) -> OKM
|
|
14914
|
+
const n = Math.ceil(outLen / hashLen);
|
|
14915
|
+
const outputKeyingMaterial = new Uint8Array(n * hashLen);
|
|
14916
|
+
|
|
14917
|
+
// HMAC input buffer updated at each iteration
|
|
14918
|
+
const roundInput = new Uint8Array(hashLen + info.length + 1);
|
|
14919
|
+
// T_i and last byte are updated at each iteration, but `info` remains constant
|
|
14920
|
+
roundInput.set(info, hashLen);
|
|
14921
|
+
|
|
14922
|
+
for (let i = 0; i < n; i++) {
|
|
14923
|
+
// T(0) = empty string (zero length)
|
|
14924
|
+
// T(i) = HMAC-Hash(PRK, T(i-1) | info | i)
|
|
14925
|
+
roundInput[roundInput.length - 1] = i + 1;
|
|
14926
|
+
// t = T(i+1)
|
|
14927
|
+
const t = computeHMAC(pseudoRandomKey, i > 0 ? roundInput : roundInput.subarray(hashLen));
|
|
14928
|
+
roundInput.set(t, 0);
|
|
14929
|
+
|
|
14930
|
+
outputKeyingMaterial.set(t, i * hashLen);
|
|
14931
|
+
}
|
|
14932
|
+
|
|
14933
|
+
return outputKeyingMaterial.subarray(0, outLen);
|
|
14934
|
+
}
|
|
14935
|
+
|
|
14936
|
+
throw new Error('No HKDF implementation available');
|
|
14937
|
+
}
|
|
14938
|
+
|
|
14939
|
+
/**
|
|
14940
|
+
* @fileoverview Key encryption and decryption for RFC 6637 ECDH
|
|
14941
|
+
* @module crypto/public_key/elliptic/ecdh
|
|
14942
|
+
* @private
|
|
14943
|
+
*/
|
|
14944
|
+
|
|
14945
|
+
const HKDF_INFO = {
|
|
14946
|
+
x25519: util.encodeUTF8('OpenPGP X25519')
|
|
14947
|
+
};
|
|
14948
|
+
|
|
14949
|
+
/**
|
|
14950
|
+
* Generate ECDH key for Montgomery curves
|
|
14951
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14952
|
+
* @returns {Promise<{ A: Uint8Array, k: Uint8Array }>}
|
|
14953
|
+
*/
|
|
14954
|
+
async function generate$3(algo) {
|
|
14955
|
+
switch (algo) {
|
|
14956
|
+
case enums.publicKey.x25519: {
|
|
14957
|
+
// k stays in little-endian, unlike legacy ECDH over curve25519
|
|
14958
|
+
const k = getRandomBytes(32);
|
|
14959
|
+
k[0] &= 248;
|
|
14960
|
+
k[31] = (k[31] & 127) | 64;
|
|
14961
|
+
const { publicKey: A } = naclFastLight.box.keyPair.fromSecretKey(k);
|
|
14962
|
+
return { A, k };
|
|
14963
|
+
}
|
|
14964
|
+
default:
|
|
14965
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
14966
|
+
}
|
|
14967
|
+
}
|
|
14968
|
+
|
|
14969
|
+
/**
|
|
14970
|
+
* Validate ECDH parameters
|
|
14971
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14972
|
+
* @param {Uint8Array} A - ECDH public point
|
|
14973
|
+
* @param {Uint8Array} k - ECDH secret scalar
|
|
14974
|
+
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14975
|
+
* @async
|
|
14976
|
+
*/
|
|
14977
|
+
async function validateParams$6(algo, A, k) {
|
|
14978
|
+
switch (algo) {
|
|
14979
|
+
case enums.publicKey.x25519: {
|
|
14980
|
+
/**
|
|
14981
|
+
* Derive public point A' from private key
|
|
14982
|
+
* and expect A == A'
|
|
14983
|
+
*/
|
|
14984
|
+
const { publicKey } = naclFastLight.box.keyPair.fromSecretKey(k);
|
|
14985
|
+
return util.equalsUint8Array(A, publicKey);
|
|
14986
|
+
}
|
|
14987
|
+
|
|
14988
|
+
default:
|
|
14989
|
+
return false;
|
|
14990
|
+
}
|
|
14991
|
+
}
|
|
14992
|
+
|
|
14993
|
+
/**
|
|
14994
|
+
* Wrap and encrypt a session key
|
|
14995
|
+
*
|
|
14996
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
14997
|
+
* @param {Uint8Array} data - session key data to be encrypted
|
|
14998
|
+
* @param {Uint8Array} recipientA - Recipient public key (K_B)
|
|
14999
|
+
* @returns {Promise<{
|
|
15000
|
+
* ephemeralPublicKey: Uint8Array,
|
|
15001
|
+
* wrappedKey: Uint8Array
|
|
15002
|
+
* }>} ephemeral public key (K_A) and encrypted key
|
|
15003
|
+
* @async
|
|
15004
|
+
*/
|
|
15005
|
+
async function encrypt$4(algo, data, recipientA) {
|
|
15006
|
+
switch (algo) {
|
|
15007
|
+
case enums.publicKey.x25519: {
|
|
15008
|
+
const ephemeralSecretKey = getRandomBytes(32);
|
|
15009
|
+
const sharedSecret = naclFastLight.scalarMult(ephemeralSecretKey, recipientA);
|
|
15010
|
+
const { publicKey: ephemeralPublicKey } = naclFastLight.box.keyPair.fromSecretKey(ephemeralSecretKey);
|
|
15011
|
+
const hkdfInput = util.concatUint8Array([
|
|
15012
|
+
ephemeralPublicKey,
|
|
15013
|
+
recipientA,
|
|
15014
|
+
sharedSecret
|
|
15015
|
+
]);
|
|
15016
|
+
const { keySize } = getCipher(enums.symmetric.aes128);
|
|
15017
|
+
const encryptionKey = await HKDF(enums.hash.sha256, hkdfInput, new Uint8Array(), HKDF_INFO.x25519, keySize);
|
|
15018
|
+
const wrappedKey = wrap(encryptionKey, data);
|
|
15019
|
+
return { ephemeralPublicKey, wrappedKey };
|
|
15020
|
+
}
|
|
15021
|
+
|
|
15022
|
+
default:
|
|
15023
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
15024
|
+
}
|
|
15025
|
+
}
|
|
15026
|
+
|
|
15027
|
+
/**
|
|
15028
|
+
* Decrypt and unwrap the session key
|
|
15029
|
+
*
|
|
15030
|
+
* @param {module:enums.publicKey} algo - Algorithm identifier
|
|
15031
|
+
* @param {Uint8Array} ephemeralPublicKey - (K_A)
|
|
15032
|
+
* @param {Uint8Array} wrappedKey,
|
|
15033
|
+
* @param {Uint8Array} A - Recipient public key (K_b), needed for KDF
|
|
15034
|
+
* @param {Uint8Array} k - Recipient secret key (b)
|
|
15035
|
+
* @returns {Promise<Uint8Array>} decrypted session key data
|
|
15036
|
+
* @async
|
|
15037
|
+
*/
|
|
15038
|
+
async function decrypt$4(algo, ephemeralPublicKey, wrappedKey, A, k) {
|
|
15039
|
+
switch (algo) {
|
|
15040
|
+
case enums.publicKey.x25519: {
|
|
15041
|
+
const sharedSecret = naclFastLight.scalarMult(k, ephemeralPublicKey);
|
|
15042
|
+
const hkdfInput = util.concatUint8Array([
|
|
15043
|
+
ephemeralPublicKey,
|
|
15044
|
+
A,
|
|
15045
|
+
sharedSecret
|
|
15046
|
+
]);
|
|
15047
|
+
const { keySize } = getCipher(enums.symmetric.aes128);
|
|
15048
|
+
const encryptionKey = await HKDF(enums.hash.sha256, hkdfInput, new Uint8Array(), HKDF_INFO.x25519, keySize);
|
|
15049
|
+
return unwrap(encryptionKey, wrappedKey);
|
|
15050
|
+
}
|
|
15051
|
+
default:
|
|
15052
|
+
throw new Error('Unsupported ECDH algorithm');
|
|
15053
|
+
}
|
|
15054
|
+
}
|
|
15055
|
+
|
|
15056
|
+
var ecdh_x = /*#__PURE__*/Object.freeze({
|
|
15057
|
+
__proto__: null,
|
|
15058
|
+
generate: generate$3,
|
|
15059
|
+
validateParams: validateParams$6,
|
|
15060
|
+
encrypt: encrypt$4,
|
|
15061
|
+
decrypt: decrypt$4
|
|
15062
|
+
});
|
|
15063
|
+
|
|
14756
15064
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
14757
15065
|
|
|
14758
15066
|
var elliptic = /*#__PURE__*/Object.freeze({
|
|
14759
15067
|
__proto__: null,
|
|
14760
|
-
|
|
15068
|
+
CurveWithOID: CurveWithOID,
|
|
14761
15069
|
ecdh: ecdh,
|
|
15070
|
+
ecdhX: ecdh_x,
|
|
14762
15071
|
ecdsa: ecdsa,
|
|
15072
|
+
eddsaLegacy: eddsa_legacy,
|
|
14763
15073
|
eddsa: eddsa,
|
|
14764
15074
|
generate: generate$1,
|
|
14765
15075
|
getPreferredHashAlgo: getPreferredHashAlgo
|
|
@@ -14784,7 +15094,7 @@ var elliptic = /*#__PURE__*/Object.freeze({
|
|
|
14784
15094
|
* @returns {Promise<{ r: Uint8Array, s: Uint8Array }>}
|
|
14785
15095
|
* @async
|
|
14786
15096
|
*/
|
|
14787
|
-
async function sign$
|
|
15097
|
+
async function sign$4(hashAlgo, hashed, g, p, q, x) {
|
|
14788
15098
|
const BigInteger = await util.getBigInteger();
|
|
14789
15099
|
const one = new BigInteger(1);
|
|
14790
15100
|
p = new BigInteger(p);
|
|
@@ -14843,7 +15153,7 @@ async function sign$3(hashAlgo, hashed, g, p, q, x) {
|
|
|
14843
15153
|
* @returns {boolean}
|
|
14844
15154
|
* @async
|
|
14845
15155
|
*/
|
|
14846
|
-
async function verify$
|
|
15156
|
+
async function verify$4(hashAlgo, r, s, hashed, g, p, q, y) {
|
|
14847
15157
|
const BigInteger = await util.getBigInteger();
|
|
14848
15158
|
const zero = new BigInteger(0);
|
|
14849
15159
|
r = new BigInteger(r);
|
|
@@ -14886,7 +15196,7 @@ async function verify$3(hashAlgo, r, s, hashed, g, p, q, y) {
|
|
|
14886
15196
|
* @returns {Promise<Boolean>} Whether params are valid.
|
|
14887
15197
|
* @async
|
|
14888
15198
|
*/
|
|
14889
|
-
async function validateParams$
|
|
15199
|
+
async function validateParams$7(p, q, g, y, x) {
|
|
14890
15200
|
const BigInteger = await util.getBigInteger();
|
|
14891
15201
|
p = new BigInteger(p);
|
|
14892
15202
|
q = new BigInteger(q);
|
|
@@ -14941,9 +15251,9 @@ async function validateParams$5(p, q, g, y, x) {
|
|
|
14941
15251
|
|
|
14942
15252
|
var dsa = /*#__PURE__*/Object.freeze({
|
|
14943
15253
|
__proto__: null,
|
|
14944
|
-
sign: sign$
|
|
14945
|
-
verify: verify$
|
|
14946
|
-
validateParams: validateParams$
|
|
15254
|
+
sign: sign$4,
|
|
15255
|
+
verify: verify$4,
|
|
15256
|
+
validateParams: validateParams$7
|
|
14947
15257
|
});
|
|
14948
15258
|
|
|
14949
15259
|
/**
|
|
@@ -15079,10 +15389,11 @@ function parseSignatureParams(algo, signature) {
|
|
|
15079
15389
|
const s = util.readMPI(signature.subarray(read));
|
|
15080
15390
|
return { r, s };
|
|
15081
15391
|
}
|
|
15082
|
-
// Algorithm-Specific Fields for EdDSA signatures:
|
|
15392
|
+
// Algorithm-Specific Fields for legacy EdDSA signatures:
|
|
15083
15393
|
// - MPI of an EC point r.
|
|
15084
15394
|
// - EdDSA value s, in MPI, in the little endian representation
|
|
15085
|
-
case enums.publicKey.eddsa:
|
|
15395
|
+
case enums.publicKey.eddsa:
|
|
15396
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15086
15397
|
// When parsing little-endian MPI data, we always need to left-pad it, as done with big-endian values:
|
|
15087
15398
|
// https://www.ietf.org/archive/id/draft-ietf-openpgp-rfc4880bis-10.html#section-3.2-9
|
|
15088
15399
|
let r = util.readMPI(signature.subarray(read)); read += r.length + 2;
|
|
@@ -15091,7 +15402,12 @@ function parseSignatureParams(algo, signature) {
|
|
|
15091
15402
|
s = util.leftPad(s, 32);
|
|
15092
15403
|
return { r, s };
|
|
15093
15404
|
}
|
|
15094
|
-
|
|
15405
|
+
// Algorithm-Specific Fields for Ed25519 signatures:
|
|
15406
|
+
// - 64 octets of the native signature
|
|
15407
|
+
case enums.publicKey.ed25519: {
|
|
15408
|
+
const RS = signature.subarray(read, read + 64); read += RS.length;
|
|
15409
|
+
return { RS };
|
|
15410
|
+
}
|
|
15095
15411
|
case enums.publicKey.hmac: {
|
|
15096
15412
|
const mac = new ShortByteString(); mac.read(signature.subarray(read));
|
|
15097
15413
|
return { mac };
|
|
@@ -15116,7 +15432,7 @@ function parseSignatureParams(algo, signature) {
|
|
|
15116
15432
|
* @returns {Promise<Boolean>} True if signature is valid.
|
|
15117
15433
|
* @async
|
|
15118
15434
|
*/
|
|
15119
|
-
async function verify$
|
|
15435
|
+
async function verify$5(algo, hashAlgo, signature, publicParams, privateParams, data, hashed) {
|
|
15120
15436
|
switch (algo) {
|
|
15121
15437
|
case enums.publicKey.rsaEncryptSign:
|
|
15122
15438
|
case enums.publicKey.rsaEncrypt:
|
|
@@ -15132,16 +15448,21 @@ async function verify$4(algo, hashAlgo, signature, publicParams, privateParams,
|
|
|
15132
15448
|
}
|
|
15133
15449
|
case enums.publicKey.ecdsa: {
|
|
15134
15450
|
const { oid, Q } = publicParams;
|
|
15135
|
-
const curveSize = new publicKey.elliptic.
|
|
15451
|
+
const curveSize = new publicKey.elliptic.CurveWithOID(oid).payloadSize;
|
|
15136
15452
|
// padding needed for webcrypto
|
|
15137
15453
|
const r = util.leftPad(signature.r, curveSize);
|
|
15138
15454
|
const s = util.leftPad(signature.s, curveSize);
|
|
15139
15455
|
return publicKey.elliptic.ecdsa.verify(oid, hashAlgo, { r, s }, data, Q, hashed);
|
|
15140
15456
|
}
|
|
15141
|
-
case enums.publicKey.eddsa:
|
|
15457
|
+
case enums.publicKey.eddsa:
|
|
15458
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15142
15459
|
const { oid, Q } = publicParams;
|
|
15143
15460
|
// signature already padded on parsing
|
|
15144
|
-
return publicKey.elliptic.
|
|
15461
|
+
return publicKey.elliptic.eddsaLegacy.verify(oid, hashAlgo, signature, data, Q, hashed);
|
|
15462
|
+
}
|
|
15463
|
+
case enums.publicKey.ed25519: {
|
|
15464
|
+
const { A } = publicParams;
|
|
15465
|
+
return publicKey.elliptic.eddsa.verify(algo, hashAlgo, signature, data, A, hashed);
|
|
15145
15466
|
}
|
|
15146
15467
|
case enums.publicKey.hmac: {
|
|
15147
15468
|
if (!privateParams) {
|
|
@@ -15171,7 +15492,7 @@ async function verify$4(algo, hashAlgo, signature, publicParams, privateParams,
|
|
|
15171
15492
|
* @returns {Promise<Object>} Signature Object containing named signature parameters.
|
|
15172
15493
|
* @async
|
|
15173
15494
|
*/
|
|
15174
|
-
async function sign$
|
|
15495
|
+
async function sign$5(algo, hashAlgo, publicKeyParams, privateKeyParams, data, hashed) {
|
|
15175
15496
|
if (!publicKeyParams || !privateKeyParams) {
|
|
15176
15497
|
throw new Error('Missing key parameters');
|
|
15177
15498
|
}
|
|
@@ -15197,10 +15518,16 @@ async function sign$4(algo, hashAlgo, publicKeyParams, privateKeyParams, data, h
|
|
|
15197
15518
|
const { d } = privateKeyParams;
|
|
15198
15519
|
return publicKey.elliptic.ecdsa.sign(oid, hashAlgo, data, Q, d, hashed);
|
|
15199
15520
|
}
|
|
15200
|
-
case enums.publicKey.eddsa:
|
|
15521
|
+
case enums.publicKey.eddsa:
|
|
15522
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15201
15523
|
const { oid, Q } = publicKeyParams;
|
|
15202
15524
|
const { seed } = privateKeyParams;
|
|
15203
|
-
return publicKey.elliptic.
|
|
15525
|
+
return publicKey.elliptic.eddsaLegacy.sign(oid, hashAlgo, data, Q, seed, hashed);
|
|
15526
|
+
}
|
|
15527
|
+
case enums.publicKey.ed25519: {
|
|
15528
|
+
const { A } = publicKeyParams;
|
|
15529
|
+
const { seed } = privateKeyParams;
|
|
15530
|
+
return publicKey.elliptic.eddsa.sign(algo, hashAlgo, data, A, seed, hashed);
|
|
15204
15531
|
}
|
|
15205
15532
|
case enums.publicKey.hmac: {
|
|
15206
15533
|
const { cipher: algo } = publicKeyParams;
|
|
@@ -15216,34 +15543,31 @@ async function sign$4(algo, hashAlgo, publicKeyParams, privateKeyParams, data, h
|
|
|
15216
15543
|
var signature = /*#__PURE__*/Object.freeze({
|
|
15217
15544
|
__proto__: null,
|
|
15218
15545
|
parseSignatureParams: parseSignatureParams,
|
|
15219
|
-
verify: verify$
|
|
15220
|
-
sign: sign$
|
|
15546
|
+
verify: verify$5,
|
|
15547
|
+
sign: sign$5
|
|
15221
15548
|
});
|
|
15222
15549
|
|
|
15223
15550
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
15224
15551
|
|
|
15225
15552
|
class ECDHSymmetricKey {
|
|
15226
15553
|
constructor(data) {
|
|
15227
|
-
if (
|
|
15228
|
-
data =
|
|
15229
|
-
} else if (util.isString(data)) {
|
|
15230
|
-
data = util.stringToUint8Array(data);
|
|
15231
|
-
} else {
|
|
15232
|
-
data = new Uint8Array(data);
|
|
15554
|
+
if (data) {
|
|
15555
|
+
this.data = data;
|
|
15233
15556
|
}
|
|
15234
|
-
this.data = data;
|
|
15235
15557
|
}
|
|
15236
15558
|
|
|
15237
15559
|
/**
|
|
15238
|
-
* Read an ECDHSymmetricKey from an Uint8Array
|
|
15239
|
-
*
|
|
15560
|
+
* Read an ECDHSymmetricKey from an Uint8Array:
|
|
15561
|
+
* - 1 octect for the length `l`
|
|
15562
|
+
* - `l` octects of encoded session key data
|
|
15563
|
+
* @param {Uint8Array} bytes
|
|
15240
15564
|
* @returns {Number} Number of read bytes.
|
|
15241
15565
|
*/
|
|
15242
|
-
read(
|
|
15243
|
-
if (
|
|
15244
|
-
const length =
|
|
15245
|
-
if (
|
|
15246
|
-
this.data =
|
|
15566
|
+
read(bytes) {
|
|
15567
|
+
if (bytes.length >= 1) {
|
|
15568
|
+
const length = bytes[0];
|
|
15569
|
+
if (bytes.length >= 1 + length) {
|
|
15570
|
+
this.data = bytes.subarray(1, 1 + length);
|
|
15247
15571
|
return 1 + this.data.length;
|
|
15248
15572
|
}
|
|
15249
15573
|
}
|
|
@@ -15252,7 +15576,7 @@ class ECDHSymmetricKey {
|
|
|
15252
15576
|
|
|
15253
15577
|
/**
|
|
15254
15578
|
* Write an ECDHSymmetricKey as an Uint8Array
|
|
15255
|
-
* @returns {Uint8Array}
|
|
15579
|
+
* @returns {Uint8Array} Serialised data
|
|
15256
15580
|
*/
|
|
15257
15581
|
write() {
|
|
15258
15582
|
return util.concatUint8Array([new Uint8Array([this.data.length]), this.data]);
|
|
@@ -15292,6 +15616,9 @@ class KDFParams {
|
|
|
15292
15616
|
* @returns {Number} Number of read bytes.
|
|
15293
15617
|
*/
|
|
15294
15618
|
read(input) {
|
|
15619
|
+
if (input.length < 4 || (input[1] !== 1 && input[1] !== VERSION_FORWARDING)) {
|
|
15620
|
+
throw new UnsupportedError('Cannot read KDFParams');
|
|
15621
|
+
}
|
|
15295
15622
|
const totalBytes = input[0];
|
|
15296
15623
|
this.version = input[1];
|
|
15297
15624
|
this.hash = input[2];
|
|
@@ -15379,12 +15706,57 @@ const AEADEnum = type_enum(enums.aead);
|
|
|
15379
15706
|
const SymAlgoEnum = type_enum(enums.symmetric);
|
|
15380
15707
|
const HashEnum = type_enum(enums.hash);
|
|
15381
15708
|
|
|
15709
|
+
/**
|
|
15710
|
+
* Encoded symmetric key for x25519 and x448
|
|
15711
|
+
* The payload format varies for v3 and v6 PKESK:
|
|
15712
|
+
* the former includes an algorithm byte preceeding the encrypted session key.
|
|
15713
|
+
*
|
|
15714
|
+
* @module type/x25519x448_symkey
|
|
15715
|
+
*/
|
|
15716
|
+
|
|
15717
|
+
class ECDHXSymmetricKey {
|
|
15718
|
+
static fromObject({ wrappedKey, algorithm }) {
|
|
15719
|
+
const instance = new ECDHXSymmetricKey();
|
|
15720
|
+
instance.wrappedKey = wrappedKey;
|
|
15721
|
+
instance.algorithm = algorithm;
|
|
15722
|
+
return instance;
|
|
15723
|
+
}
|
|
15724
|
+
|
|
15725
|
+
/**
|
|
15726
|
+
* - 1 octect for the length `l`
|
|
15727
|
+
* - `l` octects of encoded session key data (with optional leading algorithm byte)
|
|
15728
|
+
* @param {Uint8Array} bytes
|
|
15729
|
+
* @returns {Number} Number of read bytes.
|
|
15730
|
+
*/
|
|
15731
|
+
read(bytes) {
|
|
15732
|
+
let read = 0;
|
|
15733
|
+
let followLength = bytes[read++];
|
|
15734
|
+
this.algorithm = followLength % 2 ? bytes[read++] : null; // session key size is always even
|
|
15735
|
+
followLength -= followLength % 2;
|
|
15736
|
+
this.wrappedKey = bytes.subarray(read, read + followLength); read += followLength;
|
|
15737
|
+
}
|
|
15738
|
+
|
|
15739
|
+
/**
|
|
15740
|
+
* Write an MontgomerySymmetricKey as an Uint8Array
|
|
15741
|
+
* @returns {Uint8Array} Serialised data
|
|
15742
|
+
*/
|
|
15743
|
+
write() {
|
|
15744
|
+
return util.concatUint8Array([
|
|
15745
|
+
this.algorithm ?
|
|
15746
|
+
new Uint8Array([this.wrappedKey.length + 1, this.algorithm]) :
|
|
15747
|
+
new Uint8Array([this.wrappedKey.length]),
|
|
15748
|
+
this.wrappedKey
|
|
15749
|
+
]);
|
|
15750
|
+
}
|
|
15751
|
+
}
|
|
15752
|
+
|
|
15382
15753
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
15383
15754
|
|
|
15384
15755
|
/**
|
|
15385
15756
|
* Encrypts data using specified algorithm and public key parameters.
|
|
15386
15757
|
* See {@link https://tools.ietf.org/html/rfc4880#section-9.1|RFC 4880 9.1} for public key algorithms.
|
|
15387
|
-
* @param {module:enums.publicKey}
|
|
15758
|
+
* @param {module:enums.publicKey} keyAlgo - Public key algorithm
|
|
15759
|
+
* @param {module:enums.symmetric} symmetricAlgo - Cipher algorithm
|
|
15388
15760
|
* @param {Object} publicParams - Algorithm-specific public key parameters
|
|
15389
15761
|
* @param {Object} privateParams - Algorithm-specific private key parameters
|
|
15390
15762
|
* @param {Uint8Array} data - Data to be encrypted
|
|
@@ -15392,8 +15764,8 @@ const HashEnum = type_enum(enums.hash);
|
|
|
15392
15764
|
* @returns {Promise<Object>} Encrypted session key parameters.
|
|
15393
15765
|
* @async
|
|
15394
15766
|
*/
|
|
15395
|
-
async function publicKeyEncrypt(
|
|
15396
|
-
switch (
|
|
15767
|
+
async function publicKeyEncrypt(keyAlgo, symmetricAlgo, publicParams, privateParams, data, fingerprint) {
|
|
15768
|
+
switch (keyAlgo) {
|
|
15397
15769
|
case enums.publicKey.rsaEncrypt:
|
|
15398
15770
|
case enums.publicKey.rsaEncryptSign: {
|
|
15399
15771
|
const { n, e } = publicParams;
|
|
@@ -15410,6 +15782,17 @@ async function publicKeyEncrypt(algo, publicParams, privateParams, data, fingerp
|
|
|
15410
15782
|
oid, kdfParams, data, Q, fingerprint);
|
|
15411
15783
|
return { V, C: new ECDHSymmetricKey(C) };
|
|
15412
15784
|
}
|
|
15785
|
+
case enums.publicKey.x25519: {
|
|
15786
|
+
if (!util.isAES(symmetricAlgo)) {
|
|
15787
|
+
// see https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/276
|
|
15788
|
+
throw new Error('X25519 keys can only encrypt AES session keys');
|
|
15789
|
+
}
|
|
15790
|
+
const { A } = publicParams;
|
|
15791
|
+
const { ephemeralPublicKey, wrappedKey } = await publicKey.elliptic.ecdhX.encrypt(
|
|
15792
|
+
keyAlgo, data, A);
|
|
15793
|
+
const C = ECDHXSymmetricKey.fromObject({ algorithm: symmetricAlgo, wrappedKey });
|
|
15794
|
+
return { ephemeralPublicKey, C };
|
|
15795
|
+
}
|
|
15413
15796
|
case enums.publicKey.aead: {
|
|
15414
15797
|
if (!privateParams) {
|
|
15415
15798
|
throw new Error('Cannot encrypt with symmetric key missing private parameters');
|
|
@@ -15466,6 +15849,16 @@ async function publicKeyDecrypt(algo, publicKeyParams, privateKeyParams, session
|
|
|
15466
15849
|
return publicKey.elliptic.ecdh.decrypt(
|
|
15467
15850
|
oid, kdfParams, V, C.data, Q, d, fingerprint);
|
|
15468
15851
|
}
|
|
15852
|
+
case enums.publicKey.x25519: {
|
|
15853
|
+
const { A } = publicKeyParams;
|
|
15854
|
+
const { k } = privateKeyParams;
|
|
15855
|
+
const { ephemeralPublicKey, C } = sessionKeyParams;
|
|
15856
|
+
if (!util.isAES(C.algorithm)) {
|
|
15857
|
+
throw new Error('AES session key expected');
|
|
15858
|
+
}
|
|
15859
|
+
return publicKey.elliptic.ecdhX.decrypt(
|
|
15860
|
+
algo, ephemeralPublicKey, C.wrappedKey, A, k);
|
|
15861
|
+
}
|
|
15469
15862
|
case enums.publicKey.aead: {
|
|
15470
15863
|
const { cipher: algo } = publicKeyParams;
|
|
15471
15864
|
const algoValue = algo.getValue();
|
|
@@ -15517,7 +15910,8 @@ function parsePublicKeyParams(algo, bytes) {
|
|
|
15517
15910
|
const Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
|
15518
15911
|
return { read: read, publicParams: { oid, Q } };
|
|
15519
15912
|
}
|
|
15520
|
-
case enums.publicKey.eddsa:
|
|
15913
|
+
case enums.publicKey.eddsa:
|
|
15914
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15521
15915
|
const oid = new OID(); read += oid.read(bytes);
|
|
15522
15916
|
checkSupportedCurve(oid);
|
|
15523
15917
|
let Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
|
@@ -15531,6 +15925,11 @@ function parsePublicKeyParams(algo, bytes) {
|
|
|
15531
15925
|
const kdfParams = new KDFParams(); read += kdfParams.read(bytes.subarray(read));
|
|
15532
15926
|
return { read: read, publicParams: { oid, Q, kdfParams } };
|
|
15533
15927
|
}
|
|
15928
|
+
case enums.publicKey.ed25519:
|
|
15929
|
+
case enums.publicKey.x25519: {
|
|
15930
|
+
const A = bytes.subarray(read, read + 32); read += A.length;
|
|
15931
|
+
return { read, publicParams: { A } };
|
|
15932
|
+
}
|
|
15534
15933
|
case enums.publicKey.hmac:
|
|
15535
15934
|
case enums.publicKey.aead: {
|
|
15536
15935
|
const algo = new SymAlgoEnum(); read += algo.read(bytes);
|
|
@@ -15569,17 +15968,26 @@ function parsePrivateKeyParams(algo, bytes, publicParams) {
|
|
|
15569
15968
|
}
|
|
15570
15969
|
case enums.publicKey.ecdsa:
|
|
15571
15970
|
case enums.publicKey.ecdh: {
|
|
15572
|
-
const curve = new
|
|
15971
|
+
const curve = new CurveWithOID(publicParams.oid);
|
|
15573
15972
|
let d = util.readMPI(bytes.subarray(read)); read += d.length + 2;
|
|
15574
15973
|
d = util.leftPad(d, curve.payloadSize);
|
|
15575
15974
|
return { read, privateParams: { d } };
|
|
15576
15975
|
}
|
|
15577
|
-
case enums.publicKey.eddsa:
|
|
15578
|
-
|
|
15976
|
+
case enums.publicKey.eddsa:
|
|
15977
|
+
case enums.publicKey.ed25519Legacy: {
|
|
15978
|
+
const curve = new CurveWithOID(publicParams.oid);
|
|
15579
15979
|
let seed = util.readMPI(bytes.subarray(read)); read += seed.length + 2;
|
|
15580
15980
|
seed = util.leftPad(seed, curve.payloadSize);
|
|
15581
15981
|
return { read, privateParams: { seed } };
|
|
15582
15982
|
}
|
|
15983
|
+
case enums.publicKey.ed25519: {
|
|
15984
|
+
const seed = bytes.subarray(read, read + 32); read += seed.length;
|
|
15985
|
+
return { read, privateParams: { seed } };
|
|
15986
|
+
}
|
|
15987
|
+
case enums.publicKey.x25519: {
|
|
15988
|
+
const k = bytes.subarray(read, read + 32); read += k.length;
|
|
15989
|
+
return { read, privateParams: { k } };
|
|
15990
|
+
}
|
|
15583
15991
|
case enums.publicKey.hmac: {
|
|
15584
15992
|
const { cipher: algo } = publicParams;
|
|
15585
15993
|
const keySize = hash.getHashByteLength(algo.getValue());
|
|
@@ -15631,6 +16039,16 @@ function parseEncSessionKeyParams(algo, bytes) {
|
|
|
15631
16039
|
const C = new ECDHSymmetricKey(); C.read(bytes.subarray(read));
|
|
15632
16040
|
return { V, C };
|
|
15633
16041
|
}
|
|
16042
|
+
// Algorithm-Specific Fields for X25519 encrypted session keys:
|
|
16043
|
+
// - 32 octets representing an ephemeral X25519 public key.
|
|
16044
|
+
// - A one-octet size of the following fields.
|
|
16045
|
+
// - The one-octet algorithm identifier, if it was passed (in the case of a v3 PKESK packet).
|
|
16046
|
+
// - The encrypted session key.
|
|
16047
|
+
case enums.publicKey.x25519: {
|
|
16048
|
+
const ephemeralPublicKey = bytes.subarray(read, read + 32); read += ephemeralPublicKey.length;
|
|
16049
|
+
const C = new ECDHXSymmetricKey(); C.read(bytes.subarray(read));
|
|
16050
|
+
return { ephemeralPublicKey, C };
|
|
16051
|
+
}
|
|
15634
16052
|
// Algorithm-Specific Fields for symmetric AEAD encryption:
|
|
15635
16053
|
// - AEAD algorithm
|
|
15636
16054
|
// - Starting initialization vector
|
|
@@ -15657,22 +16075,13 @@ function parseEncSessionKeyParams(algo, bytes) {
|
|
|
15657
16075
|
* @returns {Uint8Array} The array containing the MPIs.
|
|
15658
16076
|
*/
|
|
15659
16077
|
function serializeParams(algo, params) {
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
});
|
|
15668
|
-
break;
|
|
15669
|
-
}
|
|
15670
|
-
default:
|
|
15671
|
-
orderedParams = Object.keys(params).map(name => {
|
|
15672
|
-
const param = params[name];
|
|
15673
|
-
return util.isUint8Array(param) ? util.uint8ArrayToMPI(param) : param.write();
|
|
15674
|
-
});
|
|
15675
|
-
}
|
|
16078
|
+
// Some algorithms do not rely on MPIs to store the binary params
|
|
16079
|
+
const algosWithNativeRepresentation = new Set([enums.publicKey.ed25519, enums.publicKey.x25519, enums.publicKey.aead, enums.publicKey.hmac]);
|
|
16080
|
+
const orderedParams = Object.keys(params).map(name => {
|
|
16081
|
+
const param = params[name];
|
|
16082
|
+
if (!util.isUint8Array(param)) return param.write();
|
|
16083
|
+
return algosWithNativeRepresentation.has(algo) ? param : util.uint8ArrayToMPI(param);
|
|
16084
|
+
});
|
|
15676
16085
|
return util.concatUint8Array(orderedParams);
|
|
15677
16086
|
}
|
|
15678
16087
|
|
|
@@ -15701,6 +16110,7 @@ function generateParams(algo, bits, oid, symmetric) {
|
|
|
15701
16110
|
publicParams: { oid: new OID(oid), Q }
|
|
15702
16111
|
}));
|
|
15703
16112
|
case enums.publicKey.eddsa:
|
|
16113
|
+
case enums.publicKey.ed25519Legacy:
|
|
15704
16114
|
return publicKey.elliptic.generate(oid).then(({ oid, Q, secret }) => ({
|
|
15705
16115
|
privateParams: { seed: secret },
|
|
15706
16116
|
publicParams: { oid: new OID(oid), Q }
|
|
@@ -15714,6 +16124,16 @@ function generateParams(algo, bits, oid, symmetric) {
|
|
|
15714
16124
|
kdfParams: new KDFParams({ hash, cipher })
|
|
15715
16125
|
}
|
|
15716
16126
|
}));
|
|
16127
|
+
case enums.publicKey.ed25519:
|
|
16128
|
+
return publicKey.elliptic.eddsa.generate(algo).then(({ A, seed }) => ({
|
|
16129
|
+
privateParams: { seed },
|
|
16130
|
+
publicParams: { A }
|
|
16131
|
+
}));
|
|
16132
|
+
case enums.publicKey.x25519:
|
|
16133
|
+
return publicKey.elliptic.ecdhX.generate(algo).then(({ A, k }) => ({
|
|
16134
|
+
privateParams: { k },
|
|
16135
|
+
publicParams: { A }
|
|
16136
|
+
}));
|
|
15717
16137
|
case enums.publicKey.hmac: {
|
|
15718
16138
|
const symAlgo = enums.write(enums.hash, symmetric);
|
|
15719
16139
|
const keyMaterial = getRandomBytes(hash.getHashByteLength(symAlgo));
|
|
@@ -15755,7 +16175,7 @@ async function createSymmetricParams(key, algo) {
|
|
|
15755
16175
|
* @returns {Promise<Boolean>} Whether the parameters are valid.
|
|
15756
16176
|
* @async
|
|
15757
16177
|
*/
|
|
15758
|
-
async function validateParams$
|
|
16178
|
+
async function validateParams$8(algo, publicParams, privateParams) {
|
|
15759
16179
|
if (!publicParams || !privateParams) {
|
|
15760
16180
|
throw new Error('Missing key parameters');
|
|
15761
16181
|
}
|
|
@@ -15784,10 +16204,21 @@ async function validateParams$6(algo, publicParams, privateParams) {
|
|
|
15784
16204
|
const { d } = privateParams;
|
|
15785
16205
|
return algoModule.validateParams(oid, Q, d);
|
|
15786
16206
|
}
|
|
15787
|
-
case enums.publicKey.eddsa:
|
|
15788
|
-
|
|
16207
|
+
case enums.publicKey.eddsa:
|
|
16208
|
+
case enums.publicKey.ed25519Legacy: {
|
|
16209
|
+
const { Q, oid } = publicParams;
|
|
15789
16210
|
const { seed } = privateParams;
|
|
15790
|
-
return publicKey.elliptic.
|
|
16211
|
+
return publicKey.elliptic.eddsaLegacy.validateParams(oid, Q, seed);
|
|
16212
|
+
}
|
|
16213
|
+
case enums.publicKey.ed25519: {
|
|
16214
|
+
const { A } = publicParams;
|
|
16215
|
+
const { seed } = privateParams;
|
|
16216
|
+
return publicKey.elliptic.eddsa.validateParams(algo, A, seed);
|
|
16217
|
+
}
|
|
16218
|
+
case enums.publicKey.x25519: {
|
|
16219
|
+
const { A } = publicParams;
|
|
16220
|
+
const { k } = privateParams;
|
|
16221
|
+
return publicKey.elliptic.ecdhX.validateParams(algo, A, k);
|
|
15791
16222
|
}
|
|
15792
16223
|
case enums.publicKey.hmac: {
|
|
15793
16224
|
const { cipher: algo, digest } = publicParams;
|
|
@@ -15866,7 +16297,7 @@ var crypto$1 = /*#__PURE__*/Object.freeze({
|
|
|
15866
16297
|
parseEncSessionKeyParams: parseEncSessionKeyParams,
|
|
15867
16298
|
serializeParams: serializeParams,
|
|
15868
16299
|
generateParams: generateParams,
|
|
15869
|
-
validateParams: validateParams$
|
|
16300
|
+
validateParams: validateParams$8,
|
|
15870
16301
|
getPrefixRandom: getPrefixRandom,
|
|
15871
16302
|
generateSessionKey: generateSessionKey,
|
|
15872
16303
|
getAEADMode: getAEADMode,
|
|
@@ -16113,15 +16544,15 @@ class GenericS2K {
|
|
|
16113
16544
|
this.type = 'gnu-dummy';
|
|
16114
16545
|
// GnuPG extension mode 1001 -- don't write secret key at all
|
|
16115
16546
|
} else {
|
|
16116
|
-
throw new
|
|
16547
|
+
throw new UnsupportedError('Unknown s2k gnu protection mode.');
|
|
16117
16548
|
}
|
|
16118
16549
|
} else {
|
|
16119
|
-
throw new
|
|
16550
|
+
throw new UnsupportedError('Unknown s2k type.');
|
|
16120
16551
|
}
|
|
16121
16552
|
break;
|
|
16122
16553
|
|
|
16123
16554
|
default:
|
|
16124
|
-
throw new
|
|
16555
|
+
throw new UnsupportedError('Unknown s2k type.'); // unreachable
|
|
16125
16556
|
}
|
|
16126
16557
|
|
|
16127
16558
|
return i;
|
|
@@ -16225,7 +16656,7 @@ function newS2KFromType(type, config$1 = config) {
|
|
|
16225
16656
|
case enums.s2k.simple:
|
|
16226
16657
|
return new GenericS2K(type, config$1);
|
|
16227
16658
|
default:
|
|
16228
|
-
throw new
|
|
16659
|
+
throw new UnsupportedError(`Unsupported S2K type ${type}`);
|
|
16229
16660
|
}
|
|
16230
16661
|
}
|
|
16231
16662
|
|
|
@@ -24979,13 +25410,17 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
24979
25410
|
* @param {Uint8Array} bytes - Payload of a tag 1 packet
|
|
24980
25411
|
*/
|
|
24981
25412
|
read(bytes) {
|
|
24982
|
-
|
|
25413
|
+
let i = 0;
|
|
25414
|
+
this.version = bytes[i++];
|
|
24983
25415
|
if (this.version !== VERSION$3) {
|
|
24984
25416
|
throw new UnsupportedError(`Version ${this.version} of the PKESK packet is unsupported.`);
|
|
24985
25417
|
}
|
|
24986
|
-
this.publicKeyID.read(bytes.subarray(
|
|
24987
|
-
this.publicKeyAlgorithm = bytes[
|
|
24988
|
-
this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(
|
|
25418
|
+
i += this.publicKeyID.read(bytes.subarray(i));
|
|
25419
|
+
this.publicKeyAlgorithm = bytes[i++];
|
|
25420
|
+
this.encrypted = mod.parseEncSessionKeyParams(this.publicKeyAlgorithm, bytes.subarray(i), this.version);
|
|
25421
|
+
if (this.publicKeyAlgorithm === enums.publicKey.x25519) {
|
|
25422
|
+
this.sessionKeyAlgorithm = enums.write(enums.symmetric, this.encrypted.C.algorithm);
|
|
25423
|
+
}
|
|
24989
25424
|
}
|
|
24990
25425
|
|
|
24991
25426
|
/**
|
|
@@ -25011,15 +25446,11 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
25011
25446
|
* @async
|
|
25012
25447
|
*/
|
|
25013
25448
|
async encrypt(key) {
|
|
25014
|
-
const data = util.concatUint8Array([
|
|
25015
|
-
new Uint8Array([enums.write(enums.symmetric, this.sessionKeyAlgorithm)]),
|
|
25016
|
-
this.sessionKey,
|
|
25017
|
-
util.writeChecksum(this.sessionKey)
|
|
25018
|
-
]);
|
|
25019
25449
|
const algo = enums.write(enums.publicKey, this.publicKeyAlgorithm);
|
|
25450
|
+
const encoded = encodeSessionKey(this.version, algo, this.sessionKeyAlgorithm, this.sessionKey);
|
|
25020
25451
|
const privateParams = algo === enums.publicKey.aead ? key.privateParams : null;
|
|
25021
25452
|
this.encrypted = await mod.publicKeyEncrypt(
|
|
25022
|
-
algo, key.publicParams, privateParams,
|
|
25453
|
+
algo, this.sessionKeyAlgorithm, key.publicParams, privateParams, encoded, key.getFingerprintBytes());
|
|
25023
25454
|
}
|
|
25024
25455
|
|
|
25025
25456
|
/**
|
|
@@ -25036,34 +25467,86 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
25036
25467
|
throw new Error('Decryption error');
|
|
25037
25468
|
}
|
|
25038
25469
|
|
|
25039
|
-
const randomPayload = randomSessionKey ?
|
|
25040
|
-
|
|
25041
|
-
|
|
25042
|
-
|
|
25043
|
-
]) : null;
|
|
25044
|
-
const decoded = await mod.publicKeyDecrypt(this.publicKeyAlgorithm, key.publicParams, key.privateParams, this.encrypted, key.getFingerprintBytes(), randomPayload);
|
|
25045
|
-
const symmetricAlgoByte = decoded[0];
|
|
25046
|
-
const sessionKey = decoded.subarray(1, decoded.length - 2);
|
|
25047
|
-
const checksum = decoded.subarray(decoded.length - 2);
|
|
25048
|
-
const computedChecksum = util.writeChecksum(sessionKey);
|
|
25049
|
-
const isValidChecksum = computedChecksum[0] === checksum[0] & computedChecksum[1] === checksum[1];
|
|
25050
|
-
|
|
25051
|
-
if (randomSessionKey) {
|
|
25052
|
-
// We must not leak info about the validity of the decrypted checksum or cipher algo.
|
|
25053
|
-
// 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.
|
|
25054
|
-
const isValidPayload = isValidChecksum & symmetricAlgoByte === randomSessionKey.sessionKeyAlgorithm & sessionKey.length === randomSessionKey.sessionKey.length;
|
|
25055
|
-
this.sessionKeyAlgorithm = util.selectUint8(isValidPayload, symmetricAlgoByte, randomSessionKey.sessionKeyAlgorithm);
|
|
25056
|
-
this.sessionKey = util.selectUint8Array(isValidPayload, sessionKey, randomSessionKey.sessionKey);
|
|
25470
|
+
const randomPayload = randomSessionKey ?
|
|
25471
|
+
encodeSessionKey(this.version, this.publicKeyAlgorithm, randomSessionKey.sessionKeyAlgorithm, randomSessionKey.sessionKey) :
|
|
25472
|
+
null;
|
|
25473
|
+
const decryptedData = await mod.publicKeyDecrypt(this.publicKeyAlgorithm, key.publicParams, key.privateParams, this.encrypted, key.getFingerprintBytes(), randomPayload);
|
|
25057
25474
|
|
|
25058
|
-
}
|
|
25059
|
-
|
|
25060
|
-
|
|
25061
|
-
|
|
25062
|
-
|
|
25475
|
+
const { sessionKey, sessionKeyAlgorithm } = decodeSessionKey(this.version, this.publicKeyAlgorithm, decryptedData, randomSessionKey);
|
|
25476
|
+
|
|
25477
|
+
// v3 Montgomery curves have cleartext cipher algo
|
|
25478
|
+
if (this.publicKeyAlgorithm !== enums.publicKey.x25519) {
|
|
25479
|
+
this.sessionKeyAlgorithm = sessionKeyAlgorithm;
|
|
25480
|
+
}
|
|
25481
|
+
this.sessionKey = sessionKey;
|
|
25482
|
+
}
|
|
25483
|
+
}
|
|
25484
|
+
|
|
25485
|
+
|
|
25486
|
+
function encodeSessionKey(version, keyAlgo, cipherAlgo, sessionKeyData) {
|
|
25487
|
+
switch (keyAlgo) {
|
|
25488
|
+
case enums.publicKey.rsaEncrypt:
|
|
25489
|
+
case enums.publicKey.rsaEncryptSign:
|
|
25490
|
+
case enums.publicKey.elgamal:
|
|
25491
|
+
case enums.publicKey.ecdh:
|
|
25492
|
+
case enums.publicKey.aead: {
|
|
25493
|
+
// add checksum
|
|
25494
|
+
return util.concatUint8Array([
|
|
25495
|
+
new Uint8Array([cipherAlgo]),
|
|
25496
|
+
sessionKeyData,
|
|
25497
|
+
util.writeChecksum(sessionKeyData.subarray(sessionKeyData.length % 8))
|
|
25498
|
+
]);
|
|
25499
|
+
}
|
|
25500
|
+
case enums.publicKey.x25519:
|
|
25501
|
+
return sessionKeyData;
|
|
25502
|
+
default:
|
|
25503
|
+
throw new Error('Unsupported public key algorithm');
|
|
25504
|
+
}
|
|
25505
|
+
}
|
|
25506
|
+
|
|
25507
|
+
|
|
25508
|
+
function decodeSessionKey(version, keyAlgo, decryptedData, randomSessionKey) {
|
|
25509
|
+
switch (keyAlgo) {
|
|
25510
|
+
case enums.publicKey.rsaEncrypt:
|
|
25511
|
+
case enums.publicKey.rsaEncryptSign:
|
|
25512
|
+
case enums.publicKey.elgamal:
|
|
25513
|
+
case enums.publicKey.ecdh:
|
|
25514
|
+
case enums.publicKey.aead: {
|
|
25515
|
+
// verify checksum in constant time
|
|
25516
|
+
const result = decryptedData.subarray(0, decryptedData.length - 2);
|
|
25517
|
+
const checksum = decryptedData.subarray(decryptedData.length - 2);
|
|
25518
|
+
const computedChecksum = util.writeChecksum(result.subarray(result.length % 8));
|
|
25519
|
+
const isValidChecksum = computedChecksum[0] === checksum[0] & computedChecksum[1] === checksum[1];
|
|
25520
|
+
const decryptedSessionKey = { sessionKeyAlgorithm: result[0], sessionKey: result.subarray(1) };
|
|
25521
|
+
if (randomSessionKey) {
|
|
25522
|
+
// We must not leak info about the validity of the decrypted checksum or cipher algo.
|
|
25523
|
+
// 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.
|
|
25524
|
+
const isValidPayload = isValidChecksum &
|
|
25525
|
+
decryptedSessionKey.sessionKeyAlgorithm === randomSessionKey.sessionKeyAlgorithm &
|
|
25526
|
+
decryptedSessionKey.sessionKey.length === randomSessionKey.sessionKey.length;
|
|
25527
|
+
return {
|
|
25528
|
+
sessionKey: util.selectUint8Array(isValidPayload, decryptedSessionKey.sessionKey, randomSessionKey.sessionKey),
|
|
25529
|
+
sessionKeyAlgorithm: util.selectUint8(
|
|
25530
|
+
isValidPayload,
|
|
25531
|
+
decryptedSessionKey.sessionKeyAlgorithm,
|
|
25532
|
+
randomSessionKey.sessionKeyAlgorithm
|
|
25533
|
+
)
|
|
25534
|
+
};
|
|
25063
25535
|
} else {
|
|
25064
|
-
|
|
25536
|
+
const isValidPayload = isValidChecksum && enums.read(enums.symmetric, decryptedSessionKey.sessionKeyAlgorithm);
|
|
25537
|
+
if (isValidPayload) {
|
|
25538
|
+
return decryptedSessionKey;
|
|
25539
|
+
} else {
|
|
25540
|
+
throw new Error('Decryption error');
|
|
25541
|
+
}
|
|
25065
25542
|
}
|
|
25066
25543
|
}
|
|
25544
|
+
case enums.publicKey.x25519:
|
|
25545
|
+
return {
|
|
25546
|
+
sessionKey: decryptedData
|
|
25547
|
+
};
|
|
25548
|
+
default:
|
|
25549
|
+
throw new Error('Unsupported public key algorithm');
|
|
25067
25550
|
}
|
|
25068
25551
|
}
|
|
25069
25552
|
|
|
@@ -25494,7 +25977,7 @@ class PublicKeyPacket {
|
|
|
25494
25977
|
result.bits = util.uint8ArrayBitLength(modulo);
|
|
25495
25978
|
} else if (this.publicParams.oid) {
|
|
25496
25979
|
result.curve = this.publicParams.oid.getName();
|
|
25497
|
-
} else {
|
|
25980
|
+
} else if (this.publicParams.cipher) {
|
|
25498
25981
|
result.symmetric = this.publicParams.cipher.getName();
|
|
25499
25982
|
}
|
|
25500
25983
|
return result;
|
|
@@ -25826,6 +26309,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25826
26309
|
async read(bytes) {
|
|
25827
26310
|
// - A Public-Key or Public-Subkey packet, as described above.
|
|
25828
26311
|
let i = await this.readPublicKey(bytes);
|
|
26312
|
+
const startOfSecretKeyData = i;
|
|
25829
26313
|
|
|
25830
26314
|
// - One octet indicating string-to-key usage conventions. Zero
|
|
25831
26315
|
// indicates that the secret-key data is not encrypted. 255 or 254
|
|
@@ -25839,41 +26323,48 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25839
26323
|
i++;
|
|
25840
26324
|
}
|
|
25841
26325
|
|
|
25842
|
-
|
|
25843
|
-
|
|
25844
|
-
|
|
25845
|
-
this.
|
|
26326
|
+
try {
|
|
26327
|
+
// - [Optional] If string-to-key usage octet was 255, 254, or 253, a
|
|
26328
|
+
// one-octet symmetric encryption algorithm.
|
|
26329
|
+
if (this.s2kUsage === 255 || this.s2kUsage === 254 || this.s2kUsage === 253) {
|
|
26330
|
+
this.symmetric = bytes[i++];
|
|
25846
26331
|
|
|
25847
|
-
|
|
25848
|
-
|
|
25849
|
-
|
|
25850
|
-
|
|
25851
|
-
|
|
26332
|
+
// - [Optional] If string-to-key usage octet was 253, a one-octet
|
|
26333
|
+
// AEAD algorithm.
|
|
26334
|
+
if (this.s2kUsage === 253) {
|
|
26335
|
+
this.aead = bytes[i++];
|
|
26336
|
+
}
|
|
25852
26337
|
|
|
25853
|
-
|
|
25854
|
-
|
|
25855
|
-
|
|
25856
|
-
|
|
25857
|
-
|
|
25858
|
-
|
|
26338
|
+
// - [Optional] If string-to-key usage octet was 255, 254, or 253, a
|
|
26339
|
+
// string-to-key specifier. The length of the string-to-key
|
|
26340
|
+
// specifier is implied by its type, as described above.
|
|
26341
|
+
const s2kType = bytes[i++];
|
|
26342
|
+
this.s2k = newS2KFromType(s2kType);
|
|
26343
|
+
i += this.s2k.read(bytes.subarray(i, bytes.length));
|
|
25859
26344
|
|
|
25860
|
-
|
|
25861
|
-
|
|
26345
|
+
if (this.s2k.type === 'gnu-dummy') {
|
|
26346
|
+
return;
|
|
26347
|
+
}
|
|
26348
|
+
} else if (this.s2kUsage) {
|
|
26349
|
+
this.symmetric = this.s2kUsage;
|
|
25862
26350
|
}
|
|
25863
|
-
} else if (this.s2kUsage) {
|
|
25864
|
-
this.symmetric = this.s2kUsage;
|
|
25865
|
-
}
|
|
25866
26351
|
|
|
25867
|
-
|
|
25868
|
-
|
|
25869
|
-
|
|
25870
|
-
|
|
25871
|
-
|
|
25872
|
-
|
|
25873
|
-
|
|
25874
|
-
|
|
26352
|
+
// - [Optional] If secret data is encrypted (string-to-key usage octet
|
|
26353
|
+
// not zero), an Initial Vector (IV) of the same length as the
|
|
26354
|
+
// cipher's block size.
|
|
26355
|
+
if (this.s2kUsage) {
|
|
26356
|
+
this.iv = bytes.subarray(
|
|
26357
|
+
i,
|
|
26358
|
+
i + mod.getCipher(this.symmetric).blockSize
|
|
26359
|
+
);
|
|
25875
26360
|
|
|
25876
|
-
|
|
26361
|
+
i += this.iv.length;
|
|
26362
|
+
}
|
|
26363
|
+
} catch (e) {
|
|
26364
|
+
// if the s2k is unsupported, we still want to support encrypting and verifying with the given key
|
|
26365
|
+
if (!this.s2kUsage) throw e; // always throw for decrypted keys
|
|
26366
|
+
this.unparseableKeyMaterial = bytes.subarray(startOfSecretKeyData);
|
|
26367
|
+
this.isEncrypted = true;
|
|
25877
26368
|
}
|
|
25878
26369
|
|
|
25879
26370
|
// - Only for a version 5 packet, a four-octet scalar octet count for
|
|
@@ -25909,8 +26400,15 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25909
26400
|
* @returns {Uint8Array} A string of bytes containing the secret key OpenPGP packet.
|
|
25910
26401
|
*/
|
|
25911
26402
|
write() {
|
|
25912
|
-
const
|
|
26403
|
+
const serializedPublicKey = this.writePublicKey();
|
|
26404
|
+
if (this.unparseableKeyMaterial) {
|
|
26405
|
+
return util.concatUint8Array([
|
|
26406
|
+
serializedPublicKey,
|
|
26407
|
+
this.unparseableKeyMaterial
|
|
26408
|
+
]);
|
|
26409
|
+
}
|
|
25913
26410
|
|
|
26411
|
+
const arr = [serializedPublicKey];
|
|
25914
26412
|
arr.push(new Uint8Array([this.s2kUsage]));
|
|
25915
26413
|
|
|
25916
26414
|
const optionalFieldsArr = [];
|
|
@@ -25970,6 +26468,18 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25970
26468
|
return this.isEncrypted === false;
|
|
25971
26469
|
}
|
|
25972
26470
|
|
|
26471
|
+
/**
|
|
26472
|
+
* Check whether the key includes secret key material.
|
|
26473
|
+
* Some secret keys do not include it, and can thus only be used
|
|
26474
|
+
* for public-key operations (encryption and verification).
|
|
26475
|
+
* Such keys are:
|
|
26476
|
+
* - GNU-dummy keys, where the secret material has been stripped away
|
|
26477
|
+
* - encrypted keys with unsupported S2K or cipher
|
|
26478
|
+
*/
|
|
26479
|
+
isMissingSecretKeyMaterial() {
|
|
26480
|
+
return this.unparseableKeyMaterial !== undefined || this.isDummy();
|
|
26481
|
+
}
|
|
26482
|
+
|
|
25973
26483
|
/**
|
|
25974
26484
|
* Check whether this is a gnu-dummy key
|
|
25975
26485
|
* @returns {Boolean}
|
|
@@ -25990,6 +26500,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25990
26500
|
if (this.isDecrypted()) {
|
|
25991
26501
|
this.clearPrivateParams();
|
|
25992
26502
|
}
|
|
26503
|
+
delete this.unparseableKeyMaterial;
|
|
25993
26504
|
this.isEncrypted = null;
|
|
25994
26505
|
this.keyMaterial = null;
|
|
25995
26506
|
this.s2k = newS2KFromType(enums.s2k.gnu, config$1);
|
|
@@ -26061,6 +26572,10 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
26061
26572
|
return false;
|
|
26062
26573
|
}
|
|
26063
26574
|
|
|
26575
|
+
if (this.unparseableKeyMaterial) {
|
|
26576
|
+
throw new Error('Key packet cannot be decrypted: unsupported S2K or cipher algo');
|
|
26577
|
+
}
|
|
26578
|
+
|
|
26064
26579
|
if (this.isDecrypted()) {
|
|
26065
26580
|
throw new Error('Key packet is already decrypted.');
|
|
26066
26581
|
}
|
|
@@ -26145,7 +26660,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
26145
26660
|
* Clear private key parameters
|
|
26146
26661
|
*/
|
|
26147
26662
|
clearPrivateParams() {
|
|
26148
|
-
if (this.
|
|
26663
|
+
if (this.isMissingSecretKeyMaterial()) {
|
|
26149
26664
|
return;
|
|
26150
26665
|
}
|
|
26151
26666
|
|
|
@@ -27554,7 +28069,9 @@ async function createBindingSignature(subkey, primaryKey, options, config) {
|
|
|
27554
28069
|
signatureType: enums.signature.keyBinding
|
|
27555
28070
|
}, options.date, undefined, undefined, undefined, config);
|
|
27556
28071
|
} else {
|
|
27557
|
-
subkeySignaturePacket.keyFlags =
|
|
28072
|
+
subkeySignaturePacket.keyFlags = options.forwarding ?
|
|
28073
|
+
[enums.keyFlags.forwardedCommunication] :
|
|
28074
|
+
[enums.keyFlags.encryptCommunication | enums.keyFlags.encryptStorage];
|
|
27558
28075
|
}
|
|
27559
28076
|
if (options.keyExpirationTime > 0) {
|
|
27560
28077
|
subkeySignaturePacket.keyExpirationTime = options.keyExpirationTime;
|
|
@@ -27792,6 +28309,10 @@ function sanitizeKeyOptions(options, subkeyDefaults = {}) {
|
|
|
27792
28309
|
options.date = options.date || subkeyDefaults.date;
|
|
27793
28310
|
|
|
27794
28311
|
options.sign = options.sign || false;
|
|
28312
|
+
options.forwarding = options.forwarding || false;
|
|
28313
|
+
if (options.sign && options.forwarding) {
|
|
28314
|
+
throw new Error('Incompatible options: "sign" and "forwarding" cannot be set together');
|
|
28315
|
+
}
|
|
27795
28316
|
|
|
27796
28317
|
switch (options.type) {
|
|
27797
28318
|
case 'ecc':
|
|
@@ -27832,6 +28353,7 @@ function isValidSigningKeyPacket(keyPacket, signature) {
|
|
|
27832
28353
|
return keyAlgo !== enums.publicKey.rsaEncrypt &&
|
|
27833
28354
|
keyAlgo !== enums.publicKey.elgamal &&
|
|
27834
28355
|
keyAlgo !== enums.publicKey.ecdh &&
|
|
28356
|
+
keyAlgo !== enums.publicKey.x25519 &&
|
|
27835
28357
|
(!signature.keyFlags ||
|
|
27836
28358
|
(signature.keyFlags[0] & enums.keyFlags.signData) !== 0);
|
|
27837
28359
|
}
|
|
@@ -27842,13 +28364,19 @@ function isValidEncryptionKeyPacket(keyPacket, signature) {
|
|
|
27842
28364
|
keyAlgo !== enums.publicKey.rsaSign &&
|
|
27843
28365
|
keyAlgo !== enums.publicKey.ecdsa &&
|
|
27844
28366
|
keyAlgo !== enums.publicKey.eddsa &&
|
|
28367
|
+
keyAlgo !== enums.publicKey.ed25519 &&
|
|
27845
28368
|
(!signature.keyFlags ||
|
|
27846
28369
|
(signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
|
|
27847
28370
|
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0);
|
|
27848
28371
|
}
|
|
27849
28372
|
|
|
27850
28373
|
function isValidDecryptionKeyPacket(signature, config) {
|
|
27851
|
-
|
|
28374
|
+
const isSigningKey = !signature.keyFlags ||
|
|
28375
|
+
(signature.keyFlags[0] & enums.keyFlags.sign) !== 0 ||
|
|
28376
|
+
(signature.keyFlags[0] & enums.keyFlags.certifyKeys) !== 0 ||
|
|
28377
|
+
(signature.keyFlags[0] & enums.keyFlags.authentication) !== 0;
|
|
28378
|
+
|
|
28379
|
+
if (isSigningKey && config.allowInsecureDecryptionWithSigningKeys) {
|
|
27852
28380
|
// This is only relevant for RSA keys, all other signing algorithms cannot decrypt
|
|
27853
28381
|
return true;
|
|
27854
28382
|
}
|
|
@@ -29391,7 +29919,7 @@ function createKey(packetlist) {
|
|
|
29391
29919
|
* @static
|
|
29392
29920
|
* @private
|
|
29393
29921
|
*/
|
|
29394
|
-
async function generate$
|
|
29922
|
+
async function generate$4(options, config) {
|
|
29395
29923
|
options.sign = true; // primary key is always a signing key
|
|
29396
29924
|
options = sanitizeKeyOptions(options);
|
|
29397
29925
|
options.subkeys = options.subkeys.map((subkey, index) => sanitizeKeyOptions(options.subkeys[index], options));
|
|
@@ -29447,7 +29975,8 @@ async function reformat(options, config) {
|
|
|
29447
29975
|
getLatestValidSignature(subkey.bindingSignatures, secretKeyPacket, enums.signature.subkeyBinding, dataToVerify, null, config)
|
|
29448
29976
|
).catch(() => ({}));
|
|
29449
29977
|
return {
|
|
29450
|
-
sign: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.signData)
|
|
29978
|
+
sign: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.signData),
|
|
29979
|
+
forwarding: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.forwardedCommunication)
|
|
29451
29980
|
};
|
|
29452
29981
|
}));
|
|
29453
29982
|
}
|
|
@@ -30069,6 +30598,15 @@ class Message {
|
|
|
30069
30598
|
enums.read(enums.aead, await getPreferredAlgo('aead', encryptionKeys, date, userIDs, config$1)) :
|
|
30070
30599
|
undefined;
|
|
30071
30600
|
|
|
30601
|
+
await Promise.all(encryptionKeys.map(key => key.getEncryptionKey()
|
|
30602
|
+
.catch(() => null) // ignore key strength requirements
|
|
30603
|
+
.then(maybeKey => {
|
|
30604
|
+
if (maybeKey && (maybeKey.keyPacket.algorithm === enums.publicKey.x25519) && !util.isAES(algo)) {
|
|
30605
|
+
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.');
|
|
30606
|
+
}
|
|
30607
|
+
})
|
|
30608
|
+
));
|
|
30609
|
+
|
|
30072
30610
|
const sessionKeyData = mod.generateSessionKey(algo);
|
|
30073
30611
|
return { data: sessionKeyData, algorithm: algorithmName, aeadAlgorithm: aeadAlgorithmName };
|
|
30074
30612
|
}
|
|
@@ -30376,7 +30914,7 @@ class Message {
|
|
|
30376
30914
|
if (literalDataList.length !== 1) {
|
|
30377
30915
|
throw new Error('Can only verify message with one literal data packet.');
|
|
30378
30916
|
}
|
|
30379
|
-
const signatureList = signature.packets;
|
|
30917
|
+
const signatureList = signature.packets.filterByTag(enums.packet.signature); // drop UnparsablePackets
|
|
30380
30918
|
return createVerificationObjects(signatureList, literalDataList, verificationKeys, date, true, config$1);
|
|
30381
30919
|
}
|
|
30382
30920
|
|
|
@@ -30723,7 +31261,7 @@ class CleartextMessage {
|
|
|
30723
31261
|
* @async
|
|
30724
31262
|
*/
|
|
30725
31263
|
verify(keys, date = new Date(), config$1 = config) {
|
|
30726
|
-
const signatureList = this.signature.packets;
|
|
31264
|
+
const signatureList = this.signature.packets.filterByTag(enums.packet.signature); // drop UnparsablePackets
|
|
30727
31265
|
const literalDataPacket = new LiteralDataPacket();
|
|
30728
31266
|
// we assume that cleartext signature is generated based on UTF8 cleartext
|
|
30729
31267
|
literalDataPacket.setText(this.text);
|
|
@@ -30808,7 +31346,7 @@ function verifyHeaders$1(headers, packetlist) {
|
|
|
30808
31346
|
let oneHeader = null;
|
|
30809
31347
|
let hashAlgos = [];
|
|
30810
31348
|
headers.forEach(function(header) {
|
|
30811
|
-
oneHeader = header.match(
|
|
31349
|
+
oneHeader = header.match(/^Hash: (.+)$/); // get header value
|
|
30812
31350
|
if (oneHeader) {
|
|
30813
31351
|
oneHeader = oneHeader[1].replace(/\s/g, ''); // remove whitespace
|
|
30814
31352
|
oneHeader = oneHeader.split(',');
|
|
@@ -30900,7 +31438,7 @@ async function generateKey({ userIDs = [], passphrase, type = 'ecc', rsaBits = 4
|
|
|
30900
31438
|
const options = { userIDs, passphrase, type, rsaBits, curve, keyExpirationTime, date, subkeys, symmetricHash, symmetricCipher };
|
|
30901
31439
|
|
|
30902
31440
|
try {
|
|
30903
|
-
const { key, revocationCertificate } = await generate$
|
|
31441
|
+
const { key, revocationCertificate } = await generate$4(options, config$1);
|
|
30904
31442
|
key.getKeys().forEach(({ keyPacket }) => checkKeyRequirements(keyPacket, config$1));
|
|
30905
31443
|
|
|
30906
31444
|
return {
|
|
@@ -31094,7 +31632,7 @@ async function encryptKey({ privateKey, passphrase, config: config$1, ...rest })
|
|
|
31094
31632
|
* @async
|
|
31095
31633
|
* @static
|
|
31096
31634
|
*/
|
|
31097
|
-
async function encrypt$
|
|
31635
|
+
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 }) {
|
|
31098
31636
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31099
31637
|
checkMessage(message); checkOutputMessageFormat(format);
|
|
31100
31638
|
encryptionKeys = toArray$1(encryptionKeys); signingKeys = toArray$1(signingKeys); passwords = toArray$1(passwords);
|
|
@@ -31163,7 +31701,7 @@ async function encrypt$4({ message, encryptionKeys, signingKeys, passwords, sess
|
|
|
31163
31701
|
* @async
|
|
31164
31702
|
* @static
|
|
31165
31703
|
*/
|
|
31166
|
-
async function decrypt$
|
|
31704
|
+
async function decrypt$5({ message, decryptionKeys, passwords, sessionKeys, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
|
|
31167
31705
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31168
31706
|
checkMessage(message); verificationKeys = toArray$1(verificationKeys); decryptionKeys = toArray$1(decryptionKeys); passwords = toArray$1(passwords); sessionKeys = toArray$1(sessionKeys);
|
|
31169
31707
|
if (rest.privateKeys) throw new Error('The `privateKeys` option has been removed from openpgp.decrypt, pass `decryptionKeys` instead');
|
|
@@ -31226,7 +31764,7 @@ async function decrypt$4({ message, decryptionKeys, passwords, sessionKeys, veri
|
|
|
31226
31764
|
* @async
|
|
31227
31765
|
* @static
|
|
31228
31766
|
*/
|
|
31229
|
-
async function sign$
|
|
31767
|
+
async function sign$6({ message, signingKeys, format = 'armored', detached = false, signingKeyIDs = [], date = new Date(), signingUserIDs = [], signatureNotations = [], config: config$1, ...rest }) {
|
|
31230
31768
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31231
31769
|
checkCleartextOrMessage(message); checkOutputMessageFormat(format);
|
|
31232
31770
|
signingKeys = toArray$1(signingKeys); signingKeyIDs = toArray$1(signingKeyIDs); signingUserIDs = toArray$1(signingUserIDs); signatureNotations = toArray$1(signatureNotations);
|
|
@@ -31295,7 +31833,7 @@ async function sign$5({ message, signingKeys, format = 'armored', detached = fal
|
|
|
31295
31833
|
* @async
|
|
31296
31834
|
* @static
|
|
31297
31835
|
*/
|
|
31298
|
-
async function verify$
|
|
31836
|
+
async function verify$6({ message, verificationKeys, expectSigned = false, format = 'utf8', signature = null, date = new Date(), config: config$1, ...rest }) {
|
|
31299
31837
|
config$1 = { ...config, ...config$1 }; checkConfig(config$1);
|
|
31300
31838
|
checkCleartextOrMessage(message); verificationKeys = toArray$1(verificationKeys);
|
|
31301
31839
|
if (rest.publicKeys) throw new Error('The `publicKeys` option has been removed from openpgp.verify, pass `verificationKeys` instead');
|
|
@@ -44464,7 +45002,7 @@ function* makePRNG(wasmContext, pass, lane, slice, m_, totalPasses, segmentLengt
|
|
|
44464
45002
|
return [];
|
|
44465
45003
|
}
|
|
44466
45004
|
|
|
44467
|
-
function validateParams$
|
|
45005
|
+
function validateParams$9({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {
|
|
44468
45006
|
const assertLength = (name, value, min, max) => {
|
|
44469
45007
|
if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }
|
|
44470
45008
|
};
|
|
@@ -44487,7 +45025,7 @@ const WASM_PAGE_SIZE = 64 * KB;
|
|
|
44487
45025
|
function argon2id(params, { memory, instance: wasmInstance }) {
|
|
44488
45026
|
if (!isLittleEndian$1) throw new Error('BigEndian system not supported'); // optmisations assume LE system
|
|
44489
45027
|
|
|
44490
|
-
const ctx = validateParams$
|
|
45028
|
+
const ctx = validateParams$9({ type: TYPE$2, version: VERSION$4, ...params });
|
|
44491
45029
|
|
|
44492
45030
|
const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;
|
|
44493
45031
|
const wasmRefs = {};
|
|
@@ -44761,4 +45299,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
44761
45299
|
'default': loadWasm
|
|
44762
45300
|
});
|
|
44763
45301
|
|
|
44764
|
-
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$
|
|
45302
|
+
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 };
|