Botan: Botan::GMP_Engine Class Reference

Botan 1.10.16

Public Member Functions | List of all members
Botan::GMP_Engine Class Reference

`#include <gnump_engine.h>`

Inheritance diagram for Botan::GMP_Engine:

## Public Member Functions
virtual BlockCipher * | find_block_cipher (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual HashFunction * | find_hash (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual MessageAuthenticationCode * | find_mac (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual PBKDF * | find_pbkdf (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual StreamCipher * | find_stream_cipher (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual Keyed_Filter * | get_cipher (const std::string &algo_spec, Cipher_Dir dir, Algorithm_Factory &af)
PK_Ops::Decryption * | get_decryption_op (const Private_Key &key) const
PK_Ops::Encryption * | get_encryption_op (const Public_Key &key) const
PK_Ops::Key_Agreement * | get_key_agreement_op (const Private_Key &key) const
PK_Ops::Signature * | get_signature_op (const Private_Key &key) const
PK_Ops::Verification * | get_verify_op (const Public_Key &key) const
| GMP_Engine ()
Modular_Exponentiator * | mod_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.

References Botan::Allocator::get().

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 }
Botan::Allocator::get
static Allocator * get(bool locking)
Definition: defalloc.cpp:90

## ◆ ~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_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

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

Definition at line 13 of file engine.cpp.

15 {
16 return 0;
17 }

## ◆ find_hash()

HashFunction * Botan::Engine::find_hash | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtualinherited

Parameters

  algo_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

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

Definition at line 27 of file engine.cpp.

29 {
30 return 0;
31 }

## ◆ find_mac()

MessageAuthenticationCode * Botan::Engine::find_mac | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtualinherited

Parameters

  algo_spec | the algorithm name/specification
  af | an 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 }

## ◆ find_pbkdf()

PBKDF * Botan::Engine::find_pbkdf | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtualinherited

Parameters

  algo_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

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

Definition at line 41 of file engine.cpp.

43 {
44 return 0;
45 }

## ◆ find_stream_cipher()

StreamCipher * Botan::Engine::find_stream_cipher | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtualinherited

Parameters

  algo_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

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

Definition at line 20 of file engine.cpp.

22 {
23 return 0;
24 }

## ◆ 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_spec | the algorithm name/specification
  dir | specifies if encryption or decryption is desired
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

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

Definition at line 54 of file engine.cpp.

57 {
58 return 0;
59 }

## ◆ 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

  key | the 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.

Referenced by provider_name().

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

  key | the 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.

Referenced by provider_name().

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

  key | the 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.

Referenced by provider_name().

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

  key | the 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.

Referenced by provider_name().

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

  key | the 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.

Referenced by provider_name().

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

  n | the modulus
  hints | any use hints

Returns
  newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 47 of file gmp_powm.cpp.

Referenced by provider_name().

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.

References get_decryption_op(), get_encryption_op(), get_key_agreement_op(), get_signature_op(), get_verify_op(), and mod_exp().

24 { return "gmp"; }

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

- src/engine/gnump/gnump_engine.h
- src/engine/gnump/gmp_mem.cpp
- src/engine/gnump/gmp_powm.cpp
- src/engine/gnump/gnump_pk.cpp