3
* (C) 1999-2007 Jack Lloyd
5
* Botan is released under the Simplified BSD License (see license.txt)
8
#ifndef BOTAN_PUBKEY_EMSA_H_
9
#define BOTAN_PUBKEY_EMSA_H_
11
#include <botan/secmem.h>
12
#include <botan/alg_id.h>
17
class RandomNumberGenerator;
20
* EMSA, from IEEE 1363s Encoding Method for Signatures, Appendix
22
* Any way of encoding/padding signatures
24
class BOTAN_PUBLIC_API(2,0) EMSA
27
virtual ~EMSA() = default;
30
* Add more data to the signature computation
31
* @param input some data
32
* @param length length of input in bytes
34
virtual void update(const uint8_t input[], size_t length) = 0;
39
virtual secure_vector<uint8_t> raw_data() = 0;
42
* Return the encoding of a message
43
* @param msg the result of raw_data()
44
* @param output_bits the desired output bit size
45
* @param rng a random number generator
46
* @return encoded signature
48
virtual secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
50
RandomNumberGenerator& rng) = 0;
54
* @param coded the received (coded) message representative
55
* @param raw the computed (local, uncoded) message representative
56
* @param key_bits the size of the key in bits
57
* @return true if coded is a valid encoding of raw, otherwise false
59
virtual bool verify(const secure_vector<uint8_t>& coded,
60
const secure_vector<uint8_t>& raw,
64
* Prepare sig_algo for use in choose_sig_format for x509 certs
66
* @param key used for checking compatibility with the encoding scheme
67
* @param cert_hash_name is checked to equal the hash for the encoding
68
* @return algorithm identifier to signatures created using this key,
69
* padding method and hash.
71
virtual AlgorithmIdentifier config_for_x509(const Private_Key& key,
72
const std::string& cert_hash_name) const;
75
* @return a new object representing the same encoding method as *this
77
virtual EMSA* clone() = 0;
80
* @return the SCAN name of the encoding/padding scheme
82
virtual std::string name() const = 0;
86
* Factory method for EMSA (message-encoding methods for signatures
87
* with appendix) objects
88
* @param algo_spec the name of the EMSA to create
89
* @return pointer to newly allocated object of that type
91
BOTAN_PUBLIC_API(2,0) EMSA* get_emsa(const std::string& algo_spec);
94
* Returns the hash function used in the given EMSA scheme
95
* If the hash function is not specified or not understood,
97
* @param algo_spec the name of the EMSA
98
* @return hash function used in the given EMSA scheme
100
BOTAN_PUBLIC_API(2,0) std::string hash_for_emsa(const std::string& algo_spec);