Security Scol plugin
pssr.h
Go to the documentation of this file.
1// pssr.h - originally written and placed in the public domain by Wei Dai
2
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
18NAMESPACE_BEGIN(CryptoPP)
19
20
23{
24public:
25 virtual ~PSSR_MEM_Base() {}
26
27protected:
28 virtual bool AllowRecovery() const =0;
29 virtual size_t SaltLen(size_t hashLen) const =0;
30 virtual size_t MinPadLen(size_t hashLen) const =0;
31 virtual const MaskGeneratingFunction & GetMGF() const =0;
32
33private:
34 size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const;
35 size_t MaxRecoverableLength(size_t representativeBitLength, size_t hashIdentifierLength, size_t digestLength) const;
36 bool IsProbabilistic() const;
37 bool AllowNonrecoverablePart() const;
38 bool RecoverablePartFirst() const;
39 void ComputeMessageRepresentative(RandomNumberGenerator &rng,
40 const byte *recoverableMessage, size_t recoverableMessageLength,
41 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
42 byte *representative, size_t representativeBitLength) const;
43 DecodingResult RecoverMessageFromRepresentative(
44 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
45 byte *representative, size_t representativeBitLength,
46 byte *recoverableMessage) const;
47};
48
52template <bool USE_HASH_ID> class PSSR_MEM_BaseWithHashId;
53
56template<> class PSSR_MEM_BaseWithHashId<true> : public EMSA2HashIdLookup<PSSR_MEM_Base> {};
57
61template<> class PSSR_MEM_BaseWithHashId<false> : public PSSR_MEM_Base {};
62
73template <bool ALLOW_RECOVERY, class MGF=P1363_MGF1, int SALT_LEN=-1, int MIN_PAD_LEN=0, bool USE_HASH_ID=false>
74class PSSR_MEM : public PSSR_MEM_BaseWithHashId<USE_HASH_ID>
75{
76 virtual bool AllowRecovery() const {return ALLOW_RECOVERY;}
77 virtual size_t SaltLen(size_t hashLen) const {return SALT_LEN < 0 ? hashLen : SALT_LEN;}
78 virtual size_t MinPadLen(size_t hashLen) const {return MIN_PAD_LEN < 0 ? hashLen : MIN_PAD_LEN;}
79 virtual const MaskGeneratingFunction & GetMGF() const {static MGF mgf; return mgf;}
80
81public:
82 static std::string CRYPTOPP_API StaticAlgorithmName() {return std::string(ALLOW_RECOVERY ? "PSSR-" : "PSS-") + MGF::StaticAlgorithmName();}
83};
84
93
102
103NAMESPACE_END
104
105#endif
EMSA2 padding method.
Definition emsa2.h:34
Interface for hash functions and data processing part of MACs.
Definition cryptlib.h:1113
Mask generation function interface.
Definition pubkey.h:688
P1363 mask generation function.
Definition pubkey.h:719
Interface for message encoding method for public key signature schemes.
Definition pubkey.h:403
PSSR Message Encoding Method interface.
Definition pssr.h:23
PSSR Message Encoding Method with Hash Identifier.
Definition pssr.h:52
PSSR Message Encoding Method.
Definition pssr.h:75
Interface for random number generators.
Definition cryptlib.h:1435
Abstract base classes that provide a uniform interface to this library.
Classes and functions for various padding schemes used in public key algorithms.
This file contains helper classes/functions for implementing public key algorithms.
Classes for SHA-1 and SHA-2 family of message digests.
Returns a decoding results.
Definition cryptlib.h:278
Probabilistic Signature Scheme with Appendix.
Definition pssr.h:99
Probabilistic Signature Scheme with Recovery.
Definition pssr.h:90
Base class for public key signature standard classes.
Definition pubkey.h:2279