Botan  1.11.15
src/lib/pk_pad/emsa.h
Go to the documentation of this file.
00001 /*
00002 * EMSA Classes
00003 * (C) 1999-2007 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_PUBKEY_EMSA_H__
00009 #define BOTAN_PUBKEY_EMSA_H__
00010 
00011 #include <botan/scan_name.h>
00012 #include <botan/secmem.h>
00013 #include <botan/rng.h>
00014 
00015 namespace Botan {
00016 
00017 /**
00018 * Encoding Method for Signatures, Appendix
00019 */
00020 class BOTAN_DLL EMSA
00021    {
00022    public:
00023       typedef SCAN_Name Spec;
00024 
00025       /**
00026       * Add more data to the signature computation
00027       * @param input some data
00028       * @param length length of input in bytes
00029       */
00030       virtual void update(const byte input[], size_t length) = 0;
00031 
00032       /**
00033       * @return raw hash
00034       */
00035       virtual secure_vector<byte> raw_data() = 0;
00036 
00037       /**
00038       * Return the encoding of a message
00039       * @param msg the result of raw_data()
00040       * @param output_bits the desired output bit size
00041       * @param rng a random number generator
00042       * @return encoded signature
00043       */
00044       virtual secure_vector<byte> encoding_of(const secure_vector<byte>& msg,
00045                                              size_t output_bits,
00046                                              RandomNumberGenerator& rng) = 0;
00047 
00048       /**
00049       * Verify the encoding
00050       * @param coded the received (coded) message representative
00051       * @param raw the computed (local, uncoded) message representative
00052       * @param key_bits the size of the key in bits
00053       * @return true if coded is a valid encoding of raw, otherwise false
00054       */
00055       virtual bool verify(const secure_vector<byte>& coded,
00056                           const secure_vector<byte>& raw,
00057                           size_t key_bits) = 0;
00058       virtual ~EMSA() {}
00059    };
00060 
00061 /**
00062 * Factory method for EMSA (message-encoding methods for signatures
00063 * with appendix) objects
00064 * @param algo_spec the name of the EME to create
00065 * @return pointer to newly allocated object of that type
00066 */
00067 BOTAN_DLL EMSA* get_emsa(const std::string& algo_spec);
00068 
00069 }
00070 
00071 #endif