diff --git a/eccrypto.h b/eccrypto.h index 8a4aa420..c5049f13 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -40,14 +40,33 @@ public: virtual ~DL_GroupParameters_EC() {} + //! \brief Construct an EC GroupParameters DL_GroupParameters_EC() : m_compress(false), m_encodeAsOID(true) {} + + //! \brief Construct an EC GroupParameters + //! \param oid the OID of a curve DL_GroupParameters_EC(const OID &oid) : m_compress(false), m_encodeAsOID(true) {Initialize(oid);} + + //! \brief Construct an EC GroupParameters + //! \param ec the elliptic curve + //! \param G the base point + //! \param n the order of the base point + //! \param k the cofactor DL_GroupParameters_EC(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k = Integer::Zero()) : m_compress(false), m_encodeAsOID(true) {Initialize(ec, G, n, k);} + + //! \brief Construct an EC GroupParameters + //! \param bt BufferedTransformation with group parameters DL_GroupParameters_EC(BufferedTransformation &bt) : m_compress(false), m_encodeAsOID(true) {BERDecode(bt);} + //! \brief Initialize an EC GroupParameters using {EC,G,n,k} + //! \param ec the elliptic curve + //! \param G the base point + //! \param n the order of the base point + //! \param k the cofactor + //! \details This Initialize() function overload initializes group parameters from existing parameters. void Initialize(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k = Integer::Zero()) { this->m_groupPrecomputation.SetCurve(ec); @@ -55,6 +74,10 @@ public: m_n = n; m_k = k; } + + //! \brief Initialize a DL_GroupParameters_EC {EC,G,n,k} + //! \param oid the OID of a curve + //! \details This Initialize() function overload initializes group parameters from existing parameters. void Initialize(const OID &oid); // NameValuePairs @@ -156,8 +179,19 @@ public: virtual ~DL_PublicKey_EC() {} + //! \brief Initialize an EC Public Key using {GP,Q} + //! \param params group parameters + //! \param Q the public point + //! \details This Initialize() function overload initializes a public key from existing parameters. void Initialize(const DL_GroupParameters_EC ¶ms, const Element &Q) {this->AccessGroupParameters() = params; this->SetPublicElement(Q);} + + //! \brief Initialize an EC Public Key using {EC,G,n,Q} + //! \param ec the elliptic curve + //! \param G the base point + //! \param n the order of the base point + //! \param Q the public point + //! \details This Initialize() function overload initializes a public key from existing parameters. void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q) {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPublicElement(Q);} @@ -177,24 +211,37 @@ public: virtual ~DL_PrivateKey_EC() {} + //! \brief Initialize an EC Private Key using {GP,x} + //! \param params group parameters + //! \param x the private exponent + //! \details This Initialize() function overload initializes a private key from existing parameters. void Initialize(const DL_GroupParameters_EC ¶ms, const Integer &x) {this->AccessGroupParameters() = params; this->SetPrivateExponent(x);} + + //! \brief Initialize an EC Private Key using {EC,G,n,x} + //! \param ec the elliptic curve + //! \param G the base point + //! \param n the order of the base point + //! \param x the private exponent + //! \details This Initialize() function overload initializes a private key from existing parameters. void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x) {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPrivateExponent(x);} + //! \brief Create an EC private key //! \param rng a RandomNumberGenerator derived class //! \param params the EC group parameters - //! \details This function overload of Initialize() creates a new keypair because it + //! \details This function overload of Initialize() creates a new private key because it //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, const DL_GroupParameters_EC ¶ms) {this->GenerateRandom(rng, params);} + //! \brief Create an EC private key //! \param rng a RandomNumberGenerator derived class //! \param ec the elliptic curve //! \param G the base point - //! \param n the cofactor - //! \details This function overload of Initialize() creates a new keypair because it + //! \param n the order of the base point + //! \details This function overload of Initialize() creates a new private key because it //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n) @@ -325,7 +372,6 @@ struct ECNR : public DL_SS, DL_Algorithm_ECNR, DL_SignatureMe { }; - //! \class ECIES //! \brief Elliptic Curve Integrated Encryption Scheme //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option" diff --git a/esign.h b/esign.h index c76129fd..3eabf13f 100644 --- a/esign.h +++ b/esign.h @@ -23,6 +23,10 @@ class ESIGNFunction : public TrapdoorFunction, public ASN1CryptoMaterial public: virtual ~DL_PublicKey_GFP() {} + //! \brief Initialize a public key over GF(p) + //! \param params the group parameters + //! \param y the public element void Initialize(const DL_GroupParameters_IntegerBased ¶ms, const Integer &y) {this->AccessGroupParameters().Initialize(params); this->SetPublicElement(y);} + + //! \brief Initialize a public key over GF(p) + //! \param p the modulus + //! \param g the generator + //! \param y the public element void Initialize(const Integer &p, const Integer &g, const Integer &y) {this->AccessGroupParameters().Initialize(p, g); this->SetPublicElement(y);} + + //! \brief Initialize a public key over GF(p) + //! \param p the modulus + //! \param q the subgroup order + //! \param g the generator + //! \param y the public element void Initialize(const Integer &p, const Integer &q, const Integer &g, const Integer &y) {this->AccessGroupParameters().Initialize(p, q, g); this->SetPublicElement(y);} @@ -280,7 +306,7 @@ public: //! \brief Create a private key //! \param rng a RandomNumberGenerator derived class //! \param modulusBits the size of the modulus, in bits - //! \details This function overload of Initialize() creates a new keypair because it + //! \details This function overload of Initialize() creates a new private key because it //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits) @@ -288,9 +314,9 @@ public: //! \brief Create a private key //! \param rng a RandomNumberGenerator derived class - //! \param p TODO - //! \param g TODO - //! \details This function overload of Initialize() creates a new keypair because it + //! \param p the modulus + //! \param g the generator + //! \details This function overload of Initialize() creates a new private key because it //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, const Integer &p, const Integer &g) @@ -298,20 +324,33 @@ public: //! \brief Create a private key //! \param rng a RandomNumberGenerator derived class - //! \param p TODO - //! \param q TODO - //! \param g TODO - //! \details This function overload of Initialize() creates a new keypair because it + //! \param p the modulus + //! \param q the subgroup order + //! \param g the generator + //! \details This function overload of Initialize() creates a new private key because it //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, const Integer &p, const Integer &q, const Integer &g) {this->GenerateRandom(rng, MakeParameters("Modulus", p)("SubgroupOrder", q)("SubgroupGenerator", g));} + //! \brief Initialize a private key over GF(p) + //! \param params the group parameters + //! \param x the private exponent void Initialize(const DL_GroupParameters_IntegerBased ¶ms, const Integer &x) {this->AccessGroupParameters().Initialize(params); this->SetPrivateExponent(x);} + //! \brief Initialize a private key over GF(p) + //! \param p the modulus + //! \param g the generator + //! \param x the private exponent void Initialize(const Integer &p, const Integer &g, const Integer &x) {this->AccessGroupParameters().Initialize(p, g); this->SetPrivateExponent(x);} + + //! \brief Initialize a private key over GF(p) + //! \param p the modulus + //! \param q the subgroup order + //! \param g the generator + //! \param x the private exponent void Initialize(const Integer &p, const Integer &q, const Integer &g, const Integer &x) {this->AccessGroupParameters().Initialize(p, q, g); this->SetPrivateExponent(x);} }; diff --git a/luc.h b/luc.h index 5d114274..a4330b99 100644 --- a/luc.h +++ b/luc.h @@ -40,6 +40,9 @@ class LUCFunction : public TrapdoorFunction, public PublicKey public: virtual ~LUCFunction() {} + //! \brief Initialize a LUC public key with {n,e} + //! \param n the modulus + //! \param e the public exponent void Initialize(const Integer &n, const Integer &e) {m_n = n; m_e = e;} @@ -85,6 +88,14 @@ public: //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits, const Integer &eStart=17); + + //! \brief Initialize a LUC private key with {n,e,p,q,dp,dq,u} + //! \param n modulus + //! \param e public exponent + //! \param p first prime factor + //! \param q second prime factor + //! \param u q-1 mod p + //! \details This Initialize() function overload initializes a private key from existing parameters. 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;} @@ -120,6 +131,7 @@ struct LUC }; //! \brief LUC cryptosystem +//! \tparam STANDARD signature standard //! \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. @@ -129,6 +141,8 @@ struct LUCES : public TF_ES }; //! \brief LUC signature scheme with appendix +//! \tparam STANDARD signature standard +//! \tparam H hash transformation //! \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. @@ -194,7 +208,8 @@ private: Integer m_g; }; -//! _ +//! \class DL_GroupParameters_LUC +//! \brief LUC GroupParameters specialization class DL_GroupParameters_LUC : public DL_GroupParameters_IntegerBasedImpl { public: @@ -224,7 +239,8 @@ private: int GetFieldType() const {return 2;} }; -//! _ +//! \class DL_GroupParameters_LUC_DefaultSafePrime +//! \brief GF(p) group parameters that default to safe primes class DL_GroupParameters_LUC_DefaultSafePrime : public DL_GroupParameters_LUC { public: @@ -234,7 +250,8 @@ protected: unsigned int GetDefaultSubgroupOrderSize(unsigned int modulusSize) const {return modulusSize-1;} }; -//! _ +//! \class DL_Algorithm_LUC_HMP +//! \brief LUC HMP signature algorithm class DL_Algorithm_LUC_HMP : public DL_ElgamalLikeSignatureAlgorithm { public: @@ -249,7 +266,7 @@ public: {return params.GetGroupOrder().ByteCount();} }; -//! _ +//! \brief LUC signature keys struct DL_SignatureKeys_LUC { typedef DL_GroupParameters_LUC GroupParameters; @@ -258,6 +275,7 @@ struct DL_SignatureKeys_LUC }; //! \brief LUC-HMP, based on "Digital signature schemes based on Lucas functions" by Patrick Horster, Markus Michels, Holger Petersen +//! \tparam H hash transformation //! \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. @@ -266,7 +284,7 @@ struct LUC_HMP : public DL_SS PrivateKey; }; -//! LUC-IES -template +//! \class LUC-IES +//! \brief LUC Integrated Encryption Scheme +//! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option" +//! \tparam HASH HashTransformation derived class used for key drivation and MAC computation +//! \tparam DHAES_MODE flag indicating if the MAC includes additional context parameters such as u·V, v·U and label +//! \tparam LABEL_OCTETS flag indicating if the label size is specified in octets or bits +//! \since Crypto++ 4.0, Crypto++ 5.7 for Bouncy Castle and Botan compatibility +template struct LUC_IES : public DL_ES< DL_CryptoKeys_LUC, DL_KeyAgreementAlgorithm_DH, - DL_KeyDerivationAlgorithm_P1363 >, - DL_EncryptionAlgorithm_Xor, DHAES_MODE>, + DL_KeyDerivationAlgorithm_P1363 >, + DL_EncryptionAlgorithm_Xor, DHAES_MODE, LABEL_OCTETS>, LUC_IES<> > { - static std::string StaticAlgorithmName() {return "LUC-IES";} // non-standard name + CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "LUC-IES";} // non-standard name }; // ******************************************************** diff --git a/rabin.h b/rabin.h index 41cc6780..54fbe12e 100644 --- a/rabin.h +++ b/rabin.h @@ -21,6 +21,11 @@ class RabinFunction : public TrapdoorFunction, public PublicKey typedef RabinFunction ThisClass; public: + + //! \brief Initialize a Rabin public key + //! \param n the modulus + //! \param r element r + //! \param s element s void Initialize(const Integer &n, const Integer &r, const Integer &s) {m_n = n; m_r = r; m_s = s;} @@ -55,14 +60,22 @@ class InvertibleRabinFunction : public RabinFunction, public TrapdoorFunctionInv typedef InvertibleRabinFunction ThisClass; public: - void Initialize(const Integer &n, const Integer &r, const Integer &s, - const Integer &p, const Integer &q, const Integer &u) + + //! \brief Initialize a Rabin private key + //! \param n modulus + //! \param r element r + //! \param s element s + //! \param p first prime factor + //! \param q second prime factor + //! \param u q-1 mod p + //! \details This Initialize() function overload initializes a private key from existing parameters. + void Initialize(const Integer &n, const Integer &r, const Integer &s, const Integer &p, const Integer &q, const Integer &u) {m_n = n; m_r = r; m_s = s; m_p = p; m_q = q; m_u = u;} //! \brief Create a Rabin private key //! \param rng a RandomNumberGenerator derived class //! \param keybits the size of the key, in bits - //! \details This function overload of Initialize() creates a new keypair because it + //! \details This function overload of Initialize() creates a new private key because it //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, unsigned int keybits) diff --git a/rsa.h b/rsa.h index 972fea2b..70aaecf6 100644 --- a/rsa.h +++ b/rsa.h @@ -26,7 +26,7 @@ class CRYPTOPP_DLL RSAFunction : public TrapdoorFunction, public X509PublicKey typedef RSAFunction ThisClass; public: - //! \brief Initialize a RSA public key with {n,e} + //! \brief Initialize a RSA public key //! \param n the modulus //! \param e the public exponent void Initialize(const Integer &n, const Integer &e) @@ -71,12 +71,12 @@ public: //! \param modulusBits the size of the modulus, in bits //! \param e the desired public exponent //! \details Initialize() creates a new keypair using a public exponent of 17. - //! \details This function overload of Initialize() creates a new keypair because it + //! \details This function overload of Initialize() creates a new private key because it //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits, const Integer &e = 17); - //! \brief Initialize a RSA private key with {n,e,d,p,q,dp,dq,u} + //! \brief Initialize a RSA private key //! \param n modulus //! \param e public exponent //! \param d private exponent @@ -85,14 +85,16 @@ public: //! \param dp d mod p //! \param dq d mod q //! \param u q-1 mod p + //! \details This Initialize() function overload initializes a private key from existing parameters. void Initialize(const Integer &n, const Integer &e, const Integer &d, const Integer &p, const Integer &q, const Integer &dp, const Integer &dq, const Integer &u) {m_n = n; m_e = e; m_d = d; m_p = p; m_q = q; m_dp = dp; m_dq = dq; m_u = u;} - //! \brief Initialize a RSA private key with {n,e,d} + //! \brief Initialize a RSA private key //! \param n modulus //! \param e public exponent //! \param d private exponent - //! \details Initialize() will factor n using d and populate {p,q,dp,dq,u}. + //! \details This Initialize() function overload initializes a private key from existing parameters. + //! Initialize() will factor n using d and populate {p,q,dp,dq,u}. void Initialize(const Integer &n, const Integer &e, const Integer &d); // PKCS8PrivateKey diff --git a/rw.h b/rw.h index 9a890297..acfad02c 100644 --- a/rw.h +++ b/rw.h @@ -25,6 +25,9 @@ class CRYPTOPP_DLL RWFunction : public TrapdoorFunction, public PublicKey typedef RWFunction ThisClass; public: + + //! \brief Initialize a Rabin-Williams public key + //! \param n the modulus void Initialize(const Integer &n) {m_n = n;} @@ -59,14 +62,21 @@ class CRYPTOPP_DLL InvertibleRWFunction : public RWFunction, public TrapdoorFunc typedef InvertibleRWFunction ThisClass; public: + //! \brief Construct an InvertibleRWFunction InvertibleRWFunction() : m_precompute(false) {} + //! \brief Initialize a Rabin-Williams private key + //! \param n modulus + //! \param p first prime factor + //! \param q second prime factor + //! \param u q-1 mod p + //! \details This Initialize() function overload initializes a private key from existing parameters. void Initialize(const Integer &n, const Integer &p, const Integer &q, const Integer &u); //! \brief Create a Rabin-Williams private key //! \param rng a RandomNumberGenerator derived class //! \param modulusBits the size of the modulus, in bits - //! \details This function overload of Initialize() creates a new keypair because it + //! \details This function overload of Initialize() creates a new private key because it //! takes a RandomNumberGenerator() as a parameter. If you have an existing keypair, //! then use one of the other Initialize() overloads. void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits)