Coverage Report

Created: 2020-11-21 08:34

/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
      /**
44
      * @return algorithm name
45
      */
46
371k
      const std::string& algo_name() const { return m_alg_name; }
47
48
      /**
49
      * @return number of arguments
50
      */
51
135k
      size_t arg_count() const { return m_args.size(); }
52
53
      /**
54
      * @param lower is the lower bound
55
      * @param upper is the upper bound
56
      * @return if the number of arguments is between lower and upper
57
      */
58
      bool arg_count_between(size_t lower, size_t upper) const
59
80
         { return ((arg_count() >= lower) && (arg_count() <= upper)); }
60
61
      /**
62
      * @param i which argument
63
      * @return ith argument
64
      */
65
      std::string arg(size_t i) const;
66
67
      /**
68
      * @param i which argument
69
      * @param def_value the default value
70
      * @return ith argument or the default value
71
      */
72
      std::string arg(size_t i, const std::string& def_value) const;
73
74
      /**
75
      * @param i which argument
76
      * @param def_value the default value
77
      * @return ith argument as an integer, or the default value
78
      */
79
      size_t arg_as_integer(size_t i, size_t def_value) const;
80
81
      /**
82
      * @param i which argument
83
      * @return ith argument as an integer
84
      */
85
      size_t arg_as_integer(size_t i) const;
86
87
      /**
88
      * @return cipher mode (if any)
89
      */
90
      std::string cipher_mode() const
91
0
         { return (m_mode_info.size() >= 1) ? m_mode_info[0] : ""; }
92
93
      /**
94
      * @return cipher mode padding (if any)
95
      */
96
      std::string cipher_mode_pad() const
97
0
         { return (m_mode_info.size() >= 2) ? m_mode_info[1] : ""; }
98
99
   private:
100
      std::string m_orig_algo_spec;
101
      std::string m_alg_name;
102
      std::vector<std::string> m_args;
103
      std::vector<std::string> m_mode_info;
104
   };
105
106
// This is unrelated but it is convenient to stash it here
107
template<typename T>
108
std::vector<std::string> probe_providers_of(const std::string& algo_spec,
109
                                            const std::vector<std::string>& possible)
110
890
   {
111
890
   std::vector<std::string> providers;
112
890
   for(auto&& prov : possible)
113
2.67k
      {
114
2.67k
      std::unique_ptr<T> o(T::create(algo_spec, prov));
115
2.67k
      if(o)
116
890
         {
117
890
         providers.push_back(prov); // available
118
890
         }
119
2.67k
      }
120
890
   return providers;
121
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
110
350
   {
111
350
   std::vector<std::string> providers;
112
350
   for(auto&& prov : possible)
113
1.05k
      {
114
1.05k
      std::unique_ptr<T> o(T::create(algo_spec, prov));
115
1.05k
      if(o)
116
350
         {
117
350
         providers.push_back(prov); // available
118
350
         }
119
1.05k
      }
120
350
   return providers;
121
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
110
540
   {
111
540
   std::vector<std::string> providers;
112
540
   for(auto&& prov : possible)
113
1.62k
      {
114
1.62k
      std::unique_ptr<T> o(T::create(algo_spec, prov));
115
1.62k
      if(o)
116
540
         {
117
540
         providers.push_back(prov); // available
118
540
         }
119
1.62k
      }
120
540
   return providers;
121
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&)
122
123
}
124
125
#endif