Botan 3.8.1
Crypto and TLS for C&
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/types.h>
12#include <memory>
13#include <span>
14#include <string>
15#include <vector>
16
17namespace Botan {
18
20
21/**
22* EMSA, from IEEE 1363s Encoding Method for Signatures, Appendix
23*
24* Any way of encoding/padding signatures
25*/
27 public:
28 virtual ~EMSA() = default;
29
30 /**
31 * Factory method for EMSA (message-encoding methods for signatures
32 * with appendix) objects
33 * @param algo_spec the name of the EMSA to create
34 * @return pointer to newly allocated object of that type, or nullptr
35 */
36 static std::unique_ptr<EMSA> create(std::string_view algo_spec);
37
38 /**
39 * Factory method for EMSA (message-encoding methods for signatures
40 * with appendix) objects
41 * @param algo_spec the name of the EMSA to create
42 * @return pointer to newly allocated object of that type, or throws
43 */
44 static std::unique_ptr<EMSA> create_or_throw(std::string_view algo_spec);
45
46 /**
47 * Add more data to the signature computation
48 * @param input some data
49 * @param length length of input in bytes
50 */
51 virtual void update(const uint8_t input[], size_t length) = 0;
52
53 /**
54 * @return raw hash
55 */
56 virtual std::vector<uint8_t> raw_data() = 0;
57
58 /**
59 * Return the encoding of a message
60 * @param msg the result of raw_data()
61 * @param output_bits the desired output bit size
62 * @param rng a random number generator
63 * @return encoded signature
64 */
65 virtual std::vector<uint8_t> encoding_of(std::span<const uint8_t> msg,
66 size_t output_bits,
67 RandomNumberGenerator& rng) = 0;
68
69 /**
70 * Verify the encoding
71 * @param encoding the received (coded) message representative
72 * @param raw_hash the computed (local, uncoded) message representative
73 * @param key_bits the size of the key in bits
74 * @return true if coded is a valid encoding of raw, otherwise false
75 */
76 virtual bool verify(std::span<const uint8_t> encoding, std::span<const uint8_t> raw_hash, size_t key_bits) = 0;
77
78 /**
79 * Return the hash function being used by this padding scheme
80 */
81 virtual std::string hash_function() const = 0;
82
83 /**
84 * @return the SCAN name of the encoding/padding scheme
85 */
86 virtual std::string name() const = 0;
87};
88
89} // namespace Botan
90
91#endif
#define BOTAN_TEST_API
Definition api.h:39
static std::unique_ptr< EMSA > create_or_throw(std::string_view algo_spec)
Definition emsa.cpp:135
virtual bool verify(std::span< const uint8_t > encoding, std::span< const uint8_t > raw_hash, size_t key_bits)=0
static std::unique_ptr< EMSA > create(std::string_view algo_spec)
Definition emsa.cpp:35
virtual std::vector< uint8_t > encoding_of(std::span< const uint8_t > msg, size_t output_bits, RandomNumberGenerator &rng)=0
virtual ~EMSA()=default
virtual std::string hash_function() const =0
virtual std::string name() const =0
virtual std::vector< uint8_t > raw_data()=0
virtual void update(const uint8_t input[], size_t length)=0