Botan 3.9.0
Crypto and TLS for C&
pkcs1_sig_padding.h
Go to the documentation of this file.
1/*
2* PKCS #1 v1.5 signature padding
3* (C) 1999-2008 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_PKCS1V15_SIGNATURE_PADDING_H_
9#define BOTAN_PKCS1V15_SIGNATURE_PADDING_H_
10
11#include <botan/internal/sig_padding.h>
12
13#include <memory>
14#include <string>
15#include <string_view>
16#include <vector>
17
18namespace Botan {
19
20class HashFunction;
21
22/**
23* PKCS #1 v1.5 signature padding
24* aka PKCS #1 block type 1
25* aka EMSA3 from IEEE 1363
26*/
28 public:
29 /**
30 * @param hash the hash function to use
31 */
32 explicit PKCS1v15_SignaturePaddingScheme(std::unique_ptr<HashFunction> hash);
33
34 void update(const uint8_t input[], size_t length) override;
35
36 std::vector<uint8_t> raw_data() override;
37
38 std::vector<uint8_t> encoding_of(std::span<const uint8_t> msg,
39 size_t output_bits,
40 RandomNumberGenerator& rng) override;
41
42 bool verify(std::span<const uint8_t> coded, std::span<const uint8_t> raw, size_t key_bits) override;
43
44 std::string name() const override;
45
46 std::string hash_function() const override;
47
48 private:
49 std::unique_ptr<HashFunction> m_hash;
50 std::vector<uint8_t> m_hash_id;
51};
52
53/**
54* PKCS1v15_SignaturePaddingScheme_Raw which is PKCS1v15_SignaturePaddingScheme without a hash or digest id
55* (which according to QCA docs is "identical to PKCS#11's CKM_RSA_PKCS
56* mechanism", something I have not confirmed)
57*/
59 public:
60 void update(const uint8_t input[], size_t length) override;
61
62 std::vector<uint8_t> raw_data() override;
63
64 std::vector<uint8_t> encoding_of(std::span<const uint8_t> msg,
65 size_t output_bits,
66 RandomNumberGenerator& rng) override;
67
68 bool verify(std::span<const uint8_t> coded, std::span<const uint8_t> raw, size_t key_bits) override;
69
71
72 /**
73 * @param hash_algo the digest id for that hash is included in
74 * the signature.
75 */
76 explicit PKCS1v15_Raw_SignaturePaddingScheme(std::string_view hash_algo);
77
78 std::string hash_function() const override { return m_hash_name; }
79
80 std::string name() const override;
81
82 private:
83 size_t m_hash_output_len = 0;
84 std::string m_hash_name;
85 std::vector<uint8_t> m_hash_id;
86 std::vector<uint8_t> m_message;
87};
88
89} // namespace Botan
90
91#endif
std::vector< uint8_t > encoding_of(std::span< const uint8_t > msg, size_t output_bits, RandomNumberGenerator &rng) override
std::vector< uint8_t > raw_data() override
std::string hash_function() const override
void update(const uint8_t input[], size_t length) override
bool verify(std::span< const uint8_t > coded, std::span< const uint8_t > raw, size_t key_bits) override
PKCS1v15_SignaturePaddingScheme(std::unique_ptr< HashFunction > hash)
void update(const uint8_t input[], size_t length) override
std::vector< uint8_t > encoding_of(std::span< const uint8_t > msg, size_t output_bits, RandomNumberGenerator &rng) override
std::vector< uint8_t > raw_data() override
bool verify(std::span< const uint8_t > coded, std::span< const uint8_t > raw, size_t key_bits) override
std::string hash_function() const override