monotone

monotone Mtn Source Tree

Root/botan/algolist.cpp

1/*************************************************
2* Algorithms List Source File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#include <botan/lookup.h>
7#include <botan/parsing.h>
8#include <botan/mode_pad.h>
9#include <botan/pkcs5.h>
10
11namespace Botan {
12
13namespace Algolist {
14
15/*************************************************
16* Attempt to get a string to key object *
17*************************************************/
18S2K* get_s2k(const std::string& algo_spec)
19 {
20 std::vector<std::string> name = parse_algorithm_name(algo_spec);
21 if(name.size() == 0)
22 return 0;
23 if(name.size() != 2)
24 throw Invalid_Algorithm_Name(algo_spec);
25
26 const std::string algo_name = deref_alias(name[0]);
27
28 if(algo_name == "PBKDF1") return new PKCS5_PBKDF1(name[1]);
29 if(algo_name == "PBKDF2") return new PKCS5_PBKDF2(name[1]);
30
31 return 0;
32 }
33
34/*************************************************
35* Attempt to get a block cipher padding method *
36*************************************************/
37BlockCipherModePaddingMethod* get_bc_pad(const std::string& algo_spec)
38 {
39 std::vector<std::string> name = parse_algorithm_name(algo_spec);
40 if(name.size() == 0)
41 return 0;
42 if(name.size() != 1)
43 throw Invalid_Algorithm_Name(algo_spec);
44
45 const std::string algo_name = deref_alias(name[0]);
46
47 if(algo_name == "PKCS7") return new PKCS7_Padding;
48 if(algo_name == "OneAndZeros") return new OneAndZeros_Padding;
49 if(algo_name == "X9.23") return new ANSI_X923_Padding;
50 if(algo_name == "NoPadding") return new Null_Padding;
51
52 return 0;
53 }
54
55}
56
57}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status