Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

# rw.h

Go to the documentation of this file.

    00001 #ifndef CRYPTOPP_RW_H
    00002 #define CRYPTOPP_RW_H
    00003
    00004 /** \file
    00005         This file contains classes that implement the
    00006         Rabin-Williams signature schemes as defined in IEEE P1363.
    00007 */
    00008
    00009 #include "pubkey.h"
    00010
    00011 NAMESPACE_BEGIN(CryptoPP)
    00012
    00013 //! _
    00014 class CRYPTOPP_DLL RWFunction : virtual public TrapdoorFunction, public PublicKey
    00015 {
    00016         typedef RWFunction ThisClass;
    00017
    00018 public:
    00019         void Initialize(const Integer &n)
    00020                 {m_n = n;}
    00021
    00022         void BERDecode(BufferedTransformation &bt);
    00023         void DEREncode(BufferedTransformation &bt) const;
    00024
    00025         Integer ApplyFunction(const Integer &x) const;
    00026         Integer PreimageBound() const {return ++(m_n>>1);}
    00027         Integer ImageBound() const {return m_n;}
    00028
    00029         bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
    00030         bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
    00031         void AssignFrom(const NameValuePairs &source);
    00032
    00033         const Integer& GetModulus() const {return m_n;}
    00034         void SetModulus(const Integer &n) {m_n = n;}
    00035
    00036 protected:
    00037         Integer m_n;
    00038 };
    00039
    00040 //! _
    00041 class CRYPTOPP_DLL InvertibleRWFunction : public RWFunction, public TrapdoorFunctionInverse, public PrivateKey
    00042 {
    00043         typedef InvertibleRWFunction ThisClass;
    00044
    00045 public:
    00046         void Initialize(const Integer &n, const Integer &p, const Integer &q, const Integer &u)
    00047                 {m_n = n; m_p = p; m_q = q; m_u = u;}
    00048         // generate a random private key
    00049         void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits)
    00050                 {GenerateRandomWithKeySize(rng, modulusBits);}
    00051
    00052         void BERDecode(BufferedTransformation &bt);
    00053         void DEREncode(BufferedTransformation &bt) const;
    00054
    00055         Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const;
    00056
    00057         // GeneratibleCryptoMaterial
    00058         bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
    00059         bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
    00060         void AssignFrom(const NameValuePairs &source);
    00061         /*! parameters: (ModulusSize) */
    00062         void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg);
    00063
    00064         const Integer& GetPrime1() const {return m_p;}
    00065         const Integer& GetPrime2() const {return m_q;}
    00066         const Integer& GetMultiplicativeInverseOfPrime2ModPrime1() const {return m_u;}
    00067
    00068         void SetPrime1(const Integer &p) {m_p = p;}
    00069         void SetPrime2(const Integer &q) {m_q = q;}
    00070         void SetMultiplicativeInverseOfPrime2ModPrime1(const Integer &u) {m_u = u;}
    00071
    00072 protected:
    00073         Integer m_p, m_q, m_u;
    00074 };
    00075
    00076 //! RW
    00077 struct RW
    00078 {
    00079         static std::string StaticAlgorithmName() {return "RW";}
    00080         typedef RWFunction PublicKey;
    00081         typedef InvertibleRWFunction PrivateKey;
    00082 };
    00083
    00084 //! RWSS
    00085 template <class STANDARD, class H>
    00086 struct RWSS : public TF_SS<STANDARD, H, RW>
    00087 {
    00088 };
    00089
    00090 NAMESPACE_END
    00091
    00092 #endif