Botan 3.14.1
Crypto and TLS for C&
sig_padding.h
Go to the documentation of this file.
1/*
2* (C) 1999-2007 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_SIGNATURE_PADDING_SCHEME_H_
8#define BOTAN_SIGNATURE_PADDING_SCHEME_H_
9
10#include <botan/types.h>
11#include <memory>
12#include <span>
13#include <string>
14#include <vector>
15
16namespace Botan {
17
20
21/**
22* RSA Signature Padding Scheme
23*
24* Previously called 'EMSA' from IEEE 1363's "Encoding Method for Signatures, Appendix"
25*/
26class BOTAN_TEST_API SignaturePaddingScheme /* NOLINT(*-special-member-functions) */ {
27 public:
28 virtual ~SignaturePaddingScheme() = default;
29
30 /**
31 * Factory method for SignaturePaddingScheme objects
32 *
33 * @param options the algorithm parameters
34 * @return pointer to newly allocated object of that type, or throws
35 */
36 static std::unique_ptr<SignaturePaddingScheme> create_or_throw(const PK_Signature_Options_Reader& options);
37
38 /**
39 * Add more data to the signature computation
40 * @param input some data
41 * @param length length of input in bytes
42 */
43 virtual void update(const uint8_t input[], size_t length) = 0;
44
45 /**
46 * @return raw hash
47 */
48 virtual std::vector<uint8_t> raw_data() = 0;
49
50 /**
51 * Return the encoding of a message
52 * @param msg the result of raw_data()
53 * @param output_bits the desired output bit size
54 * @param rng a random number generator
55 * @return encoded signature
56 */
57 virtual std::vector<uint8_t> encoding_of(std::span<const uint8_t> msg,
58 size_t output_bits,
59 RandomNumberGenerator& rng) = 0;
60
61 /**
62 * Verify the encoding
63 * @param encoding the received (coded) message representative
64 * @param raw_hash the computed (local, uncoded) message representative
65 * @param key_bits the size of the key in bits
66 * @return true if coded is a valid encoding of raw, otherwise false
67 */
68 virtual bool verify(std::span<const uint8_t> encoding, std::span<const uint8_t> raw_hash, size_t key_bits) = 0;
69
70 /**
71 * Return the hash function being used by this padding scheme
72 */
73 virtual std::string hash_function() const = 0;
74
75 /**
76 * @return the SCAN name of the encoding/padding scheme
77 */
78 virtual std::string name() const = 0;
79};
80
81} // namespace Botan
82
83#endif
#define BOTAN_TEST_API
Definition api.h:41
virtual std::string hash_function() const =0
static std::unique_ptr< SignaturePaddingScheme > create_or_throw(const PK_Signature_Options_Reader &options)
virtual std::vector< uint8_t > encoding_of(std::span< const uint8_t > msg, size_t output_bits, RandomNumberGenerator &rng)=0
virtual std::vector< uint8_t > raw_data()=0
virtual ~SignaturePaddingScheme()=default
virtual std::string name() const =0
virtual void update(const uint8_t input[], size_t length)=0
virtual bool verify(std::span< const uint8_t > encoding, std::span< const uint8_t > raw_hash, size_t key_bits)=0