File: algolist.cpp

package info (click to toggle)
monotone 0.31-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 20,680 kB
  • ctags: 14,801
  • sloc: cpp: 87,711; ansic: 64,862; sh: 5,691; lisp: 954; perl: 783; makefile: 509; python: 265; sql: 98; sed: 16
file content (57 lines) | stat: -rw-r--r-- 1,662 bytes parent folder | download
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
/*************************************************
* Algorithms List Source File                    *
* (C) 1999-2005 The Botan Project                *
*************************************************/

#include <botan/lookup.h>
#include <botan/parsing.h>
#include <botan/mode_pad.h>
#include <botan/pkcs5.h>

namespace Botan {

namespace Algolist {

/*************************************************
* Attempt to get a string to key object          *
*************************************************/
S2K* get_s2k(const std::string& algo_spec)
   {
   std::vector<std::string> name = parse_algorithm_name(algo_spec);
   if(name.size() == 0)
      return 0;
   if(name.size() != 2)
      throw Invalid_Algorithm_Name(algo_spec);

   const std::string algo_name = deref_alias(name[0]);

   if(algo_name == "PBKDF1") return new PKCS5_PBKDF1(name[1]);
   if(algo_name == "PBKDF2") return new PKCS5_PBKDF2(name[1]);

   return 0;
   }

/*************************************************
* Attempt to get a block cipher padding method   *
*************************************************/
BlockCipherModePaddingMethod* get_bc_pad(const std::string& algo_spec)
   {
   std::vector<std::string> name = parse_algorithm_name(algo_spec);
   if(name.size() == 0)
      return 0;
   if(name.size() != 1)
      throw Invalid_Algorithm_Name(algo_spec);

   const std::string algo_name = deref_alias(name[0]);

   if(algo_name == "PKCS7") return new PKCS7_Padding;
   if(algo_name == "OneAndZeros") return new OneAndZeros_Padding;
   if(algo_name == "X9.23") return new  ANSI_X923_Padding;
   if(algo_name == "NoPadding") return new Null_Padding;

   return 0;
   }

}

}