#ifndef CRYPTOPP_PSSR_H #define CRYPTOPP_PSSR_H #include "pubkey.h" #include NAMESPACE_BEGIN(CryptoPP) class PSSR_MEM_Base : public PK_RecoverableSignatureMessageEncodingMethod { virtual bool AllowRecovery() const =0; virtual unsigned int SaltLen(unsigned int hashLen) const =0; virtual unsigned int MinPadLen(unsigned int hashLen) const =0; virtual const MaskGeneratingFunction & GetMGF() const =0; public: unsigned int MaxRecoverableLength(unsigned int representativeBitLength, unsigned int hashIdentifierLength, unsigned int digestLength) const; bool IsProbabilistic() const; bool AllowNonrecoverablePart() const; bool RecoverablePartFirst() const; void ComputeMessageRepresentative(RandomNumberGenerator &rng, const byte *recoverableMessage, unsigned int recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, unsigned int representativeBitLength) const; DecodingResult RecoverMessageFromRepresentative( HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, unsigned int representativeBitLength, byte *recoverableMessage) const; }; template struct EMSA2HashId { static const byte id; }; // EMSA2HashId can be instantiated with the following two classes. class SHA; class RIPEMD160; class RIPEMD128; class SHA256; class SHA384; class SHA512; class Whirlpool; template class EMSA2HashIdLookup : public BASE { public: struct HashIdentifierLookup { template struct HashIdentifierLookup2 { static HashIdentifier Lookup() { return HashIdentifier(&EMSA2HashId::id, 1); } }; }; }; template class PSSR_MEM_BaseWithHashId; template<> class PSSR_MEM_BaseWithHashId : public EMSA2HashIdLookup {}; template<> class PSSR_MEM_BaseWithHashId : public PSSR_MEM_Base {}; template class PSSR_MEM : public PSSR_MEM_BaseWithHashId { virtual bool AllowRecovery() const {return ALLOW_RECOVERY;} virtual unsigned int SaltLen(unsigned int hashLen) const {return SALT_LEN < 0 ? hashLen : SALT_LEN;} virtual unsigned int MinPadLen(unsigned int hashLen) const {return MIN_PAD_LEN < 0 ? hashLen : MIN_PAD_LEN;} virtual const MaskGeneratingFunction & GetMGF() const {static MGF mgf; return mgf;} public: static std::string StaticAlgorithmName() {return std::string(ALLOW_RECOVERY ? "PSSR-" : "PSS-") + MGF::StaticAlgorithmName();} }; //! PSSR-MGF1 struct PSSR : public SignatureStandard { typedef PSSR_MEM SignatureMessageEncodingMethod; }; //! PSS-MGF1 struct PSS : public SignatureStandard { typedef PSSR_MEM SignatureMessageEncodingMethod; }; NAMESPACE_END #endif