mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Replace custom exceptions with std::runtime_error
This commit is contained in:
@@ -2247,14 +2247,10 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\Base58Data.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\bignum_error.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\CAutoBN_CTX.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\CBigNum.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\CKey.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\DHUtil.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\ECDSA.h">
|
||||
|
||||
@@ -3216,18 +3216,12 @@
|
||||
<ClInclude Include="..\..\src\ripple\crypto\Base58Data.h">
|
||||
<Filter>ripple\crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\bignum_error.h">
|
||||
<Filter>ripple\crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\CAutoBN_CTX.h">
|
||||
<Filter>ripple\crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\CBigNum.h">
|
||||
<Filter>ripple\crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\CKey.h">
|
||||
<Filter>ripple\crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\crypto\DHUtil.h">
|
||||
<Filter>ripple\crypto</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
#ifndef RIPPLE_CRYPTO_CAUTOBN_CTX_H_INCLUDED
|
||||
#define RIPPLE_CRYPTO_CAUTOBN_CTX_H_INCLUDED
|
||||
|
||||
#include <ripple/crypto/bignum_error.h>
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class CAutoBN_CTX
|
||||
@@ -41,7 +43,7 @@ public:
|
||||
pctx = BN_CTX_new ();
|
||||
|
||||
if (pctx == nullptr)
|
||||
throw bignum_error ("CAutoBN_CTX : BN_CTX_new() returned nullptr");
|
||||
throw std::runtime_error ("CAutoBN_CTX : BN_CTX_new() returned nullptr");
|
||||
}
|
||||
|
||||
~CAutoBN_CTX ()
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2011 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef RIPPLE_CRYPTO_CKEY_H_INCLUDED
|
||||
#define RIPPLE_CRYPTO_CKEY_H_INCLUDED
|
||||
|
||||
#include <ripple/crypto/ECDSACanonical.h>
|
||||
#include <ripple/crypto/GenerateDeterministicKey.h>
|
||||
#include <ripple/types/base_uint.h>
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// secp256k1:
|
||||
// const unsigned int PRIVATE_KEY_SIZE = 279;
|
||||
// const unsigned int PUBLIC_KEY_SIZE = 65; // but we don't use full keys
|
||||
// const unsigned int COMPUB_KEY_SIZE = 33;
|
||||
// const unsigned int SIGNATURE_SIZE = 72;
|
||||
//
|
||||
// see www.keylength.com
|
||||
// script supports up to 75 for single byte push
|
||||
|
||||
class key_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit key_error (std::string const& str) : std::runtime_error (str) {}
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -1,43 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2011 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef RIPPLE_CRYPTO_BIGNUM_ERROR_H_INCLUDED
|
||||
#define RIPPLE_CRYPTO_BIGNUM_ERROR_H_INCLUDED
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class bignum_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit bignum_error (std::string const& str)
|
||||
: std::runtime_error (str)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -22,10 +22,12 @@
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <ripple/crypto/bignum_error.h>
|
||||
#include <ripple/crypto/CBigNum.h>
|
||||
#include <ripple/crypto/CAutoBN_CTX.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
CBigNum::CBigNum ()
|
||||
@@ -40,14 +42,14 @@ CBigNum::CBigNum (const CBigNum& b)
|
||||
if (!BN_copy (this, &b))
|
||||
{
|
||||
BN_clear_free (this);
|
||||
throw bignum_error ("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
|
||||
throw std::runtime_error ("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
|
||||
}
|
||||
}
|
||||
|
||||
CBigNum& CBigNum::operator= (const CBigNum& b)
|
||||
{
|
||||
if (!BN_copy (this, &b))
|
||||
throw bignum_error ("CBigNum::operator= : BN_copy failed");
|
||||
throw std::runtime_error ("CBigNum::operator= : BN_copy failed");
|
||||
|
||||
return (*this);
|
||||
}
|
||||
@@ -378,7 +380,7 @@ std::string CBigNum::ToString (int nBase) const
|
||||
while (BN_cmp (&bn, &bn0) > 0)
|
||||
{
|
||||
if (!BN_div (&dv, &rem, &bn, &bnBase, pctx))
|
||||
throw bignum_error ("CBigNum::ToString() : BN_div failed");
|
||||
throw std::runtime_error ("CBigNum::ToString() : BN_div failed");
|
||||
|
||||
bn = dv;
|
||||
unsigned int c = rem.getuint ();
|
||||
@@ -405,7 +407,7 @@ bool CBigNum::operator! () const
|
||||
CBigNum& CBigNum::operator+= (const CBigNum& b)
|
||||
{
|
||||
if (!BN_add (this, this, &b))
|
||||
throw bignum_error ("CBigNum::operator+= : BN_add failed");
|
||||
throw std::runtime_error ("CBigNum::operator+= : BN_add failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -421,7 +423,7 @@ CBigNum& CBigNum::operator*= (const CBigNum& b)
|
||||
CAutoBN_CTX pctx;
|
||||
|
||||
if (!BN_mul (this, this, &b, pctx))
|
||||
throw bignum_error ("CBigNum::operator*= : BN_mul failed");
|
||||
throw std::runtime_error ("CBigNum::operator*= : BN_mul failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -441,7 +443,7 @@ CBigNum& CBigNum::operator%= (const CBigNum& b)
|
||||
CBigNum& CBigNum::operator<<= (unsigned int shift)
|
||||
{
|
||||
if (!BN_lshift (this, this, shift))
|
||||
throw bignum_error ("CBigNum:operator<<= : BN_lshift failed");
|
||||
throw std::runtime_error ("CBigNum:operator<<= : BN_lshift failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -460,7 +462,7 @@ CBigNum& CBigNum::operator>>= (unsigned int shift)
|
||||
}
|
||||
|
||||
if (!BN_rshift (this, this, shift))
|
||||
throw bignum_error ("CBigNum:operator>>= : BN_rshift failed");
|
||||
throw std::runtime_error ("CBigNum:operator>>= : BN_rshift failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -470,7 +472,7 @@ CBigNum& CBigNum::operator++ ()
|
||||
{
|
||||
// prefix operator
|
||||
if (!BN_add (this, this, BN_value_one ()))
|
||||
throw bignum_error ("CBigNum::operator++ : BN_add failed");
|
||||
throw std::runtime_error ("CBigNum::operator++ : BN_add failed");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -489,7 +491,7 @@ CBigNum& CBigNum::operator-- ()
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_sub (&r, this, BN_value_one ()))
|
||||
throw bignum_error ("CBigNum::operator-- : BN_sub failed");
|
||||
throw std::runtime_error ("CBigNum::operator-- : BN_sub failed");
|
||||
|
||||
*this = r;
|
||||
return *this;
|
||||
@@ -506,7 +508,7 @@ const CBigNum CBigNum::operator-- (int)
|
||||
void CBigNum::setulong (unsigned long n)
|
||||
{
|
||||
if (!BN_set_word (this, n))
|
||||
throw bignum_error ("CBigNum conversion from unsigned long : BN_set_word failed");
|
||||
throw std::runtime_error ("CBigNum conversion from unsigned long : BN_set_word failed");
|
||||
}
|
||||
|
||||
unsigned long CBigNum::getulong () const
|
||||
@@ -519,7 +521,7 @@ const CBigNum operator+ (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_add (&r, &a, &b))
|
||||
throw bignum_error ("CBigNum::operator+ : BN_add failed");
|
||||
throw std::runtime_error ("CBigNum::operator+ : BN_add failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -529,7 +531,7 @@ const CBigNum operator- (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_sub (&r, &a, &b))
|
||||
throw bignum_error ("CBigNum::operator- : BN_sub failed");
|
||||
throw std::runtime_error ("CBigNum::operator- : BN_sub failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -547,7 +549,7 @@ const CBigNum operator* (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_mul (&r, &a, &b, pctx))
|
||||
throw bignum_error ("CBigNum::operator* : BN_mul failed");
|
||||
throw std::runtime_error ("CBigNum::operator* : BN_mul failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -558,7 +560,7 @@ const CBigNum operator/ (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_div (&r, nullptr, &a, &b, pctx))
|
||||
throw bignum_error ("CBigNum::operator/ : BN_div failed");
|
||||
throw std::runtime_error ("CBigNum::operator/ : BN_div failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -569,7 +571,7 @@ const CBigNum operator% (const CBigNum& a, const CBigNum& b)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_mod (&r, &a, &b, pctx))
|
||||
throw bignum_error ("CBigNum::operator% : BN_div failed");
|
||||
throw std::runtime_error ("CBigNum::operator% : BN_div failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -579,7 +581,7 @@ const CBigNum operator<< (const CBigNum& a, unsigned int shift)
|
||||
CBigNum r;
|
||||
|
||||
if (!BN_lshift (&r, &a, shift))
|
||||
throw bignum_error ("CBigNum:operator<< : BN_lshift failed");
|
||||
throw std::runtime_error ("CBigNum:operator<< : BN_lshift failed");
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/crypto/CKey.h>
|
||||
#include <ripple/crypto/ECIES.h>
|
||||
#include <ripple/crypto/RandomNumbers.h>
|
||||
#include <openssl/ec.h>
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/crypto/CKey.h>
|
||||
#include <ripple/crypto/ECDSA.h>
|
||||
#include <ripple/crypto/ECIES.h>
|
||||
#include <ripple/crypto/GenerateDeterministicKey.h>
|
||||
#include <ripple/crypto/RandomNumbers.h>
|
||||
#include <ripple/crypto/RFC1751.h>
|
||||
#include <ripple/protocol/RippleAddress.h>
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include <ripple/types/Base58.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2011 The Bitcoin Developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
@@ -86,7 +89,7 @@ std::string Base58::raw_encode (
|
||||
while (bn > bn0)
|
||||
{
|
||||
if (!BN_div (&dv, &rem, &bn, &bn58, pctx))
|
||||
throw bignum_error ("EncodeBase58 : BN_div failed");
|
||||
throw std::runtime_error ("EncodeBase58 : BN_div failed");
|
||||
|
||||
bn = dv;
|
||||
unsigned int c = rem.getuint ();
|
||||
@@ -196,7 +199,7 @@ bool Base58::decode (const char* psz, Blob& vchRet, Alphabet const& alphabet)
|
||||
bnChar.setuint (p1 - alphabet.chars());
|
||||
|
||||
if (!BN_mul (&bn, &bn, &bn58, pctx))
|
||||
throw bignum_error ("DecodeBase58 : BN_mul failed");
|
||||
throw std::runtime_error ("DecodeBase58 : BN_mul failed");
|
||||
|
||||
bn += bnChar;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <openssl/ripemd.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include <ripple/sslutil/bignum_error.h>
|
||||
#include <ripple/sslutil/CAutoBN_CTX.h>
|
||||
#include <ripple/sslutil/CBigNum.h>
|
||||
#include <ripple/sslutil/DHUtil.h>
|
||||
|
||||
Reference in New Issue
Block a user