Fabcoin Core  0.16.2
P2P Digital Currency
pssr.h
Go to the documentation of this file.
1 // pssr.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_PSSR_H
7 #define CRYPTOPP_PSSR_H
8 
9 #include "cryptlib.h"
10 #include "pubkey.h"
11 #include "emsa2.h"
12 
13 #ifdef CRYPTOPP_IS_DLL
14 #include "sha.h"
15 #endif
16 
18 
21 {
22 public:
23  virtual ~PSSR_MEM_Base() {}
24 
25 protected:
26  virtual bool AllowRecovery() const =0;
27  virtual size_t SaltLen(size_t hashLen) const =0;
28  virtual size_t MinPadLen(size_t hashLen) const =0;
29  virtual const MaskGeneratingFunction & GetMGF() const =0;
30 
31 private:
32  size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const;
33  size_t MaxRecoverableLength(size_t representativeBitLength, size_t hashIdentifierLength, size_t digestLength) const;
34  bool IsProbabilistic() const;
35  bool AllowNonrecoverablePart() const;
36  bool RecoverablePartFirst() const;
37  void ComputeMessageRepresentative(RandomNumberGenerator &rng,
38  const byte *recoverableMessage, size_t recoverableMessageLength,
39  HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
40  byte *representative, size_t representativeBitLength) const;
41  DecodingResult RecoverMessageFromRepresentative(
42  HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
43  byte *representative, size_t representativeBitLength,
44  byte *recoverableMessage) const;
45 };
46 
49 template <bool USE_HASH_ID> class PSSR_MEM_BaseWithHashId;
50 
53 template<> class PSSR_MEM_BaseWithHashId<true> : public EMSA2HashIdLookup<PSSR_MEM_Base> {};
54 
57 template<> class PSSR_MEM_BaseWithHashId<false> : public PSSR_MEM_Base {};
58 
68 template <bool ALLOW_RECOVERY, class MGF=P1363_MGF1, int SALT_LEN=-1, int MIN_PAD_LEN=0, bool USE_HASH_ID=false>
69 class PSSR_MEM : public PSSR_MEM_BaseWithHashId<USE_HASH_ID>
70 {
71  virtual bool AllowRecovery() const {return ALLOW_RECOVERY;}
72  virtual size_t SaltLen(size_t hashLen) const {return SALT_LEN < 0 ? hashLen : SALT_LEN;}
73  virtual size_t MinPadLen(size_t hashLen) const {return MIN_PAD_LEN < 0 ? hashLen : MIN_PAD_LEN;}
74  virtual const MaskGeneratingFunction & GetMGF() const {static MGF mgf; return mgf;}
75 
76 public:
77  static std::string CRYPTOPP_API StaticAlgorithmName() {return std::string(ALLOW_RECOVERY ? "PSSR-" : "PSS-") + MGF::StaticAlgorithmName();}
78 };
79 
83 struct PSSR : public SignatureStandard
84 {
86 };
87 
91 struct PSS : public SignatureStandard
92 {
94 };
95 
97 
98 #endif
uint8_t byte
Definition: Common.h:57
virtual size_t MinPadLen(size_t hashLen) const
Definition: pssr.h:73
Classes and functions for various padding schemes used in public key algorithms.
virtual const MaskGeneratingFunction & GetMGF() const
Definition: pssr.h:74
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
Abstract base classes that provide a uniform interface to this library.
virtual ~PSSR_MEM_Base()
Definition: pssr.h:23
Interface for random number generators.
Definition: cryptlib.h:1188
PSSR Message Encoding Method interface.
Definition: pssr.h:20
Base class for public key signature standard classes.
Definition: pubkey.h:2071
Returns a decoding results.
Definition: cryptlib.h:238
virtual size_t SaltLen(size_t hashLen) const
Definition: pssr.h:72
P1363 mask generation function.
Definition: pubkey.h:696
PSSR_MEM< false > SignatureMessageEncodingMethod
Definition: pssr.h:93
virtual bool AllowRecovery() const
Definition: pssr.h:71
PSSR Message Encoding Method with Hash Identifier.
Definition: pssr.h:49
#define CRYPTOPP_API
Definition: config.h:705
Mask generation function interface.
Definition: pubkey.h:666
Classes for SHA-1 and SHA-2 family of message digests.
Probabilistic Signature Scheme with Recovery.
Definition: pssr.h:83
PSSR_MEM< true > SignatureMessageEncodingMethod
Definition: pssr.h:85
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:930
#define NAMESPACE_END
Definition: config.h:201
std::pair< const byte *, unsigned int > HashIdentifier
Definition: pubkey.h:314
PSSR Message Encoding Method.
Definition: pssr.h:69
#define CRYPTOPP_DLL
Definition: config.h:704
static std::string CRYPTOPP_API StaticAlgorithmName()
Definition: pssr.h:77
Interface for message encoding method for public key signature schemes.
Definition: pubkey.h:416
Probabilistic Signature Scheme with Appendix.
Definition: pssr.h:91