Crypto++  5.6.3
Free C++ class library of cryptographic schemes
pssr.h
Go to the documentation of this file.
1 // pssr.h - written and placed in the public domain by Wei Dai
2 
3 //! \file
4 //! \headerfile pssr.h
5 //! \brief Classes for probablistic signature schemes
6 
7 #ifndef CRYPTOPP_PSSR_H
8 #define CRYPTOPP_PSSR_H
9 
10 #include "cryptlib.h"
11 #include "pubkey.h"
12 #include "emsa2.h"
13 
14 #ifdef CRYPTOPP_IS_DLL
15 #include "sha.h"
16 #endif
17 
18 NAMESPACE_BEGIN(CryptoPP)
19 
21 {
22  virtual bool AllowRecovery() const =0;
23  virtual size_t SaltLen(size_t hashLen) const =0;
24  virtual size_t MinPadLen(size_t hashLen) const =0;
25  virtual const MaskGeneratingFunction & GetMGF() const =0;
26 
27 public:
28  size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const;
29  size_t MaxRecoverableLength(size_t representativeBitLength, size_t hashIdentifierLength, size_t digestLength) const;
30  bool IsProbabilistic() const;
31  bool AllowNonrecoverablePart() const;
32  bool RecoverablePartFirst() const;
33  void ComputeMessageRepresentative(RandomNumberGenerator &rng,
34  const byte *recoverableMessage, size_t recoverableMessageLength,
35  HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
36  byte *representative, size_t representativeBitLength) const;
37  DecodingResult RecoverMessageFromRepresentative(
38  HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
39  byte *representative, size_t representativeBitLength,
40  byte *recoverableMessage) const;
41 };
42 
43 template <bool USE_HASH_ID> class PSSR_MEM_BaseWithHashId;
44 template<> class PSSR_MEM_BaseWithHashId<true> : public EMSA2HashIdLookup<PSSR_MEM_Base> {};
45 template<> class PSSR_MEM_BaseWithHashId<false> : public PSSR_MEM_Base {};
46 
47 template <bool ALLOW_RECOVERY, class MGF=P1363_MGF1, int SALT_LEN=-1, int MIN_PAD_LEN=0, bool USE_HASH_ID=false>
48 class PSSR_MEM : public PSSR_MEM_BaseWithHashId<USE_HASH_ID>
49 {
50  virtual bool AllowRecovery() const {return ALLOW_RECOVERY;}
51  virtual size_t SaltLen(size_t hashLen) const {return SALT_LEN < 0 ? hashLen : SALT_LEN;}
52  virtual size_t MinPadLen(size_t hashLen) const {return MIN_PAD_LEN < 0 ? hashLen : MIN_PAD_LEN;}
53  virtual const MaskGeneratingFunction & GetMGF() const {static MGF mgf; return mgf;}
54 
55 public:
56  static std::string CRYPTOPP_API StaticAlgorithmName() {return std::string(ALLOW_RECOVERY ? "PSSR-" : "PSS-") + MGF::StaticAlgorithmName();}
57 };
58 
59 //! <a href="http://www.weidai.com/scan-mirror/sig.html#sem_PSSR-MGF1">PSSR-MGF1</a>
60 struct PSSR : public SignatureStandard
61 {
63 };
64 
65 //! <a href="http://www.weidai.com/scan-mirror/sig.html#sem_PSS-MGF1">PSS-MGF1</a>
66 struct PSS : public SignatureStandard
67 {
69 };
70 
71 NAMESPACE_END
72 
73 #endif
Classes and functions for various padding schemes used in public key algorithms.
This file contains helper classes/functions for implementing public key algorithms.
Abstract base classes that provide a uniform interface to this library.
Interface for random number generators.
Definition: cryptlib.h:1176
Base class for public key signature standard classes.
Definition: pubkey.h:2058
Returns a decoding results.
Definition: cryptlib.h:236
P1363 mask generation function.
Definition: pubkey.h:708
Mask generation function interface.
Definition: pubkey.h:679
Classes for SHA-1 and SHA-2 family of message digests.
PSSR-MGF1
Definition: pssr.h:60
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:912
Crypto++ library namespace.
Definition: pssr.h:48
Interface for message encoding method for public key signature schemes.
Definition: pubkey.h:417
PSS-MGF1
Definition: pssr.h:66