Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

iso9796.h
Go to the documentation of this file.
1 /*
2 * ISO-9796-2 - Digital signature schemes giving message recovery schemes 2 and 3
3 * (C) 2016 Tobias Niemann, Hackmanit GmbH
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_ISO9796_H__
9 #define BOTAN_ISO9796_H__
10
11 #include <botan/emsa.h>
12 #include <botan/hash.h>
13
14 namespace Botan {
15
16 /**
17 * ISO-9796-2 - Digital signature scheme 2 (probabilistic)
18 */
19 class BOTAN_DLL ISO_9796_DS2 final : public EMSA
20 {
21 public:
22 /**
23 * @param hash function to use
24 * @param implicit whether or not the trailer is implicit
25 */
26 explicit ISO_9796_DS2(HashFunction* hash, bool implicit = false) : m_hash(hash), m_implicit(implicit),
27 m_SALT_SIZE(hash->output_length()) {}
28
29 /**
30 * @param hash function to use
31 * @param implicit whether or not the trailer is implicit
32 * @param salt_size size of the salt to use in bytes
33 */
34 ISO_9796_DS2(HashFunction* hash, bool implicit, size_t salt_size) : m_hash(hash), m_implicit(implicit),
35 m_SALT_SIZE(salt_size) {}
36
37 EMSA* clone() override
38 {return new ISO_9796_DS2(m_hash->clone(), m_implicit, m_SALT_SIZE);}
39 private:
40 void update(const uint8_t input[], size_t length) override;
41
42 secure_vector<uint8_t> raw_data() override;
43
44 secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
45 size_t output_bits,
46 RandomNumberGenerator& rng) override;
47
48 bool verify(const secure_vector<uint8_t>& coded,
49 const secure_vector<uint8_t>& raw,
50 size_t key_bits) override;
51
52 std::unique_ptr<HashFunction> m_hash;
53 bool m_implicit;
54 size_t m_SALT_SIZE;
55 secure_vector<uint8_t> m_msg_buffer;
56 };
57
58 /**
59 * ISO-9796-2 - Digital signature scheme 3 (deterministic)
60 */
61 class BOTAN_DLL ISO_9796_DS3 final : public EMSA
62 {
63 public:
64 /**
65 * @param hash function to use
66 * @param implicit whether or not the trailer is implicit
67 */
68 ISO_9796_DS3(HashFunction* hash, bool implicit = false) : m_hash(hash), m_implicit(implicit)
69 {}
70
71 EMSA* clone() override
72 {return new ISO_9796_DS3(m_hash->clone(), m_implicit);}
73 private:
74 void update(const uint8_t input[], size_t length) override;
75
76 secure_vector<uint8_t> raw_data() override;
77
78 secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
79 size_t output_bits,
80 RandomNumberGenerator& rng) override;
81
82 bool verify(const secure_vector<uint8_t>& coded,
83 const secure_vector<uint8_t>& raw,
84 size_t key_bits) override;
85
86 std::unique_ptr<HashFunction> m_hash;
87 bool m_implicit;
88 secure_vector<uint8_t> m_msg_buffer;
89 };
90
91 }
92
93 #endif
94
Botan::RandomNumberGenerator
Definition: rng.h:25
salt_size
size_t salt_size
Definition: p11_mechanism.cpp:69
Botan::ISO_9796_DS3::clone
EMSA * clone() override
Definition: iso9796.h:71
Botan::ISO_9796_DS3
Definition: iso9796.h:61
Botan::ISO_9796_DS2
Definition: iso9796.h:19
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::ISO_9796_DS3::ISO_9796_DS3
ISO_9796_DS3(HashFunction *hash, bool implicit=false)
Definition: iso9796.h:68
Botan::EMSA
Definition: emsa.h:21
Botan
Definition: alg_id.cpp:13
Botan::ISO_9796_DS2::clone
EMSA * clone() override
Definition: iso9796.h:37
Botan::HashFunction
Definition: hash.h:19
Botan::ISO_9796_DS2::ISO_9796_DS2
ISO_9796_DS2(HashFunction *hash, bool implicit=false)
Definition: iso9796.h:26
m_hash
std::unique_ptr< HashFunction > m_hash
Definition: tpm.cpp:439
hash
MechanismType hash
Definition: p11_mechanism.cpp:63
Botan::ISO_9796_DS2::ISO_9796_DS2
ISO_9796_DS2(HashFunction *hash, bool implicit, size_t salt_size)
Definition: iso9796.h:34