/* * (C) 2010,2015 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #ifndef BOTAN_PK_OPERATIONS_H__ #define BOTAN_PK_OPERATIONS_H__ /** * Ordinary applications should never need to include or use this * header. It is exposed only for specialized applications which want * to implement new versions of public key crypto without merging them * as changes to the library. One actual example of such usage is an * application which creates RSA signatures using a custom TPM library. * Unless you're doing something like that, you don't need anything * here. Instead use pubkey.h which wraps these types safely and * provides a stable application-oriented API. */ #include #include #include namespace Botan { class EME; class KDF; class EMSA; namespace PK_Ops { /** * Public key encryption interface */ class BOTAN_DLL Encryption { public: virtual secure_vector encrypt(const byte msg[], size_t msg_len, RandomNumberGenerator& rng) = 0; virtual size_t max_input_bits() const = 0; virtual ~Encryption() {} }; /** * Public key decryption interface */ class BOTAN_DLL Decryption { public: virtual secure_vector decrypt(byte& valid_mask, const byte ciphertext[], size_t ciphertext_len) = 0; virtual ~Decryption() {} }; /** * Public key signature verification interface */ class BOTAN_DLL Verification { public: /* * Add more data to the message currently being signed * @param msg the message * @param msg_len the length of msg in bytes */ virtual void update(const byte msg[], size_t msg_len) = 0; /* * Perform a verification operation * @param rng a random number generator */ virtual bool is_valid_signature(const byte sig[], size_t sig_len) = 0; virtual ~Verification() {} }; /** * Public key signature creation interface */ class BOTAN_DLL Signature { public: /* * Add more data to the message currently being signed * @param msg the message * @param msg_len the length of msg in bytes */ virtual void update(const byte msg[], size_t msg_len) = 0; /* * Perform a signature operation * @param rng a random number generator */ virtual secure_vector sign(RandomNumberGenerator& rng) = 0; virtual ~Signature() {} }; /** * A generic key agreement operation (eg DH or ECDH) */ class BOTAN_DLL Key_Agreement { public: virtual secure_vector agree(size_t key_len, const byte other_key[], size_t other_key_len, const byte salt[], size_t salt_len) = 0; virtual ~Key_Agreement() {} }; /** * KEM (key encapsulation) */ class BOTAN_DLL KEM_Encryption { public: virtual void kem_encrypt(secure_vector& out_encapsulated_key, secure_vector& out_shared_key, size_t desired_shared_key_len, Botan::RandomNumberGenerator& rng, const uint8_t salt[], size_t salt_len) = 0; virtual ~KEM_Encryption() {} }; class BOTAN_DLL KEM_Decryption { public: virtual secure_vector kem_decrypt(const byte encap_key[], size_t len, size_t desired_shared_key_len, const uint8_t salt[], size_t salt_len) = 0; virtual ~KEM_Decryption() {} }; } } #endif