Botan 1.10.17
Botan::GMP_Engine Class Reference

#include <gnump_engine.h>

Inheritance diagram for Botan::GMP_Engine:
Botan::Engine

Public Member Functions

virtual BlockCipherfind_block_cipher (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual HashFunctionfind_hash (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual MessageAuthenticationCodefind_mac (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual PBKDFfind_pbkdf (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual StreamCipherfind_stream_cipher (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual Keyed_Filterget_cipher (const std::string &algo_spec, Cipher_Dir dir, Algorithm_Factory &af)
PK_Ops::Decryptionget_decryption_op (const Private_Key &key) const
PK_Ops::Encryptionget_encryption_op (const Public_Key &key) const
PK_Ops::Key_Agreementget_key_agreement_op (const Private_Key &key) const
PK_Ops::Signatureget_signature_op (const Private_Key &key) const
PK_Ops::Verificationget_verify_op (const Public_Key &key) const
 GMP_Engine ()
Modular_Exponentiatormod_exp (const BigInt &, Power_Mod::Usage_Hints) const
std::string provider_name () const
 ~GMP_Engine ()

Detailed Description

Engine using GNU MP

Definition at line 18 of file gnump_engine.h.

Constructor & Destructor Documentation

◆ GMP_Engine()

Botan::GMP_Engine::GMP_Engine ( )

Definition at line 54 of file gmp_mem.cpp.

55 {
56 if(gmp_alloc == 0)
57 {
58 gmp_alloc = Allocator::get(true);
59 mp_set_memory_functions(gmp_malloc, gmp_realloc, gmp_free);
60 }
61
62 ++gmp_alloc_refcnt;
63 }
static Allocator * get(bool locking)
Definition defalloc.cpp:90

References Botan::Allocator::get().

◆ ~GMP_Engine()

Botan::GMP_Engine::~GMP_Engine ( )

Definition at line 65 of file gmp_mem.cpp.

66 {
67 --gmp_alloc_refcnt;
68
69 if(gmp_alloc_refcnt == 0)
70 {
71 mp_set_memory_functions(NULL, NULL, NULL);
72 gmp_alloc = 0;
73 }
74 }

Member Function Documentation

◆ find_block_cipher()

BlockCipher * Botan::Engine::find_block_cipher ( const SCAN_Name & algo_spec,
Algorithm_Factory & af ) const
virtualinherited
Parameters
algo_specthe algorithm name/specification
afan algorithm factory object
Returns
newly allocated object, or NULL

Reimplemented in Botan::AES_ISA_Engine, Botan::Assembler_Engine, Botan::Core_Engine, Botan::Dynamically_Loaded_Engine, Botan::OpenSSL_Engine, and Botan::SIMD_Engine.

Definition at line 13 of file engine.cpp.

15 {
16 return 0;
17 }

Referenced by provider_name().

◆ find_hash()

HashFunction * Botan::Engine::find_hash ( const SCAN_Name & algo_spec,
Algorithm_Factory & af ) const
virtualinherited
Parameters
algo_specthe algorithm name/specification
afan algorithm factory object
Returns
newly allocated object, or NULL

Reimplemented in Botan::Assembler_Engine, Botan::Core_Engine, Botan::Dynamically_Loaded_Engine, Botan::OpenSSL_Engine, and Botan::SIMD_Engine.

Definition at line 27 of file engine.cpp.

29 {
30 return 0;
31 }

Referenced by provider_name().

◆ find_mac()

MessageAuthenticationCode * Botan::Engine::find_mac ( const SCAN_Name & algo_spec,
Algorithm_Factory & af ) const
virtualinherited
Parameters
algo_specthe algorithm name/specification
afan algorithm factory object
Returns
newly allocated object, or NULL

Reimplemented in Botan::Core_Engine, and Botan::Dynamically_Loaded_Engine.

Definition at line 34 of file engine.cpp.

36 {
37 return 0;
38 }

Referenced by provider_name().

◆ find_pbkdf()

PBKDF * Botan::Engine::find_pbkdf ( const SCAN_Name & algo_spec,
Algorithm_Factory & af ) const
virtualinherited
Parameters
algo_specthe algorithm name/specification
afan algorithm factory object
Returns
newly allocated object, or NULL

Reimplemented in Botan::Core_Engine, and Botan::Dynamically_Loaded_Engine.

Definition at line 41 of file engine.cpp.

43 {
44 return 0;
45 }

Referenced by provider_name().

◆ find_stream_cipher()

StreamCipher * Botan::Engine::find_stream_cipher ( const SCAN_Name & algo_spec,
Algorithm_Factory & af ) const
virtualinherited
Parameters
algo_specthe algorithm name/specification
afan algorithm factory object
Returns
newly allocated object, or NULL

Reimplemented in Botan::Core_Engine, Botan::Dynamically_Loaded_Engine, and Botan::OpenSSL_Engine.

Definition at line 20 of file engine.cpp.

22 {
23 return 0;
24 }

Referenced by provider_name().

◆ get_cipher()

Keyed_Filter * Botan::Engine::get_cipher ( const std::string & algo_spec,
Cipher_Dir dir,
Algorithm_Factory & af )
virtualinherited

Return a new cipher object

Parameters
algo_specthe algorithm name/specification
dirspecifies if encryption or decryption is desired
afan algorithm factory object
Returns
newly allocated object, or NULL

Reimplemented in Botan::Core_Engine, and Botan::Dynamically_Loaded_Engine.

Definition at line 54 of file engine.cpp.

57 {
58 return 0;
59 }

Referenced by provider_name().

◆ get_decryption_op()

PK_Ops::Decryption * Botan::GMP_Engine::get_decryption_op ( const Private_Key & key) const
virtual

Return a new operator object for this key, if possible

Parameters
keythe key we want an operator for
Returns
newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 328 of file gnump_pk.cpp.

329 {
330#if defined(BOTAN_HAS_RSA)
331 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
332 return new GMP_RSA_Private_Operation(*s);
333#endif
334
335 return 0;
336 }

◆ get_encryption_op()

PK_Ops::Encryption * Botan::GMP_Engine::get_encryption_op ( const Public_Key & key) const
virtual

Return a new operator object for this key, if possible

Parameters
keythe key we want an operator for
Returns
newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 317 of file gnump_pk.cpp.

318 {
319#if defined(BOTAN_HAS_RSA)
320 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
321 return new GMP_RSA_Public_Operation(*s);
322#endif
323
324 return 0;
325 }

◆ get_key_agreement_op()

PK_Ops::Key_Agreement * Botan::GMP_Engine::get_key_agreement_op ( const Private_Key & key) const
virtual

Return a new operator object for this key, if possible

Parameters
keythe key we want an operator for
Returns
newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 274 of file gnump_pk.cpp.

275 {
276#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
277 if(const DH_PrivateKey* dh = dynamic_cast<const DH_PrivateKey*>(&key))
278 return new GMP_DH_KA_Operation(*dh);
279#endif
280
281 return 0;
282 }

◆ get_signature_op()

PK_Ops::Signature * Botan::GMP_Engine::get_signature_op ( const Private_Key & key) const
virtual

Return a new operator object for this key, if possible

Parameters
keythe key we want an operator for
Returns
newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 285 of file gnump_pk.cpp.

286 {
287#if defined(BOTAN_HAS_RSA)
288 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
289 return new GMP_RSA_Private_Operation(*s);
290#endif
291
292#if defined(BOTAN_HAS_DSA)
293 if(const DSA_PrivateKey* s = dynamic_cast<const DSA_PrivateKey*>(&key))
294 return new GMP_DSA_Signature_Operation(*s);
295#endif
296
297 return 0;
298 }

◆ get_verify_op()

PK_Ops::Verification * Botan::GMP_Engine::get_verify_op ( const Public_Key & key) const
virtual

Return a new operator object for this key, if possible

Parameters
keythe key we want an operator for
Returns
newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 301 of file gnump_pk.cpp.

302 {
303#if defined(BOTAN_HAS_RSA)
304 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
305 return new GMP_RSA_Public_Operation(*s);
306#endif
307
308#if defined(BOTAN_HAS_DSA)
309 if(const DSA_PublicKey* s = dynamic_cast<const DSA_PublicKey*>(&key))
310 return new GMP_DSA_Verification_Operation(*s);
311#endif
312
313 return 0;
314 }

◆ mod_exp()

Modular_Exponentiator * Botan::GMP_Engine::mod_exp ( const BigInt & n,
Power_Mod::Usage_Hints hints ) const
virtual
Parameters
nthe modulus
hintsany use hints
Returns
newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 47 of file gmp_powm.cpp.

49 {
50 return new GMP_Modular_Exponentiator(n);
51 }

◆ provider_name()

std::string Botan::GMP_Engine::provider_name ( ) const
inlinevirtual
Returns
name of this engine

Implements Botan::Engine.

Definition at line 24 of file gnump_engine.h.

24{ return "gmp"; }

The documentation for this class was generated from the following files: