From 84c4ae429f643cf1e84b5ef11cb2f5f12a5d6d76 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 3 Aug 2019 03:24:26 -0400 Subject: [PATCH] Fix const-ness in HMQV and FHMQV --- fhmqv.h | 14 +++++++------- hmqv.h | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fhmqv.h b/fhmqv.h index 91cbd9b1..eaf6193b 100644 --- a/fhmqv.h +++ b/fhmqv.h @@ -126,7 +126,7 @@ public: const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const { - byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; + const byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; size_t xxs = 0, yys = 0, aas = 0, bbs = 0; // Depending on the role, this will hold either A's or B's static @@ -144,11 +144,11 @@ public: Element B = params.ExponentiateBase(b); params.EncodeElement(true, B, tt); - XX = const_cast(ephemeralOtherPublicKey); + XX = ephemeralOtherPublicKey; xxs = EphemeralPublicKeyLength(); - YY = const_cast(ephemeralPrivateKey) + StaticPrivateKeyLength(); + YY = ephemeralPrivateKey + StaticPrivateKeyLength(); yys = EphemeralPublicKeyLength(); - AA = const_cast(staticOtherPublicKey); + AA = staticOtherPublicKey; aas = StaticPublicKeyLength(); BB = tt.BytePtr(); bbs = tt.SizeInBytes(); @@ -159,13 +159,13 @@ public: Element A = params.ExponentiateBase(a); params.EncodeElement(true, A, tt); - XX = const_cast(ephemeralPrivateKey) + StaticPrivateKeyLength(); + XX = ephemeralPrivateKey + StaticPrivateKeyLength(); xxs = EphemeralPublicKeyLength(); - YY = const_cast(ephemeralOtherPublicKey); + YY = ephemeralOtherPublicKey; yys = EphemeralPublicKeyLength(); AA = tt.BytePtr(); aas = tt.SizeInBytes(); - BB = const_cast(staticOtherPublicKey); + BB = staticOtherPublicKey; bbs = StaticPublicKeyLength(); } else diff --git a/hmqv.h b/hmqv.h index 3834a619..f3c99731 100644 --- a/hmqv.h +++ b/hmqv.h @@ -125,7 +125,7 @@ public: const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const { - byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; + const byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; size_t xxs = 0, yys = 0, aas = 0, bbs = 0; // Depending on the role, this will hold either A's or B's static @@ -143,11 +143,11 @@ public: Element B = params.ExponentiateBase(b); params.EncodeElement(true, B, tt); - XX = const_cast(ephemeralOtherPublicKey); + XX = ephemeralOtherPublicKey; xxs = EphemeralPublicKeyLength(); - YY = const_cast(ephemeralPrivateKey) + StaticPrivateKeyLength(); + YY = ephemeralPrivateKey + StaticPrivateKeyLength(); yys = EphemeralPublicKeyLength(); - AA = const_cast(staticOtherPublicKey); + AA = staticOtherPublicKey; aas = StaticPublicKeyLength(); BB = tt.BytePtr(); bbs = tt.SizeInBytes(); @@ -158,13 +158,13 @@ public: Element A = params.ExponentiateBase(a); params.EncodeElement(true, A, tt); - XX = const_cast(ephemeralPrivateKey) + StaticPrivateKeyLength(); + XX = ephemeralPrivateKey + StaticPrivateKeyLength(); xxs = EphemeralPublicKeyLength(); - YY = const_cast(ephemeralOtherPublicKey); + YY = ephemeralOtherPublicKey; yys = EphemeralPublicKeyLength(); AA = tt.BytePtr(); aas = tt.SizeInBytes(); - BB = const_cast(staticOtherPublicKey); + BB = staticOtherPublicKey; bbs = StaticPublicKeyLength(); } else