Skip to content

Commit

Permalink
Make pk_ops.h and pk_ops_impl.h public
Browse files Browse the repository at this point in the history
They used to be public in Botan 2.x but were removed from the public
interface. Though, those headers are needed by applications that wish
to implement custom public-key algorithms.

Closes #3878
  • Loading branch information
reneme committed Jan 9, 2024
1 parent fb4df9a commit 596f5ab
Show file tree
Hide file tree
Showing 33 changed files with 51 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/lib/prov/pkcs11/p11_ecdh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#if defined(BOTAN_HAS_ECDH)

#include <botan/der_enc.h>
#include <botan/pk_ops.h>
#include <botan/rng.h>
#include <botan/internal/p11_mechanism.h>
#include <botan/internal/pk_ops.h>

namespace Botan::PKCS11 {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/prov/pkcs11/p11_ecdsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

#if defined(BOTAN_HAS_ECDSA)

#include <botan/pk_ops.h>
#include <botan/rng.h>
#include <botan/internal/keypair.h>
#include <botan/internal/p11_mechanism.h>
#include <botan/internal/pk_ops.h>

namespace Botan::PKCS11 {

Expand Down
3 changes: 1 addition & 2 deletions src/lib/prov/pkcs11/p11_rsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

#if defined(BOTAN_HAS_RSA)

#include <botan/pk_ops_impl.h>
#include <botan/pubkey.h>
#include <botan/rng.h>
#include <botan/internal/blinding.h>
#include <botan/internal/p11_mechanism.h>
#include <botan/internal/pk_ops.h>
#include <botan/internal/pk_ops_impl.h>

namespace Botan::PKCS11 {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/prov/tpm/tpm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include <botan/der_enc.h>
#include <botan/hash.h>
#include <botan/pk_ops.h>
#include <botan/rsa.h>
#include <botan/internal/fmt.h>
#include <botan/internal/hash_id.h>
#include <botan/internal/pk_ops.h>
#include <botan/internal/workfactor.h>
#include <limits>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/curve25519/curve25519.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/pk_ops_impl.h>
#include <botan/rng.h>
#include <botan/internal/fmt.h>
#include <botan/internal/pk_ops_impl.h>

namespace Botan {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/dh/dh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include <botan/dh.h>

#include <botan/pk_ops_impl.h>
#include <botan/internal/blinding.h>
#include <botan/internal/dl_scheme.h>
#include <botan/internal/pk_ops_impl.h>

namespace Botan {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/dilithium/dilithium_common/dilithium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

#include <botan/exceptn.h>
#include <botan/hash.h>
#include <botan/pk_ops_impl.h>
#include <botan/rng.h>

#include <botan/internal/dilithium_polynomials.h>
#include <botan/internal/fmt.h>
#include <botan/internal/parsing.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/shake.h>
#include <botan/internal/stl_util.h>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/dsa/dsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <botan/dsa.h>

#include <botan/numthry.h>
#include <botan/pk_ops_impl.h>
#include <botan/internal/divide.h>
#include <botan/internal/dl_scheme.h>
#include <botan/internal/keypair.h>
#include <botan/internal/pk_ops_impl.h>

#if defined(BOTAN_HAS_RFC6979_GENERATOR)
#include <botan/internal/rfc6979.h>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/ecdh/ecdh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <botan/ecdh.h>

#include <botan/numthry.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/pk_ops_impl.h>

namespace Botan {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/ecdsa/ecdsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include <botan/ecdsa.h>

#include <botan/pk_ops_impl.h>
#include <botan/reducer.h>
#include <botan/internal/keypair.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/point_mul.h>

#if defined(BOTAN_HAS_RFC6979_GENERATOR)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/ecgdsa/ecgdsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <botan/ecgdsa.h>

#include <botan/pk_ops_impl.h>
#include <botan/reducer.h>
#include <botan/internal/keypair.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/point_mul.h>

namespace Botan {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/ecies/ecies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <botan/cipher_mode.h>
#include <botan/mac.h>
#include <botan/numthry.h>
#include <botan/pk_ops_impl.h>
#include <botan/internal/ct_utils.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/stl_util.h>

namespace Botan {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/eckcdsa/eckcdsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include <botan/eckcdsa.h>

#include <botan/hash.h>
#include <botan/pk_ops_impl.h>
#include <botan/reducer.h>
#include <botan/rng.h>
#include <botan/internal/fmt.h>
#include <botan/internal/keypair.h>
#include <botan/internal/parsing.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/point_mul.h>
#include <botan/internal/scan_name.h>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/ed25519/ed25519_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/hash.h>
#include <botan/pk_ops_impl.h>
#include <botan/rng.h>
#include <botan/internal/ct_utils.h>
#include <botan/internal/ed25519_internal.h>
#include <botan/internal/pk_ops_impl.h>

namespace Botan {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/elgamal/elgamal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include <botan/elgamal.h>

#include <botan/pk_ops_impl.h>
#include <botan/internal/blinding.h>
#include <botan/internal/dl_scheme.h>
#include <botan/internal/keypair.h>
#include <botan/internal/monty_exp.h>
#include <botan/internal/pk_ops_impl.h>

namespace Botan {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/frodokem/frodokem_common/frodokem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

#include <botan/assert.h>
#include <botan/hex.h>
#include <botan/pk_ops_impl.h>
#include <botan/rng.h>
#include <botan/xof.h>
#include <botan/internal/ct_utils.h>
#include <botan/internal/frodo_constants.h>
#include <botan/internal/frodo_matrix.h>
#include <botan/internal/frodo_types.h>
#include <botan/internal/loadstor.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/stl_util.h>

#include <algorithm>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/gost_3410/gost_3410.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/pk_ops_impl.h>
#include <botan/reducer.h>
#include <botan/internal/fmt.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/point_mul.h>

namespace Botan {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pubkey/info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ brief -> "Implementations of public key schemes"
pk_algs.h
pk_keys.h
pk_ops_fwd.h
pk_ops_impl.h
pk_ops.h
pkcs8.h
pubkey.h
x509_key.h
</header:public>

<header:internal>
blinding.h
pk_ops.h
pk_ops_impl.h
workfactor.h
</header:internal>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/kyber/kyber_common/kyber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <botan/ber_dec.h>
#include <botan/hash.h>
#include <botan/mem_ops.h>
#include <botan/pk_ops_impl.h>
#include <botan/pubkey.h>
#include <botan/rng.h>
#include <botan/secmem.h>
Expand All @@ -25,7 +26,6 @@
#include <botan/internal/fmt.h>
#include <botan/internal/kyber_symmetric_primitives.h>
#include <botan/internal/loadstor.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/stl_util.h>

#if defined(BOTAN_HAS_KYBER)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/mce/mce_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define BOTAN_MCELIECE_INTERNAL_H_

#include <botan/mceliece.h>
#include <botan/internal/pk_ops.h>
#include <botan/pk_ops.h>
#include <botan/internal/polyn_gf2m.h>

namespace Botan {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/mce/mceliece_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/pk_ops_impl.h>
#include <botan/rng.h>
#include <botan/internal/bit_ops.h>
#include <botan/internal/code_based_util.h>
#include <botan/internal/loadstor.h>
#include <botan/internal/mce_internal.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/polyn_gf2m.h>
#include <botan/internal/stl_util.h>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/pk_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <botan/der_enc.h>
#include <botan/hash.h>
#include <botan/hex.h>
#include <botan/pk_ops.h>
#include <botan/internal/fmt.h>
#include <botan/internal/pk_ops.h>

namespace Botan {

Expand Down
8 changes: 7 additions & 1 deletion src/lib/pubkey/pk_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* Botan is released under the Simplified BSD License (see license.txt)
*/

#include <botan/internal/pk_ops_impl.h>
#include <botan/pk_ops_impl.h>

#include <botan/hash.h>
#include <botan/rng.h>
#include <botan/internal/bit_ops.h>
#include <botan/internal/eme.h>
#include <botan/internal/fmt.h>
#include <botan/internal/parsing.h>
#include <botan/internal/scan_name.h>

#include <sstream>

#if defined(BOTAN_HAS_RAW_HASH_FN)
Expand All @@ -39,6 +41,8 @@ secure_vector<uint8_t> PK_Ops::Encryption_with_EME::encrypt(const uint8_t msg[],
return raw_encrypt(encoded.data(), encoded.size(), rng);
}

PK_Ops::Encryption_with_EME::~Encryption_with_EME() = default;

PK_Ops::Decryption_with_EME::Decryption_with_EME(std::string_view eme) : m_eme(EME::create(eme)) {}

secure_vector<uint8_t> PK_Ops::Decryption_with_EME::decrypt(uint8_t& valid_mask,
Expand All @@ -48,6 +52,8 @@ secure_vector<uint8_t> PK_Ops::Decryption_with_EME::decrypt(uint8_t& valid_mask,
return m_eme->unpad(valid_mask, raw.data(), raw.size());
}

PK_Ops::Decryption_with_EME::~Decryption_with_EME() = default;

PK_Ops::Key_Agreement_with_KDF::Key_Agreement_with_KDF(std::string_view kdf) {
if(kdf != "Raw") {
m_kdf = KDF::create_or_throw(kdf);
Expand Down
16 changes: 10 additions & 6 deletions src/lib/pubkey/pk_ops_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@

#include <botan/hash.h>
#include <botan/kdf.h>
#include <botan/internal/eme.h>
#include <botan/internal/pk_ops.h>
#include <botan/pk_ops.h>

namespace Botan::PK_Ops {
namespace Botan {

class EME;

namespace PK_Ops {

class Encryption_with_EME : public Encryption {
public:
size_t max_input_bits() const override;

secure_vector<uint8_t> encrypt(const uint8_t msg[], size_t msg_len, RandomNumberGenerator& rng) override;

~Encryption_with_EME() override = default;
~Encryption_with_EME() override;

protected:
explicit Encryption_with_EME(std::string_view eme);
Expand All @@ -37,7 +40,7 @@ class Decryption_with_EME : public Decryption {
public:
secure_vector<uint8_t> decrypt(uint8_t& valid_mask, const uint8_t msg[], size_t msg_len) override;

~Decryption_with_EME() override = default;
~Decryption_with_EME() override;

protected:
explicit Decryption_with_EME(std::string_view eme);
Expand Down Expand Up @@ -166,6 +169,7 @@ class KEM_Decryption_with_KDF : public KEM_Decryption {
std::unique_ptr<KDF> m_kdf;
};

} // namespace Botan::PK_Ops
} // namespace PK_Ops
} // namespace Botan

#endif
2 changes: 1 addition & 1 deletion src/lib/pubkey/pubkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include <botan/bigint.h>
#include <botan/der_enc.h>
#include <botan/mem_ops.h>
#include <botan/pk_ops.h>
#include <botan/rng.h>
#include <botan/internal/ct_utils.h>
#include <botan/internal/fmt.h>
#include <botan/internal/parsing.h>
#include <botan/internal/pk_ops.h>
#include <botan/internal/pss_params.h>

namespace Botan {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/rsa/rsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/pk_ops_impl.h>
#include <botan/reducer.h>
#include <botan/internal/blinding.h>
#include <botan/internal/divide.h>
Expand All @@ -18,7 +19,6 @@
#include <botan/internal/monty.h>
#include <botan/internal/monty_exp.h>
#include <botan/internal/parsing.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/pss_params.h>
#include <botan/internal/workfactor.h>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/sm2/sm2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

#include <botan/hash.h>
#include <botan/numthry.h>
#include <botan/pk_ops_impl.h>
#include <botan/internal/keypair.h>
#include <botan/internal/loadstor.h>
#include <botan/internal/parsing.h>
#include <botan/internal/pk_ops_impl.h>
#include <botan/internal/point_mul.h>

namespace Botan {
Expand Down
Loading

0 comments on commit 596f5ab

Please sign in to comment.