Botan  2.1.0
Crypto and TLS for C++11
emsa_pkcs1.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_EMSA_PKCS1_H__
9 #define BOTAN_EMSA_PKCS1_H__
10 
11 #include <botan/emsa.h>
12 #include <botan/hash.h>
13 
14 namespace Botan {
15 
16 /**
17 * PKCS #1 v1.5 signature padding
18 * aka PKCS #1 block type 1
19 * aka EMSA3 from IEEE 1363
20 */
21 class BOTAN_DLL EMSA_PKCS1v15 final : public EMSA
22  {
23  public:
24  /**
25  * @param hash the hash function to use
26  */
27  explicit EMSA_PKCS1v15(HashFunction* hash);
28 
29  EMSA* clone() override { return new EMSA_PKCS1v15(m_hash->clone()); }
30 
31  void update(const uint8_t[], size_t) override;
32 
33  secure_vector<uint8_t> raw_data() override;
34 
35  secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
36  RandomNumberGenerator& rng) override;
37 
38  bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
39  size_t) override;
40  private:
41  std::unique_ptr<HashFunction> m_hash;
42  std::vector<uint8_t> m_hash_id;
43  };
44 
45 /**
46 * EMSA_PKCS1v15_Raw which is EMSA_PKCS1v15 without a hash or digest id
47 * (which according to QCA docs is "identical to PKCS#11's CKM_RSA_PKCS
48 * mechanism", something I have not confirmed)
49 */
50 class BOTAN_DLL EMSA_PKCS1v15_Raw final : public EMSA
51  {
52  public:
53  EMSA* clone() override { return new EMSA_PKCS1v15_Raw(); }
54 
55  void update(const uint8_t[], size_t) override;
56 
57  secure_vector<uint8_t> raw_data() override;
58 
59  secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>&, size_t,
60  RandomNumberGenerator& rng) override;
61 
62  bool verify(const secure_vector<uint8_t>&, const secure_vector<uint8_t>&,
63  size_t) override;
64 
65  private:
66  secure_vector<uint8_t> m_message;
67  };
68 
69 }
70 
71 #endif
EMSA * clone() override
Definition: emsa_pkcs1.h:53
EMSA * clone() override
Definition: emsa_pkcs1.h:29
std::vector< uint8_t > m_hash_id
Definition: tpm.cpp:440
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Definition: alg_id.cpp:13
std::unique_ptr< HashFunction > m_hash
Definition: tpm.cpp:439
MechanismType hash