aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate/algo_factory.h
blob: 098c7836b97d565bd2e64083ccdd81547d149823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Algorithm Factory
* (C) 2008 Jack Lloyd
*/

#ifndef BOTAN_ALGORITHM_FACTORY_H__
#define BOTAN_ALGORITHM_FACTORY_H__

#include <botan/scan_name.h>
#include <botan/mutex.h>
#include <string>
#include <vector>

namespace Botan {

class HashFunction;
class MessageAuthenticationCode;

/**
* Algorithm Factory
*/
class BOTAN_DLL Algorithm_Factory
   {
   public:
      ~Algorithm_Factory();

      void add_engine(class Engine*);

      class BOTAN_DLL Engine_Iterator
         {
         public:
            class Engine* next() { return af.get_engine_n(n++); }
            Engine_Iterator(const Algorithm_Factory& a) : af(a) { n = 0; }
         private:
            const Algorithm_Factory& af;
            u32bit n;
         };
      friend class Engine_Iterator;

      // Hash function operations
      const HashFunction* prototype_hash_function(const SCAN_Name& request);
      HashFunction* make_hash_function(const SCAN_Name& request);
      void add_hash_function(HashFunction* hash);

      // MAC operations
      const MessageAuthenticationCode* prototype_mac(const SCAN_Name& request);
      MessageAuthenticationCode* make_mac(const SCAN_Name& request);
      void add_mac(MessageAuthenticationCode* mac);

   private:
      class Engine* get_engine_n(u32bit) const;

      std::vector<class Engine*> engines;
   };

}

#endif