summaryrefslogtreecommitdiff
path: root/luc.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-12-03 00:32:07 -0500
committerJeffrey Walton <noloader@gmail.com>2016-12-03 00:32:07 -0500
commit40230dd3bf5400ec3fda20cc791fb05c7a1c5b62 (patch)
tree834a1ab74d205c54d55b801d5dc1ab949ebc5bca /luc.h
parent6eb2792bc26aebc83924e7e7be28c0444dca506c (diff)
downloadcryptopp-git-40230dd3bf5400ec3fda20cc791fb05c7a1c5b62.tar.gz
Removed MAINTAIN_BACKWARDS_COMPATIBILITY_562 (Issue 70)
Diffstat (limited to 'luc.h')
-rw-r--r--luc.h93
1 files changed, 40 insertions, 53 deletions
diff --git a/luc.h b/luc.h
index ead0a4fc..beb07c0e 100644
--- a/luc.h
+++ b/luc.h
@@ -1,9 +1,14 @@
+// luc.h - written and placed in the public domain by Wei Dai
+
+//! \file luc.h
+//! \brief Classes for the LUC cryptosystem
+//! \details This class is here for historical and pedagogical interest. It has no practical advantages over other
+//! trapdoor functions and probably shouldn't be used in production software. The discrete log based LUC schemes
+//! defined later in this .h file may be of more practical interest.
+
#ifndef CRYPTOPP_LUC_H
#define CRYPTOPP_LUC_H
-/** \file
-*/
-
#include "cryptlib.h"
#include "gfpcrypt.h"
#include "integer.h"
@@ -24,17 +29,17 @@
NAMESPACE_BEGIN(CryptoPP)
-//! The LUC function.
-/*! This class is here for historical and pedagogical interest. It has no
- practical advantages over other trapdoor functions and probably shouldn't
- be used in production software. The discrete log based LUC schemes
- defined later in this .h file may be of more practical interest.
-*/
+//! \brief The LUC function.
+//! \details This class is here for historical and pedagogical interest. It has no practical advantages over other
+//! trapdoor functions and probably shouldn't be used in production software. The discrete log based LUC schemes
+//! defined later in this .h file may be of more practical interest.
class LUCFunction : public TrapdoorFunction, public PublicKey
{
typedef LUCFunction ThisClass;
public:
+ virtual ~LUCFunction() {}
+
void Initialize(const Integer &n, const Integer &e)
{m_n = n; m_e = e;}
@@ -56,20 +61,21 @@ public:
void SetModulus(const Integer &n) {m_n = n;}
void SetPublicExponent(const Integer &e) {m_e = e;}
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~LUCFunction() {}
-#endif
-
protected:
Integer m_n, m_e;
};
-//! _
+//! \brief The LUC inverse function.
+//! \details This class is here for historical and pedagogical interest. It has no practical advantages over other
+//! trapdoor functions and probably shouldn't be used in production software. The discrete log based LUC schemes
+//! defined later in this .h file may be of more practical interest.
class InvertibleLUCFunction : public LUCFunction, public TrapdoorFunctionInverse, public PrivateKey
{
typedef InvertibleLUCFunction ThisClass;
public:
+ virtual ~InvertibleLUCFunction() {}
+
void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits, const Integer &eStart=17);
void Initialize(const Integer &n, const Integer &e, const Integer &p, const Integer &q, const Integer &u)
{m_n = n; m_e = e; m_p = p; m_q = q; m_u = u;}
@@ -94,10 +100,6 @@ public:
void SetPrime2(const Integer &q) {m_q = q;}
void SetMultiplicativeInverseOfPrime2ModPrime1(const Integer &u) {m_u = u;}
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~InvertibleLUCFunction() {}
-#endif
-
protected:
Integer m_p, m_q, m_u;
};
@@ -109,13 +111,19 @@ struct LUC
typedef InvertibleLUCFunction PrivateKey;
};
-//! LUC cryptosystem
+//! \brief LUC cryptosystem
+//! \details This class is here for historical and pedagogical interest. It has no practical advantages over other
+//! trapdoor functions and probably shouldn't be used in production software. The discrete log based LUC schemes
+//! defined later in this .h file may be of more practical interest.
template <class STANDARD>
struct LUCES : public TF_ES<STANDARD, LUC>
{
};
-//! LUC signature scheme with appendix
+//! \brief LUC signature scheme with appendix
+//! \details This class is here for historical and pedagogical interest. It has no practical advantages over other
+//! trapdoor functions and probably shouldn't be used in production software. The discrete log based LUC schemes
+//! defined later in this .h file may be of more practical interest.
template <class STANDARD, class H>
struct LUCSS : public TF_SS<STANDARD, H, LUC>
{
@@ -134,6 +142,8 @@ typedef LUCSS<PKCS1v15, SHA>::Verifier LUCSSA_PKCS1v15_SHA_Verifier;
class DL_GroupPrecomputation_LUC : public DL_GroupPrecomputation<Integer>
{
public:
+ virtual ~DL_GroupPrecomputation_LUC() {}
+
const AbstractGroup<Element> & GetGroup() const {CRYPTOPP_ASSERT(false); throw 0;}
Element BERDecodeElement(BufferedTransformation &bt) const {return Integer(bt);}
void DEREncodeElement(BufferedTransformation &bt, const Element &v) const {v.DEREncode(bt);}
@@ -142,10 +152,6 @@ public:
void SetModulus(const Integer &v) {m_p = v;}
const Integer & GetModulus() const {return m_p;}
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~DL_GroupPrecomputation_LUC() {}
-#endif
-
private:
Integer m_p;
};
@@ -154,6 +160,8 @@ private:
class DL_BasePrecomputation_LUC : public DL_FixedBasePrecomputation<Integer>
{
public:
+ virtual ~DL_BasePrecomputation_LUC() {}
+
// DL_FixedBasePrecomputation
bool IsInitialized() const {return m_g.NotZero();}
void SetBase(const DL_GroupPrecomputation<Element> &group, const Integer &base)
@@ -174,10 +182,6 @@ public:
throw NotImplemented("DL_BasePrecomputation_LUC: CascadeExponentiate not implemented");
}
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~DL_BasePrecomputation_LUC() {}
-#endif
-
private:
Integer m_g;
};
@@ -186,6 +190,8 @@ private:
class DL_GroupParameters_LUC : public DL_GroupParameters_IntegerBasedImpl<DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC>
{
public:
+ virtual ~DL_GroupParameters_LUC() {}
+
// DL_GroupParameters
bool IsIdentity(const Integer &element) const {return element == Integer::Two();}
void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const;
@@ -206,10 +212,6 @@ public:
return GetValueHelper<DL_GroupParameters_IntegerBased>(this, name, valueType, pValue).Assignable();
}
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~DL_GroupParameters_LUC() {}
-#endif
-
private:
int GetFieldType() const {return 2;}
};
@@ -220,10 +222,6 @@ class DL_GroupParameters_LUC_DefaultSafePrime : public DL_GroupParameters_LUC
public:
typedef NoCofactorMultiplication DefaultCofactorOption;
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~DL_GroupParameters_LUC_DefaultSafePrime() {}
-#endif
-
protected:
unsigned int GetDefaultSubgroupOrderSize(unsigned int modulusSize) const {return modulusSize-1;}
};
@@ -234,15 +232,13 @@ class DL_Algorithm_LUC_HMP : public DL_ElgamalLikeSignatureAlgorithm<Integer>
public:
CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "LUC-HMP";}
+ virtual ~DL_Algorithm_LUC_HMP() {}
+
void Sign(const DL_GroupParameters<Integer> &params, const Integer &x, const Integer &k, const Integer &e, Integer &r, Integer &s) const;
bool Verify(const DL_GroupParameters<Integer> &params, const DL_PublicKey<Integer> &publicKey, const Integer &e, const Integer &r, const Integer &s) const;
size_t RLen(const DL_GroupParameters<Integer> &params) const
{return params.GetGroupOrder().ByteCount();}
-
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~DL_Algorithm_LUC_HMP() {}
-#endif
};
//! _
@@ -251,13 +247,12 @@ struct DL_SignatureKeys_LUC
typedef DL_GroupParameters_LUC GroupParameters;
typedef DL_PublicKey_GFP<GroupParameters> PublicKey;
typedef DL_PrivateKey_GFP<GroupParameters> PrivateKey;
-
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~DL_SignatureKeys_LUC() {}
-#endif
};
-//! LUC-HMP, based on "Digital signature schemes based on Lucas functions" by Patrick Horster, Markus Michels, Holger Petersen
+//! \brief LUC-HMP, based on "Digital signature schemes based on Lucas functions" by Patrick Horster, Markus Michels, Holger Petersen
+//! \details This class is here for historical and pedagogical interest. It has no practical advantages over other
+//! trapdoor functions and probably shouldn't be used in production software. The discrete log based LUC schemes
+//! defined later in this .h file may be of more practical interest.
template <class H>
struct LUC_HMP : public DL_SS<DL_SignatureKeys_LUC, DL_Algorithm_LUC_HMP, DL_SignatureMessageEncodingMethod_DSA, H>
{
@@ -269,10 +264,6 @@ struct DL_CryptoKeys_LUC
typedef DL_GroupParameters_LUC_DefaultSafePrime GroupParameters;
typedef DL_PublicKey_GFP<GroupParameters> PublicKey;
typedef DL_PrivateKey_GFP<GroupParameters> PrivateKey;
-
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~DL_CryptoKeys_LUC() {}
-#endif
};
//! LUC-IES
@@ -286,10 +277,6 @@ struct LUC_IES
LUC_IES<> >
{
static std::string StaticAlgorithmName() {return "LUC-IES";} // non-standard name
-
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~LUC_IES() {}
-#endif
};
// ********************************************************