summaryrefslogtreecommitdiff
path: root/eccrypto.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-08-05 03:51:58 -0400
committerGitHub <noreply@github.com>2019-08-05 03:51:58 -0400
commitc9ef9420e762b91cc06463d349cf06e04c749b9d (patch)
tree69a074fcf855a9f8b04d12b359904217e9ea618f /eccrypto.cpp
parentb3eb4c6a690d6dfb342856f2a66a71dcec8c429b (diff)
downloadcryptopp-git-c9ef9420e762b91cc06463d349cf06e04c749b9d.tar.gz
Fix ECP leakage in Add() and Double() (GH #869, PR #871)
This check-in provides the fix for leaks in ECP's Add() and Double(). The fixes were taken from Joost Renes, Craig Costello, and Lejla Batina's [Complete addition formulas for prime order elliptic curves](https://eprint.iacr.org/2015/1060.pdf). The Pull Request includes two additional changes that were related to testing the primary fix. First, an `AuthenticatedKeyAgreementWithRolesValidate` interface was added. It allows us to test key agreement when roles are involved. Roles are "client", "server", "initiator", "recipient", etc. Second, `SetGlobalSeed` was added to `test.cpp` to help with reproducible results. We had code in two different places that set the seed value for the random number generator. But it was sloppy and doing a poor job since results could not be reproduced under some circumstances.
Diffstat (limited to 'eccrypto.cpp')
-rw-r--r--eccrypto.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/eccrypto.cpp b/eccrypto.cpp
index f76c495a..9a0914c0 100644
--- a/eccrypto.cpp
+++ b/eccrypto.cpp
@@ -28,6 +28,9 @@
#include "ec2n.h"
#include "misc.h"
+#include <iostream>
+#include <sstream>
+
// Squash MS LNK4221 and libtool warnings
#ifndef CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
extern const char ECCRYPTO_FNAME[] = __FILE__;
@@ -683,6 +686,13 @@ OID DL_GroupParameters_EC<EC>::GetAlgorithmID() const
return ASN1::id_ecPublicKey();
}
+std::ostream& operator<<(std::ostream& os, const DL_GroupParameters_EC<ECP>::Element& obj)
+{
+ std::ostringstream oss;
+ oss << "(" << std::hex << obj.x << ", " << std::hex << obj.y << ")";
+ return os << oss.str();
+}
+
// ******************************************************************
template <class EC>