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 "integer.h" 00010 #include "pssr.h" 00011 00012 NAMESPACE_BEGIN(CryptoPP) 00013 00014 //! . 00015 class RWFunction : virtual public TrapdoorFunction, public PublicKey 00016 { 00017 typedef RWFunction ThisClass; 00018 00019 public: 00020 void Initialize(const Integer &n) 00021 {m_n = n;} 00022 00023 void BERDecode(BufferedTransformation &bt); 00024 void DEREncode(BufferedTransformation &bt) const; 00025 00026 Integer ApplyFunction(const Integer &x) const; 00027 Integer PreimageBound() const {return ++(m_n>>1);} 00028 Integer ImageBound() const {return m_n;} 00029 00030 bool Validate(RandomNumberGenerator &rng, unsigned int level) const; 00031 bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const; 00032 void AssignFrom(const NameValuePairs &source); 00033 00034 const Integer& GetModulus() const {return m_n;} 00035 void SetModulus(const Integer &n) {m_n = n;} 00036 00037 protected: 00038 Integer m_n; 00039 }; 00040 00041 //! . 00042 class InvertibleRWFunction : public RWFunction, public TrapdoorFunctionInverse, public PrivateKey 00043 { 00044 typedef InvertibleRWFunction ThisClass; 00045 00046 public: 00047 void Initialize(const Integer &n, const Integer &p, const Integer &q, const Integer &u) 00048 {m_n = n; m_p = p; m_q = q; m_u = u;} 00049 // generate a random private key 00050 void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits) 00051 {GenerateRandomWithKeySize(rng, modulusBits);} 00052 00053 void BERDecode(BufferedTransformation &bt); 00054 void DEREncode(BufferedTransformation &bt) const; 00055 00056 Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const; 00057 00058 // GeneratibleCryptoMaterial 00059 bool Validate(RandomNumberGenerator &rng, unsigned int level) const; 00060 bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const; 00061 void AssignFrom(const NameValuePairs &source); 00062 /*! parameters: (ModulusSize) */ 00063 void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg); 00064 00065 const Integer& GetPrime1() const {return m_p;} 00066 const Integer& GetPrime2() const {return m_q;} 00067 const Integer& GetMultiplicativeInverseOfPrime2ModPrime1() const {return m_u;} 00068 00069 void SetPrime1(const Integer &p) {m_p = p;} 00070 void SetPrime2(const Integer &q) {m_q = q;} 00071 void SetMultiplicativeInverseOfPrime2ModPrime1(const Integer &u) {m_u = u;} 00072 00073 protected: 00074 Integer m_p, m_q, m_u; 00075 }; 00076 00077 //! . 00078 class EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod> 00079 { 00080 public: 00081 static const char *StaticAlgorithmName() {return "EMSA2";} 00082 00083 unsigned int MaxUnpaddedLength(unsigned int paddedLength) const {return (paddedLength+1)/8-2;} 00084 00085 void ComputeMessageRepresentative(RandomNumberGenerator &rng, 00086 const byte *recoverableMessage, unsigned int recoverableMessageLength, 00087 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, 00088 byte *representative, unsigned int representativeBitLength) const; 00089 }; 00090 00091 //! EMSA2, for use with RW 00092 /*! The following hash functions are supported: SHA, RIPEMD160. */ 00093 struct P1363_EMSA2 : public SignatureStandard 00094 { 00095 typedef EMSA2Pad SignatureMessageEncodingMethod; 00096 }; 00097 00098 //! . 00099 struct RW 00100 { 00101 static std::string StaticAlgorithmName() {return "RW";} 00102 typedef RWFunction PublicKey; 00103 typedef InvertibleRWFunction PrivateKey; 00104 }; 00105 00106 //! RWSS 00107 template <class STANDARD, class H> 00108 struct RWSS : public TF_SS<STANDARD, H, RW> 00109 { 00110 }; 00111 00112 NAMESPACE_END 00113 00114 #endif

Generated on Fri Aug 13 09:56:55 2004 for Crypto++ by doxygen 1.3.7