From 990ca6cd3fce60ce2dd1c70ec30ada80addb27ea Mon Sep 17 00:00:00 2001
From: Nickolay Olshevsky <o.nickolay@gmail.com>
Date: Wed, 25 Dec 2024 15:46:18 +0200
Subject: [PATCH] Remove redundant pgp:: namespace reference.

---
 src/lib/crypto/dsa.h            | 14 +++++------
 src/lib/crypto/dsa_ossl.cpp     |  2 +-
 src/lib/crypto/ec.h             |  8 +++---
 src/lib/crypto/ec_ossl.cpp      | 14 +++++------
 src/lib/crypto/ec_ossl.h        |  6 ++---
 src/lib/crypto/ecdh_utils.cpp   |  4 +--
 src/lib/crypto/ecdh_utils.h     |  2 +-
 src/lib/crypto/ecdsa.cpp        | 26 +++++++++----------
 src/lib/crypto/eddsa.cpp        | 15 +++++------
 src/lib/crypto/eddsa_ossl.cpp   | 15 +++++------
 src/lib/crypto/elgamal.h        | 16 ++++++------
 src/lib/crypto/elgamal_ossl.cpp |  4 +--
 src/lib/key_material.cpp        | 44 ++++++++++++++++-----------------
 13 files changed, 82 insertions(+), 88 deletions(-)

