Botan  2.1.0
Crypto and TLS for C++11
emsa.h
Go to the documentation of this file.
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 <botan/rng.h>
13 
14 namespace Botan {
15 
16 /**
17 * EMSA, from IEEE 1363s Encoding Method for Signatures, Appendix
18 *
19 * Any way of encoding/padding signatures
20 */
21 class BOTAN_DLL EMSA
22  {
23  public:
24  /**
25  * Add more data to the signature computation
26  * @param input some data
27  * @param length length of input in bytes
28  */
29  virtual void update(const uint8_t input[], size_t length) = 0;
30 
31  /**
32  * @return raw hash
33  */
34  virtual secure_vector<uint8_t> raw_data() = 0;
35 
36  /**
37  * Return the encoding of a message
38  * @param msg the result of raw_data()
39  * @param output_bits the desired output bit size
40  * @param rng a random number generator
41  * @return encoded signature
42  */
43  virtual secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
44  size_t output_bits,
45  RandomNumberGenerator& rng) = 0;
46 
47  /**
48  * Verify the encoding
49  * @param coded the received (coded) message representative
50  * @param raw the computed (local, uncoded) message representative
51  * @param key_bits the size of the key in bits
52  * @return true if coded is a valid encoding of raw, otherwise false
53  */
54  virtual bool verify(const secure_vector<uint8_t>& coded,
55  const secure_vector<uint8_t>& raw,
56  size_t key_bits) = 0;
57 
58  virtual ~EMSA() = default;
59 
60  /**
61  * @return a new object representing the same encoding method as *this
62  */
63  virtual EMSA* clone() = 0;
64  };
65 
66 /**
67 * Factory method for EMSA (message-encoding methods for signatures
68 * with appendix) objects
69 * @param algo_spec the name of the EMSA to create
70 * @return pointer to newly allocated object of that type
71 */
72 BOTAN_DLL EMSA* get_emsa(const std::string& algo_spec);
73 
74 /**
75 * Returns the hash function used in the given EMSA scheme
76 * If the hash function is not specified or not understood,
77 * returns "SHA-512"
78 * @param algo_spec the name of the EMSA
79 * @return hash function used in the given EMSA scheme
80 */
81 BOTAN_DLL std::string hash_for_emsa(const std::string& algo_spec);
82 
83 }
84 
85 #endif
std::string hash_for_emsa(const std::string &algo_spec)
Definition: emsa.cpp:142
EMSA * get_emsa(const std::string &algo_spec)
Definition: emsa.cpp:36
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Definition: alg_id.cpp:13