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