Botan 3.0.0
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | List of all members
Botan::ISO_9796_DS3 Class Referencefinal

#include <iso9796.h>

Inheritance diagram for Botan::ISO_9796_DS3:
Botan::EMSA

Public Member Functions

std::string hash_function () const override
 
 ISO_9796_DS3 (std::unique_ptr< HashFunction > hash, bool implicit=false)
 
std::string name () const override
 

Static Public Member Functions

static std::unique_ptr< EMSAcreate (std::string_view algo_spec)
 
static std::unique_ptr< EMSAcreate_or_throw (std::string_view algo_spec)
 

Detailed Description

ISO-9796-2 - Digital signature scheme 3 (deterministic)

Definition at line 68 of file iso9796.h.

Constructor & Destructor Documentation

◆ ISO_9796_DS3()

Botan::ISO_9796_DS3::ISO_9796_DS3 ( std::unique_ptr< HashFunction hash,
bool  implicit = false 
)
inline
Parameters
hashfunction to use
implicitwhether or not the trailer is implicit

Definition at line 75 of file iso9796.h.

75 :
76 m_hash(std::move(hash)),
77 m_implicit(implicit)
78 {}

Member Function Documentation

◆ create()

std::unique_ptr< EMSA > Botan::EMSA::create ( std::string_view  algo_spec)
staticinherited

Factory method for EMSA (message-encoding methods for signatures with appendix) objects

Parameters
algo_specthe name of the EMSA to create
Returns
pointer to newly allocated object of that type, or nullptr

Definition at line 34 of file emsa.cpp.

35 {
36 SCAN_Name req(algo_spec);
37
38#if defined(BOTAN_HAS_EMSA_PKCS1)
39 if(req.algo_name() == "EMSA_PKCS1" ||
40 req.algo_name() == "PKCS1v15" ||
41 req.algo_name() == "EMSA-PKCS1-v1_5" ||
42 req.algo_name() == "EMSA3")
43 {
44 if(req.arg_count() == 2 && req.arg(0) == "Raw")
45 {
46 return std::make_unique<EMSA_PKCS1v15_Raw>(req.arg(1));
47 }
48 else if(req.arg_count() == 1)
49 {
50 if(req.arg(0) == "Raw")
51 {
52 return std::make_unique<EMSA_PKCS1v15_Raw>();
53 }
54 else
55 {
56 if(auto hash = HashFunction::create(req.arg(0)))
57 {
58 return std::make_unique<EMSA_PKCS1v15>(std::move(hash));
59 }
60 }
61 }
62 }
63#endif
64
65#if defined(BOTAN_HAS_EMSA_PSSR)
66 if(req.algo_name() == "PSS_Raw" ||
67 req.algo_name() == "PSSR_Raw")
68 {
69 if(req.arg_count_between(1, 3) && req.arg(1, "MGF1") == "MGF1")
70 {
71 if(auto hash = HashFunction::create(req.arg(0)))
72 {
73 if(req.arg_count() == 3)
74 {
75 const size_t salt_size = req.arg_as_integer(2, 0);
76 return std::make_unique<PSSR_Raw>(std::move(hash), salt_size);
77 }
78 else
79 {
80 return std::make_unique<PSSR_Raw>(std::move(hash));
81 }
82 }
83 }
84 }
85
86 if(req.algo_name() == "PSS" ||
87 req.algo_name() == "PSSR" ||
88 req.algo_name() == "EMSA-PSS" ||
89 req.algo_name() == "PSS-MGF1" ||
90 req.algo_name() == "EMSA4")
91 {
92 if(req.arg_count_between(1, 3) && req.arg(1, "MGF1") == "MGF1")
93 {
94 if(auto hash = HashFunction::create(req.arg(0)))
95 {
96 if(req.arg_count() == 3)
97 {
98 const size_t salt_size = req.arg_as_integer(2, 0);
99 return std::make_unique<PSSR>(std::move(hash), salt_size);
100 }
101 else
102 {
103 return std::make_unique<PSSR>(std::move(hash));
104 }
105 }
106 }
107 }
108#endif
109
110#if defined(BOTAN_HAS_ISO_9796)
111 if(req.algo_name() == "ISO_9796_DS2")
112 {
113 if(req.arg_count_between(1, 3))
114 {
115 if(auto hash = HashFunction::create(req.arg(0)))
116 {
117 const size_t salt_size = req.arg_as_integer(2, hash->output_length());
118 const bool implicit = req.arg(1, "exp") == "imp";
119 return std::make_unique<ISO_9796_DS2>(std::move(hash), implicit, salt_size);
120 }
121 }
122 }
123 //ISO-9796-2 DS 3 is deterministic and DS2 without a salt
124 if(req.algo_name() == "ISO_9796_DS3")
125 {
126 if(req.arg_count_between(1, 2))
127 {
128 if(auto hash = HashFunction::create(req.arg(0)))
129 {
130 const bool implicit = req.arg(1, "exp") == "imp";
131 return std::make_unique<ISO_9796_DS3>(std::move(hash), implicit);
132 }
133 }
134 }
135#endif
136
137#if defined(BOTAN_HAS_EMSA_X931)
138 if(req.algo_name() == "EMSA_X931" ||
139 req.algo_name() == "EMSA2" ||
140 req.algo_name() == "X9.31")
141 {
142 if(req.arg_count() == 1)
143 {
144 if(auto hash = HashFunction::create(req.arg(0)))
145 {
146 return std::make_unique<EMSA_X931>(std::move(hash));
147 }
148 }
149 }
150#endif
151
152#if defined(BOTAN_HAS_EMSA_RAW)
153 if(req.algo_name() == "Raw")
154 {
155 if(req.arg_count() == 0)
156 {
157 return std::make_unique<EMSA_Raw>();
158 }
159 else
160 {
161 auto hash = HashFunction::create(req.arg(0));
162 if(hash)
163 return std::make_unique<EMSA_Raw>(hash->output_length());
164 }
165 }
166#endif
167
168 return nullptr;
169 }
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
Definition: hash.cpp:102

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), Botan::SCAN_Name::arg_count_between(), and Botan::HashFunction::create().

Referenced by Botan::EMSA::create_or_throw().

◆ create_or_throw()

std::unique_ptr< EMSA > Botan::EMSA::create_or_throw ( std::string_view  algo_spec)
staticinherited

Factory method for EMSA (message-encoding methods for signatures with appendix) objects

Parameters
algo_specthe name of the EMSA to create
Returns
pointer to newly allocated object of that type, or throws

Definition at line 171 of file emsa.cpp.

172 {
173 auto emsa = EMSA::create(algo_spec);
174 if(emsa)
175 return emsa;
176 throw Algorithm_Not_Found(algo_spec);
177 }
static std::unique_ptr< EMSA > create(std::string_view algo_spec)
Definition: emsa.cpp:34

References Botan::EMSA::create().

◆ hash_function()

std::string Botan::ISO_9796_DS3::hash_function ( ) const
inlineoverridevirtual

Return the hash function being used by this padding scheme

Implements Botan::EMSA.

Definition at line 82 of file iso9796.h.

82{ return m_hash->name(); }

◆ name()

std::string Botan::ISO_9796_DS3::name ( ) const
overridevirtual
Returns
the SCAN name of the encoding/padding scheme

Implements Botan::EMSA.

Definition at line 307 of file iso9796.cpp.

308 {
309 return "ISO_9796_DS3(" + m_hash->name() + "," +
310 (m_implicit ? "imp" : "exp") + ")";
311 }

The documentation for this class was generated from the following files: