From d23a489940499bd6c634a1cb0a9875f094f8a850 Mon Sep 17 00:00:00 2001 From: weidai Date: Thu, 20 Mar 2003 01:24:12 +0000 Subject: various changes for 5.1 git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@38 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- rw.h | 76 +++++++++++++------------------------------------------------------- 1 file changed, 14 insertions(+), 62 deletions(-) (limited to 'rw.h') diff --git a/rw.h b/rw.h index 2dbfce5..76031f0 100644 --- a/rw.h +++ b/rw.h @@ -6,16 +6,12 @@ Rabin-Williams signature schemes as defined in IEEE P1363. */ -#include "pubkey.h" #include "integer.h" +#include "pssr.h" NAMESPACE_BEGIN(CryptoPP) -const word IFSSR_R = 6; -const word IFSSA_R = 12; - //! . -template class RWFunction : virtual public TrapdoorFunction, public PublicKey { typedef RWFunction ThisClass; @@ -43,8 +39,7 @@ protected: }; //! . -template -class InvertibleRWFunction : public RWFunction, public TrapdoorFunctionInverse, public PrivateKey +class InvertibleRWFunction : public RWFunction, public TrapdoorFunctionInverse, public PrivateKey { typedef InvertibleRWFunction ThisClass; @@ -58,7 +53,7 @@ public: void BERDecode(BufferedTransformation &bt); void DEREncode(BufferedTransformation &bt) const; - Integer CalculateInverse(const Integer &x) const; + Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const; // GeneratibleCryptoMaterial bool Validate(RandomNumberGenerator &rng, unsigned int level) const; @@ -80,80 +75,37 @@ protected: }; //! . -class EMSA2Pad : public PK_PaddingAlgorithm +class EMSA2Pad : public EMSA2HashIdLookup { public: static const char *StaticAlgorithmName() {return "EMSA2";} unsigned int MaxUnpaddedLength(unsigned int paddedLength) const {return (paddedLength+1)/8-2;} - void Pad(RandomNumberGenerator &rng, const byte *raw, unsigned int inputLength, byte *padded, unsigned int paddedLength) const; - DecodingResult Unpad(const byte *padded, unsigned int paddedLength, byte *raw) const; -}; - -//! . -template -class EMSA2DecoratedHashModule : public HashTransformationWithDefaultTruncation -{ -public: - EMSA2DecoratedHashModule() : empty(true) {} - void Update(const byte *input, unsigned int length) - {h.Update(input, length); empty = empty && length==0;} - unsigned int DigestSize() const; - void Final(byte *digest); - void Restart() {h.Restart(); empty=true;} - -private: - H h; - bool empty; -}; - -template struct EMSA2DigestDecoration -{ - static const byte decoration; + void ComputeMessageRepresentative(RandomNumberGenerator &rng, + const byte *recoverableMessage, unsigned int recoverableMessageLength, + HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, + byte *representative, unsigned int representativeBitLength) const; }; //! EMSA2, for use with RW /*! The following hash functions are supported: SHA, RIPEMD160. */ struct P1363_EMSA2 : public SignatureStandard { - template struct SignaturePaddingAlgorithm {typedef EMSA2Pad type;}; - template struct DecoratedHashingAlgorithm {typedef EMSA2DecoratedHashModule type;}; + typedef EMSA2Pad SignatureMessageEncodingMethod; }; -template<> struct CryptoStandardTraits : public P1363_EMSA2 {}; - -// EMSA2DecoratedHashModule can be instantiated with the following two classes. -class SHA; -class RIPEMD160; - -template -void EMSA2DecoratedHashModule::Final(byte *digest) -{ - digest[0] = empty ? 0x4b : 0x6b; - h.Final(digest+1); - digest[DigestSize()-1] = EMSA2DigestDecoration::decoration; - empty=true; -} - -template -unsigned int EMSA2DecoratedHashModule::DigestSize() const -{ - return h.DigestSize() + 2; -} - //! . -template struct RW { static std::string StaticAlgorithmName() {return "RW";} - typedef RWFunction PublicKey; - typedef InvertibleRWFunction PrivateKey; + typedef RWFunction PublicKey; + typedef InvertibleRWFunction PrivateKey; }; -//! RW -template -struct RWSSA : public TF_SSA > +//! RWSS +template +struct RWSS : public TF_SS { }; -- cgit v1.2.1