From 75ef4eab909154ebfb18ead6d3fe55a6a259539e Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Mon, 2 May 2016 22:17:00 +0300 Subject: [PATCH] GetVariant() : additional validations for point encoding and decoding --- src/key.cpp | 8 ++++++-- src/key.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/key.cpp b/src/key.cpp index e1a6014..072199b 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -708,7 +708,9 @@ void CMalleablePubKey::GetVariant(CPubKey &R, CPubKey &vchPubKeyVariant) bnHash.setuint160(Hash160(vchLr)); CPoint pointH; - pointH.setPubKey(pubKeyH); + if (!pointH.setPubKey(pubKeyH)) { + throw key_error("CMalleablePubKey::GetVariant() : Unable to decode H value"); + } CPoint P; // Calculate P = Hash(L*r)*G + H @@ -719,7 +721,9 @@ void CMalleablePubKey::GetVariant(CPubKey &R, CPubKey &vchPubKeyVariant) } std::vector vchResult; - P.getBytes(vchResult); + if (!P.getBytes(vchResult)) { + throw key_error("CMalleablePubKey::GetVariant() : Unable to convert P value"); + } vchPubKeyVariant = CPubKey(vchResult); } diff --git a/src/key.h b/src/key.h index a8ed447..c4c1c96 100644 --- a/src/key.h +++ b/src/key.h @@ -400,7 +400,7 @@ private: CPubKey vchPubKeyH; public: - CMalleableKeyView() { }; + CMalleableKeyView() { } CMalleableKeyView(const CMalleableKey &b); CMalleableKeyView(const std::string &strMalleableKey); -- 1.7.1