/src/botan/build/include/botan/internal/iso9796.h
Line | Count | Source (jump to first uncovered line) |
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/internal/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 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 | 0 | 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 | 0 | m_SALT_SIZE(salt_size) {} |
36 | | |
37 | | EMSA* clone() override; |
38 | | |
39 | | std::string name() const override; |
40 | | private: |
41 | | void update(const uint8_t input[], size_t length) override; |
42 | | |
43 | | secure_vector<uint8_t> raw_data() override; |
44 | | |
45 | | secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg, |
46 | | size_t output_bits, |
47 | | RandomNumberGenerator& rng) override; |
48 | | |
49 | | bool verify(const secure_vector<uint8_t>& coded, |
50 | | const secure_vector<uint8_t>& raw, |
51 | | size_t key_bits) override; |
52 | | |
53 | | std::unique_ptr<HashFunction> m_hash; |
54 | | bool m_implicit; |
55 | | size_t m_SALT_SIZE; |
56 | | secure_vector<uint8_t> m_msg_buffer; |
57 | | }; |
58 | | |
59 | | /** |
60 | | * ISO-9796-2 - Digital signature scheme 3 (deterministic) |
61 | | */ |
62 | | class ISO_9796_DS3 final : public EMSA |
63 | | { |
64 | | public: |
65 | | /** |
66 | | * @param hash function to use |
67 | | * @param implicit whether or not the trailer is implicit |
68 | | */ |
69 | | ISO_9796_DS3(HashFunction* hash, bool implicit = false) : m_hash(hash), m_implicit(implicit) |
70 | 0 | {} |
71 | | |
72 | | EMSA* clone() override; |
73 | | |
74 | | std::string name() const override; |
75 | | private: |
76 | | void update(const uint8_t input[], size_t length) override; |
77 | | |
78 | | secure_vector<uint8_t> raw_data() override; |
79 | | |
80 | | secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg, |
81 | | size_t output_bits, |
82 | | RandomNumberGenerator& rng) override; |
83 | | |
84 | | bool verify(const secure_vector<uint8_t>& coded, |
85 | | const secure_vector<uint8_t>& raw, |
86 | | size_t key_bits) override; |
87 | | |
88 | | std::unique_ptr<HashFunction> m_hash; |
89 | | bool m_implicit; |
90 | | secure_vector<uint8_t> m_msg_buffer; |
91 | | }; |
92 | | |
93 | | } |
94 | | |
95 | | #endif |
96 | | |