Botan  1.11.15
src/lib/pubkey/blinding.h
Go to the documentation of this file.
00001 /*
00002 * Blinding for public key operations
00003 * (C) 1999-2010 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_BLINDER_H__
00009 #define BOTAN_BLINDER_H__
00010 
00011 #include <botan/bigint.h>
00012 #include <botan/reducer.h>
00013 #include <functional>
00014 
00015 namespace Botan {
00016 
00017 /**
00018 * Blinding Function Object
00019 */
00020 class BOTAN_DLL Blinder
00021    {
00022    public:
00023       BigInt blind(const BigInt& x) const;
00024 
00025       BigInt unblind(const BigInt& x) const;
00026 
00027       bool initialized() const { return m_reducer.initialized(); }
00028 
00029       Blinder() {}
00030 
00031       Blinder(const BigInt& modulus,
00032               std::function<BigInt (const BigInt&)> fwd_func,
00033               std::function<BigInt (const BigInt&)> inv_func);
00034 
00035    private:
00036       Modular_Reducer m_reducer;
00037       mutable BigInt m_e, m_d;
00038    };
00039 
00040 }
00041 
00042 #endif