diff --git a/src/lib/crypto/dsa.h b/src/lib/crypto/dsa.h
index ee2c37016..6bdcb2a67 100644
--- a/src/lib/crypto/dsa.h
+++ b/src/lib/crypto/dsa.h
@@ -40,18 +40,18 @@ namespace dsa {
 
 class Signature {
   public:
-    pgp::mpi r;
-    pgp::mpi s;
+    mpi r;
+    mpi s;
 };
 
 class Key {
   public:
-    pgp::mpi p{};
-    pgp::mpi q{};
-    pgp::mpi g{};
-    pgp::mpi y{};
+    mpi p{};
+    mpi q{};
+    mpi g{};
+    mpi y{};
     /* secret mpi */
-    pgp::mpi x{};
+    mpi x{};
 
     void
     clear_secret()
diff --git a/src/lib/crypto/dsa_ossl.cpp b/src/lib/crypto/dsa_ossl.cpp
index 33367bbdc..3d1b56945 100644
--- a/src/lib/crypto/dsa_ossl.cpp
+++ b/src/lib/crypto/dsa_ossl.cpp
@@ -245,7 +245,7 @@ Key::verify(const Signature &sig, const rnp::secure_bytes &hash) const
         RNP_LOG("Failed to initialize verify: %lu", ERR_peek_last_error());
         return RNP_ERROR_GENERIC;
     }
-    pgp::mpi sigbuf;
+    mpi sigbuf;
     if (!encode_sig(sigbuf.mpi, &sigbuf.len, sig)) {
         return RNP_ERROR_GENERIC;
     }
diff --git a/src/lib/crypto/ec.h b/src/lib/crypto/ec.h
index eba765ff4..71cd8e92d 100644
--- a/src/lib/crypto/ec.h
+++ b/src/lib/crypto/ec.h
@@ -106,16 +106,16 @@ class Curve {
 
 class Signature {
   public:
-    pgp::mpi r;
-    pgp::mpi s;
+    mpi r;
+    mpi s;
 };
 
 class Key {
   public:
     pgp_curve_t curve;
-    pgp::mpi    p;
+    mpi         p;
     /* secret mpi */
-    pgp::mpi x;
+    mpi x;
     /* ecdh params */
     pgp_hash_alg_t kdf_hash_alg; /* Hash used by kdf */
     pgp_symm_alg_t key_wrap_alg; /* Symmetric algorithm used to wrap KEK*/
diff --git a/src/lib/crypto/ec_ossl.cpp b/src/lib/crypto/ec_ossl.cpp
index fa6bbb42b..3c9b3ba9c 100644
--- a/src/lib/crypto/ec_ossl.cpp
+++ b/src/lib/crypto/ec_ossl.cpp
@@ -101,7 +101,7 @@ generate_pkey(const pgp_pubkey_alg_t alg_id, const pgp_curve_t curve)
 }
 
 static bool
-write_raw_seckey(const rnp::ossl::evp::PKey &pkey, pgp::ec::Key &key)
+write_raw_seckey(const rnp::ossl::evp::PKey &pkey, ec::Key &key)
 {
     /* EdDSA and X25519 keys are saved in a different way */
     static_assert(sizeof(key.x.mpi) > 32, "mpi is too small.");
@@ -123,7 +123,7 @@ write_raw_seckey(const rnp::ossl::evp::PKey &pkey, pgp::ec::Key &key)
 }
 
 static bool
-write_seckey(rnp::ossl::evp::PKey &pkey, pgp::mpi &key)
+write_seckey(rnp::ossl::evp::PKey &pkey, mpi &key)
 {
 #if defined(CRYPTO_BACKEND_OPENSSL3)
     rnp::bn x;
@@ -173,7 +173,7 @@ Key::generate(rnp::RNG &rng, const pgp_pubkey_alg_t alg_id, const pgp_curve_t cu
 }
 
 static rnp::ossl::evp::PKey
-load_raw_key(const pgp::mpi &keyp, const pgp::mpi *keyx, int nid)
+load_raw_key(const mpi &keyp, const mpi *keyx, int nid)
 {
     if (!keyx) {
         /* as per RFC, EdDSA & 25519 keys must use 0x40 byte for encoding */
@@ -219,7 +219,7 @@ load_raw_key(const pgp::mpi &keyp, const pgp::mpi *keyx, int nid)
 
 #if defined(CRYPTO_BACKEND_OPENSSL3)
 static rnp::ossl::Param
-build_params(const pgp::mpi &p, const pgp::mpi *x, const char *curve)
+build_params(const mpi &p, const mpi *x, const char *curve)
 {
     rnp::ossl::ParamBld bld(OSSL_PARAM_BLD_new());
     if (!bld) {
@@ -235,7 +235,7 @@ build_params(const pgp::mpi &p, const pgp::mpi *x, const char *curve)
 }
 
 static rnp::ossl::evp::PKey
-load_key_openssl3(const pgp::mpi &keyp, const pgp::mpi *keyx, const Curve &curv_desc)
+load_key_openssl3(const mpi &keyp, const mpi *keyx, const Curve &curv_desc)
 {
     auto params = build_params(keyp, keyx, curv_desc.openssl_name);
     if (!params) {
@@ -266,7 +266,7 @@ load_key_openssl3(const pgp::mpi &keyp, const pgp::mpi *keyx, const Curve &curv_
 #endif
 
 rnp::ossl::evp::PKey
-load_key(const pgp::mpi &keyp, const pgp::mpi *keyx, pgp_curve_t curve)
+load_key(const mpi &keyp, const mpi *keyx, pgp_curve_t curve)
 {
     auto curv_desc = Curve::get(curve);
     if (!curv_desc) {
@@ -394,7 +394,7 @@ validate_key(const Key &key, bool secret)
 }
 
 bool
-write_pubkey(const rnp::ossl::evp::PKey &pkey, pgp::mpi &mpi, pgp_curve_t curve)
+write_pubkey(const rnp::ossl::evp::PKey &pkey, mpi &mpi, pgp_curve_t curve)
 {
     if (is_raw_key(curve)) {
         /* EdDSA and X25519 keys are saved in a different way */
diff --git a/src/lib/crypto/ec_ossl.h b/src/lib/crypto/ec_ossl.h
index 9b7f95667..c98086a52 100644
--- a/src/lib/crypto/ec_ossl.h
+++ b/src/lib/crypto/ec_ossl.h
@@ -35,13 +35,13 @@
 namespace pgp {
 namespace ec {
 
-rnp::ossl::evp::PKey load_key(const pgp::mpi &keyp, const pgp::mpi *keyx, pgp_curve_t curve);
+rnp::ossl::evp::PKey load_key(const mpi &keyp, const mpi *keyx, pgp_curve_t curve);
 
-rnp_result_t validate_key(const pgp::ec::Key &key, bool secret);
+rnp_result_t validate_key(const ec::Key &key, bool secret);
 
 rnp::ossl::evp::PKey generate_pkey(const pgp_pubkey_alg_t alg_id, const pgp_curve_t curve);
 
-bool write_pubkey(const rnp::ossl::evp::PKey &key, pgp::mpi &mpi, pgp_curve_t curve);
+bool write_pubkey(const rnp::ossl::evp::PKey &key, mpi &mpi, pgp_curve_t curve);
 
 } // namespace ec
 } // namespace pgp
diff --git a/src/lib/crypto/ecdh_utils.cpp b/src/lib/crypto/ecdh_utils.cpp
index f36cbde51..5861dfe93 100644
--- a/src/lib/crypto/ecdh_utils.cpp
+++ b/src/lib/crypto/ecdh_utils.cpp
@@ -53,7 +53,7 @@ static const struct ecdh_params_t {
 
 // returns size of data written to other_info
 std::vector<uint8_t>
-kdf_other_info_serialize(const pgp::ec::Curve &      curve,
+kdf_other_info_serialize(const ec::Curve &           curve,
                          const std::vector<uint8_t> &fp,
                          const pgp_hash_alg_t        kdf_hash,
                          const pgp_symm_alg_t        wrap_alg)
@@ -117,7 +117,7 @@ unpad_pkcs7(rnp::secure_bytes &buf)
 }
 
 bool
-set_params(pgp::ec::Key &key, pgp_curve_t curve_id)
+set_params(ec::Key &key, pgp_curve_t curve_id)
 {
     for (size_t i = 0; i < ARRAY_SIZE(ecdh_params); i++) {
         if (ecdh_params[i].curve == curve_id) {
diff --git a/src/lib/crypto/ecdh_utils.h b/src/lib/crypto/ecdh_utils.h
index c03831385..447dbfcae 100644
--- a/src/lib/crypto/ecdh_utils.h
+++ b/src/lib/crypto/ecdh_utils.h
@@ -35,7 +35,7 @@
 
 namespace pgp {
 namespace ecdh {
-std::vector<uint8_t> kdf_other_info_serialize(const pgp::ec::Curve &      curve,
+std::vector<uint8_t> kdf_other_info_serialize(const ec::Curve &           curve,
                                               const std::vector<uint8_t> &fp,
                                               const pgp_hash_alg_t        kdf_hash,
                                               const pgp_symm_alg_t        wrap_alg);
diff --git a/src/lib/crypto/ecdsa.cpp b/src/lib/crypto/ecdsa.cpp
index fddd80025..e103f5c59 100644
--- a/src/lib/crypto/ecdsa.cpp
+++ b/src/lib/crypto/ecdsa.cpp
@@ -34,9 +34,9 @@ namespace pgp {
 namespace ecdsa {
 
 static bool
-load_public_key(rnp::botan::Pubkey &pubkey, const pgp::ec::Key &keydata)
+load_public_key(rnp::botan::Pubkey &pubkey, const ec::Key &keydata)
 {
-    auto curve = pgp::ec::Curve::get(keydata.curve);
+    auto curve = ec::Curve::get(keydata.curve);
     if (!curve) {
         RNP_LOG("unknown curve");
         return false;
@@ -62,9 +62,9 @@ load_public_key(rnp::botan::Pubkey &pubkey, const pgp::ec::Key &keydata)
 }
 
 static bool
-load_secret_key(rnp::botan::Privkey &seckey, const pgp::ec::Key &keydata)
+load_secret_key(rnp::botan::Privkey &seckey, const ec::Key &keydata)
 {
-    auto curve = pgp::ec::Curve::get(keydata.curve);
+    auto curve = ec::Curve::get(keydata.curve);
     if (!curve) {
         return false;
     }
@@ -82,7 +82,7 @@ load_secret_key(rnp::botan::Privkey &seckey, const pgp::ec::Key &keydata)
 }
 
 rnp_result_t
-validate_key(rnp::RNG &rng, const pgp::ec::Key &key, bool secret)
+validate_key(rnp::RNG &rng, const ec::Key &key, bool secret)
 {
     rnp::botan::Pubkey bpkey;
     if (!load_public_key(bpkey, key) || botan_pubkey_check_key(bpkey.get(), rng.handle(), 0)) {
@@ -131,12 +131,12 @@ padding_str_for(pgp_hash_alg_t hash_alg)
 
 rnp_result_t
 sign(rnp::RNG &               rng,
-     pgp::ec::Signature &     sig,
+     ec::Signature &          sig,
      pgp_hash_alg_t           hash_alg,
      const rnp::secure_bytes &hash,
-     const pgp::ec::Key &     key)
+     const ec::Key &          key)
 {
-    auto curve = pgp::ec::Curve::get(key.curve);
+    auto curve = ec::Curve::get(key.curve);
     if (!curve) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -172,12 +172,12 @@ sign(rnp::RNG &               rng,
 }
 
 rnp_result_t
-verify(const pgp::ec::Signature &sig,
-       pgp_hash_alg_t            hash_alg,
-       const rnp::secure_bytes & hash,
-       const pgp::ec::Key &      key)
+verify(const ec::Signature &    sig,
+       pgp_hash_alg_t           hash_alg,
+       const rnp::secure_bytes &hash,
+       const ec::Key &          key)
 {
-    auto curve = pgp::ec::Curve::get(key.curve);
+    auto curve = ec::Curve::get(key.curve);
     if (!curve) {
         RNP_LOG("unknown curve");
         return RNP_ERROR_BAD_PARAMETERS;
diff --git a/src/lib/crypto/eddsa.cpp b/src/lib/crypto/eddsa.cpp
index d59bae741..71ddbf774 100644
--- a/src/lib/crypto/eddsa.cpp
+++ b/src/lib/crypto/eddsa.cpp
@@ -35,7 +35,7 @@ namespace pgp {
 namespace eddsa {
 
 static bool
-load_public_key(rnp::botan::Pubkey &pubkey, const pgp::ec::Key &keydata)
+load_public_key(rnp::botan::Pubkey &pubkey, const ec::Key &keydata)
 {
     if (keydata.curve != PGP_CURVE_ED25519) {
         return false;
@@ -53,7 +53,7 @@ load_public_key(rnp::botan::Pubkey &pubkey, const pgp::ec::Key &keydata)
 }
 
 static bool
-load_secret_key(rnp::botan::Privkey &seckey, const pgp::ec::Key &keydata)
+load_secret_key(rnp::botan::Privkey &seckey, const ec::Key &keydata)
 {
     if (keydata.curve != PGP_CURVE_ED25519) {
         return false;
@@ -72,7 +72,7 @@ load_secret_key(rnp::botan::Privkey &seckey, const pgp::ec::Key &keydata)
 }
 
 rnp_result_t
-validate_key(rnp::RNG &rng, const pgp::ec::Key &key, bool secret)
+validate_key(rnp::RNG &rng, const ec::Key &key, bool secret)
 {
     rnp::botan::Pubkey bpkey;
     if (!load_public_key(bpkey, key) || botan_pubkey_check_key(bpkey.get(), rng.handle(), 0)) {
@@ -92,7 +92,7 @@ validate_key(rnp::RNG &rng, const pgp::ec::Key &key, bool secret)
 }
 
 rnp_result_t
-generate(rnp::RNG &rng, pgp::ec::Key &key)
+generate(rnp::RNG &rng, ec::Key &key)
 {
     rnp::botan::Privkey eddsa;
     if (botan_privkey_create(&eddsa.get(), "Ed25519", NULL, rng.handle())) {
@@ -115,7 +115,7 @@ generate(rnp::RNG &rng, pgp::ec::Key &key)
 }
 
 rnp_result_t
-verify(const pgp::ec::Signature &sig, const rnp::secure_bytes &hash, const pgp::ec::Key &key)
+verify(const ec::Signature &sig, const rnp::secure_bytes &hash, const ec::Key &key)
 {
     // Unexpected size for Ed25519 signature
     if ((sig.r.bytes() > 32) || (sig.s.bytes() > 32)) {
@@ -144,10 +144,7 @@ verify(const pgp::ec::Signature &sig, const rnp::secure_bytes &hash, const pgp::
 }
 
 rnp_result_t
-sign(rnp::RNG &               rng,
-     pgp::ec::Signature &     sig,
-     const rnp::secure_bytes &hash,
-     const pgp::ec::Key &     key)
+sign(rnp::RNG &rng, ec::Signature &sig, const rnp::secure_bytes &hash, const ec::Key &key)
 {
     rnp::botan::Privkey eddsa;
     if (!load_secret_key(eddsa, key)) {
diff --git a/src/lib/crypto/eddsa_ossl.cpp b/src/lib/crypto/eddsa_ossl.cpp
index 275414521..150f877a8 100644
--- a/src/lib/crypto/eddsa_ossl.cpp
+++ b/src/lib/crypto/eddsa_ossl.cpp
@@ -40,7 +40,7 @@ namespace pgp {
 namespace eddsa {
 
 rnp_result_t
-validate_key(rnp::RNG &rng, const pgp::ec::Key &key, bool secret)
+validate_key(rnp::RNG &rng, const ec::Key &key, bool secret)
 {
     /* Not implemented in the OpenSSL, so just do basic size checks. */
     if ((key.p.bytes() != 33) || (key.p.mpi[0] != 0x40)) {
@@ -53,7 +53,7 @@ validate_key(rnp::RNG &rng, const pgp::ec::Key &key, bool secret)
 }
 
 rnp_result_t
-generate(rnp::RNG &rng, pgp::ec::Key &key)
+generate(rnp::RNG &rng, ec::Key &key)
 {
     rnp_result_t ret = key.generate(rng, PGP_PKA_EDDSA, PGP_CURVE_ED25519);
     if (!ret) {
@@ -63,7 +63,7 @@ generate(rnp::RNG &rng, pgp::ec::Key &key)
 }
 
 rnp_result_t
-verify(const pgp::ec::Signature &sig, const rnp::secure_bytes &hash, const pgp::ec::Key &key)
+verify(const ec::Signature &sig, const rnp::secure_bytes &hash, const ec::Key &key)
 {
     if ((sig.r.bytes() > 32) || (sig.s.bytes() > 32)) {
         RNP_LOG("Invalid EdDSA signature.");
@@ -74,7 +74,7 @@ verify(const pgp::ec::Signature &sig, const rnp::secure_bytes &hash, const pgp::
         return RNP_ERROR_BAD_PARAMETERS;
     }
 
-    auto evpkey = pgp::ec::load_key(key.p, NULL, PGP_CURVE_ED25519);
+    auto evpkey = ec::load_key(key.p, NULL, PGP_CURVE_ED25519);
     if (!evpkey) {
         RNP_LOG("Failed to load key");
         return RNP_ERROR_BAD_PARAMETERS;
@@ -103,16 +103,13 @@ verify(const pgp::ec::Signature &sig, const rnp::secure_bytes &hash, const pgp::
 }
 
 rnp_result_t
-sign(rnp::RNG &               rng,
-     pgp::ec::Signature &     sig,
-     const rnp::secure_bytes &hash,
-     const pgp::ec::Key &     key)
+sign(rnp::RNG &rng, ec::Signature &sig, const rnp::secure_bytes &hash, const ec::Key &key)
 {
     if (!key.x.bytes()) {
         RNP_LOG("private key not set");
         return RNP_ERROR_BAD_PARAMETERS;
     }
-    auto evpkey = pgp::ec::load_key(key.p, &key.x, PGP_CURVE_ED25519);
+    auto evpkey = ec::load_key(key.p, &key.x, PGP_CURVE_ED25519);
     if (!evpkey) {
         RNP_LOG("Failed to load private key: %lu", ERR_peek_last_error());
         return RNP_ERROR_BAD_PARAMETERS;
diff --git a/src/lib/crypto/elgamal.h b/src/lib/crypto/elgamal.h
index 56878b636..a4f372985 100644
--- a/src/lib/crypto/elgamal.h
+++ b/src/lib/crypto/elgamal.h
@@ -39,23 +39,23 @@ class Signature {
   public:
     /* This is kept only for packet reading. Implementation MUST
      * not create elgamal signatures */
-    pgp::mpi r;
-    pgp::mpi s;
+    mpi r;
+    mpi s;
 };
 
 class Encrypted {
   public:
-    pgp::mpi g;
-    pgp::mpi m;
+    mpi g;
+    mpi m;
 };
 
 class Key {
   public:
-    pgp::mpi p;
-    pgp::mpi g;
-    pgp::mpi y;
+    mpi p;
+    mpi g;
+    mpi y;
     /* secret mpi */
-    pgp::mpi x;
+    mpi x;
 
     void
     clear_secret()
diff --git a/src/lib/crypto/elgamal_ossl.cpp b/src/lib/crypto/elgamal_ossl.cpp
index 60f2834b2..aa7f43d5b 100644
--- a/src/lib/crypto/elgamal_ossl.cpp
+++ b/src/lib/crypto/elgamal_ossl.cpp
@@ -306,8 +306,8 @@ Key::decrypt_pkcs1(rnp::RNG &rng, rnp::secure_bytes &out, const Encrypted &in) c
         return RNP_ERROR_GENERIC;
         /* LCOV_EXCL_END */
     }
-    pgp::mpi mm = {};
-    bool     res = m.mpi(mm);
+    mpi  mm = {};
+    bool res = m.mpi(mm);
     assert(res);
     if (!res) {
         return RNP_ERROR_OUT_OF_MEMORY; // LCOV_EXCL_LINE
diff --git a/src/lib/key_material.cpp b/src/lib/key_material.cpp
index b1d5edaa1..36486328d 100644
--- a/src/lib/key_material.cpp
+++ b/src/lib/key_material.cpp
@@ -566,7 +566,7 @@ RSAKeyMaterial::encrypt(rnp::SecurityContext &   ctx,
                         EncMaterial &            out,
                         const rnp::secure_bytes &data) const
 {
-    auto rsa = dynamic_cast<pgp::RSAEncMaterial *>(&out);
+    auto rsa = dynamic_cast<RSAEncMaterial *>(&out);
     if (!rsa) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -578,7 +578,7 @@ RSAKeyMaterial::decrypt(rnp::SecurityContext &ctx,
                         rnp::secure_bytes &   out,
                         const EncMaterial &   in) const
 {
-    auto rsa = dynamic_cast<const pgp::RSAEncMaterial *>(&in);
+    auto rsa = dynamic_cast<const RSAEncMaterial *>(&in);
     if (!rsa) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -904,7 +904,7 @@ EGKeyMaterial::encrypt(rnp::SecurityContext &   ctx,
                        EncMaterial &            out,
                        const rnp::secure_bytes &data) const
 {
-    auto eg = dynamic_cast<pgp::EGEncMaterial *>(&out);
+    auto eg = dynamic_cast<EGEncMaterial *>(&out);
     if (!eg) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -916,7 +916,7 @@ EGKeyMaterial::decrypt(rnp::SecurityContext &ctx,
                        rnp::secure_bytes &   out,
                        const EncMaterial &   in) const
 {
-    auto eg = dynamic_cast<const pgp::EGEncMaterial *>(&in);
+    auto eg = dynamic_cast<const EGEncMaterial *>(&in);
     if (!eg) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -1225,7 +1225,7 @@ ECDHKeyMaterial::encrypt(rnp::SecurityContext &   ctx,
         RNP_LOG("ECDH encrypt: curve %d is not supported.", key_.curve);
         return RNP_ERROR_NOT_SUPPORTED;
     }
-    auto ecdh = dynamic_cast<pgp::ECDHEncMaterial *>(&out);
+    auto ecdh = dynamic_cast<ECDHEncMaterial *>(&out);
     if (!ecdh) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -1244,7 +1244,7 @@ ECDHKeyMaterial::decrypt(rnp::SecurityContext &ctx,
     if ((key_.curve == PGP_CURVE_25519) && !x25519_bits_tweaked()) {
         RNP_LOG("Warning: bits of 25519 secret key are not tweaked.");
     }
-    auto ecdh = dynamic_cast<const pgp::ECDHEncMaterial *>(&in);
+    auto ecdh = dynamic_cast<const ECDHEncMaterial *>(&in);
     if (!ecdh) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -1317,7 +1317,7 @@ bool
 SM2KeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset)
 {
 #if defined(ENABLE_SM2)
-    return !pgp::sm2::validate_key(ctx.rng, key_, secret_);
+    return !sm2::validate_key(ctx.rng, key_, secret_);
 #else
     RNP_LOG("SM2 key validation is not available.");
     return false;
@@ -1336,11 +1336,11 @@ SM2KeyMaterial::encrypt(rnp::SecurityContext &   ctx,
                         const rnp::secure_bytes &data) const
 {
 #if defined(ENABLE_SM2)
-    auto sm2 = dynamic_cast<pgp::SM2EncMaterial *>(&out);
+    auto sm2 = dynamic_cast<SM2EncMaterial *>(&out);
     if (!sm2) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
-    return pgp::sm2::encrypt(ctx.rng, sm2->enc, data, PGP_HASH_SM3, key_);
+    return sm2::encrypt(ctx.rng, sm2->enc, data, PGP_HASH_SM3, key_);
 #else
     RNP_LOG("sm2_encrypt is not available");
     return RNP_ERROR_NOT_IMPLEMENTED;
@@ -1353,11 +1353,11 @@ SM2KeyMaterial::decrypt(rnp::SecurityContext &ctx,
                         const EncMaterial &   in) const
 {
 #if defined(ENABLE_SM2)
-    auto sm2 = dynamic_cast<const pgp::SM2EncMaterial *>(&in);
+    auto sm2 = dynamic_cast<const SM2EncMaterial *>(&in);
     if (!sm2) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
-    return pgp::sm2::decrypt(out, sm2->enc, key_);
+    return sm2::decrypt(out, sm2->enc, key_);
 #else
     RNP_LOG("SM2 decryption is not available.");
     return RNP_ERROR_NOT_IMPLEMENTED;
@@ -1370,7 +1370,7 @@ SM2KeyMaterial::verify(const rnp::SecurityContext &    ctx,
                        const rnp::secure_bytes &       hash) const
 {
 #if defined(ENABLE_SM2)
-    return pgp::sm2::verify(sig.ecc, sig.halg, hash, key_);
+    return sm2::verify(sig.ecc, sig.halg, hash, key_);
 #else
     RNP_LOG("SM2 verification is not available.");
     return RNP_ERROR_NOT_IMPLEMENTED;
@@ -1387,7 +1387,7 @@ SM2KeyMaterial::sign(rnp::SecurityContext &    ctx,
     if (ret) {
         return ret;
     }
-    return pgp::sm2::sign(ctx.rng, sig.ecc, sig.halg, hash, key_);
+    return sm2::sign(ctx.rng, sig.ecc, sig.halg, hash, key_);
 #else
     RNP_LOG("SM2 signing is not available.");
     return RNP_ERROR_NOT_IMPLEMENTED;
@@ -1398,7 +1398,7 @@ void
 SM2KeyMaterial::compute_za(rnp::Hash &hash) const
 {
 #if defined(ENABLE_SM2)
-    auto res = pgp::sm2::compute_za(key_, hash);
+    auto res = sm2::compute_za(key_, hash);
     if (res) {
         RNP_LOG("failed to compute SM2 ZA field");
         throw rnp::rnp_exception(res);
@@ -1450,7 +1450,7 @@ bool
 Ed25519KeyMaterial::parse(pgp_packet_body_t &pkt) noexcept
 {
     secret_ = false;
-    auto                 ec_desc = pgp::ec::Curve::get(PGP_CURVE_ED25519);
+    auto                 ec_desc = ec::Curve::get(PGP_CURVE_ED25519);
     std::vector<uint8_t> buf(ec_desc->bytes());
     if (!pkt.get(buf.data(), buf.size())) {
         RNP_LOG("failed to parse Ed25519 public key data");
@@ -1463,7 +1463,7 @@ Ed25519KeyMaterial::parse(pgp_packet_body_t &pkt) noexcept
 bool
 Ed25519KeyMaterial::parse_secret(pgp_packet_body_t &pkt) noexcept
 {
-    auto                 ec_desc = pgp::ec::Curve::get(PGP_CURVE_ED25519);
+    auto                 ec_desc = ec::Curve::get(PGP_CURVE_ED25519);
     std::vector<uint8_t> buf(ec_desc->bytes());
     if (!pkt.get(buf.data(), buf.size())) {
         RNP_LOG("failed to parse Ed25519 secret key data");
@@ -1576,7 +1576,7 @@ bool
 X25519KeyMaterial::parse(pgp_packet_body_t &pkt) noexcept
 {
     secret_ = false;
-    auto                 ec_desc = pgp::ec::Curve::get(PGP_CURVE_25519);
+    auto                 ec_desc = ec::Curve::get(PGP_CURVE_25519);
     std::vector<uint8_t> buf(ec_desc->bytes());
     if (!pkt.get(buf.data(), buf.size())) {
         RNP_LOG("failed to parse X25519 public key data");
@@ -1589,7 +1589,7 @@ X25519KeyMaterial::parse(pgp_packet_body_t &pkt) noexcept
 bool
 X25519KeyMaterial::parse_secret(pgp_packet_body_t &pkt) noexcept
 {
-    auto                 ec_desc = pgp::ec::Curve::get(PGP_CURVE_25519);
+    auto                 ec_desc = ec::Curve::get(PGP_CURVE_25519);
     std::vector<uint8_t> buf(ec_desc->bytes());
     if (!pkt.get(buf.data(), buf.size())) {
         RNP_LOG("failed to parse X25519 secret key data");
@@ -1627,7 +1627,7 @@ X25519KeyMaterial::encrypt(rnp::SecurityContext &   ctx,
                            EncMaterial &            out,
                            const rnp::secure_bytes &data) const
 {
-    auto x25519 = dynamic_cast<pgp::X25519EncMaterial *>(&out);
+    auto x25519 = dynamic_cast<X25519EncMaterial *>(&out);
     if (!x25519) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -1639,7 +1639,7 @@ X25519KeyMaterial::decrypt(rnp::SecurityContext &ctx,
                            rnp::secure_bytes &   out,
                            const EncMaterial &   in) const
 {
-    auto x25519 = dynamic_cast<const pgp::X25519EncMaterial *>(&in);
+    auto x25519 = dynamic_cast<const X25519EncMaterial *>(&in);
     if (!x25519) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -1766,7 +1766,7 @@ MlkemEcdhKeyMaterial::encrypt(rnp::SecurityContext &   ctx,
                               EncMaterial &            out,
                               const rnp::secure_bytes &data) const
 {
-    auto mlkem = dynamic_cast<pgp::MlkemEcdhEncMaterial *>(&out);
+    auto mlkem = dynamic_cast<MlkemEcdhEncMaterial *>(&out);
     if (!mlkem) {
         return RNP_ERROR_BAD_PARAMETERS;
     }
@@ -1778,7 +1778,7 @@ MlkemEcdhKeyMaterial::decrypt(rnp::SecurityContext &ctx,
                               rnp::secure_bytes &   out,
                               const EncMaterial &   in) const
 {
-    auto mlkem = dynamic_cast<const pgp::MlkemEcdhEncMaterial *>(&in);
+    auto mlkem = dynamic_cast<const MlkemEcdhEncMaterial *>(&in);
     if (!mlkem) {
         return RNP_ERROR_BAD_PARAMETERS;
     }