GetVariant() : additional validations for point encoding and decoding
authorCryptoManiac <balthazar@yandex.ru>
Mon, 2 May 2016 19:17:00 +0000 (22:17 +0300)
committerCryptoManiac <balthazar@yandex.ru>
Mon, 2 May 2016 19:17:00 +0000 (22:17 +0300)
src/key.cpp
src/key.h

index e1a6014..072199b 100644 (file)
@@ -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<unsigned char> vchResult;
-    P.getBytes(vchResult);
+    if (!P.getBytes(vchResult)) {
+        throw key_error("CMalleablePubKey::GetVariant() : Unable to convert P value");
+    }
 
     vchPubKeyVariant = CPubKey(vchResult);
 }
index a8ed447..c4c1c96 100644 (file)
--- 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);