diff --git a/src/lib/config.h.in b/src/lib/config.h.in index 5a9396e3..0e938e9b 100644 --- a/src/lib/config.h.in +++ b/src/lib/config.h.in @@ -73,3 +73,10 @@ ((defined(__clang__) && (__clang_major__ >= 4)) ) #define RNP_USE_STD_REGEX 1 #endif + +/* do not use the statement for old MSVC versions */ +#if (!defined(_MSVC_LANG) || _MSVC_LANG >= 201703L) +# define FALLTHROUGH_STATEMENT [[fallthrough]]; +#else +# define FALLTHROUGH_STATEMENT +#endif \ No newline at end of file diff --git a/src/lib/crypto.cpp b/src/lib/crypto.cpp index 876ea117..59126b69 100644 --- a/src/lib/crypto.cpp +++ b/src/lib/crypto.cpp @@ -133,9 +133,7 @@ pgp_generate_seckey(const rnp_keygen_crypto_params_t &crypto, seckey.material.ec.curve = crypto.ecc.curve; break; } -#if (!defined(_MSVC_LANG) || _MSVC_LANG >= 201703L) - [[fallthrough]]; -#endif + FALLTHROUGH_STATEMENT; case PGP_PKA_ECDSA: case PGP_PKA_SM2: if (!curve_supported(crypto.ecc.curve)) { @@ -175,14 +173,14 @@ pgp_generate_seckey(const rnp_keygen_crypto_params_t &crypto, #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: if (pgp_kyber_ecdh_composite_key_t::gen_keypair( &crypto.ctx->rng, &seckey.material.kyber_ecdh, seckey.alg)) { @@ -191,14 +189,14 @@ pgp_generate_seckey(const rnp_keygen_crypto_params_t &crypto, } break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: if (pgp_dilithium_exdsa_composite_key_t::gen_keypair( &crypto.ctx->rng, &seckey.material.dilithium_exdsa, seckey.alg)) { @@ -208,7 +206,7 @@ pgp_generate_seckey(const rnp_keygen_crypto_params_t &crypto, } break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: if (pgp_sphincsplus_generate(&crypto.ctx->rng, &seckey.material.sphincsplus, @@ -267,29 +265,29 @@ key_material_equal(const pgp_key_material_t *key1, const pgp_key_material_t *key #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return (key1->kyber_ecdh.pub == key2->kyber_ecdh.pub); case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: return (key1->dilithium_exdsa.pub == key2->dilithium_exdsa.pub); case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return (key1->sphincsplus.pub == key2->sphincsplus.pub); #endif @@ -348,29 +346,29 @@ validate_pgp_key_material(const pgp_key_material_t *material, rnp::RNG *rng) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return kyber_ecdh_validate_key(rng, &material->kyber_ecdh, material->secret); case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: return dilithium_exdsa_validate_key(rng, &material->dilithium_exdsa, material->secret); case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return sphincsplus_validate_key(rng, &material->sphincsplus, material->secret); #endif diff --git a/src/lib/crypto/dilithium_exdsa_composite.cpp b/src/lib/crypto/dilithium_exdsa_composite.cpp index 116d7597..cd2ed80c 100644 --- a/src/lib/crypto/dilithium_exdsa_composite.cpp +++ b/src/lib/crypto/dilithium_exdsa_composite.cpp @@ -142,16 +142,14 @@ pgp_dilithium_exdsa_composite_key_t::pk_alg_to_dilithium_id(pgp_pubkey_alg_t pk_ { switch (pk_alg) { case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: return dilithium_L3; case PGP_PKA_DILITHIUM5_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - //[[fallthrough]]; - // case PGP_PKA_DILITHIUM5_ED448: return dilithium_L5; default: RNP_LOG("invalid PK alg given"); diff --git a/src/lib/crypto/ec.cpp b/src/lib/crypto/ec.cpp index ef937350..8aca0a47 100644 --- a/src/lib/crypto/ec.cpp +++ b/src/lib/crypto/ec.cpp @@ -199,17 +199,17 @@ is_generic_prime_curve(pgp_curve_t curve) { switch (curve) { case PGP_CURVE_NIST_P_256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_NIST_P_384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_NIST_P_521: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_BP512: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_P256K1: return true; default: diff --git a/src/lib/crypto/ecdh.cpp b/src/lib/crypto/ecdh.cpp index 85a0b637..31f078ac 100644 --- a/src/lib/crypto/ecdh.cpp +++ b/src/lib/crypto/ecdh.cpp @@ -412,17 +412,17 @@ exdsa_gen_keypair_native(rnp::RNG * rng, alg = PGP_PKA_EDDSA; break; case PGP_CURVE_NIST_P_256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_NIST_P_384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_NIST_P_521: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_BP512: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_CURVE_P256K1: alg = PGP_PKA_ECDSA; break; diff --git a/src/lib/crypto/kyber_ecdh_composite.cpp b/src/lib/crypto/kyber_ecdh_composite.cpp index 01ac337f..b6955621 100644 --- a/src/lib/crypto/kyber_ecdh_composite.cpp +++ b/src/lib/crypto/kyber_ecdh_composite.cpp @@ -170,16 +170,14 @@ pgp_kyber_ecdh_composite_key_t::pk_alg_to_kyber_id(pgp_pubkey_alg_t pk_alg) { switch (pk_alg) { case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: return kyber_768; case PGP_PKA_KYBER1024_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - //[[fallthrough]]; - // case PGP_PKA_KYBER1024_X448: return kyber_1024; default: RNP_LOG("invalid PK alg given"); diff --git a/src/lib/crypto/signatures.cpp b/src/lib/crypto/signatures.cpp index e4dcf9b1..8255ca68 100644 --- a/src/lib/crypto/signatures.cpp +++ b/src/lib/crypto/signatures.cpp @@ -196,20 +196,20 @@ signature_calculate(pgp_signature_t & sig, } #if defined(ENABLE_PQC) case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: ret = seckey.dilithium_exdsa.priv.sign( &ctx.rng, &material.dilithium_exdsa, hash_alg, hval, hlen); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: ret = seckey.sphincsplus.priv.sign(&ctx.rng, &material.sphincsplus, hval, hlen); break; @@ -256,7 +256,7 @@ signature_validate(const pgp_signature_t & sig, bool hash_alg_valid = false; switch (key.alg) { case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: hash_alg_valid = key.sphincsplus.pub.validate_signature_hash_requirements(hash.alg()); break; @@ -339,20 +339,20 @@ signature_validate(const pgp_signature_t & sig, break; #if defined(ENABLE_PQC) case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: ret = key.dilithium_exdsa.pub.verify(&material.dilithium_exdsa, hash.alg(), hval, hlen); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: ret = key.sphincsplus.pub.verify(&material.sphincsplus, hval, hlen); break; diff --git a/src/lib/crypto/sphincsplus.cpp b/src/lib/crypto/sphincsplus.cpp index ea212276..5589212e 100644 --- a/src/lib/crypto/sphincsplus.cpp +++ b/src/lib/crypto/sphincsplus.cpp @@ -338,18 +338,18 @@ sphincsplus_hash_allowed(pgp_pubkey_alg_t pk_alg, case PGP_PKA_SPHINCSPLUS_SHA2: switch (sphincsplus_param) { case sphincsplus_simple_128s: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case sphincsplus_simple_128f: if (hash_alg != PGP_HASH_SHA256) { return false; } break; case sphincsplus_simple_192s: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case sphincsplus_simple_192f: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case sphincsplus_simple_256s: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case sphincsplus_simple_256f: if (hash_alg != PGP_HASH_SHA512) { return false; @@ -360,18 +360,18 @@ sphincsplus_hash_allowed(pgp_pubkey_alg_t pk_alg, case PGP_PKA_SPHINCSPLUS_SHAKE: switch (sphincsplus_param) { case sphincsplus_simple_128s: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case sphincsplus_simple_128f: if (hash_alg != PGP_HASH_SHA3_256) { return false; } break; case sphincsplus_simple_192s: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case sphincsplus_simple_192f: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case sphincsplus_simple_256s: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case sphincsplus_simple_256f: if (hash_alg != PGP_HASH_SHA3_512) { return false; diff --git a/src/lib/fingerprint.cpp b/src/lib/fingerprint.cpp index b6464ebb..a1b002d4 100644 --- a/src/lib/fingerprint.cpp +++ b/src/lib/fingerprint.cpp @@ -60,7 +60,7 @@ pgp_fingerprint(pgp_fingerprint_t &fp, const pgp_key_pkt_t &key) switch (key.version) { #if defined(ENABLE_CRYPTO_REFRESH) case PGP_V6: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; #endif case PGP_V4: break; diff --git a/src/lib/generate-key.cpp b/src/lib/generate-key.cpp index 88e02e4d..52481f97 100644 --- a/src/lib/generate-key.cpp +++ b/src/lib/generate-key.cpp @@ -282,29 +282,29 @@ get_numbits(const rnp_keygen_crypto_params_t *crypto) return crypto->elgamal.key_bitlen; #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return pgp_kyber_ecdh_composite_public_key_t::encoded_size(crypto->key_alg) * 8; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: return pgp_dilithium_exdsa_composite_public_key_t::encoded_size(crypto->key_alg) * 8; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return sphincsplus_pubkey_size(crypto->sphincsplus.param) * 8; #endif @@ -359,7 +359,7 @@ pgp_check_key_hash_requirements(rnp_keygen_crypto_params_t &crypto) { switch (crypto.key_alg) { case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: if (!sphincsplus_hash_allowed( crypto.key_alg, crypto.sphincsplus.param, crypto.hash_alg)) { @@ -367,14 +367,14 @@ pgp_check_key_hash_requirements(rnp_keygen_crypto_params_t &crypto) } break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: if (!dilithium_hash_allowed(crypto.hash_alg)) { return false; diff --git a/src/lib/pgp-key.cpp b/src/lib/pgp-key.cpp index 58e62eef..99f21ab9 100644 --- a/src/lib/pgp-key.cpp +++ b/src/lib/pgp-key.cpp @@ -209,30 +209,30 @@ pgp_pk_alg_capabilities(pgp_pubkey_alg_t alg) #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return PGP_KF_ENCRYPT; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return pgp_key_flags_t(PGP_KF_SIGN | PGP_KF_CERTIFY | PGP_KF_AUTH); #endif @@ -2783,11 +2783,11 @@ pgp_key_material_t::curve() const { switch (alg) { case PGP_PKA_ECDH: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_ECDSA: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_EDDSA: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SM2: return ec.curve; #if defined(ENABLE_CRYPTO_REFRESH) @@ -2815,16 +2815,16 @@ pgp_key_material_t::bits() const case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN: return 8 * mpi_bytes(&eg.y); case PGP_PKA_ECDH: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_ECDSA: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_EDDSA: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; #if defined(ENABLE_CRYPTO_REFRESH) case PGP_PKA_ED25519: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_X25519: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; #endif case PGP_PKA_SM2: { /* handle ecc cases */ @@ -2833,29 +2833,29 @@ pgp_key_material_t::bits() const } #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return 8 * kyber_ecdh.pub.get_encoded().size(); /* public key length */ case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: return 8 * dilithium_exdsa.pub.get_encoded().size(); /* public key length*/ case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return 8 * sphincsplus.pub.get_encoded().size(); /* public key length */ #endif diff --git a/src/lib/rnp.cpp b/src/lib/rnp.cpp index bfe81165..11ea7ec5 100644 --- a/src/lib/rnp.cpp +++ b/src/lib/rnp.cpp @@ -5266,29 +5266,29 @@ default_key_flags(pgp_pubkey_alg_t alg, bool subkey) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return PGP_KF_ENCRYPT; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return subkey ? PGP_KF_SIGN : pgp_key_flags_t(PGP_KF_SIGN | PGP_KF_CERTIFY); #endif @@ -7548,29 +7548,29 @@ add_json_public_mpis(json_object *jso, pgp_key_t *key) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return RNP_SUCCESS; /* TODO */ case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return RNP_SUCCESS; /* TODO */ #endif @@ -7607,14 +7607,14 @@ add_json_secret_mpis(json_object *jso, pgp_key_t *key) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return RNP_SUCCESS; /* TODO */ #endif @@ -7657,18 +7657,18 @@ add_json_sig_mpis(json_object *jso, const pgp_signature_t *sig) #endif #if defined(ENABLE_PQC) case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return RNP_SUCCESS; /* TODO */ #endif @@ -7874,10 +7874,7 @@ key_to_json(json_object *jso, rnp_key_handle_t handle, uint32_t flags) return RNP_ERROR_OUT_OF_MEMORY; } } - -#if (!defined(_MSVC_LANG) || _MSVC_LANG >= 201703L) - [[fallthrough]]; -#endif + FALLTHROUGH_STATEMENT; case PGP_PKA_ECDSA: case PGP_PKA_EDDSA: case PGP_PKA_SM2: { @@ -7896,29 +7893,29 @@ key_to_json(json_object *jso, rnp_key_handle_t handle, uint32_t flags) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: return RNP_SUCCESS; /* TODO */ case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: return RNP_SUCCESS; /* TODO */ #endif diff --git a/src/librekey/rnp_key_store.cpp b/src/librekey/rnp_key_store.cpp index 2af71534..0918d155 100644 --- a/src/librekey/rnp_key_store.cpp +++ b/src/librekey/rnp_key_store.cpp @@ -749,31 +749,31 @@ rnp_key_store_get_key_grip(const pgp_key_material_t *key, pgp_key_grip_t &grip) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: hash->add(key->kyber_ecdh.pub.get_encoded()); break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: hash->add(key->dilithium_exdsa.pub.get_encoded()); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: hash->add(key->sphincsplus.pub.get_encoded()); break; diff --git a/src/librepgp/stream-dump.cpp b/src/librepgp/stream-dump.cpp index 30cd1ff0..644af5b6 100644 --- a/src/librepgp/stream-dump.cpp +++ b/src/librepgp/stream-dump.cpp @@ -828,20 +828,20 @@ stream_dump_signature_pkt(rnp_dump_ctx_t *ctx, pgp_signature_t *sig, pgp_dest_t #endif #if defined(ENABLE_PQC) case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: dst_print_vec( dst, "dilithium-ecdsa/eddsa sig", material.dilithium_exdsa.sig, ctx->dump_mpi); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: dst_print_vec(dst, "sphincs+ sig", material.sphincsplus.sig, ctx->dump_mpi); break; @@ -950,14 +950,14 @@ stream_dump_key(rnp_dump_ctx_t *ctx, pgp_source_t *src, pgp_dest_t *dst) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: dst_print_vec(dst, "kyber-ecdh encoded pubkey", @@ -965,14 +965,14 @@ stream_dump_key(rnp_dump_ctx_t *ctx, pgp_source_t *src, pgp_dest_t *dst) ctx->dump_mpi); break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: dst_print_vec(dst, "dilithium-ecdsa/eddsa encodced pubkey", @@ -980,7 +980,7 @@ stream_dump_key(rnp_dump_ctx_t *ctx, pgp_source_t *src, pgp_dest_t *dst) ctx->dump_mpi); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: dst_print_vec(dst, "sphincs+ encoded pubkey", @@ -1161,14 +1161,14 @@ stream_dump_pk_session_key(rnp_dump_ctx_t *ctx, pgp_source_t *src, pgp_dest_t *d #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: dst_print_vec(dst, "kyber-ecdh composite ciphertext", @@ -1988,19 +1988,19 @@ stream_dump_signature_pkt_json(rnp_dump_ctx_t * ctx, #endif #if defined(ENABLE_PQC) case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: /* TODO */ break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: /* TODO */ break; @@ -2126,31 +2126,31 @@ stream_dump_key_json(rnp_dump_ctx_t *ctx, pgp_source_t *src, json_object *pkt) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: // TODO break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: /* TODO */ break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: /* TODO */ break; @@ -2292,14 +2292,14 @@ stream_dump_pk_session_key_json(rnp_dump_ctx_t *ctx, pgp_source_t *src, json_obj #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: // TODO break; diff --git a/src/librepgp/stream-key.cpp b/src/librepgp/stream-key.cpp index ac95d548..c3b180bb 100644 --- a/src/librepgp/stream-key.cpp +++ b/src/librepgp/stream-key.cpp @@ -545,7 +545,7 @@ parse_secret_key_mpis(pgp_key_pkt_t &key, const uint8_t *mpis, size_t len) if (key.version == PGP_V6) { break; /* checksum removed for v6 and usage byte zero */ } - [[fallthrough]]; + FALLTHROUGH_STATEMENT; #endif case PGP_S2KU_ENCRYPTED: { /* calculate and check sum16 of the cleartext */ @@ -658,14 +658,14 @@ parse_secret_key_mpis(pgp_key_pkt_t &key, const uint8_t *mpis, size_t len) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: tmpbuf.resize(pgp_kyber_ecdh_composite_private_key_t::encoded_size(key.alg)); if (!body.get(tmpbuf.data(), tmpbuf.size())) { @@ -676,14 +676,14 @@ parse_secret_key_mpis(pgp_key_pkt_t &key, const uint8_t *mpis, size_t len) pgp_kyber_ecdh_composite_private_key_t(tmpbuf.data(), tmpbuf.size(), key.alg); break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: tmpbuf.resize(pgp_dilithium_exdsa_composite_private_key_t::encoded_size(key.alg)); if (!body.get(tmpbuf.data(), tmpbuf.size())) { @@ -694,7 +694,7 @@ parse_secret_key_mpis(pgp_key_pkt_t &key, const uint8_t *mpis, size_t len) tmpbuf.data(), tmpbuf.size(), key.alg); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: { uint8_t param; if (!body.get(param)) { @@ -844,31 +844,31 @@ write_secret_key_mpis(pgp_packet_body_t &body, pgp_key_pkt_t &key) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: body.add(key.material.kyber_ecdh.priv.get_encoded()); break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: body.add(key.material.dilithium_exdsa.priv.get_encoded()); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: body.add_byte((uint8_t) key.material.sphincsplus.priv.param()); body.add(key.material.sphincsplus.priv.get_encoded()); @@ -1029,28 +1029,28 @@ forget_secret_key_fields(pgp_key_material_t *key) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: key->dilithium_exdsa.priv.secure_clear(); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: key->sphincsplus.priv.secure_clear(); break; @@ -1403,9 +1403,9 @@ pgp_key_pkt_t::parse(pgp_source_t &src) } switch (ver) { case PGP_V2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V3: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V4: break; #if defined(ENABLE_CRYPTO_REFRESH) @@ -1517,14 +1517,14 @@ pgp_key_pkt_t::parse(pgp_source_t &src) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: tmpbuf.resize(pgp_kyber_ecdh_composite_public_key_t::encoded_size(alg)); if (!pkt.get(tmpbuf.data(), tmpbuf.size())) { @@ -1534,14 +1534,14 @@ pgp_key_pkt_t::parse(pgp_source_t &src) material.kyber_ecdh.pub = pgp_kyber_ecdh_composite_public_key_t(tmpbuf, alg); break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: tmpbuf.resize(pgp_dilithium_exdsa_composite_public_key_t::encoded_size(alg)); if (!pkt.get(tmpbuf.data(), tmpbuf.size())) { @@ -1551,7 +1551,7 @@ pgp_key_pkt_t::parse(pgp_source_t &src) material.dilithium_exdsa.pub = pgp_dilithium_exdsa_composite_public_key_t(tmpbuf, alg); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: { uint8_t param; if (!pkt.get(param)) { @@ -1717,31 +1717,31 @@ pgp_key_pkt_t::make_alg_spec_fields_for_public_key(pgp_packet_body_t &hbody) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: hbody.add(material.kyber_ecdh.pub.get_encoded()); break; case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: hbody.add(material.dilithium_exdsa.pub.get_encoded()); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: hbody.add_byte((uint8_t) material.sphincsplus.pub.param()); hbody.add(material.sphincsplus.pub.get_encoded()); diff --git a/src/librepgp/stream-packet.cpp b/src/librepgp/stream-packet.cpp index b547ff01..7342a326 100644 --- a/src/librepgp/stream-packet.cpp +++ b/src/librepgp/stream-packet.cpp @@ -1243,14 +1243,14 @@ pgp_pk_sesskey_t::parse_material(pgp_encrypted_material_t &material) const #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: { uint8_t wrapped_key_len = 0; material.kyber_ecdh.composite_ciphertext.resize( @@ -1316,14 +1316,14 @@ pgp_pk_sesskey_t::write_material(const pgp_encrypted_material_t &material) #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: pktbody.add(material.kyber_ecdh.composite_ciphertext); pktbody.add_byte(static_cast(material.kyber_ecdh.wrapped_sesskey.size())); diff --git a/src/librepgp/stream-parse.cpp b/src/librepgp/stream-parse.cpp index 4b924bc2..aed70530 100644 --- a/src/librepgp/stream-parse.cpp +++ b/src/librepgp/stream-parse.cpp @@ -1504,15 +1504,15 @@ do_enforce_aes_v3pkesk(pgp_pubkey_alg_t alg) switch (alg) { #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; #endif case PGP_PKA_X25519: return true; @@ -1644,14 +1644,14 @@ encrypted_try_key(pgp_source_encrypted_param_t *param, #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: { pgp_key_t key(*seckey, true); /* make public-key `pgp_key_t` object from seckey */ declen = decbuf.size(); diff --git a/src/librepgp/stream-sig.cpp b/src/librepgp/stream-sig.cpp index 684e3104..c256ef46 100644 --- a/src/librepgp/stream-sig.cpp +++ b/src/librepgp/stream-sig.cpp @@ -50,9 +50,9 @@ signature_hash_key(const pgp_key_pkt_t &key, rnp::Hash &hash) { switch (key.version) { case PGP_V2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V3: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V4: { uint8_t hdr[3] = {0x99, 0x00, 0x00}; if (key.hashed_data) { @@ -1443,13 +1443,13 @@ pgp_signature_t::parse(pgp_packet_body_t &pkt) rnp_result_t res; switch (ver) { case PGP_V2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V3: res = parse_v2v3(pkt); break; #if defined(ENABLE_CRYPTO_REFRESH) case PGP_V6: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; #endif case PGP_V4: res = parse_v4up(pkt); @@ -1539,9 +1539,7 @@ pgp_signature_t::parse_material(pgp_signature_material_t &material) const if (version < PGP_V4) { RNP_LOG("Warning! v3 EdDSA signature."); } -#if (!defined(_MSVC_LANG) || _MSVC_LANG >= 201703L) - [[fallthrough]]; -#endif + FALLTHROUGH_STATEMENT; case PGP_PKA_ECDSA: case PGP_PKA_SM2: case PGP_PKA_ECDH: @@ -1568,14 +1566,14 @@ pgp_signature_t::parse_material(pgp_signature_material_t &material) const #endif #if defined(ENABLE_PQC) case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: material.dilithium_exdsa.sig.resize( pgp_dilithium_exdsa_signature_t::composite_signature_size(palg)); @@ -1586,7 +1584,7 @@ pgp_signature_t::parse_material(pgp_signature_material_t &material) const } break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: { uint8_t param; if (!pkt.get(param)) { @@ -1620,9 +1618,9 @@ pgp_signature_t::write(pgp_dest_t &dst) const { switch (version) { case PGP_V2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V3: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V4: break; #if defined(ENABLE_CRYPTO_REFRESH) @@ -1693,19 +1691,19 @@ pgp_signature_t::write_material(const pgp_signature_material_t &material) #endif #if defined(ENABLE_PQC) case PGP_PKA_DILITHIUM3_ED25519: - [[fallthrough]]; - // TODO: add case PGP_PKA_DILITHIUM5_ED448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM3_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_DILITHIUM5_BP384: pktbody.add(material.dilithium_exdsa.sig); break; case PGP_PKA_SPHINCSPLUS_SHA2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_SPHINCSPLUS_SHAKE: pktbody.add_byte((uint8_t) material.sphincsplus.param); pktbody.add(material.sphincsplus.sig); @@ -1731,9 +1729,9 @@ pgp_signature_t::fill_hashed_data() /* we don't have a need to write v2-v3 signatures */ switch (version) { case PGP_V2: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V3: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_V4: break; #if defined(ENABLE_CRYPTO_REFRESH) diff --git a/src/librepgp/stream-write.cpp b/src/librepgp/stream-write.cpp index 9223681f..acf122f9 100644 --- a/src/librepgp/stream-write.cpp +++ b/src/librepgp/stream-write.cpp @@ -722,14 +722,14 @@ encrypted_add_recipient(pgp_write_handler_t *handler, #endif #if defined(ENABLE_PQC) case PGP_PKA_KYBER768_X25519: - [[fallthrough]]; - // TODO add case PGP_PKA_KYBER1024_X448: [[fallthrough]]; + FALLTHROUGH_STATEMENT; + // TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_P256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_P384: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER768_BP256: - [[fallthrough]]; + FALLTHROUGH_STATEMENT; case PGP_PKA_KYBER1024_BP384: ret = userkey->material().kyber_ecdh.pub.encrypt( &handler->ctx->ctx->rng, &material.kyber_ecdh, enckey.data(), enckey_len); diff --git a/src/rnp/rnp.cpp b/src/rnp/rnp.cpp index 3dfcad85..a4b41f1e 100644 --- a/src/rnp/rnp.cpp +++ b/src/rnp/rnp.cpp @@ -307,9 +307,7 @@ setcmd(rnp_cfg &cfg, int cmd, const char *arg) break; case CMD_CLEARSIGN: cfg.set_bool(CFG_CLEARTEXT, true); -#if (!defined(_MSVC_LANG) || _MSVC_LANG >= 201703L) - [[fallthrough]]; -#endif + FALLTHROUGH_STATEMENT; case CMD_SIGN: cfg.set_bool(CFG_NEEDSSECKEY, true); cfg.set_bool(CFG_SIGN_NEEDED, true); @@ -326,9 +324,7 @@ setcmd(rnp_cfg &cfg, int cmd, const char *arg) case CMD_VERIFY: /* single verify will discard output, decrypt will not */ cfg.set_bool(CFG_NO_OUTPUT, true); -#if (!defined(_MSVC_LANG) || _MSVC_LANG >= 201703L) - [[fallthrough]]; -#endif + FALLTHROUGH_STATEMENT; case CMD_VERIFY_CAT: newcmd = CMD_PROCESS; break; @@ -607,9 +603,7 @@ set_short_option(rnp_cfg &cfg, int ch, const char *arg) cfg.set_bool(CFG_KEYSTORE_DISABLED, true); break; case 'h': -#if (!defined(_MSVC_LANG) || _MSVC_LANG >= 201703L) - [[fallthrough]]; -#endif + FALLTHROUGH_STATEMENT; default: return setcmd(cfg, CMD_HELP, optarg); } diff --git a/src/rnpkeys/main.cpp b/src/rnpkeys/main.cpp index 3dd088cc..75e3efe5 100644 --- a/src/rnpkeys/main.cpp +++ b/src/rnpkeys/main.cpp @@ -52,9 +52,7 @@ get_short_cmd(int ch) case 'l': return CMD_LIST_KEYS; case 'h': -#if (!defined(_MSVC_LANG) || _MSVC_LANG >= 201703L) - [[fallthrough]]; -#endif + FALLTHROUGH_STATEMENT; default: return CMD_HELP; } diff --git a/src/rnpkeys/tui.cpp b/src/rnpkeys/tui.cpp index 52e9e693..cd9724a7 100644 --- a/src/rnpkeys/tui.cpp +++ b/src/rnpkeys/tui.cpp @@ -311,7 +311,7 @@ rnpkeys_ask_generate_params(rnp_cfg &cfg, FILE *input_fp) #if defined(ENABLE_CRYPTO_REFRESH) case 21: { cfg.set_str(CFG_KG_V6_KEY, "true"); - [[fallthrough]]; + FALLTHROUGH_STATEMENT; } #endif case 22: {