Botan  1.11.15
src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h
Go to the documentation of this file.
00001 /*
00002 * PKCS #1 v1.5 signature padding
00003 * (C) 1999-2008 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_EMSA_PKCS1_H__
00009 #define BOTAN_EMSA_PKCS1_H__
00010 
00011 #include <botan/emsa.h>
00012 #include <botan/hash.h>
00013 
00014 namespace Botan {
00015 
00016 /**
00017 * PKCS #1 v1.5 signature padding
00018 * aka PKCS #1 block type 1
00019 * aka EMSA3 from IEEE 1363
00020 */
00021 class BOTAN_DLL EMSA_PKCS1v15 : public EMSA
00022    {
00023    public:
00024       /**
00025       * @param hash the hash object to use
00026       */
00027       EMSA_PKCS1v15(HashFunction* hash);
00028 
00029       void update(const byte[], size_t);
00030 
00031       secure_vector<byte> raw_data();
00032 
00033       secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
00034                                      RandomNumberGenerator& rng);
00035 
00036       bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
00037                   size_t);
00038    private:
00039       std::unique_ptr<HashFunction> m_hash;
00040       std::vector<byte> m_hash_id;
00041    };
00042 
00043 /**
00044 * EMSA_PKCS1v15_Raw which is EMSA_PKCS1v15 without a hash or digest id
00045 * (which according to QCA docs is "identical to PKCS#11's CKM_RSA_PKCS
00046 * mechanism", something I have not confirmed)
00047 */
00048 class BOTAN_DLL EMSA_PKCS1v15_Raw : public EMSA
00049    {
00050    public:
00051       void update(const byte[], size_t);
00052 
00053       secure_vector<byte> raw_data();
00054 
00055       secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t,
00056                                      RandomNumberGenerator& rng);
00057 
00058       bool verify(const secure_vector<byte>&, const secure_vector<byte>&,
00059                   size_t);
00060 
00061    private:
00062       secure_vector<byte> message;
00063    };
00064 
00065 }
00066 
00067 #endif