Coverage Report

Created: 2020-02-14 15:38

/src/botan/build/include/botan/scan_name.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* SCAN Name Abstraction
3
* (C) 2008,2015 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_SCAN_NAME_H_
9
#define BOTAN_SCAN_NAME_H_
10
11
#include <botan/types.h>
12
#include <string>
13
#include <vector>
14
15
BOTAN_FUTURE_INTERNAL_HEADER(scan_name.h)
16
17
namespace Botan {
18
19
/**
20
A class encapsulating a SCAN name (similar to JCE conventions)
21
http://www.users.zetnet.co.uk/hopwood/crypto/scan/
22
*/
23
class BOTAN_PUBLIC_API(2,0) SCAN_Name final
24
   {
25
   public:
26
      /**
27
      * Create a SCAN_Name
28
      * @param algo_spec A SCAN-format name
29
      */
30
      explicit SCAN_Name(const char* algo_spec);
31
32
      /**
33
      * Create a SCAN_Name
34
      * @param algo_spec A SCAN-format name
35
      */
36
      explicit SCAN_Name(std::string algo_spec);
37
38
      /**
39
      * @return original input string
40
      */
41
0
      const std::string& to_string() const { return m_orig_algo_spec; }
42
43
      BOTAN_DEPRECATED("Use SCAN_Name::to_string") const std::string& as_string() const
44
0
         {
45
0
         return this->to_string();
46
0
         }
47
48
      /**
49
      * @return algorithm name
50
      */
51
371k
      const std::string& algo_name() const { return m_alg_name; }
52
53
      /**
54
      * @return number of arguments
55
      */
56
132k
      size_t arg_count() const { return m_args.size(); }
57
58
      /**
59
      * @param lower is the lower bound
60
      * @param upper is the upper bound
61
      * @return if the number of arguments is between lower and upper
62
      */
63
      bool arg_count_between(size_t lower, size_t upper) const
64
88
         { return ((arg_count() >= lower) && (arg_count() <= upper)); }
65
66
      /**
67
      * @param i which argument
68
      * @return ith argument
69
      */
70
      std::string arg(size_t i) const;
71
72
      /**
73
      * @param i which argument
74
      * @param def_value the default value
75
      * @return ith argument or the default value
76
      */
77
      std::string arg(size_t i, const std::string& def_value) const;
78
79
      /**
80
      * @param i which argument
81
      * @param def_value the default value
82
      * @return ith argument as an integer, or the default value
83
      */
84
      size_t arg_as_integer(size_t i, size_t def_value) const;
85
86
      /**
87
      * @return cipher mode (if any)
88
      */
89
      std::string cipher_mode() const
90
0
         { return (m_mode_info.size() >= 1) ? m_mode_info[0] : ""; }
91
92
      /**
93
      * @return cipher mode padding (if any)
94
      */
95
      std::string cipher_mode_pad() const
96
0
         { return (m_mode_info.size() >= 2) ? m_mode_info[1] : ""; }
97
98
   private:
99
      std::string m_orig_algo_spec;
100
      std::string m_alg_name;
101
      std::vector<std::string> m_args;
102
      std::vector<std::string> m_mode_info;
103
   };
104
105
// This is unrelated but it is convenient to stash it here
106
template<typename T>
107
std::vector<std::string> probe_providers_of(const std::string& algo_spec,
108
                                            const std::vector<std::string>& possible)
109
890
   {
110
890
   std::vector<std::string> providers;
111
890
   for(auto&& prov : possible)
112
2.67k
      {
113
2.67k
      std::unique_ptr<T> o(T::create(algo_spec, prov));
114
2.67k
      if(o)
115
890
         {
116
890
         providers.push_back(prov); // available
117
890
         }
118
2.67k
      }
119
890
   return providers;
120
890
   }
Unexecuted instantiation: std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > Botan::probe_providers_of<Botan::StreamCipher>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)
std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > Botan::probe_providers_of<Botan::BlockCipher>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)
Line
Count
Source
109
350
   {
110
350
   std::vector<std::string> providers;
111
350
   for(auto&& prov : possible)
112
1.05k
      {
113
1.05k
      std::unique_ptr<T> o(T::create(algo_spec, prov));
114
1.05k
      if(o)
115
350
         {
116
350
         providers.push_back(prov); // available
117
350
         }
118
1.05k
      }
119
350
   return providers;
120
350
   }
std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > Botan::probe_providers_of<Botan::HashFunction>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)
Line
Count
Source
109
540
   {
110
540
   std::vector<std::string> providers;
111
540
   for(auto&& prov : possible)
112
1.62k
      {
113
1.62k
      std::unique_ptr<T> o(T::create(algo_spec, prov));
114
1.62k
      if(o)
115
540
         {
116
540
         providers.push_back(prov); // available
117
540
         }
118
1.62k
      }
119
540
   return providers;
120
540
   }
Unexecuted instantiation: std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > Botan::probe_providers_of<Botan::MessageAuthenticationCode>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)
Unexecuted instantiation: std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > Botan::probe_providers_of<Botan::KDF>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)
Unexecuted instantiation: std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > Botan::probe_providers_of<Botan::PBKDF>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)
Unexecuted instantiation: std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > Botan::probe_providers_of<Botan::PasswordHashFamily>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)
121
122
}
123
124
#endif