From 6e648b1cbc44ebcc78036ac94f76fe5f14dbe971 Mon Sep 17 00:00:00 2001 From: Ilya Chesnokov Date: Thu, 7 May 2020 00:46:58 +0700 Subject: [PATCH] Rename enums to use camelCase (#1093) --- README.md | 2 +- src/crypto/crypto.js | 36 ++++----- src/crypto/index.js | 2 +- src/crypto/signature.js | 12 +-- src/encoding/armor.js | 16 ++-- src/enums.js | 106 +++++++++++++-------------- src/key/factory.js | 18 ++--- src/key/helper.js | 28 +++---- src/key/key.js | 44 +++++------ src/key/subkey.js | 14 ++-- src/key/user.js | 14 ++-- src/packet/signature.js | 68 ++++++++--------- test/crypto/rsa.js | 14 ++-- test/general/key.js | 48 ++++++------ test/general/openpgp.js | 2 +- test/general/packet.js | 20 ++--- test/general/signature.js | 4 +- test/general/x25519.js | 6 +- test/security/subkey_trust.js | 4 +- test/security/unsigned_subpackets.js | 2 +- 20 files changed, 230 insertions(+), 230 deletions(-) diff --git a/README.md b/README.md index 52745f1a..5278c50a 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ library to convert back and forth between them. ``` openpgp.config.aeadMode = openpgp.enums.aead.eax // Default, native openpgp.config.aeadMode = openpgp.enums.aead.ocb // Non-native - openpgp.config.aeadMode = openpgp.enums.aead.experimental_gcm // **Non-standard**, fastest + openpgp.config.aeadMode = openpgp.enums.aead.experimentalGcm // **Non-standard**, fastest ``` * For environments that don't provide native crypto, the library falls back to [asm.js](https://caniuse.com/#feat=asmjs) implementations of AES, SHA-1, and SHA-256. We use [Rusha](https://github.com/srijs/rusha) and [asmCrypto Lite](https://github.com/openpgpjs/asmcrypto-lite) (a minimal subset of asmCrypto.js built specifically for OpenPGP.js). diff --git a/src/crypto/crypto.js b/src/crypto/crypto.js index 7789164c..3563bcba 100644 --- a/src/crypto/crypto.js +++ b/src/crypto/crypto.js @@ -70,8 +70,8 @@ export default { publicKeyEncrypt: async function(algo, pub_params, data, fingerprint) { const types = this.getEncSessionKeyParamTypes(algo); switch (algo) { - case enums.publicKey.rsa_encrypt: - case enums.publicKey.rsa_encrypt_sign: { + case enums.publicKey.rsaEncrypt: + case enums.publicKey.rsaEncryptSign: { data = util.strToUint8Array(data); const n = pub_params[0].toUint8Array(); const e = pub_params[1].toUint8Array(); @@ -117,8 +117,8 @@ export default { */ publicKeyDecrypt: async function(algo, key_params, data_params, fingerprint) { switch (algo) { - case enums.publicKey.rsa_encrypt_sign: - case enums.publicKey.rsa_encrypt: { + case enums.publicKey.rsaEncryptSign: + case enums.publicKey.rsaEncrypt: { const c = data_params[0].toUint8Array(); const n = key_params[0].toUint8Array(); // n = pq const e = key_params[1].toUint8Array(); @@ -165,9 +165,9 @@ export default { // - MPI of RSA secret prime value p. // - MPI of RSA secret prime value q (p < q). // - MPI of u, the multiplicative inverse of p, mod q. - case enums.publicKey.rsa_encrypt: - case enums.publicKey.rsa_encrypt_sign: - case enums.publicKey.rsa_sign: + case enums.publicKey.rsaEncrypt: + case enums.publicKey.rsaEncryptSign: + case enums.publicKey.rsaSign: return [type_mpi, type_mpi, type_mpi, type_mpi]; // Algorithm-Specific Fields for Elgamal secret keys: // - MPI of Elgamal secret exponent x. @@ -197,9 +197,9 @@ export default { // Algorithm-Specific Fields for RSA public keys: // - a multiprecision integer (MPI) of RSA public modulus n; // - an MPI of RSA public encryption exponent e. - case enums.publicKey.rsa_encrypt: - case enums.publicKey.rsa_encrypt_sign: - case enums.publicKey.rsa_sign: + case enums.publicKey.rsaEncrypt: + case enums.publicKey.rsaEncryptSign: + case enums.publicKey.rsaSign: return [type_mpi, type_mpi]; // Algorithm-Specific Fields for Elgamal public keys: // - MPI of Elgamal prime p; @@ -239,8 +239,8 @@ export default { switch (algo) { // Algorithm-Specific Fields for RSA encrypted session keys: // - MPI of RSA encrypted value m**e mod n. - case enums.publicKey.rsa_encrypt: - case enums.publicKey.rsa_encrypt_sign: + case enums.publicKey.rsaEncrypt: + case enums.publicKey.rsaEncryptSign: return [type_mpi]; // Algorithm-Specific Fields for Elgamal encrypted session keys: @@ -268,9 +268,9 @@ export default { generateParams: function(algo, bits, oid) { const types = [].concat(this.getPubKeyParamTypes(algo), this.getPrivKeyParamTypes(algo)); switch (algo) { - case enums.publicKey.rsa_encrypt: - case enums.publicKey.rsa_encrypt_sign: - case enums.publicKey.rsa_sign: { + case enums.publicKey.rsaEncrypt: + case enums.publicKey.rsaEncryptSign: + case enums.publicKey.rsaSign: { return publicKey.rsa.generate(bits, "10001").then(function(keyObject) { return constructParams( types, [keyObject.n, keyObject.e, keyObject.d, keyObject.p, keyObject.q, keyObject.u] @@ -308,9 +308,9 @@ export default { */ validateParams: async function(algo, params) { switch (algo) { - case enums.publicKey.rsa_encrypt: - case enums.publicKey.rsa_encrypt_sign: - case enums.publicKey.rsa_sign: { + case enums.publicKey.rsaEncrypt: + case enums.publicKey.rsaEncryptSign: + case enums.publicKey.rsaSign: { if (params.length < 6) { throw new Error('Missing key parameters'); } diff --git a/src/crypto/index.js b/src/crypto/index.js index c136af1e..398006a2 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -33,7 +33,7 @@ const mod = { cfb: cfb, /** @see module:crypto/gcm */ gcm: gcm, - experimental_gcm: gcm, + experimentalGcm: gcm, /** @see module:crypto/eax */ eax: eax, /** @see module:crypto/ocb */ diff --git a/src/crypto/signature.js b/src/crypto/signature.js index cf9dbd88..edd2271e 100644 --- a/src/crypto/signature.js +++ b/src/crypto/signature.js @@ -33,9 +33,9 @@ export default { throw new Error('Missing public key parameters'); } switch (algo) { - case enums.publicKey.rsa_encrypt_sign: - case enums.publicKey.rsa_encrypt: - case enums.publicKey.rsa_sign: { + case enums.publicKey.rsaEncryptSign: + case enums.publicKey.rsaEncrypt: + case enums.publicKey.rsaSign: { const n = pub_MPIs[0].toUint8Array(); const e = pub_MPIs[1].toUint8Array(); const m = msg_MPIs[0].toUint8Array('be', n.length); @@ -88,9 +88,9 @@ export default { throw new Error('Missing private key parameters'); } switch (algo) { - case enums.publicKey.rsa_encrypt_sign: - case enums.publicKey.rsa_encrypt: - case enums.publicKey.rsa_sign: { + case enums.publicKey.rsaEncryptSign: + case enums.publicKey.rsaEncrypt: + case enums.publicKey.rsaSign: { const n = key_params[0].toUint8Array(); const e = key_params[1].toUint8Array(); const d = key_params[2].toUint8Array(); diff --git a/src/encoding/armor.js b/src/encoding/armor.js index 46186bc1..c7957b93 100644 --- a/src/encoding/armor.js +++ b/src/encoding/armor.js @@ -55,14 +55,14 @@ function getType(text) { // Used for multi-part messages, where the armor is split amongst Y // parts, and this is the Xth part out of Y. if (/MESSAGE, PART \d+\/\d+/.test(header[1])) { - return enums.armor.multipart_section; + return enums.armor.multipartSection; } else // BEGIN PGP MESSAGE, PART X // Used for multi-part messages, where this is the Xth part of an // unspecified number of parts. Requires the MESSAGE-ID Armor // Header to be used. if (/MESSAGE, PART \d+/.test(header[1])) { - return enums.armor.multipart_last; + return enums.armor.multipartLast; } else // BEGIN PGP SIGNED MESSAGE if (/SIGNED MESSAGE/.test(header[1])) { @@ -76,12 +76,12 @@ function getType(text) { // BEGIN PGP PUBLIC KEY BLOCK // Used for armoring public keys. if (/PUBLIC KEY BLOCK/.test(header[1])) { - return enums.armor.public_key; + return enums.armor.publicKey; } else // BEGIN PGP PRIVATE KEY BLOCK // Used for armoring private keys. if (/PRIVATE KEY BLOCK/.test(header[1])) { - return enums.armor.private_key; + return enums.armor.privateKey; } else // BEGIN PGP SIGNATURE // Used for detached signatures, OpenPGP/MIME signatures, and @@ -370,14 +370,14 @@ function armor(messagetype, body, partindex, parttotal, customComment) { const bodyClone = stream.passiveClone(body); const result = []; switch (messagetype) { - case enums.armor.multipart_section: + case enums.armor.multipartSection: result.push("-----BEGIN PGP MESSAGE, PART " + partindex + "/" + parttotal + "-----\r\n"); result.push(addheader(customComment)); result.push(base64.encode(body)); result.push("=", getCheckSum(bodyClone)); result.push("-----END PGP MESSAGE, PART " + partindex + "/" + parttotal + "-----\r\n"); break; - case enums.armor.multipart_last: + case enums.armor.multipartLast: result.push("-----BEGIN PGP MESSAGE, PART " + partindex + "-----\r\n"); result.push(addheader(customComment)); result.push(base64.encode(body)); @@ -401,14 +401,14 @@ function armor(messagetype, body, partindex, parttotal, customComment) { result.push("=", getCheckSum(bodyClone)); result.push("-----END PGP MESSAGE-----\r\n"); break; - case enums.armor.public_key: + case enums.armor.publicKey: result.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n"); result.push(addheader(customComment)); result.push(base64.encode(body)); result.push("=", getCheckSum(bodyClone)); result.push("-----END PGP PUBLIC KEY BLOCK-----\r\n"); break; - case enums.armor.private_key: + case enums.armor.privateKey: result.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n"); result.push(addheader(customComment)); result.push(base64.encode(body)); diff --git a/src/enums.js b/src/enums.js index 4d2d9b15..39520cf1 100644 --- a/src/enums.js +++ b/src/enums.js @@ -96,11 +96,11 @@ export default { */ publicKey: { /** RSA (Encrypt or Sign) [HAC] */ - rsa_encrypt_sign: 1, + rsaEncryptSign: 1, /** RSA (Encrypt only) [HAC] */ - rsa_encrypt: 2, + rsaEncrypt: 2, /** RSA (Sign only) [HAC] */ - rsa_sign: 3, + rsaSign: 3, /** Elgamal (Encrypt only) [ELGAMAL] [HAC] */ elgamal: 16, /** DSA (Sign only) [FIPS186] [HAC] */ @@ -181,7 +181,7 @@ export default { aead: { eax: 1, ocb: 2, - experimental_gcm: 100 // Private algorithm + experimentalGcm: 100 // Private algorithm }, /** A list of packet types and numeric tags associated with them. @@ -248,17 +248,17 @@ export default { * The issuer of this certification does not make any particular * assertion as to how well the certifier has checked that the owner * of the key is in fact the person described by the User ID. */ - cert_generic: 16, + certGeneric: 16, /** 0x11: Persona certification of a User ID and Public-Key packet. * * The issuer of this certification has not done any verification of * the claim that the owner of this key is the User ID specified. */ - cert_persona: 17, + certPersona: 17, /** 0x12: Casual certification of a User ID and Public-Key packet. * * The issuer of this certification has done some casual * verification of the claim of identity. */ - cert_casual: 18, + certCasual: 18, /** 0x13: Positive certification of a User ID and Public-Key packet. * * The issuer of this certification has done substantial @@ -267,7 +267,7 @@ export default { * Most OpenPGP implementations make their "key signatures" as 0x10 * certifications. Some implementations can issue 0x11-0x13 * certifications, but few differentiate between the types. */ - cert_positive: 19, + certPositive: 19, /** 0x30: Certification revocation signature * * This signature revokes an earlier User ID certification signature @@ -277,7 +277,7 @@ export default { * is computed over the same data as the certificate that it * revokes, and should have a later creation date than that * certificate. */ - cert_revocation: 48, + certRevocation: 48, /** 0x18: Subkey Binding Signature * * This signature is a statement by the top-level signing key that @@ -287,7 +287,7 @@ export default { * an Embedded Signature subpacket in this binding signature that * contains a 0x19 signature made by the signing subkey on the * primary key and subkey. */ - subkey_binding: 24, + subkeyBinding: 24, /** 0x19: Primary Key Binding Signature * * This signature is a statement by a signing subkey, indicating @@ -302,7 +302,7 @@ export default { * (type 0x18) or primary key binding signature (type 0x19) then hashes * the subkey using the same format as the main key (also using 0x99 as * the first octet). */ - key_binding: 25, + keyBinding: 25, /** 0x1F: Signature directly on a key * * This signature is calculated directly on a key. It binds the @@ -319,7 +319,7 @@ export default { * revoked key is not to be used. Only revocation signatures by the * key being revoked, or by an authorized revocation key, should be * considered valid revocation signatures.a */ - key_revocation: 32, + keyRevocation: 32, /** 0x28: Subkey revocation signature * * The signature is calculated directly on the subkey being revoked. @@ -330,7 +330,7 @@ export default { * * Key revocation signatures (types 0x20 and 0x28) * hash only the key being revoked. */ - subkey_revocation: 40, + subkeyRevocation: 40, /** 0x40: Timestamp signature. * This signature is only meaningful for the timestamp contained in * it. */ @@ -344,7 +344,7 @@ export default { * mean SHOULD. There are plausible uses for this (such as a blind * party that only sees the signature, not the key or source * document) that cannot include a target subpacket. */ - third_party: 80 + thirdParty: 80 }, /** Signature subpacket type @@ -352,32 +352,32 @@ export default { * @readonly */ signatureSubpacket: { - signature_creation_time: 2, - signature_expiration_time: 3, - exportable_certification: 4, - trust_signature: 5, - regular_expression: 6, + signatureCreationTime: 2, + signatureExpirationTime: 3, + exportableCertification: 4, + trustSignature: 5, + regularExpression: 6, revocable: 7, - key_expiration_time: 9, - placeholder_backwards_compatibility: 10, - preferred_symmetric_algorithms: 11, - revocation_key: 12, + keyExpirationTime: 9, + placeholderBackwardsCompatibility: 10, + preferredSymmetricAlgorithms: 11, + revocationKey: 12, issuer: 16, - notation_data: 20, - preferred_hash_algorithms: 21, - preferred_compression_algorithms: 22, - key_server_preferences: 23, - preferred_key_server: 24, - primary_user_id: 25, - policy_uri: 26, - key_flags: 27, - signers_user_id: 28, - reason_for_revocation: 29, + notationData: 20, + preferredHashAlgorithms: 21, + preferredCompressionAlgorithms: 22, + keyServerPreferences: 23, + preferredKeyServer: 24, + primaryUserId: 25, + policyUri: 26, + keyFlags: 27, + signersUserId: 28, + reasonForRevocation: 29, features: 30, - signature_target: 31, - embedded_signature: 32, - issuer_fingerprint: 33, - preferred_aead_algorithms: 34 + signatureTarget: 31, + embeddedSignature: 32, + issuerFingerprint: 33, + preferredAeadAlgorithms: 34 }, /** Key flags @@ -386,21 +386,21 @@ export default { */ keyFlags: { /** 0x01 - This key may be used to certify other keys. */ - certify_keys: 1, + certifyKeys: 1, /** 0x02 - This key may be used to sign data. */ - sign_data: 2, + signData: 2, /** 0x04 - This key may be used to encrypt communications. */ - encrypt_communication: 4, + encryptCommunication: 4, /** 0x08 - This key may be used to encrypt storage. */ - encrypt_storage: 8, + encryptStorage: 8, /** 0x10 - The private component of this key may have been split * by a secret-sharing mechanism. */ - split_private_key: 16, + splitPrivateKey: 16, /** 0x20 - This key may be used for authentication. */ authentication: 32, /** 0x80 - The private component of this key may be in the * possession of more than one person. */ - shared_private_key: 128 + sharedPrivateKey: 128 }, /** Armor type @@ -408,12 +408,12 @@ export default { * @readonly */ armor: { - multipart_section: 0, - multipart_last: 1, + multipartSection: 0, + multipartLast: 1, signed: 2, message: 3, - public_key: 4, - private_key: 5, + publicKey: 4, + privateKey: 5, signature: 6 }, @@ -423,15 +423,15 @@ export default { */ reasonForRevocation: { /** No reason specified (key revocations or cert revocations) */ - no_reason: 0, + noReason: 0, /** Key is superseded (key revocations) */ - key_superseded: 1, + keySuperseded: 1, /** Key material has been compromised (key revocations) */ - key_compromised: 2, + keyCompromised: 2, /** Key is retired and no longer used (key revocations) */ - key_retired: 3, + keyRetired: 3, /** User ID information is no longer valid (cert revocations) */ - userid_invalid: 32 + userIdInvalid: 32 }, /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25} @@ -440,7 +440,7 @@ export default { */ features: { /** 0x01 - Modification Detection (packets 18 and 19) */ - modification_detection: 1, + modificationDetection: 1, /** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5 * Symmetric-Key Encrypted Session Key Packets (packet 3) */ aead: 2, diff --git a/src/key/factory.js b/src/key/factory.js index 58fced56..64ddf310 100644 --- a/src/key/factory.js +++ b/src/key/factory.js @@ -38,7 +38,7 @@ import armor from '../encoding/armor'; /** * Generates a new OpenPGP key. Supports RSA and ECC keys. * Primary and subkey will be of same type. - * @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsa_encrypt_sign] + * @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsaEncryptSign] * To indicate what type of key to make. * RSA is 1. See {@link https://tools.ietf.org/html/rfc4880#section-9.1} * @param {Integer} options.rsaBits number of bits for the key creation. @@ -69,7 +69,7 @@ export async function generate(options) { /** * Reformats and signs an OpenPGP key with a given User ID. Currently only supports RSA keys. * @param {module:key.Key} options.privateKey The private key to reformat - * @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsa_encrypt_sign] + * @param {module:enums.publicKey} [options.keyType=module:enums.publicKey.rsaEncryptSign] * @param {String|Array} options.userIds * Assumes already in form of "User Name " * If array is used, the first userId is set as primary user Id @@ -172,10 +172,10 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPackets, options) { dataToSign.userId = userIdPacket; dataToSign.key = secretKeyPacket; const signaturePacket = new packet.Signature(options.date); - signaturePacket.signatureType = enums.signature.cert_generic; + signaturePacket.signatureType = enums.signature.certGeneric; signaturePacket.publicKeyAlgorithm = secretKeyPacket.algorithm; signaturePacket.hashAlgorithm = await helper.getPreferredHashAlgo(null, secretKeyPacket); - signaturePacket.keyFlags = [enums.keyFlags.certify_keys | enums.keyFlags.sign_data]; + signaturePacket.keyFlags = [enums.keyFlags.certifyKeys | enums.keyFlags.signData]; signaturePacket.preferredSymmetricAlgorithms = createdPreferredAlgos([ // prefer aes256, aes128, then aes192 (no WebCrypto support: https://www.chromium.org/blink/webcrypto#TOC-AES-support) enums.symmetric.aes256, @@ -203,7 +203,7 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPackets, options) { } if (config.integrityProtect) { signaturePacket.features = [0]; - signaturePacket.features[0] |= enums.features.modification_detection; + signaturePacket.features[0] |= enums.features.modificationDetection; } if (config.aeadProtect) { signaturePacket.features || (signaturePacket.features = [0]); @@ -242,8 +242,8 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPackets, options) { // This packet should be removed before returning the key. const dataToSign = { key: secretKeyPacket }; packetlist.push(await helper.createSignaturePacket(dataToSign, null, secretKeyPacket, { - signatureType: enums.signature.key_revocation, - reasonForRevocationFlag: enums.reasonForRevocation.no_reason, + signatureType: enums.signature.keyRevocation, + reasonForRevocationFlag: enums.reasonForRevocation.noReason, reasonForRevocationString: '' }, options.date)); @@ -284,7 +284,7 @@ export async function read(data) { */ export async function readArmored(armoredKey) { const input = await armor.decode(armoredKey); - if (!(input.type === enums.armor.public_key || input.type === enums.armor.private_key)) { + if (!(input.type === enums.armor.publicKey || input.type === enums.armor.privateKey)) { throw new Error('Armored text not of type key'); } return read(input.data); @@ -322,7 +322,7 @@ export async function readAll(data) { */ export async function readAllArmored(armoredKey) { const input = await armor.decode(armoredKey); - if (!(input.type === enums.armor.public_key || input.type === enums.armor.private_key)) { + if (!(input.type === enums.armor.publicKey || input.type === enums.armor.privateKey)) { throw new Error('Armored text not of type key'); } return readAll(input.data); diff --git a/src/key/helper.js b/src/key/helper.js index 78afac10..cbe2a574 100644 --- a/src/key/helper.js +++ b/src/key/helper.js @@ -57,8 +57,8 @@ export async function getLatestValidSignature(signatures, primaryKey, signatureT if (!signature) { throw util.wrapError( `Could not find valid ${enums.read(enums.signature, signatureType)} signature in key ${primaryKey.getKeyId().toHex()}` - .replace('cert_generic ', 'self-') - .replace('_', ' ') + .replace('certGeneric ', 'self-') + .replace(/([a-z])([A-Z])/g, (_, $1, $2) => $1 + ' ' + $2.toLowerCase()) , exception); } return signature; @@ -85,16 +85,16 @@ export async function createBindingSignature(subkey, primaryKey, options) { dataToSign.key = primaryKey; dataToSign.bind = subkey; const subkeySignaturePacket = new packet.Signature(options.date); - subkeySignaturePacket.signatureType = enums.signature.subkey_binding; + subkeySignaturePacket.signatureType = enums.signature.subkeyBinding; subkeySignaturePacket.publicKeyAlgorithm = primaryKey.algorithm; subkeySignaturePacket.hashAlgorithm = await getPreferredHashAlgo(null, subkey); if (options.sign) { - subkeySignaturePacket.keyFlags = [enums.keyFlags.sign_data]; + subkeySignaturePacket.keyFlags = [enums.keyFlags.signData]; subkeySignaturePacket.embeddedSignature = await createSignaturePacket(dataToSign, null, subkey, { - signatureType: enums.signature.key_binding + signatureType: enums.signature.keyBinding }, options.date); } else { - subkeySignaturePacket.keyFlags = [enums.keyFlags.encrypt_communication | enums.keyFlags.encrypt_storage]; + subkeySignaturePacket.keyFlags = [enums.keyFlags.encryptCommunication | enums.keyFlags.encryptStorage]; } if (options.keyExpirationTime > 0) { subkeySignaturePacket.keyExpirationTime = options.keyExpirationTime; @@ -331,7 +331,7 @@ export function sanitizeKeyOptions(options, subkeyDefaults = {}) { options.algorithm = enums.publicKey.ecdh; } } else if (options.rsaBits) { - options.algorithm = enums.publicKey.rsa_encrypt_sign; + options.algorithm = enums.publicKey.rsaEncryptSign; } else { throw new Error('Unrecognized key type'); } @@ -342,11 +342,11 @@ export function isValidSigningKeyPacket(keyPacket, signature) { if (!signature.verified || signature.revoked !== false) { // Sanity check throw new Error('Signature not verified'); } - return keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.rsa_encrypt) && + return keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.rsaEncrypt) && keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.elgamal) && keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.ecdh) && (!signature.keyFlags || - (signature.keyFlags[0] & enums.keyFlags.sign_data) !== 0); + (signature.keyFlags[0] & enums.keyFlags.signData) !== 0); } export function isValidEncryptionKeyPacket(keyPacket, signature) { @@ -354,12 +354,12 @@ export function isValidEncryptionKeyPacket(keyPacket, signature) { throw new Error('Signature not verified'); } return keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.dsa) && - keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.rsa_sign) && + keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.rsaSign) && keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.ecdsa) && keyPacket.algorithm !== enums.read(enums.publicKey, enums.publicKey.eddsa) && (!signature.keyFlags || - (signature.keyFlags[0] & enums.keyFlags.encrypt_communication) !== 0 || - (signature.keyFlags[0] & enums.keyFlags.encrypt_storage) !== 0); + (signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 || + (signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0); } export function isValidDecryptionKeyPacket(signature) { @@ -373,6 +373,6 @@ export function isValidDecryptionKeyPacket(signature) { } return !signature.keyFlags || - (signature.keyFlags[0] & enums.keyFlags.encrypt_communication) !== 0 || - (signature.keyFlags[0] & enums.keyFlags.encrypt_storage) !== 0; + (signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 || + (signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0; } diff --git a/src/key/key.js b/src/key/key.js index a41c9406..5d857a08 100644 --- a/src/key/key.js +++ b/src/key/key.js @@ -100,10 +100,10 @@ Key.prototype.packetlist2structure = function(packetlist) { break; case enums.packet.signature: switch (packetlist[i].signatureType) { - case enums.signature.cert_generic: - case enums.signature.cert_persona: - case enums.signature.cert_casual: - case enums.signature.cert_positive: + case enums.signature.certGeneric: + case enums.signature.certPersona: + case enums.signature.certCasual: + case enums.signature.certPositive: if (!user) { util.printDebug('Dropping certification signatures without preceding user packet'); continue; @@ -114,7 +114,7 @@ Key.prototype.packetlist2structure = function(packetlist) { user.otherCertifications.push(packetlist[i]); } break; - case enums.signature.cert_revocation: + case enums.signature.certRevocation: if (user) { user.revocationSignatures.push(packetlist[i]); } else { @@ -124,17 +124,17 @@ Key.prototype.packetlist2structure = function(packetlist) { case enums.signature.key: this.directSignatures.push(packetlist[i]); break; - case enums.signature.subkey_binding: + case enums.signature.subkeyBinding: if (!subKey) { util.printDebug('Dropping subkey binding signature without preceding subkey packet'); continue; } subKey.bindingSignatures.push(packetlist[i]); break; - case enums.signature.key_revocation: + case enums.signature.keyRevocation: this.revocationSignatures.push(packetlist[i]); break; - case enums.signature.subkey_revocation: + case enums.signature.subkeyRevocation: if (!subKey) { util.printDebug('Dropping subkey revocation signature without preceding subkey packet'); continue; @@ -276,7 +276,7 @@ Key.prototype.toPublic = function() { * @returns {ReadableStream} ASCII armor */ Key.prototype.armor = function() { - const type = this.isPublic() ? enums.armor.public_key : enums.armor.private_key; + const type = this.isPublic() ? enums.armor.publicKey : enums.armor.privateKey; return armor.encode(type, this.toPacketlist().write()); }; @@ -298,12 +298,12 @@ Key.prototype.getSigningKey = async function (keyId = null, date = new Date(), u try { await subKeys[i].verify(primaryKey, date); const dataToVerify = { key: primaryKey, bind: subKeys[i].keyPacket }; - const bindingSignature = await helper.getLatestValidSignature(subKeys[i].bindingSignatures, primaryKey, enums.signature.subkey_binding, dataToVerify, date); + const bindingSignature = await helper.getLatestValidSignature(subKeys[i].bindingSignatures, primaryKey, enums.signature.subkeyBinding, dataToVerify, date); if ( bindingSignature && bindingSignature.embeddedSignature && helper.isValidSigningKeyPacket(subKeys[i].keyPacket, bindingSignature) && - await helper.getLatestValidSignature([bindingSignature.embeddedSignature], subKeys[i].keyPacket, enums.signature.key_binding, dataToVerify, date) + await helper.getLatestValidSignature([bindingSignature.embeddedSignature], subKeys[i].keyPacket, enums.signature.keyBinding, dataToVerify, date) ) { return subKeys[i]; } @@ -339,7 +339,7 @@ Key.prototype.getEncryptionKey = async function(keyId, date = new Date(), userId try { await subKeys[i].verify(primaryKey, date); const dataToVerify = { key: primaryKey, bind: subKeys[i].keyPacket }; - const bindingSignature = await helper.getLatestValidSignature(subKeys[i].bindingSignatures, primaryKey, enums.signature.subkey_binding, dataToVerify, date); + const bindingSignature = await helper.getLatestValidSignature(subKeys[i].bindingSignatures, primaryKey, enums.signature.subkeyBinding, dataToVerify, date); if (bindingSignature && helper.isValidEncryptionKeyPacket(subKeys[i].keyPacket, bindingSignature)) { return subKeys[i]; } @@ -373,7 +373,7 @@ Key.prototype.getDecryptionKeys = async function(keyId, date = new Date(), userI if (!keyId || this.subKeys[i].getKeyId().equals(keyId, true)) { try { const dataToVerify = { key: primaryKey, bind: this.subKeys[i].keyPacket }; - const bindingSignature = await helper.getLatestValidSignature(this.subKeys[i].bindingSignatures, primaryKey, enums.signature.subkey_binding, dataToVerify, date); + const bindingSignature = await helper.getLatestValidSignature(this.subKeys[i].bindingSignatures, primaryKey, enums.signature.subkeyBinding, dataToVerify, date); if (bindingSignature && helper.isValidDecryptionKeyPacket(bindingSignature)) { keys.push(this.subKeys[i]); } @@ -528,7 +528,7 @@ Key.prototype.clearPrivateParams = function () { */ Key.prototype.isRevoked = async function(signature, key, date = new Date()) { return helper.isDataRevoked( - this.keyPacket, enums.signature.key_revocation, { key: this.keyPacket }, this.revocationSignatures, signature, key, date + this.keyPacket, enums.signature.keyRevocation, { key: this.keyPacket }, this.revocationSignatures, signature, key, date ); }; @@ -623,7 +623,7 @@ Key.prototype.getPrimaryUser = async function(date = new Date(), userId = {}) { throw new Error('Could not find user that matches that user ID'); } const dataToVerify = { userId: user.userId, key: primaryKey }; - const selfCertification = await helper.getLatestValidSignature(user.selfCertifications, primaryKey, enums.signature.cert_generic, dataToVerify, date); + const selfCertification = await helper.getLatestValidSignature(user.selfCertifications, primaryKey, enums.signature.certGeneric, dataToVerify, date); users.push({ index: i, user, selfCertification }); } catch (e) { exception = e; @@ -678,7 +678,7 @@ Key.prototype.update = async function(key) { } // revocation signatures await helper.mergeSignatures(key, this, 'revocationSignatures', srcRevSig => { - return helper.isDataRevoked(this.keyPacket, enums.signature.key_revocation, this, [srcRevSig], null, key.keyPacket); + return helper.isDataRevoked(this.keyPacket, enums.signature.keyRevocation, this, [srcRevSig], null, key.keyPacket); }); // direct signatures await helper.mergeSignatures(key, this, 'directSignatures'); @@ -724,7 +724,7 @@ Key.prototype.update = async function(key) { * @async */ Key.prototype.revoke = async function({ - flag: reasonForRevocationFlag = enums.reasonForRevocation.no_reason, + flag: reasonForRevocationFlag = enums.reasonForRevocation.noReason, string: reasonForRevocationString = '' } = {}, date = new Date()) { if (this.isPublic()) { @@ -733,7 +733,7 @@ Key.prototype.revoke = async function({ const dataToSign = { key: this.keyPacket }; const key = await this.clone(); key.revocationSignatures.push(await helper.createSignaturePacket(dataToSign, null, this.keyPacket, { - signatureType: enums.signature.key_revocation, + signatureType: enums.signature.keyRevocation, reasonForRevocationFlag: enums.write(enums.reasonForRevocation, reasonForRevocationFlag), reasonForRevocationString }, date)); @@ -749,10 +749,10 @@ Key.prototype.revoke = async function({ */ Key.prototype.getRevocationCertificate = async function(date = new Date()) { const dataToVerify = { key: this.keyPacket }; - const revocationSignature = await helper.getLatestValidSignature(this.revocationSignatures, this.keyPacket, enums.signature.key_revocation, dataToVerify, date); + const revocationSignature = await helper.getLatestValidSignature(this.revocationSignatures, this.keyPacket, enums.signature.keyRevocation, dataToVerify, date); const packetlist = new packet.List(); packetlist.push(revocationSignature); - return armor.encode(enums.armor.public_key, packetlist.write(), null, null, 'This is a revocation certificate'); + return armor.encode(enums.armor.publicKey, packetlist.write(), null, null, 'This is a revocation certificate'); }; /** @@ -768,7 +768,7 @@ Key.prototype.applyRevocationCertificate = async function(revocationCertificate) const packetlist = new packet.List(); await packetlist.read(input.data); const revocationSignature = packetlist.findPacket(enums.packet.signature); - if (!revocationSignature || revocationSignature.signatureType !== enums.signature.key_revocation) { + if (!revocationSignature || revocationSignature.signatureType !== enums.signature.keyRevocation) { throw new Error('Could not find revocation signature packet'); } if (!revocationSignature.issuerKeyId.equals(this.getKeyId())) { @@ -778,7 +778,7 @@ Key.prototype.applyRevocationCertificate = async function(revocationCertificate) throw new Error('Revocation signature is expired'); } try { - await revocationSignature.verify(this.keyPacket, enums.signature.key_revocation, { key: this.keyPacket }); + await revocationSignature.verify(this.keyPacket, enums.signature.keyRevocation, { key: this.keyPacket }); } catch (e) { throw util.wrapError('Could not verify revocation signature', e); } diff --git a/src/key/subkey.js b/src/key/subkey.js index 5defb3fd..672c3377 100644 --- a/src/key/subkey.js +++ b/src/key/subkey.js @@ -55,7 +55,7 @@ SubKey.prototype.toPacketlist = function() { */ SubKey.prototype.isRevoked = async function(primaryKey, signature, key, date = new Date()) { return helper.isDataRevoked( - primaryKey, enums.signature.subkey_revocation, { + primaryKey, enums.signature.subkeyRevocation, { key: primaryKey, bind: this.keyPacket }, this.revocationSignatures, signature, key, date @@ -75,7 +75,7 @@ SubKey.prototype.isRevoked = async function(primaryKey, signature, key, date = n SubKey.prototype.verify = async function(primaryKey, date = new Date()) { const dataToVerify = { key: primaryKey, bind: this.keyPacket }; // check subkey binding signatures - const bindingSignature = await helper.getLatestValidSignature(this.bindingSignatures, primaryKey, enums.signature.subkey_binding, dataToVerify, date); + const bindingSignature = await helper.getLatestValidSignature(this.bindingSignatures, primaryKey, enums.signature.subkeyBinding, dataToVerify, date); // check binding signature is not revoked if (bindingSignature.revoked || await this.isRevoked(primaryKey, bindingSignature, null, date)) { throw new Error('Subkey is revoked'); @@ -99,7 +99,7 @@ SubKey.prototype.getExpirationTime = async function(primaryKey, date = new Date( const dataToVerify = { key: primaryKey, bind: this.keyPacket }; let bindingSignature; try { - bindingSignature = await helper.getLatestValidSignature(this.bindingSignatures, primaryKey, enums.signature.subkey_binding, dataToVerify, date); + bindingSignature = await helper.getLatestValidSignature(this.bindingSignatures, primaryKey, enums.signature.subkeyBinding, dataToVerify, date); } catch (e) { return null; } @@ -138,14 +138,14 @@ SubKey.prototype.update = async function(subKey, primaryKey) { } } try { - return srcBindSig.verified || await srcBindSig.verify(primaryKey, enums.signature.subkey_binding, dataToVerify); + return srcBindSig.verified || await srcBindSig.verify(primaryKey, enums.signature.subkeyBinding, dataToVerify); } catch (e) { return false; } }); // revocation signatures await helper.mergeSignatures(subKey, this, 'revocationSignatures', function(srcRevSig) { - return helper.isDataRevoked(primaryKey, enums.signature.subkey_revocation, dataToVerify, [srcRevSig]); + return helper.isDataRevoked(primaryKey, enums.signature.subkeyRevocation, dataToVerify, [srcRevSig]); }); }; @@ -160,13 +160,13 @@ SubKey.prototype.update = async function(subKey, primaryKey) { * @async */ SubKey.prototype.revoke = async function(primaryKey, { - flag: reasonForRevocationFlag = enums.reasonForRevocation.no_reason, + flag: reasonForRevocationFlag = enums.reasonForRevocation.noReason, string: reasonForRevocationString = '' } = {}, date = new Date()) { const dataToSign = { key: primaryKey, bind: this.keyPacket }; const subKey = new SubKey(this.keyPacket); subKey.revocationSignatures.push(await helper.createSignaturePacket(dataToSign, null, primaryKey, { - signatureType: enums.signature.subkey_revocation, + signatureType: enums.signature.subkeyRevocation, reasonForRevocationFlag: enums.write(enums.reasonForRevocation, reasonForRevocationFlag), reasonForRevocationString }, date)); diff --git a/src/key/user.js b/src/key/user.js index 84d5320a..80cfdaa3 100644 --- a/src/key/user.js +++ b/src/key/user.js @@ -64,8 +64,8 @@ User.prototype.sign = async function(primaryKey, privateKeys) { const signingKey = await privateKey.getSigningKey(); return createSignaturePacket(dataToSign, privateKey, signingKey.keyPacket, { // Most OpenPGP implementations use generic certification (0x10) - signatureType: enums.signature.cert_generic, - keyFlags: [enums.keyFlags.certify_keys | enums.keyFlags.sign_data] + signatureType: enums.signature.certGeneric, + keyFlags: [enums.keyFlags.certifyKeys | enums.keyFlags.signData] }); })); await user.update(this, primaryKey); @@ -87,7 +87,7 @@ User.prototype.sign = async function(primaryKey, privateKeys) { */ User.prototype.isRevoked = async function(primaryKey, certificate, key, date = new Date()) { return isDataRevoked( - primaryKey, enums.signature.cert_revocation, { + primaryKey, enums.signature.certRevocation, { key: primaryKey, userId: this.userId, userAttribute: this.userAttribute @@ -123,7 +123,7 @@ User.prototype.verifyCertificate = async function(primaryKey, certificate, keys, throw new Error('User certificate is revoked'); } try { - certificate.verified || await certificate.verify(signingKey.keyPacket, enums.signature.cert_generic, dataToVerify); + certificate.verified || await certificate.verify(signingKey.keyPacket, enums.signature.certGeneric, dataToVerify); } catch (e) { throw util.wrapError('User certificate is invalid', e); } @@ -184,7 +184,7 @@ User.prototype.verify = async function(primaryKey, date = new Date()) { throw new Error('Self-certification is revoked'); } try { - selfCertification.verified || await selfCertification.verify(primaryKey, enums.signature.cert_generic, dataToVerify); + selfCertification.verified || await selfCertification.verify(primaryKey, enums.signature.certGeneric, dataToVerify); } catch (e) { throw util.wrapError('Self-certification is invalid', e); } @@ -216,7 +216,7 @@ User.prototype.update = async function(user, primaryKey) { // self signatures await mergeSignatures(user, this, 'selfCertifications', async function(srcSelfSig) { try { - return srcSelfSig.verified || srcSelfSig.verify(primaryKey, enums.signature.cert_generic, dataToVerify); + return srcSelfSig.verified || srcSelfSig.verify(primaryKey, enums.signature.certGeneric, dataToVerify); } catch (e) { return false; } @@ -225,6 +225,6 @@ User.prototype.update = async function(user, primaryKey) { await mergeSignatures(user, this, 'otherCertifications'); // revocation signatures await mergeSignatures(user, this, 'revocationSignatures', function(srcRevSig) { - return isDataRevoked(primaryKey, enums.signature.cert_revocation, dataToVerify, [srcRevSig]); + return isDataRevoked(primaryKey, enums.signature.certRevocation, dataToVerify, [srcRevSig]); }); }; diff --git a/src/packet/signature.js b/src/packet/signature.js index dd818a82..f687360e 100644 --- a/src/packet/signature.js +++ b/src/packet/signature.js @@ -202,35 +202,35 @@ Signature.prototype.write_hashed_sub_packets = function () { const arr = []; let bytes; if (this.created !== null) { - arr.push(write_sub_packet(sub.signature_creation_time, util.writeDate(this.created))); + arr.push(write_sub_packet(sub.signatureCreationTime, util.writeDate(this.created))); } if (this.signatureExpirationTime !== null) { - arr.push(write_sub_packet(sub.signature_expiration_time, util.writeNumber(this.signatureExpirationTime, 4))); + arr.push(write_sub_packet(sub.signatureExpirationTime, util.writeNumber(this.signatureExpirationTime, 4))); } if (this.exportable !== null) { - arr.push(write_sub_packet(sub.exportable_certification, new Uint8Array([this.exportable ? 1 : 0]))); + arr.push(write_sub_packet(sub.exportableCertification, new Uint8Array([this.exportable ? 1 : 0]))); } if (this.trustLevel !== null) { bytes = new Uint8Array([this.trustLevel, this.trustAmount]); - arr.push(write_sub_packet(sub.trust_signature, bytes)); + arr.push(write_sub_packet(sub.trustSignature, bytes)); } if (this.regularExpression !== null) { - arr.push(write_sub_packet(sub.regular_expression, this.regularExpression)); + arr.push(write_sub_packet(sub.regularExpression, this.regularExpression)); } if (this.revocable !== null) { arr.push(write_sub_packet(sub.revocable, new Uint8Array([this.revocable ? 1 : 0]))); } if (this.keyExpirationTime !== null) { - arr.push(write_sub_packet(sub.key_expiration_time, util.writeNumber(this.keyExpirationTime, 4))); + arr.push(write_sub_packet(sub.keyExpirationTime, util.writeNumber(this.keyExpirationTime, 4))); } if (this.preferredSymmetricAlgorithms !== null) { bytes = util.strToUint8Array(util.uint8ArrayToStr(this.preferredSymmetricAlgorithms)); - arr.push(write_sub_packet(sub.preferred_symmetric_algorithms, bytes)); + arr.push(write_sub_packet(sub.preferredSymmetricAlgorithms, bytes)); } if (this.revocationKeyClass !== null) { bytes = new Uint8Array([this.revocationKeyClass, this.revocationKeyAlgorithm]); bytes = util.concat([bytes, this.revocationKeyFingerprint]); - arr.push(write_sub_packet(sub.revocation_key, bytes)); + arr.push(write_sub_packet(sub.revocationKey, bytes)); } this.rawNotations.forEach(([{ name, value, humanReadable }]) => { bytes = [new Uint8Array([humanReadable ? 0x80 : 0, 0, 0, 0])]; @@ -241,39 +241,39 @@ Signature.prototype.write_hashed_sub_packets = function () { bytes.push(util.strToUint8Array(name)); bytes.push(value); bytes = util.concat(bytes); - arr.push(write_sub_packet(sub.notation_data, bytes)); + arr.push(write_sub_packet(sub.notationData, bytes)); }); if (this.preferredHashAlgorithms !== null) { bytes = util.strToUint8Array(util.uint8ArrayToStr(this.preferredHashAlgorithms)); - arr.push(write_sub_packet(sub.preferred_hash_algorithms, bytes)); + arr.push(write_sub_packet(sub.preferredHashAlgorithms, bytes)); } if (this.preferredCompressionAlgorithms !== null) { bytes = util.strToUint8Array(util.uint8ArrayToStr(this.preferredCompressionAlgorithms)); - arr.push(write_sub_packet(sub.preferred_compression_algorithms, bytes)); + arr.push(write_sub_packet(sub.preferredCompressionAlgorithms, bytes)); } if (this.keyServerPreferences !== null) { bytes = util.strToUint8Array(util.uint8ArrayToStr(this.keyServerPreferences)); - arr.push(write_sub_packet(sub.key_server_preferences, bytes)); + arr.push(write_sub_packet(sub.keyServerPreferences, bytes)); } if (this.preferredKeyServer !== null) { - arr.push(write_sub_packet(sub.preferred_key_server, util.strToUint8Array(this.preferredKeyServer))); + arr.push(write_sub_packet(sub.preferredKeyServer, util.strToUint8Array(this.preferredKeyServer))); } if (this.isPrimaryUserID !== null) { - arr.push(write_sub_packet(sub.primary_user_id, new Uint8Array([this.isPrimaryUserID ? 1 : 0]))); + arr.push(write_sub_packet(sub.primaryUserId, new Uint8Array([this.isPrimaryUserID ? 1 : 0]))); } if (this.policyURI !== null) { - arr.push(write_sub_packet(sub.policy_uri, util.strToUint8Array(this.policyURI))); + arr.push(write_sub_packet(sub.policyUri, util.strToUint8Array(this.policyURI))); } if (this.keyFlags !== null) { bytes = util.strToUint8Array(util.uint8ArrayToStr(this.keyFlags)); - arr.push(write_sub_packet(sub.key_flags, bytes)); + arr.push(write_sub_packet(sub.keyFlags, bytes)); } if (this.signersUserId !== null) { - arr.push(write_sub_packet(sub.signers_user_id, util.strToUint8Array(this.signersUserId))); + arr.push(write_sub_packet(sub.signersUserId, util.strToUint8Array(this.signersUserId))); } if (this.reasonForRevocationFlag !== null) { bytes = util.strToUint8Array(String.fromCharCode(this.reasonForRevocationFlag) + this.reasonForRevocationString); - arr.push(write_sub_packet(sub.reason_for_revocation, bytes)); + arr.push(write_sub_packet(sub.reasonForRevocation, bytes)); } if (this.features !== null) { bytes = util.strToUint8Array(util.uint8ArrayToStr(this.features)); @@ -283,11 +283,11 @@ Signature.prototype.write_hashed_sub_packets = function () { bytes = [new Uint8Array([this.signatureTargetPublicKeyAlgorithm, this.signatureTargetHashAlgorithm])]; bytes.push(util.strToUint8Array(this.signatureTargetHash)); bytes = util.concat(bytes); - arr.push(write_sub_packet(sub.signature_target, bytes)); + arr.push(write_sub_packet(sub.signatureTarget, bytes)); } if (this.preferredAeadAlgorithms !== null) { bytes = util.strToUint8Array(util.uint8ArrayToStr(this.preferredAeadAlgorithms)); - arr.push(write_sub_packet(sub.preferred_aead_algorithms, bytes)); + arr.push(write_sub_packet(sub.preferredAeadAlgorithms, bytes)); } const result = util.concat(arr); @@ -310,12 +310,12 @@ Signature.prototype.write_unhashed_sub_packets = function() { arr.push(write_sub_packet(sub.issuer, this.issuerKeyId.write())); } if (this.embeddedSignature !== null) { - arr.push(write_sub_packet(sub.embedded_signature, this.embeddedSignature.write())); + arr.push(write_sub_packet(sub.embeddedSignature, this.embeddedSignature.write())); } if (this.issuerFingerprint !== null) { bytes = [new Uint8Array([this.issuerKeyVersion]), this.issuerFingerprint]; bytes = util.concat(bytes); - arr.push(write_sub_packet(sub.issuer_fingerprint, bytes)); + arr.push(write_sub_packet(sub.issuerFingerprint, bytes)); } this.unhashedSubpackets.forEach(data => { arr.push(packet.writeSimpleLength(data.length)); @@ -367,8 +367,8 @@ Signature.prototype.read_sub_packet = function (bytes, trusted = true) { // Ignore all other unhashed subpackets. if (!trusted && ![ enums.signatureSubpacket.issuer, - enums.signatureSubpacket.issuer_fingerprint, - enums.signatureSubpacket.embedded_signature + enums.signatureSubpacket.issuerFingerprint, + enums.signatureSubpacket.embeddedSignature ].includes(type)) { this.unhashedSubpackets.push(bytes.subarray(mypos, bytes.length)); return; @@ -581,11 +581,11 @@ Signature.prototype.toSign = function (type, data) { case t.standalone: return new Uint8Array(0); - case t.cert_generic: - case t.cert_persona: - case t.cert_casual: - case t.cert_positive: - case t.cert_revocation: { + case t.certGeneric: + case t.certPersona: + case t.certCasual: + case t.certPositive: + case t.certRevocation: { let packet; let tag; @@ -607,9 +607,9 @@ Signature.prototype.toSign = function (type, data) { util.writeNumber(bytes.length, 4), bytes]); } - case t.subkey_binding: - case t.subkey_revocation: - case t.key_binding: + case t.subkeyBinding: + case t.subkeyRevocation: + case t.keyBinding: return util.concat([this.toSign(t.key, data), this.toSign(t.key, { key: data.bind })]); @@ -620,11 +620,11 @@ Signature.prototype.toSign = function (type, data) { } return data.key.writeForHash(this.version); - case t.key_revocation: + case t.keyRevocation: return this.toSign(t.key, data); case t.timestamp: return new Uint8Array(0); - case t.third_party: + case t.thirdParty: throw new Error('Not implemented'); default: throw new Error('Unknown signature type.'); diff --git a/test/crypto/rsa.js b/test/crypto/rsa.js index 8385d086..6c69b4e2 100644 --- a/test/crypto/rsa.js +++ b/test/crypto/rsa.js @@ -22,7 +22,7 @@ const native = openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(); it('sign and verify using generated key params', async function() { const bits = openpgp.util.getWebCryptoAll() ? 2048 : 1024; - const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsa_sign, bits); + const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const message = await openpgp.crypto.random.getRandomBytes(64); const hash_algo = openpgp.enums.write(openpgp.enums.hash, 'sha256'); const hashed = await openpgp.crypto.hash.digest(hash_algo, message); @@ -40,7 +40,7 @@ const native = openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(); it('encrypt and decrypt using generated key params', async function() { const bits = openpgp.util.getWebCryptoAll() ? 2048 : 1024; - const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsa_sign, bits); + const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const n = keyParams[0].toUint8Array(); const e = keyParams[1].toUint8Array(); const d = keyParams[2].toUint8Array(); @@ -59,7 +59,7 @@ const native = openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(); this.skip(); } const bits = 1024; - const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsa_sign, bits); + const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const n = keyParams[0].toUint8Array(); const e = keyParams[1].toUint8Array(); const d = keyParams[2].toUint8Array(); @@ -82,7 +82,7 @@ const native = openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(); this.skip(); } const bits = openpgp.util.getWebCrypto() ? 2048 : 1024; - const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsa_sign, bits); + const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const n = keyParams[0].toUint8Array(); const e = keyParams[1].toUint8Array(); const d = keyParams[2].toUint8Array(); @@ -109,7 +109,7 @@ const native = openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(); this.skip(); } const bits = openpgp.util.getWebCrypto() ? 2048 : 1024; - const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsa_sign, bits); + const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const n = keyParams[0].toUint8Array(); const e = keyParams[1].toUint8Array(); const d = keyParams[2].toUint8Array(); @@ -139,7 +139,7 @@ const native = openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(); this.skip(); } const bits = 1024; - const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsa_sign, bits); + const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const n = keyParams[0].toUint8Array(); const e = keyParams[1].toUint8Array(); const d = keyParams[2].toUint8Array(); @@ -160,7 +160,7 @@ const native = openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(); this.skip(); } const bits = openpgp.util.getWebCrypto() ? 2048 : 1024; - const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsa_sign, bits); + const keyParams = await openpgp.crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const n = keyParams[0].toUint8Array(); const e = keyParams[1].toUint8Array(); const d = keyParams[2].toUint8Array(); diff --git a/test/general/key.js b/test/general/key.js index 31346526..93e9bd6c 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -1970,10 +1970,10 @@ function versionSpecificTests() { const testPref = function(key) { // key flags const keyFlags = openpgp.enums.keyFlags; - expect(key.users[0].selfCertifications[0].keyFlags[0] & keyFlags.certify_keys).to.equal(keyFlags.certify_keys); - expect(key.users[0].selfCertifications[0].keyFlags[0] & keyFlags.sign_data).to.equal(keyFlags.sign_data); - expect(key.subKeys[0].bindingSignatures[0].keyFlags[0] & keyFlags.encrypt_communication).to.equal(keyFlags.encrypt_communication); - expect(key.subKeys[0].bindingSignatures[0].keyFlags[0] & keyFlags.encrypt_storage).to.equal(keyFlags.encrypt_storage); + expect(key.users[0].selfCertifications[0].keyFlags[0] & keyFlags.certifyKeys).to.equal(keyFlags.certifyKeys); + expect(key.users[0].selfCertifications[0].keyFlags[0] & keyFlags.signData).to.equal(keyFlags.signData); + expect(key.subKeys[0].bindingSignatures[0].keyFlags[0] & keyFlags.encryptCommunication).to.equal(keyFlags.encryptCommunication); + expect(key.subKeys[0].bindingSignatures[0].keyFlags[0] & keyFlags.encryptStorage).to.equal(keyFlags.encryptStorage); const sym = openpgp.enums.symmetric; expect(key.users[0].selfCertifications[0].preferredSymmetricAlgorithms).to.eql([sym.aes256, sym.aes128, sym.aes192]); if (openpgp.config.aeadProtect) { @@ -2010,20 +2010,20 @@ function versionSpecificTests() { openpgp.config.encryptionCipher = openpgp.enums.symmetric.aes192; openpgp.config.preferHashAlgorithm = openpgp.enums.hash.sha224; openpgp.config.compression = openpgp.enums.compression.zlib; - openpgp.config.aeadMode = openpgp.enums.aead.experimental_gcm; + openpgp.config.aeadMode = openpgp.enums.aead.experimentalGcm; const testPref = function(key) { // key flags const keyFlags = openpgp.enums.keyFlags; - expect(key.users[0].selfCertifications[0].keyFlags[0] & keyFlags.certify_keys).to.equal(keyFlags.certify_keys); - expect(key.users[0].selfCertifications[0].keyFlags[0] & keyFlags.sign_data).to.equal(keyFlags.sign_data); - expect(key.subKeys[0].bindingSignatures[0].keyFlags[0] & keyFlags.encrypt_communication).to.equal(keyFlags.encrypt_communication); - expect(key.subKeys[0].bindingSignatures[0].keyFlags[0] & keyFlags.encrypt_storage).to.equal(keyFlags.encrypt_storage); + expect(key.users[0].selfCertifications[0].keyFlags[0] & keyFlags.certifyKeys).to.equal(keyFlags.certifyKeys); + expect(key.users[0].selfCertifications[0].keyFlags[0] & keyFlags.signData).to.equal(keyFlags.signData); + expect(key.subKeys[0].bindingSignatures[0].keyFlags[0] & keyFlags.encryptCommunication).to.equal(keyFlags.encryptCommunication); + expect(key.subKeys[0].bindingSignatures[0].keyFlags[0] & keyFlags.encryptStorage).to.equal(keyFlags.encryptStorage); const sym = openpgp.enums.symmetric; expect(key.users[0].selfCertifications[0].preferredSymmetricAlgorithms).to.eql([sym.aes192, sym.aes256, sym.aes128]); if (openpgp.config.aeadProtect) { const aead = openpgp.enums.aead; - expect(key.users[0].selfCertifications[0].preferredAeadAlgorithms).to.eql([aead.experimental_gcm, aead.eax, aead.ocb]); + expect(key.users[0].selfCertifications[0].preferredAeadAlgorithms).to.eql([aead.experimentalGcm, aead.eax, aead.ocb]); } const hash = openpgp.enums.hash; expect(key.users[0].selfCertifications[0].preferredHashAlgorithms).to.eql([hash.sha224, hash.sha256, hash.sha512]); @@ -2189,8 +2189,8 @@ function versionSpecificTests() { expect(key.users[0].userId.userid).to.equal(userId); expect(key.users[0].selfCertifications[0].isPrimaryUserID).to.be.true; expect(key.subKeys).to.have.length(2); - expect(key.subKeys[0].getAlgorithmInfo().algorithm).to.equal('rsa_encrypt_sign'); - expect(key.subKeys[1].getAlgorithmInfo().algorithm).to.equal('rsa_encrypt_sign'); + expect(key.subKeys[0].getAlgorithmInfo().algorithm).to.equal('rsaEncryptSign'); + expect(key.subKeys[1].getAlgorithmInfo().algorithm).to.equal('rsaEncryptSign'); }); }); @@ -2238,7 +2238,7 @@ function versionSpecificTests() { expect(key.users.length).to.equal(1); expect(key.users[0].userId.userid).to.equal(userId); expect(key.users[0].selfCertifications[0].isPrimaryUserID).to.be.true; - expect(key.getAlgorithmInfo().algorithm).to.equal('rsa_encrypt_sign'); + expect(key.getAlgorithmInfo().algorithm).to.equal('rsaEncryptSign'); expect(key.getAlgorithmInfo().bits).to.equal(opt.rsaBits); expect(key.getAlgorithmInfo().rsaBits).to.equal(key.getAlgorithmInfo().bits); expect(key.subKeys[0].getAlgorithmInfo().algorithm).to.equal('ecdh'); @@ -2496,7 +2496,7 @@ function versionSpecificTests() { return openpgp.generateKey(opt).then(function(original) { return openpgp.revokeKey({key: original.key.toPublic(), revocationCertificate: original.revocationCertificate}).then(async function(revKey) { revKey = revKey.publicKey; - expect(revKey.revocationSignatures[0].reasonForRevocationFlag).to.equal(openpgp.enums.reasonForRevocation.no_reason); + expect(revKey.revocationSignatures[0].reasonForRevocationFlag).to.equal(openpgp.enums.reasonForRevocation.noReason); expect(revKey.revocationSignatures[0].reasonForRevocationString).to.equal(''); await expect(revKey.verifyPrimaryKey()).to.be.rejectedWith('Primary key is revoked'); }); @@ -2509,7 +2509,7 @@ function versionSpecificTests() { await original.key.decrypt('1234'); return openpgp.revokeKey({key: original.key, reasonForRevocation: {string: 'Testing key revocation'}}).then(async function(revKey) { revKey = revKey.publicKey; - expect(revKey.revocationSignatures[0].reasonForRevocationFlag).to.equal(openpgp.enums.reasonForRevocation.no_reason); + expect(revKey.revocationSignatures[0].reasonForRevocationFlag).to.equal(openpgp.enums.reasonForRevocation.noReason); expect(revKey.revocationSignatures[0].reasonForRevocationString).to.equal('Testing key revocation'); await expect(revKey.verifyPrimaryKey()).to.be.rejectedWith('Primary key is revoked'); }); @@ -3015,12 +3015,12 @@ describe('Key', function() { await privKey.decrypt('hello world'); await privKey.revoke({ - flag: openpgp.enums.reasonForRevocation.key_retired, + flag: openpgp.enums.reasonForRevocation.keyRetired, string: 'Testing key revocation' }).then(async revKey => { expect(revKey.revocationSignatures).to.exist.and.have.length(1); - expect(revKey.revocationSignatures[0].signatureType).to.equal(openpgp.enums.signature.key_revocation); - expect(revKey.revocationSignatures[0].reasonForRevocationFlag).to.equal(openpgp.enums.reasonForRevocation.key_retired); + expect(revKey.revocationSignatures[0].signatureType).to.equal(openpgp.enums.signature.keyRevocation); + expect(revKey.revocationSignatures[0].reasonForRevocationFlag).to.equal(openpgp.enums.reasonForRevocation.keyRetired); expect(revKey.revocationSignatures[0].reasonForRevocationString).to.equal('Testing key revocation'); await privKey.verifyPrimaryKey(); @@ -3035,11 +3035,11 @@ describe('Key', function() { const subKey = pubKey.subKeys[0]; await subKey.revoke(privKey.primaryKey, { - flag: openpgp.enums.reasonForRevocation.key_superseded + flag: openpgp.enums.reasonForRevocation.keySuperseded }).then(async revKey => { expect(revKey.revocationSignatures).to.exist.and.have.length(1); - expect(revKey.revocationSignatures[0].signatureType).to.equal(openpgp.enums.signature.subkey_revocation); - expect(revKey.revocationSignatures[0].reasonForRevocationFlag).to.equal(openpgp.enums.reasonForRevocation.key_superseded); + expect(revKey.revocationSignatures[0].signatureType).to.equal(openpgp.enums.signature.subkeyRevocation); + expect(revKey.revocationSignatures[0].reasonForRevocationFlag).to.equal(openpgp.enums.reasonForRevocation.keySuperseded); expect(revKey.revocationSignatures[0].reasonForRevocationString).to.equal(''); await subKey.verify(pubKey.primaryKey); @@ -3062,7 +3062,7 @@ describe('Key', function() { const input = await openpgp.armor.decode(revocation_certificate_arm4); const packetlist = new openpgp.packet.List(); await packetlist.read(input.data); - const armored = openpgp.armor.encode(openpgp.enums.armor.public_key, packetlist.write()); + const armored = openpgp.armor.encode(openpgp.enums.armor.publicKey, packetlist.write()); expect(revocationCertificate.replace(/^Comment: .*$\r\n/mg, '')).to.equal(armored.replace(/^Comment: .*$\r\n/mg, '')); }); @@ -3336,7 +3336,7 @@ describe('addSubkey functionality testing', function(){ const subkeyN = subKey.keyPacket.params[0]; const pkN = privateKey.primaryKey.params[0]; expect(subkeyN.byteLength()).to.be.equal(rsaBits ? (rsaBits / 8) : pkN.byteLength()); - expect(subKey.getAlgorithmInfo().algorithm).to.be.equal('rsa_encrypt_sign'); + expect(subKey.getAlgorithmInfo().algorithm).to.be.equal('rsaEncryptSign'); expect(subKey.getAlgorithmInfo().rsaBits).to.be.equal(rsaBits || privateKey.getAlgorithmInfo().rsaBits); await subKey.verify(newPrivateKey.primaryKey); }); @@ -3463,7 +3463,7 @@ describe('addSubkey functionality testing', function(){ const armoredKey = newPrivateKey.armor(); newPrivateKey = await openpgp.key.readArmored(armoredKey); const subKey = newPrivateKey.subKeys[total]; - expect(subKey.getAlgorithmInfo().algorithm).to.be.equal('rsa_encrypt_sign'); + expect(subKey.getAlgorithmInfo().algorithm).to.be.equal('rsaEncryptSign'); await subKey.verify(newPrivateKey.primaryKey); expect(await newPrivateKey.getSigningKey()).to.be.equal(subKey); const signed = await openpgp.sign({message: openpgp.message.fromText('the data to signed'), privateKeys: newPrivateKey, armor:false}); diff --git a/test/general/openpgp.js b/test/general/openpgp.js index 08ccf956..1f936ba6 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -781,7 +781,7 @@ describe('OpenPGP.js public api tests', function() { if: true, beforeEach: function() { openpgp.config.aeadProtect = true; - openpgp.config.aeadMode = openpgp.enums.aead.experimental_gcm; + openpgp.config.aeadMode = openpgp.enums.aead.experimentalGcm; openpgp.config.v5Keys = true; // Monkey-patch AEAD feature flag diff --git a/test/general/packet.js b/test/general/packet.js index e41012c3..fbc56d88 100644 --- a/test/general/packet.js +++ b/test/general/packet.js @@ -216,7 +216,7 @@ describe("Packet", function() { const literal = new openpgp.packet.Literal(); const enc = new openpgp.packet.SymEncryptedAEADProtected(); const msg = new openpgp.packet.List(); - enc.aeadAlgorithm = 'experimental_gcm'; + enc.aeadAlgorithm = 'experimentalGcm'; msg.push(enc); literal.setText(testText); @@ -330,7 +330,7 @@ describe("Packet", function() { const msg2 = new openpgp.packet.List(); enc.sessionKey = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]); - enc.publicKeyAlgorithm = 'rsa_encrypt_sign'; + enc.publicKeyAlgorithm = 'rsaEncryptSign'; enc.sessionKeyAlgorithm = 'aes256'; enc.publicKeyId.bytes = '12345678'; return enc.encrypt({ params: mpi, getFingerprintBytes() {} }).then(async () => { @@ -339,7 +339,7 @@ describe("Packet", function() { await msg2.read(msg.write()); - return msg2[0].decrypt({ algorithm: 'rsa_encrypt_sign', params: mpi, getFingerprintBytes() {} }).then(() => { + return msg2[0].decrypt({ algorithm: 'rsaEncryptSign', params: mpi, getFingerprintBytes() {} }).then(() => { expect(stringify(msg2[0].sessionKey)).to.equal(stringify(enc.sessionKey)); expect(msg2[0].sessionKeyAlgorithm).to.equal(enc.sessionKeyAlgorithm); @@ -379,7 +379,7 @@ describe("Packet", function() { const secret = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]); enc.sessionKey = secret; - enc.publicKeyAlgorithm = 'rsa_encrypt_sign'; + enc.publicKeyAlgorithm = 'rsaEncryptSign'; enc.sessionKeyAlgorithm = 'aes256'; enc.publicKeyId.bytes = '12345678'; @@ -711,13 +711,13 @@ describe("Packet", function() { await key.read((await openpgp.armor.decode(armored_key)).data); return Promise.all([ expect(key[2].verify(key[0], - openpgp.enums.signature.cert_generic, + openpgp.enums.signature.certGeneric, { userId: key[1], key: key[0] })).to.eventually.be.true, expect(key[4].verify(key[0], - openpgp.enums.signature.key_binding, + openpgp.enums.signature.keyBinding, { key: key[0], bind: key[3] @@ -855,7 +855,7 @@ V+HOQJQxXJkVRYa3QrFUehiMzTeqqMdgC6ZqJy7+ }); key[0].params = mpi; - key[0].algorithm = "rsa_sign"; + key[0].algorithm = "rsaSign"; key[0].isEncrypted = false; await key[0].encrypt('hello'); @@ -887,7 +887,7 @@ V+HOQJQxXJkVRYa3QrFUehiMzTeqqMdgC6ZqJy7+ }); key[0].params = mpi; - key[0].algorithm = "rsa_sign"; + key[0].algorithm = "rsaSign"; key[0].isEncrypted = false; await key[0].encrypt('hello'); @@ -917,7 +917,7 @@ V+HOQJQxXJkVRYa3QrFUehiMzTeqqMdgC6ZqJy7+ const testText = input.createSomeMessage(); key.params = mpi; - key.algorithm = "rsa_sign"; + key.algorithm = "rsaSign"; const signed = new openpgp.packet.List(); const literal = new openpgp.packet.Literal(); @@ -926,7 +926,7 @@ V+HOQJQxXJkVRYa3QrFUehiMzTeqqMdgC6ZqJy7+ literal.setText(testText); signature.hashAlgorithm = openpgp.enums.hash.sha256; - signature.publicKeyAlgorithm = openpgp.enums.publicKey.rsa_sign; + signature.publicKeyAlgorithm = openpgp.enums.publicKey.rsaSign; signature.signatureType = openpgp.enums.signature.text; return signature.sign(key, literal).then(async () => { diff --git a/test/general/signature.js b/test/general/signature.js index c378ef61..8a07a69a 100644 --- a/test/general/signature.js +++ b/test/general/signature.js @@ -1521,7 +1521,7 @@ hkJiXopCSWKSlQInL1devkJJUWJmTmZeugJYlpdLAagQJM0JpsCqIQZwKgAA it('Verify primary key revocation signatures', async function() { const pubKey = await openpgp.key.readArmored(pub_revoked); await expect(pubKey.revocationSignatures[0].verify( - pubKey.primaryKey, openpgp.enums.signature.key_revocation, {key: pubKey.primaryKey} + pubKey.primaryKey, openpgp.enums.signature.keyRevocation, {key: pubKey.primaryKey} )).to.eventually.be.true; }); @@ -1529,7 +1529,7 @@ hkJiXopCSWKSlQInL1devkJJUWJmTmZeugJYlpdLAagQJM0JpsCqIQZwKgAA it('Verify subkey revocation signatures', async function() { const pubKey = await openpgp.key.readArmored(pub_revoked); await expect(pubKey.subKeys[0].revocationSignatures[0].verify( - pubKey.primaryKey, openpgp.enums.signature.subkey_revocation, {key: pubKey.primaryKey, bind: pubKey.subKeys[0].keyPacket} + pubKey.primaryKey, openpgp.enums.signature.subkeyRevocation, {key: pubKey.primaryKey, bind: pubKey.subKeys[0].keyPacket} )).to.eventually.be.true; }); diff --git a/test/general/x25519.js b/test/general/x25519.js index e348ba88..727bbcda 100644 --- a/test/general/x25519.js +++ b/test/general/x25519.js @@ -454,7 +454,7 @@ function omnibus() { // Self Certificate is valid const user = hi.users[0]; await expect(user.selfCertifications[0].verify( - primaryKey, openpgp.enums.signature.cert_generic, { userId: user.userId, key: primaryKey } + primaryKey, openpgp.enums.signature.certGeneric, { userId: user.userId, key: primaryKey } )).to.eventually.be.true; await user.verifyCertificate( primaryKey, user.selfCertifications[0], [hi.toPublic()] @@ -474,7 +474,7 @@ function omnibus() { // Self Certificate is valid const user = bye.users[0]; await expect(user.selfCertifications[0].verify( - bye.primaryKey, openpgp.enums.signature.cert_generic, { userId: user.userId, key: bye.primaryKey } + bye.primaryKey, openpgp.enums.signature.certGeneric, { userId: user.userId, key: bye.primaryKey } )).to.eventually.be.true; await user.verifyCertificate( bye.primaryKey, user.selfCertifications[0], [bye.toPublic()] @@ -484,7 +484,7 @@ function omnibus() { // Hi trusts Bye! bye.toPublic().signPrimaryUser([hi]).then(trustedBye => { expect(trustedBye.users[0].otherCertifications[0].verify( - primaryKey, openpgp.enums.signature.cert_generic, { userId: user.userId, key: bye.toPublic().primaryKey } + primaryKey, openpgp.enums.signature.certGeneric, { userId: user.userId, key: bye.toPublic().primaryKey } )).to.eventually.be.true; }), // Signing message diff --git a/test/security/subkey_trust.js b/test/security/subkey_trust.js index b8a6b4fb..20e20990 100644 --- a/test/security/subkey_trust.js +++ b/test/security/subkey_trust.js @@ -49,10 +49,10 @@ async function testSubkeyTrust() { bind: pktPubVictim[3] // victim subkey }; const fakeBindingSignature = new Signature(); - fakeBindingSignature.signatureType = enums.signature.subkey_binding; + fakeBindingSignature.signatureType = enums.signature.subkeyBinding; fakeBindingSignature.publicKeyAlgorithm = attackerPrivKey.keyPacket.algorithm; fakeBindingSignature.hashAlgorithm = enums.hash.sha256; - fakeBindingSignature.keyFlags = [enums.keyFlags.sign_data]; + fakeBindingSignature.keyFlags = [enums.keyFlags.signData]; await fakeBindingSignature.sign(attackerPrivKey.keyPacket, dataToSign); const newList = new List(); newList.concat([ diff --git a/test/security/unsigned_subpackets.js b/test/security/unsigned_subpackets.js index 0d248737..fc00028c 100644 --- a/test/security/unsigned_subpackets.js +++ b/test/security/unsigned_subpackets.js @@ -76,7 +76,7 @@ async function makeKeyValid() { fake.keyExpirationTime = 0x7FFFFFFF; fake.signatureExpirationTime = 0x7FFFFFFF; // add key capability - fake.keyFlags[0] |= enums.keyFlags.encrypt_communication; + fake.keyFlags[0] |= enums.keyFlags.encryptCommunication; // create modified subpacket data pusersig.read_sub_packets(fake.write_hashed_sub_packets(), false); // reconstruct the modified key