/src/Botan-3.4.0/build/include/internal/botan/internal/emsa.h
Line | Count | Source |
1 | | /* |
2 | | * EMSA Classes |
3 | | * (C) 1999-2007 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_PUBKEY_EMSA_H_ |
9 | | #define BOTAN_PUBKEY_EMSA_H_ |
10 | | |
11 | | #include <botan/secmem.h> |
12 | | #include <string> |
13 | | |
14 | | namespace Botan { |
15 | | |
16 | | class RandomNumberGenerator; |
17 | | |
18 | | /** |
19 | | * EMSA, from IEEE 1363s Encoding Method for Signatures, Appendix |
20 | | * |
21 | | * Any way of encoding/padding signatures |
22 | | */ |
23 | | class BOTAN_TEST_API EMSA { |
24 | | public: |
25 | 54.1k | virtual ~EMSA() = default; |
26 | | |
27 | | /** |
28 | | * Factory method for EMSA (message-encoding methods for signatures |
29 | | * with appendix) objects |
30 | | * @param algo_spec the name of the EMSA to create |
31 | | * @return pointer to newly allocated object of that type, or nullptr |
32 | | */ |
33 | | static std::unique_ptr<EMSA> create(std::string_view algo_spec); |
34 | | |
35 | | /** |
36 | | * Factory method for EMSA (message-encoding methods for signatures |
37 | | * with appendix) objects |
38 | | * @param algo_spec the name of the EMSA to create |
39 | | * @return pointer to newly allocated object of that type, or throws |
40 | | */ |
41 | | static std::unique_ptr<EMSA> create_or_throw(std::string_view algo_spec); |
42 | | |
43 | | /** |
44 | | * Add more data to the signature computation |
45 | | * @param input some data |
46 | | * @param length length of input in bytes |
47 | | */ |
48 | | virtual void update(const uint8_t input[], size_t length) = 0; |
49 | | |
50 | | /** |
51 | | * @return raw hash |
52 | | */ |
53 | | virtual std::vector<uint8_t> raw_data() = 0; |
54 | | |
55 | | /** |
56 | | * Return the encoding of a message |
57 | | * @param msg the result of raw_data() |
58 | | * @param output_bits the desired output bit size |
59 | | * @param rng a random number generator |
60 | | * @return encoded signature |
61 | | */ |
62 | | virtual std::vector<uint8_t> encoding_of(const std::vector<uint8_t>& msg, |
63 | | size_t output_bits, |
64 | | RandomNumberGenerator& rng) = 0; |
65 | | |
66 | | /** |
67 | | * Verify the encoding |
68 | | * @param coded the received (coded) message representative |
69 | | * @param raw the computed (local, uncoded) message representative |
70 | | * @param key_bits the size of the key in bits |
71 | | * @return true if coded is a valid encoding of raw, otherwise false |
72 | | */ |
73 | | virtual bool verify(const std::vector<uint8_t>& coded, const std::vector<uint8_t>& raw, size_t key_bits) = 0; |
74 | | |
75 | | /** |
76 | | * Return the hash function being used by this padding scheme |
77 | | */ |
78 | | virtual std::string hash_function() const = 0; |
79 | | |
80 | | /** |
81 | | * @return the SCAN name of the encoding/padding scheme |
82 | | */ |
83 | | virtual std::string name() const = 0; |
84 | | }; |
85 | | |
86 | | } // namespace Botan |
87 | | |
88 | | #endif |