summaryrefslogtreecommitdiffstats
path: root/cryptopp562/dh.h
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-10-24 06:44:24 -0400
committerMalfurious <m@lfurio.us>2024-10-24 06:44:24 -0400
commit512aa4c77b3dc0d72db713a9215ff65a98a99ec3 (patch)
tree6db82e0109dc987b5b021f81d4e8a0926eb75ff7 /cryptopp562/dh.h
parent428471d39fb8c205a9fad899c88c30a2cb7df685 (diff)
parent10affea371406c0ae4c080e5a19390a8e9bd154b (diff)
downloadcompass-512aa4c77b3dc0d72db713a9215ff65a98a99ec3.tar.gz
compass-512aa4c77b3dc0d72db713a9215ff65a98a99ec3.zip
Merge branch 'mbedtls'
Replace Crypto++ 5.6.2 with Mbed TLS 3.6.0 Newer compilers are starting to show the age of the crypto library we've been using, as it is sometimes a pain to recompile compass lately. So, the tracked version of Crypto++ was at least due for an upgrade. However, I plan to soon begin reimplementing compass in C. So, I'm taking this opportunity to first just migrate the cryptography library to a newer C alternative. This branch does so, and integrates its use into the current C++ version of compass. * mbedtls: Remove unnecessary exception handler catch block Refactor random password generation to use mbedtls entropy source Refactor SHA256 function to use mbedtls Refactor AES functions to use mbedtls Add Mbedtls library Remove Crypto++ library
Diffstat (limited to '')
-rw-r--r--cryptopp562/dh.h99
1 files changed, 0 insertions, 99 deletions
diff --git a/cryptopp562/dh.h b/cryptopp562/dh.h
deleted file mode 100644
index 10e8d14..0000000
--- a/cryptopp562/dh.h
+++ /dev/null
@@ -1,99 +0,0 @@
-#ifndef CRYPTOPP_DH_H
-#define CRYPTOPP_DH_H
-
-/** \file
-*/
-
-#include "gfpcrypt.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! ,
-template <class GROUP_PARAMETERS, class COFACTOR_OPTION = CPP_TYPENAME GROUP_PARAMETERS::DefaultCofactorOption>
-class DH_Domain : public DL_SimpleKeyAgreementDomainBase<typename GROUP_PARAMETERS::Element>
-{
- typedef DL_SimpleKeyAgreementDomainBase<typename GROUP_PARAMETERS::Element> Base;
-
-public:
- typedef GROUP_PARAMETERS GroupParameters;
- typedef typename GroupParameters::Element Element;
- typedef DL_KeyAgreementAlgorithm_DH<Element, COFACTOR_OPTION> DH_Algorithm;
- typedef DH_Domain<GROUP_PARAMETERS, COFACTOR_OPTION> Domain;
-
- DH_Domain() {}
-
- DH_Domain(const GroupParameters &params)
- : m_groupParameters(params) {}
-
- DH_Domain(BufferedTransformation &bt)
- {m_groupParameters.BERDecode(bt);}
-
- template <class T2>
- DH_Domain(RandomNumberGenerator &v1, const T2 &v2)
- {m_groupParameters.Initialize(v1, v2);}
-
- template <class T2, class T3>
- DH_Domain(RandomNumberGenerator &v1, const T2 &v2, const T3 &v3)
- {m_groupParameters.Initialize(v1, v2, v3);}
-
- template <class T2, class T3, class T4>
- DH_Domain(RandomNumberGenerator &v1, const T2 &v2, const T3 &v3, const T4 &v4)
- {m_groupParameters.Initialize(v1, v2, v3, v4);}
-
- template <class T1, class T2>
- DH_Domain(const T1 &v1, const T2 &v2)
- {m_groupParameters.Initialize(v1, v2);}
-
- template <class T1, class T2, class T3>
- DH_Domain(const T1 &v1, const T2 &v2, const T3 &v3)
- {m_groupParameters.Initialize(v1, v2, v3);}
-
- template <class T1, class T2, class T3, class T4>
- DH_Domain(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4)
- {m_groupParameters.Initialize(v1, v2, v3, v4);}
-
- const GroupParameters & GetGroupParameters() const {return m_groupParameters;}
- GroupParameters & AccessGroupParameters() {return m_groupParameters;}
-
- void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
- {
- Base::GeneratePublicKey(rng, privateKey, publicKey);
-
- if (FIPS_140_2_ComplianceEnabled())
- {
- SecByteBlock privateKey2(this->PrivateKeyLength());
- this->GeneratePrivateKey(rng, privateKey2);
-
- SecByteBlock publicKey2(this->PublicKeyLength());
- Base::GeneratePublicKey(rng, privateKey2, publicKey2);
-
- SecByteBlock agreedValue(this->AgreedValueLength()), agreedValue2(this->AgreedValueLength());
- bool agreed1 = this->Agree(agreedValue, privateKey, publicKey2);
- bool agreed2 = this->Agree(agreedValue2, privateKey2, publicKey);
-
- if (!agreed1 || !agreed2 || agreedValue != agreedValue2)
- throw SelfTestFailure(this->AlgorithmName() + ": pairwise consistency test failed");
- }
- }
-
- static std::string CRYPTOPP_API StaticAlgorithmName()
- {return GroupParameters::StaticAlgorithmNamePrefix() + DH_Algorithm::StaticAlgorithmName();}
- std::string AlgorithmName() const {return StaticAlgorithmName();}
-
-private:
- const DL_KeyAgreementAlgorithm<Element> & GetKeyAgreementAlgorithm() const
- {return Singleton<DH_Algorithm>().Ref();}
- DL_GroupParameters<Element> & AccessAbstractGroupParameters()
- {return m_groupParameters;}
-
- GroupParameters m_groupParameters;
-};
-
-CRYPTOPP_DLL_TEMPLATE_CLASS DH_Domain<DL_GroupParameters_GFP_DefaultSafePrime>;
-
-//! <a href="http://www.weidai.com/scan-mirror/ka.html#DH">Diffie-Hellman</a> in GF(p) with key validation
-typedef DH_Domain<DL_GroupParameters_GFP_DefaultSafePrime> DH;
-
-NAMESPACE_END
-
-#endif