mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
copy constructor for Ed22519
This commit is contained in:
parent
56453f6b5c
commit
d169471e8c
2 changed files with 24 additions and 9 deletions
23
Signature.h
23
Signature.h
|
@ -373,6 +373,8 @@ namespace crypto
|
|||
BIGNUM * x, * y;
|
||||
BIGNUM * z, * t; // projective coordinates
|
||||
EDDSAPoint (): x(nullptr), y(nullptr), z(nullptr), t(nullptr) {};
|
||||
EDDSAPoint (const EDDSAPoint& other): x(nullptr), y(nullptr), z(nullptr), t(nullptr)
|
||||
{ *this = other; };
|
||||
EDDSAPoint (EDDSAPoint&& other): x(nullptr), y(nullptr), z(nullptr), t(nullptr)
|
||||
{ *this = std::move (other); };
|
||||
EDDSAPoint (BIGNUM * x1, BIGNUM * y1, BIGNUM * z1 = nullptr, BIGNUM * t1 = nullptr): x(x1), y(y1), z(z1), t(t1) {};
|
||||
|
@ -380,17 +382,22 @@ namespace crypto
|
|||
|
||||
EDDSAPoint& operator=(EDDSAPoint&& other)
|
||||
{
|
||||
if (x) BN_free (x);
|
||||
if (y) BN_free (y);
|
||||
if (z) BN_free (z);
|
||||
if (t) BN_free (t);
|
||||
x = other.x; other.x = nullptr;
|
||||
y = other.y; other.y = nullptr;
|
||||
z = other.z; other.z = nullptr;
|
||||
t = other.t; other.t = nullptr;
|
||||
if (x) BN_free (x); x = other.x; other.x = nullptr;
|
||||
if (y) BN_free (y); y = other.y; other.y = nullptr;
|
||||
if (z) BN_free (z); z = other.z; other.z = nullptr;
|
||||
if (t) BN_free (t); t = other.t; other.t = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
EDDSAPoint& operator=(const EDDSAPoint& other)
|
||||
{
|
||||
if (x) BN_free (x); x = other.x ? BN_dup (other.x) : nullptr;
|
||||
if (y) BN_free (y); y = other.y ? BN_dup (other.y) : nullptr;
|
||||
if (z) BN_free (z); z = other.z ? BN_dup (other.z) : nullptr;
|
||||
if (t) BN_free (t); t = other.t ? BN_dup (other.t) : nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
EDDSAPoint operator-() const
|
||||
{
|
||||
BIGNUM * x1 = NULL, * y1 = NULL, * z1 = NULL, * t1 = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue