5
This file contains classes that implement the
6
Rabin-Williams signature schemes as defined in IEEE P1363.
11
NAMESPACE_BEGIN(CryptoPP)
14
class CRYPTOPP_DLL RWFunction : public TrapdoorFunction, public PublicKey
16
typedef RWFunction ThisClass;
19
void Initialize(const Integer &n)
22
void BERDecode(BufferedTransformation &bt);
23
void DEREncode(BufferedTransformation &bt) const;
25
Integer ApplyFunction(const Integer &x) const;
26
Integer PreimageBound() const {return ++(m_n>>1);}
27
Integer ImageBound() const {return m_n;}
29
bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
30
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
31
void AssignFrom(const NameValuePairs &source);
33
const Integer& GetModulus() const {return m_n;}
34
void SetModulus(const Integer &n) {m_n = n;}
41
class CRYPTOPP_DLL InvertibleRWFunction : public RWFunction, public TrapdoorFunctionInverse, public PrivateKey
43
typedef InvertibleRWFunction ThisClass;
46
void Initialize(const Integer &n, const Integer &p, const Integer &q, const Integer &u)
47
{m_n = n; m_p = p; m_q = q; m_u = u;}
48
// generate a random private key
49
void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits)
50
{GenerateRandomWithKeySize(rng, modulusBits);}
52
void BERDecode(BufferedTransformation &bt);
53
void DEREncode(BufferedTransformation &bt) const;
55
Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const;
57
// GeneratibleCryptoMaterial
58
bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
59
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
60
void AssignFrom(const NameValuePairs &source);
61
/*! parameters: (ModulusSize) */
62
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg);
64
const Integer& GetPrime1() const {return m_p;}
65
const Integer& GetPrime2() const {return m_q;}
66
const Integer& GetMultiplicativeInverseOfPrime2ModPrime1() const {return m_u;}
68
void SetPrime1(const Integer &p) {m_p = p;}
69
void SetPrime2(const Integer &q) {m_q = q;}
70
void SetMultiplicativeInverseOfPrime2ModPrime1(const Integer &u) {m_u = u;}
73
Integer m_p, m_q, m_u;
79
static std::string StaticAlgorithmName() {return "RW";}
80
typedef RWFunction PublicKey;
81
typedef InvertibleRWFunction PrivateKey;
85
template <class STANDARD, class H>
86
struct RWSS : public TF_SS<STANDARD, H, RW>