propset svn:eol-style native

git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@146 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
s_nakamoto 2010-08-29 16:58:15 +00:00
parent 5b721607b1
commit 0a61b0df12
65 changed files with 31004 additions and 31004 deletions

402
base58.h
View file

@ -1,201 +1,201 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
// //
// Why base-58 instead of standard base-64 encoding? // Why base-58 instead of standard base-64 encoding?
// - Don't want 0OIl characters that look the same in some fonts and // - Don't want 0OIl characters that look the same in some fonts and
// could be used to create visually identical looking account numbers. // could be used to create visually identical looking account numbers.
// - A string with non-alphanumeric characters is not as easily accepted as an account number. // - A string with non-alphanumeric characters is not as easily accepted as an account number.
// - E-mail usually won't line-break if there's no punctuation to break at. // - E-mail usually won't line-break if there's no punctuation to break at.
// - Doubleclicking selects the whole number as one word if it's all alphanumeric. // - Doubleclicking selects the whole number as one word if it's all alphanumeric.
// //
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
inline string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) inline string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
{ {
CAutoBN_CTX pctx; CAutoBN_CTX pctx;
CBigNum bn58 = 58; CBigNum bn58 = 58;
CBigNum bn0 = 0; CBigNum bn0 = 0;
// Convert big endian data to little endian // Convert big endian data to little endian
// Extra zero at the end make sure bignum will interpret as a positive number // Extra zero at the end make sure bignum will interpret as a positive number
vector<unsigned char> vchTmp(pend-pbegin+1, 0); vector<unsigned char> vchTmp(pend-pbegin+1, 0);
reverse_copy(pbegin, pend, vchTmp.begin()); reverse_copy(pbegin, pend, vchTmp.begin());
// Convert little endian data to bignum // Convert little endian data to bignum
CBigNum bn; CBigNum bn;
bn.setvch(vchTmp); bn.setvch(vchTmp);
// Convert bignum to string // Convert bignum to string
string str; string str;
str.reserve((pend - pbegin) * 138 / 100 + 1); str.reserve((pend - pbegin) * 138 / 100 + 1);
CBigNum dv; CBigNum dv;
CBigNum rem; CBigNum rem;
while (bn > bn0) while (bn > bn0)
{ {
if (!BN_div(&dv, &rem, &bn, &bn58, pctx)) if (!BN_div(&dv, &rem, &bn, &bn58, pctx))
throw bignum_error("EncodeBase58 : BN_div failed"); throw bignum_error("EncodeBase58 : BN_div failed");
bn = dv; bn = dv;
unsigned int c = rem.getulong(); unsigned int c = rem.getulong();
str += pszBase58[c]; str += pszBase58[c];
} }
// Leading zeroes encoded as base58 zeros // Leading zeroes encoded as base58 zeros
for (const unsigned char* p = pbegin; p < pend && *p == 0; p++) for (const unsigned char* p = pbegin; p < pend && *p == 0; p++)
str += pszBase58[0]; str += pszBase58[0];
// Convert little endian string to big endian // Convert little endian string to big endian
reverse(str.begin(), str.end()); reverse(str.begin(), str.end());
return str; return str;
} }
inline string EncodeBase58(const vector<unsigned char>& vch) inline string EncodeBase58(const vector<unsigned char>& vch)
{ {
return EncodeBase58(&vch[0], &vch[0] + vch.size()); return EncodeBase58(&vch[0], &vch[0] + vch.size());
} }
inline bool DecodeBase58(const char* psz, vector<unsigned char>& vchRet) inline bool DecodeBase58(const char* psz, vector<unsigned char>& vchRet)
{ {
CAutoBN_CTX pctx; CAutoBN_CTX pctx;
vchRet.clear(); vchRet.clear();
CBigNum bn58 = 58; CBigNum bn58 = 58;
CBigNum bn = 0; CBigNum bn = 0;
CBigNum bnChar; CBigNum bnChar;
while (isspace(*psz)) while (isspace(*psz))
psz++; psz++;
// Convert big endian string to bignum // Convert big endian string to bignum
for (const char* p = psz; *p; p++) for (const char* p = psz; *p; p++)
{ {
const char* p1 = strchr(pszBase58, *p); const char* p1 = strchr(pszBase58, *p);
if (p1 == NULL) if (p1 == NULL)
{ {
while (isspace(*p)) while (isspace(*p))
p++; p++;
if (*p != '\0') if (*p != '\0')
return false; return false;
break; break;
} }
bnChar.setulong(p1 - pszBase58); bnChar.setulong(p1 - pszBase58);
if (!BN_mul(&bn, &bn, &bn58, pctx)) if (!BN_mul(&bn, &bn, &bn58, pctx))
throw bignum_error("DecodeBase58 : BN_mul failed"); throw bignum_error("DecodeBase58 : BN_mul failed");
bn += bnChar; bn += bnChar;
} }
// Get bignum as little endian data // Get bignum as little endian data
vector<unsigned char> vchTmp = bn.getvch(); vector<unsigned char> vchTmp = bn.getvch();
// Trim off sign byte if present // Trim off sign byte if present
if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80) if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80)
vchTmp.erase(vchTmp.end()-1); vchTmp.erase(vchTmp.end()-1);
// Restore leading zeros // Restore leading zeros
int nLeadingZeros = 0; int nLeadingZeros = 0;
for (const char* p = psz; *p == pszBase58[0]; p++) for (const char* p = psz; *p == pszBase58[0]; p++)
nLeadingZeros++; nLeadingZeros++;
vchRet.assign(nLeadingZeros + vchTmp.size(), 0); vchRet.assign(nLeadingZeros + vchTmp.size(), 0);
// Convert little endian data to big endian // Convert little endian data to big endian
reverse_copy(vchTmp.begin(), vchTmp.end(), vchRet.end() - vchTmp.size()); reverse_copy(vchTmp.begin(), vchTmp.end(), vchRet.end() - vchTmp.size());
return true; return true;
} }
inline bool DecodeBase58(const string& str, vector<unsigned char>& vchRet) inline bool DecodeBase58(const string& str, vector<unsigned char>& vchRet)
{ {
return DecodeBase58(str.c_str(), vchRet); return DecodeBase58(str.c_str(), vchRet);
} }
inline string EncodeBase58Check(const vector<unsigned char>& vchIn) inline string EncodeBase58Check(const vector<unsigned char>& vchIn)
{ {
// add 4-byte hash check to the end // add 4-byte hash check to the end
vector<unsigned char> vch(vchIn); vector<unsigned char> vch(vchIn);
uint256 hash = Hash(vch.begin(), vch.end()); uint256 hash = Hash(vch.begin(), vch.end());
vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4); vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);
return EncodeBase58(vch); return EncodeBase58(vch);
} }
inline bool DecodeBase58Check(const char* psz, vector<unsigned char>& vchRet) inline bool DecodeBase58Check(const char* psz, vector<unsigned char>& vchRet)
{ {
if (!DecodeBase58(psz, vchRet)) if (!DecodeBase58(psz, vchRet))
return false; return false;
if (vchRet.size() < 4) if (vchRet.size() < 4)
{ {
vchRet.clear(); vchRet.clear();
return false; return false;
} }
uint256 hash = Hash(vchRet.begin(), vchRet.end()-4); uint256 hash = Hash(vchRet.begin(), vchRet.end()-4);
if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) if (memcmp(&hash, &vchRet.end()[-4], 4) != 0)
{ {
vchRet.clear(); vchRet.clear();
return false; return false;
} }
vchRet.resize(vchRet.size()-4); vchRet.resize(vchRet.size()-4);
return true; return true;
} }
inline bool DecodeBase58Check(const string& str, vector<unsigned char>& vchRet) inline bool DecodeBase58Check(const string& str, vector<unsigned char>& vchRet)
{ {
return DecodeBase58Check(str.c_str(), vchRet); return DecodeBase58Check(str.c_str(), vchRet);
} }
static const unsigned char ADDRESSVERSION = 0; static const unsigned char ADDRESSVERSION = 0;
inline string Hash160ToAddress(uint160 hash160) inline string Hash160ToAddress(uint160 hash160)
{ {
// add 1-byte version number to the front // add 1-byte version number to the front
vector<unsigned char> vch(1, ADDRESSVERSION); vector<unsigned char> vch(1, ADDRESSVERSION);
vch.insert(vch.end(), UBEGIN(hash160), UEND(hash160)); vch.insert(vch.end(), UBEGIN(hash160), UEND(hash160));
return EncodeBase58Check(vch); return EncodeBase58Check(vch);
} }
inline bool AddressToHash160(const char* psz, uint160& hash160Ret) inline bool AddressToHash160(const char* psz, uint160& hash160Ret)
{ {
vector<unsigned char> vch; vector<unsigned char> vch;
if (!DecodeBase58Check(psz, vch)) if (!DecodeBase58Check(psz, vch))
return false; return false;
if (vch.empty()) if (vch.empty())
return false; return false;
unsigned char nVersion = vch[0]; unsigned char nVersion = vch[0];
if (vch.size() != sizeof(hash160Ret) + 1) if (vch.size() != sizeof(hash160Ret) + 1)
return false; return false;
memcpy(&hash160Ret, &vch[1], sizeof(hash160Ret)); memcpy(&hash160Ret, &vch[1], sizeof(hash160Ret));
return (nVersion <= ADDRESSVERSION); return (nVersion <= ADDRESSVERSION);
} }
inline bool AddressToHash160(const string& str, uint160& hash160Ret) inline bool AddressToHash160(const string& str, uint160& hash160Ret)
{ {
return AddressToHash160(str.c_str(), hash160Ret); return AddressToHash160(str.c_str(), hash160Ret);
} }
inline bool IsValidBitcoinAddress(const char* psz) inline bool IsValidBitcoinAddress(const char* psz)
{ {
uint160 hash160; uint160 hash160;
return AddressToHash160(psz, hash160); return AddressToHash160(psz, hash160);
} }
inline bool IsValidBitcoinAddress(const string& str) inline bool IsValidBitcoinAddress(const string& str)
{ {
return IsValidBitcoinAddress(str.c_str()); return IsValidBitcoinAddress(str.c_str());
} }
inline string PubKeyToAddress(const vector<unsigned char>& vchPubKey) inline string PubKeyToAddress(const vector<unsigned char>& vchPubKey)
{ {
return Hash160ToAddress(Hash160(vchPubKey)); return Hash160ToAddress(Hash160(vchPubKey));
} }

1064
bignum.h

File diff suppressed because it is too large Load diff

View file

@ -1,114 +1,114 @@
Copyright (c) 2009-2010 Satoshi Nakamoto Copyright (c) 2009-2010 Satoshi Nakamoto
Distributed under the MIT/X11 software license, see the accompanying Distributed under the MIT/X11 software license, see the accompanying
file license.txt or http://www.opensource.org/licenses/mit-license.php. file license.txt or http://www.opensource.org/licenses/mit-license.php.
This product includes software developed by the OpenSSL Project for use in This product includes software developed by the OpenSSL Project for use in
the OpenSSL Toolkit (http://www.openssl.org/). This product includes the OpenSSL Toolkit (http://www.openssl.org/). This product includes
cryptographic software written by Eric Young (eay@cryptsoft.com). cryptographic software written by Eric Young (eay@cryptsoft.com).
WINDOWS BUILD NOTES WINDOWS BUILD NOTES
=================== ===================
Compilers Supported Compilers Supported
------------------- -------------------
MinGW GCC (recommended) MinGW GCC (recommended)
MSVC 6.0 SP6: You'll need Boost version 1.34 because they dropped support MSVC 6.0 SP6: You'll need Boost version 1.34 because they dropped support
for MSVC 6.0 after that. However, they didn't add Asio until 1.35. for MSVC 6.0 after that. However, they didn't add Asio until 1.35.
You should still be able to build with MSVC 6.0 by adding Asio to 1.34 by You should still be able to build with MSVC 6.0 by adding Asio to 1.34 by
unpacking boost_asio_*.zip into the boost directory: unpacking boost_asio_*.zip into the boost directory:
http://sourceforge.net/projects/asio/files/asio http://sourceforge.net/projects/asio/files/asio
MSVC 8.0 (2005) SP1 has been tested. Note: MSVC 7.0 and up have a habit of MSVC 8.0 (2005) SP1 has been tested. Note: MSVC 7.0 and up have a habit of
linking to runtime DLLs that are not installed on XP by default. linking to runtime DLLs that are not installed on XP by default.
Dependencies Dependencies
------------ ------------
Libraries you need to download separately and build: Libraries you need to download separately and build:
default path download default path download
wxWidgets-2.9 \wxwidgets http://www.wxwidgets.org/downloads/ wxWidgets-2.9 \wxwidgets http://www.wxwidgets.org/downloads/
OpenSSL \openssl http://www.openssl.org/source/ OpenSSL \openssl http://www.openssl.org/source/
Berkeley DB \db http://www.oracle.com/technology/software/products/berkeley-db/index.html Berkeley DB \db http://www.oracle.com/technology/software/products/berkeley-db/index.html
Boost \boost http://www.boost.org/users/download/ Boost \boost http://www.boost.org/users/download/
Their licenses: Their licenses:
wxWidgets LGPL 2.1 with very liberal exceptions wxWidgets LGPL 2.1 with very liberal exceptions
OpenSSL Old BSD license with the problematic advertising requirement OpenSSL Old BSD license with the problematic advertising requirement
Berkeley DB New BSD license with additional requirement that linked software must be free open source Berkeley DB New BSD license with additional requirement that linked software must be free open source
Boost MIT-like license Boost MIT-like license
Versions used in this release: Versions used in this release:
MinGW GCC 3.4.5 MinGW GCC 3.4.5
wxWidgets 2.9.0 wxWidgets 2.9.0
OpenSSL 0.9.8k OpenSSL 0.9.8k
Berkeley DB 4.7.25.NC Berkeley DB 4.7.25.NC
Boost 1.42.1 Boost 1.42.1
Notes Notes
----- -----
The UI layout is edited with wxFormBuilder. The project file is The UI layout is edited with wxFormBuilder. The project file is
uiproject.fbp. It generates uibase.cpp and uibase.h, which define base uiproject.fbp. It generates uibase.cpp and uibase.h, which define base
classes that do the rote work of constructing all the UI elements. classes that do the rote work of constructing all the UI elements.
The release is built with GCC and then "strip bitcoin.exe" to strip the debug The release is built with GCC and then "strip bitcoin.exe" to strip the debug
symbols, which reduces the executable size by about 90%. symbols, which reduces the executable size by about 90%.
wxWidgets wxWidgets
--------- ---------
cd \wxwidgets\build\msw cd \wxwidgets\build\msw
make -f makefile.gcc make -f makefile.gcc
or or
nmake -f makefile.vc nmake -f makefile.vc
OpenSSL OpenSSL
------- -------
Bitcoin does not use any encryption. If you want to do a no-everything Bitcoin does not use any encryption. If you want to do a no-everything
build of OpenSSL to exclude encryption routines, a few patches are required. build of OpenSSL to exclude encryption routines, a few patches are required.
(instructions for OpenSSL v0.9.8k) (instructions for OpenSSL v0.9.8k)
Edit engines\e_gmp.c and engines\e_capi.c and add this #ifndef around Edit engines\e_gmp.c and engines\e_capi.c and add this #ifndef around
the openssl/rsa.h include: the openssl/rsa.h include:
#ifndef OPENSSL_NO_RSA #ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h> #include <openssl/rsa.h>
#endif #endif
Edit ms\mingw32.bat and replace the Configure line's parameters with this Edit ms\mingw32.bat and replace the Configure line's parameters with this
no-everything list. You have to put this in the batch file because batch no-everything list. You have to put this in the batch file because batch
files can't take more than nine command line parameters. files can't take more than nine command line parameters.
perl Configure mingw threads no-rc2 no-rc4 no-rc5 no-idea no-des no-bf no-cast no-aes no-camellia no-seed no-rsa no-dh perl Configure mingw threads no-rc2 no-rc4 no-rc5 no-idea no-des no-bf no-cast no-aes no-camellia no-seed no-rsa no-dh
Also REM out the following line in ms\mingw32.bat after the mingw32-make Also REM out the following line in ms\mingw32.bat after the mingw32-make
line. The build fails after it's already finished building libeay32, which line. The build fails after it's already finished building libeay32, which
is all we care about, but the failure aborts the script before it runs is all we care about, but the failure aborts the script before it runs
dllwrap to generate libeay32.dll. dllwrap to generate libeay32.dll.
REM if errorlevel 1 goto end REM if errorlevel 1 goto end
Build Build
cd \openssl cd \openssl
ms\mingw32.bat ms\mingw32.bat
If you want to use it with MSVC, generate the .lib file If you want to use it with MSVC, generate the .lib file
lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib
Berkeley DB Berkeley DB
----------- -----------
Using MinGW and MSYS: Using MinGW and MSYS:
cd \db\build_unix cd \db\build_unix
sh ../dist/configure --enable-mingw --enable-cxx sh ../dist/configure --enable-mingw --enable-cxx
make make
Boost Boost
----- -----
download bjam.exe from download bjam.exe from
http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941 http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941
cd \boost cd \boost
bjam toolset=gcc --build-type=complete stage bjam toolset=gcc --build-type=complete stage
or or
bjam toolset=msvc --build-type=complete stage bjam toolset=msvc --build-type=complete stage

View file

@ -1,217 +1,217 @@
Copyright (c) 2009-2010 Satoshi Nakamoto Copyright (c) 2009-2010 Satoshi Nakamoto
Distributed under the MIT/X11 software license, see the accompanying Distributed under the MIT/X11 software license, see the accompanying
file license.txt or http://www.opensource.org/licenses/mit-license.php. file license.txt or http://www.opensource.org/licenses/mit-license.php.
This product includes software developed by the OpenSSL Project for use in This product includes software developed by the OpenSSL Project for use in
the OpenSSL Toolkit (http://www.openssl.org/). This product includes the OpenSSL Toolkit (http://www.openssl.org/). This product includes
cryptographic software written by Eric Young (eay@cryptsoft.com). cryptographic software written by Eric Young (eay@cryptsoft.com).
Mac OS X build instructions Mac OS X build instructions
Laszlo Hanyecz (solar@heliacal.net) Laszlo Hanyecz (solar@heliacal.net)
Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian. Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian.
All of the commands should be executed in Terminal.app.. it's in All of the commands should be executed in Terminal.app.. it's in
/Applications/Utilities /Applications/Utilities
You need to install XCode with all the options checked so that the compiler You need to install XCode with all the options checked so that the compiler
and everything is available in /usr not just /Developer and everything is available in /usr not just /Developer
I think it comes on the DVD but you can get the current version from I think it comes on the DVD but you can get the current version from
http://developer.apple.com http://developer.apple.com
1. Pick a directory to work inside.. something like ~/bitcoin works. The 1. Pick a directory to work inside.. something like ~/bitcoin works. The
structure I use looks like this: structure I use looks like this:
(~ is your home directory) (~ is your home directory)
~/bitcoin ~/bitcoin
~/bitcoin/trunk # source code ~/bitcoin/trunk # source code
~/bitcoin/deps # dependencies.. like libraries and headers needed to compile ~/bitcoin/deps # dependencies.. like libraries and headers needed to compile
~/bitcoin/Bitcoin.app # the application bundle where you can run the app ~/bitcoin/Bitcoin.app # the application bundle where you can run the app
Just execute: mkdir ~/bitcoin Just execute: mkdir ~/bitcoin
This will create the top dir for you.. This will create the top dir for you..
WARNING: do not use the ~ notation with the configure scripts.. use the full WARNING: do not use the ~ notation with the configure scripts.. use the full
name of the directory, for example /Users/james/bitcoin/deps for a user named name of the directory, for example /Users/james/bitcoin/deps for a user named
'james'. In my examples I am using 'macosuser' so make sure you change that. 'james'. In my examples I am using 'macosuser' so make sure you change that.
2. Check out the trunk version of the bitcoin code from subversion: 2. Check out the trunk version of the bitcoin code from subversion:
cd ~/bitcoin cd ~/bitcoin
svn checkout https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk svn checkout https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk
This will make ~/bitcoin/trunk for you with all the files from subversion. This will make ~/bitcoin/trunk for you with all the files from subversion.
3. Get and build the dependencies 3. Get and build the dependencies
Boost Boost
----- -----
Download from http://www.boost.org/users/download/ Download from http://www.boost.org/users/download/
I'm assuming it ended up in ~/Downloads.. I'm assuming it ended up in ~/Downloads..
mkdir ~/bitcoin/deps mkdir ~/bitcoin/deps
cd ~/bitcoin/deps cd ~/bitcoin/deps
tar xvjf ~/Downloads/boost_1_42_0.tar.bz2 tar xvjf ~/Downloads/boost_1_42_0.tar.bz2
cd boost_1_42_0 cd boost_1_42_0
./bootstrap.sh ./bootstrap.sh
./bjam architecture=combined address-model=32_64 macosx-version=10.6 macosx-version-min=10.5 link=static runtime-link=static --toolset=darwin --prefix=/Users/macosuser/bitcoin/deps install ./bjam architecture=combined address-model=32_64 macosx-version=10.6 macosx-version-min=10.5 link=static runtime-link=static --toolset=darwin --prefix=/Users/macosuser/bitcoin/deps install
This part takes a while.. use your judgement and fix it if something doesn't This part takes a while.. use your judgement and fix it if something doesn't
build for some reason. build for some reason.
Change the prefix to whatever your directory is (my username in this example Change the prefix to whatever your directory is (my username in this example
is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change
to 10.5 if you're using leopard. to 10.5 if you're using leopard.
This is what my output looked like at the end: This is what my output looked like at the end:
...failed updating 2 targets... ...failed updating 2 targets...
...skipped 144 targets... ...skipped 144 targets...
...updated 8074 targets... ...updated 8074 targets...
OpenSSL OpenSSL
------- -------
Download from http://www.openssl.org/source/ Download from http://www.openssl.org/source/
We would like to build this as a 32 bit/64 bit library so we actually build it We would like to build this as a 32 bit/64 bit library so we actually build it
2 times and join it together here.. If you downloaded with safari it already 2 times and join it together here.. If you downloaded with safari it already
uncompressed it so it will just be a tar not a tar.gz uncompressed it so it will just be a tar not a tar.gz
cd ~/bitcoin/deps cd ~/bitcoin/deps
tar xvf ~/Downloads/openssl-1.0.0.tar tar xvf ~/Downloads/openssl-1.0.0.tar
mv openssl-1.0.0 openssl-1.0.0-i386 mv openssl-1.0.0 openssl-1.0.0-i386
tar xvf ~/Downloads/openssl-1.0.0.tar tar xvf ~/Downloads/openssl-1.0.0.tar
mv openssl-1.0.0 openssl-1.0.0-x86_64 mv openssl-1.0.0 openssl-1.0.0-x86_64
# build i386 (32 bit intel) binary # build i386 (32 bit intel) binary
cd openssl-1.0.0-i386 cd openssl-1.0.0-i386
./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin-i386-cc && make ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin-i386-cc && make
make install # only do this on one of the architectures, to install the headers make install # only do this on one of the architectures, to install the headers
cd .. cd ..
# build x86_64 (64 bit intel) binary # build x86_64 (64 bit intel) binary
cd openssl-1.0.0-x86_64 cd openssl-1.0.0-x86_64
./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin64-x86_64-cc && make ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin64-x86_64-cc && make
cd .. cd ..
# combine the libs # combine the libs
cd ~/bitcoin/deps cd ~/bitcoin/deps
lipo -arch i386 openssl-1.0.0-i386/libcrypto.a -arch x86_64 openssl-1.0.0-x86_64/libcrypto.a -o lib/libcrypto.a -create lipo -arch i386 openssl-1.0.0-i386/libcrypto.a -arch x86_64 openssl-1.0.0-x86_64/libcrypto.a -o lib/libcrypto.a -create
lipo -arch i386 openssl-1.0.0-i386/libssl.a -arch x86_64 openssl-1.0.0-x86_64/libssl.a -o lib/libssl.a -create lipo -arch i386 openssl-1.0.0-i386/libssl.a -arch x86_64 openssl-1.0.0-x86_64/libssl.a -o lib/libssl.a -create
Verify your binaries Verify your binaries
file lib/libcrypto.a file lib/libcrypto.a
output should look like this: output should look like this:
ib/libcrypto.a: Mach-O universal binary with 2 architectures ib/libcrypto.a: Mach-O universal binary with 2 architectures
lib/libcrypto.a (for architecture i386): current ar archive random library lib/libcrypto.a (for architecture i386): current ar archive random library
lib/libcrypto.a (for architecture x86_64): current ar archive random library lib/libcrypto.a (for architecture x86_64): current ar archive random library
Berkeley DB Berkeley DB
----------- -----------
Download from http://freshmeat.net/projects/berkeleydb/ Download from http://freshmeat.net/projects/berkeleydb/
cd ~/bitcoin/deps cd ~/bitcoin/deps
tar xvf ~/Downloads/db-4.8.26.tar tar xvf ~/Downloads/db-4.8.26.tar
cd db-4.8.26/build_unix cd db-4.8.26/build_unix
../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install ../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install
wxWidgets wxWidgets
--------- ---------
This is the big one.. This is the big one..
Check it out from svn Check it out from svn
cd ~/bitcoin/deps cd ~/bitcoin/deps
svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk
This will make a wxWidgets-trunk directory in deps. This will make a wxWidgets-trunk directory in deps.
Use this script snippet, change your prefix to whatever your dir is: Use this script snippet, change your prefix to whatever your dir is:
PREFIX=~/bitcoin/deps PREFIX=~/bitcoin/deps
SRCDIR="$PREFIX/wxWidgets-trunk" SRCDIR="$PREFIX/wxWidgets-trunk"
BUILDDIR="$SRCDIR/macbuild" BUILDDIR="$SRCDIR/macbuild"
cd "$PREFIX" && cd "$PREFIX" &&
#svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk && #svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk &&
cd "$SRCDIR" && cd "$SRCDIR" &&
[ -f include/wx/hashmap.h.orig ] || cp include/wx/hashmap.h include/wx/hashmap.h.orig && [ -f include/wx/hashmap.h.orig ] || cp include/wx/hashmap.h include/wx/hashmap.h.orig &&
sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashmap.h.orig > include/wx/hashmap.h && sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashmap.h.orig > include/wx/hashmap.h &&
[ -f include/wx/hashset.h.orig ] || cp include/wx/hashset.h include/wx/hashset.h.orig && [ -f include/wx/hashset.h.orig ] || cp include/wx/hashset.h include/wx/hashset.h.orig &&
sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashset.h.orig > include/wx/hashset.h && sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashset.h.orig > include/wx/hashset.h &&
rm -vrf "$BUILDDIR" && rm -vrf "$BUILDDIR" &&
mkdir "$BUILDDIR" && mkdir "$BUILDDIR" &&
cd "$BUILDDIR" && cd "$BUILDDIR" &&
../configure --prefix="$PREFIX" \ ../configure --prefix="$PREFIX" \
--with-osx_cocoa \ --with-osx_cocoa \
--disable-shared \ --disable-shared \
--disable-debug_flag \ --disable-debug_flag \
--with-macosx-version-min=10.5 \ --with-macosx-version-min=10.5 \
--enable-stl \ --enable-stl \
--enable-utf8 \ --enable-utf8 \
--enable-universal_binary \ --enable-universal_binary \
--with-libjpeg=builtin \ --with-libjpeg=builtin \
--with-libpng=builtin \ --with-libpng=builtin \
--with-regex=builtin \ --with-regex=builtin \
--with-libtiff=builtin \ --with-libtiff=builtin \
--with-zlib=builtin \ --with-zlib=builtin \
--with-expat=builtin \ --with-expat=builtin \
--with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk && --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk &&
find . -name Makefile | find . -name Makefile |
while read i; do while read i; do
echo $i; echo $i;
sed 's/-arch i386/-arch i386 -arch x86_64/g' < "$i" > "$i".new && sed 's/-arch i386/-arch i386 -arch x86_64/g' < "$i" > "$i".new &&
mv "$i" "$i".old && mv "$i" "$i".old &&
mv "$i".new "$i"; mv "$i".new "$i";
done done
make && make &&
make install make install
Now you should be able to build bitcoin Now you should be able to build bitcoin
cd ~/bitcoin/trunk cd ~/bitcoin/trunk
make -f makefile.osx bitcoin make -f makefile.osx bitcoin
Before you can run it, you need to create an application bundle for Mac OS. Before you can run it, you need to create an application bundle for Mac OS.
Create the directories in terminal using mkdir and copy the files into place. Create the directories in terminal using mkdir and copy the files into place.
They are available at http://heliacal.net/~solar/bitcoin/mac-build/ They are available at http://heliacal.net/~solar/bitcoin/mac-build/
You need the Info.plist and the .ins file. The Contents/MacOS/bitcoin file is You need the Info.plist and the .ins file. The Contents/MacOS/bitcoin file is
the output of the build. the output of the build.
Your directory structure should look like this: Your directory structure should look like this:
Bitcoin.app Bitcoin.app
Bitcoin.app/Contents Bitcoin.app/Contents
Bitcoin.app/Contents/Info.plist Bitcoin.app/Contents/Info.plist
Bitcoin.app/Contents/MacOS Bitcoin.app/Contents/MacOS
Bitcoin.app/Contents/MacOS/bitcoin Bitcoin.app/Contents/MacOS/bitcoin
Bitcoin.app/Contents/Resources Bitcoin.app/Contents/Resources
Bitcoin.app/Contents/Resources/BitcoinAppIcon.icns Bitcoin.app/Contents/Resources/BitcoinAppIcon.icns
To run it you can just click the Bitcoin.app in Finder, or just do open To run it you can just click the Bitcoin.app in Finder, or just do open
~/bitcoin/Bitcoin.app ~/bitcoin/Bitcoin.app
If you want to run it with arguments you can just run it without backgrounding If you want to run it with arguments you can just run it without backgrounding
by specifying the full name in terminal: by specifying the full name in terminal:
~/bitcoin/Bitcoin.app/Contents/MacOS/bitcoin -addnode=192.75.207.66 ~/bitcoin/Bitcoin.app/Contents/MacOS/bitcoin -addnode=192.75.207.66

View file

@ -1,80 +1,80 @@
Copyright (c) 2009-2010 Satoshi Nakamoto Copyright (c) 2009-2010 Satoshi Nakamoto
Distributed under the MIT/X11 software license, see the accompanying Distributed under the MIT/X11 software license, see the accompanying
file license.txt or http://www.opensource.org/licenses/mit-license.php. file license.txt or http://www.opensource.org/licenses/mit-license.php.
This product includes software developed by the OpenSSL Project for use in This product includes software developed by the OpenSSL Project for use in
the OpenSSL Toolkit (http://www.openssl.org/). This product includes the OpenSSL Toolkit (http://www.openssl.org/). This product includes
cryptographic software written by Eric Young (eay@cryptsoft.com). cryptographic software written by Eric Young (eay@cryptsoft.com).
UNIX BUILD NOTES UNIX BUILD NOTES
================ ================
Dependencies Dependencies
------------ ------------
sudo apt-get install build-essential sudo apt-get install build-essential
sudo apt-get install libgtk2.0-dev sudo apt-get install libgtk2.0-dev
sudo apt-get install libssl-dev sudo apt-get install libssl-dev
sudo apt-get install libdb4.7-dev sudo apt-get install libdb4.7-dev
sudo apt-get install libdb4.7++-dev sudo apt-get install libdb4.7++-dev
Boost 1.40+: sudo apt-get install libboost-all-dev Boost 1.40+: sudo apt-get install libboost-all-dev
or Boost 1.37: sudo apt-get install libboost1.37-dev or Boost 1.37: sudo apt-get install libboost1.37-dev
If using Boost 1.37, append -mt to the boost libraries in the makefile. If using Boost 1.37, append -mt to the boost libraries in the makefile.
We're now using wxWidgets 2.9, which uses UTF-8. Don't try 2.8, it won't work. We're now using wxWidgets 2.9, which uses UTF-8. Don't try 2.8, it won't work.
You need to download wxWidgets from http://www.wxwidgets.org/downloads/ You need to download wxWidgets from http://www.wxwidgets.org/downloads/
and build it yourself. See the build instructions and configure parameters and build it yourself. See the build instructions and configure parameters
below. below.
Licenses of statically linked libraries: Licenses of statically linked libraries:
wxWidgets LGPL 2.1 with very liberal exceptions wxWidgets LGPL 2.1 with very liberal exceptions
Berkeley DB New BSD license with additional requirement that linked software must be free open source Berkeley DB New BSD license with additional requirement that linked software must be free open source
Boost MIT-like license Boost MIT-like license
Versions used in this release: Versions used in this release:
GCC 4.3.3 GCC 4.3.3
OpenSSL 0.9.8g OpenSSL 0.9.8g
wxWidgets 2.9.0 wxWidgets 2.9.0
Berkeley DB 4.7.25.NC Berkeley DB 4.7.25.NC
Boost 1.37 Boost 1.37
Notes Notes
----- -----
The UI layout is edited with wxFormBuilder. The project file is The UI layout is edited with wxFormBuilder. The project file is
uiproject.fbp. It generates uibase.cpp and uibase.h, which define base uiproject.fbp. It generates uibase.cpp and uibase.h, which define base
classes that do the rote work of constructing all the UI elements. classes that do the rote work of constructing all the UI elements.
The release is built with GCC and then "strip bitcoin" to strip the debug The release is built with GCC and then "strip bitcoin" to strip the debug
symbols, which reduces the executable size by about 90%. symbols, which reduces the executable size by about 90%.
wxWidgets wxWidgets
--------- ---------
cd /usr/local cd /usr/local
tar -xzvf wxWidgets-2.9.0.tar.gz tar -xzvf wxWidgets-2.9.0.tar.gz
cd wxWidgets-2.9.0 cd wxWidgets-2.9.0
mkdir buildgtk mkdir buildgtk
cd buildgtk cd buildgtk
../configure --with-gtk --enable-debug --disable-shared --enable-monolithic ../configure --with-gtk --enable-debug --disable-shared --enable-monolithic
make make
sudo su sudo su
make install make install
ldconfig ldconfig
Berkeley DB Berkeley DB
----------- -----------
You need Berkeley DB 4.7. Don't use 4.8, the database/log0000* files You need Berkeley DB 4.7. Don't use 4.8, the database/log0000* files
are incompatible. If you have to build Berkeley DB yourself: are incompatible. If you have to build Berkeley DB yourself:
../dist/configure --enable-cxx ../dist/configure --enable-cxx
make make
Boost Boost
----- -----
If you need to build Boost yourself: If you need to build Boost yourself:
sudo su sudo su
./bootstrap.sh ./bootstrap.sh
./bjam install ./bjam install

View file

@ -1,67 +1,67 @@
Compilation Copyright (c) 1995-2009 by Wei Dai. All rights reserved. Compilation Copyright (c) 1995-2009 by Wei Dai. All rights reserved.
This copyright applies only to this software distribution package This copyright applies only to this software distribution package
as a compilation, and does not imply a copyright on any particular as a compilation, and does not imply a copyright on any particular
file in the package. file in the package.
The following files are copyrighted by their respective original authors, The following files are copyrighted by their respective original authors,
and their use is subject to additional licenses included in these files. and their use is subject to additional licenses included in these files.
mars.cpp - Copyright 1998 Brian Gladman. mars.cpp - Copyright 1998 Brian Gladman.
All other files in this compilation are placed in the public domain by All other files in this compilation are placed in the public domain by
Wei Dai and other contributors. Wei Dai and other contributors.
I would like to thank the following authors for placing their works into I would like to thank the following authors for placing their works into
the public domain: the public domain:
Joan Daemen - 3way.cpp Joan Daemen - 3way.cpp
Leonard Janke - cast.cpp, seal.cpp Leonard Janke - cast.cpp, seal.cpp
Steve Reid - cast.cpp Steve Reid - cast.cpp
Phil Karn - des.cpp Phil Karn - des.cpp
Andrew M. Kuchling - md2.cpp, md4.cpp Andrew M. Kuchling - md2.cpp, md4.cpp
Colin Plumb - md5.cpp Colin Plumb - md5.cpp
Seal Woods - rc6.cpp Seal Woods - rc6.cpp
Chris Morgan - rijndael.cpp Chris Morgan - rijndael.cpp
Paulo Baretto - rijndael.cpp, skipjack.cpp, square.cpp Paulo Baretto - rijndael.cpp, skipjack.cpp, square.cpp
Richard De Moliner - safer.cpp Richard De Moliner - safer.cpp
Matthew Skala - twofish.cpp Matthew Skala - twofish.cpp
Kevin Springle - camellia.cpp, shacal2.cpp, ttmac.cpp, whrlpool.cpp, ripemd.cpp Kevin Springle - camellia.cpp, shacal2.cpp, ttmac.cpp, whrlpool.cpp, ripemd.cpp
Permission to use, copy, modify, and distribute this compilation for Permission to use, copy, modify, and distribute this compilation for
any purpose, including commercial applications, is hereby granted any purpose, including commercial applications, is hereby granted
without fee, subject to the following restrictions: without fee, subject to the following restrictions:
1. Any copy or modification of this compilation in any form, except 1. Any copy or modification of this compilation in any form, except
in object code form as part of an application software, must include in object code form as part of an application software, must include
the above copyright notice and this license. the above copyright notice and this license.
2. Users of this software agree that any modification or extension 2. Users of this software agree that any modification or extension
they provide to Wei Dai will be considered public domain and not they provide to Wei Dai will be considered public domain and not
copyrighted unless it includes an explicit copyright notice. copyrighted unless it includes an explicit copyright notice.
3. Wei Dai makes no warranty or representation that the operation of the 3. Wei Dai makes no warranty or representation that the operation of the
software in this compilation will be error-free, and Wei Dai is under no software in this compilation will be error-free, and Wei Dai is under no
obligation to provide any services, by way of maintenance, update, or obligation to provide any services, by way of maintenance, update, or
otherwise. THE SOFTWARE AND ANY DOCUMENTATION ARE PROVIDED "AS IS" otherwise. THE SOFTWARE AND ANY DOCUMENTATION ARE PROVIDED "AS IS"
WITHOUT EXPRESS OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO, WITHOUT EXPRESS OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT WILL WEI DAI OR ANY OTHER CONTRIBUTOR BE LIABLE FOR PURPOSE. IN NO EVENT WILL WEI DAI OR ANY OTHER CONTRIBUTOR BE LIABLE FOR
DIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF DIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
4. Users will not use Wei Dai or any other contributor's name in any 4. Users will not use Wei Dai or any other contributor's name in any
publicity or advertising, without prior written consent in each case. publicity or advertising, without prior written consent in each case.
5. Export of this software from the United States may require a 5. Export of this software from the United States may require a
specific license from the United States Government. It is the specific license from the United States Government. It is the
responsibility of any person or organization contemplating export responsibility of any person or organization contemplating export
to obtain such a license before exporting. to obtain such a license before exporting.
6. Certain parts of this software may be protected by patents. It 6. Certain parts of this software may be protected by patents. It
is the users' responsibility to obtain the appropriate is the users' responsibility to obtain the appropriate
licenses before using those parts. licenses before using those parts.
If this compilation is used in object code form in an application If this compilation is used in object code form in an application
software, acknowledgement of the author is not required but would be software, acknowledgement of the author is not required but would be
appreciated. The contribution of any useful modifications or extensions appreciated. The contribution of any useful modifications or extensions
to Wei Dai is not required but would also be appreciated. to Wei Dai is not required but would also be appreciated.

View file

@ -1,429 +1,429 @@
Crypto++: a C++ Class Library of Cryptographic Schemes Crypto++: a C++ Class Library of Cryptographic Schemes
Version 5.6.0 (3/15/2009) Version 5.6.0 (3/15/2009)
Crypto++ Library is a free C++ class library of cryptographic schemes. Crypto++ Library is a free C++ class library of cryptographic schemes.
Currently the library contains the following algorithms: Currently the library contains the following algorithms:
algorithm type name algorithm type name
authenticated encryption schemes GCM, CCM, EAX authenticated encryption schemes GCM, CCM, EAX
high speed stream ciphers Panama, Sosemanuk, Salsa20, XSalsa20 high speed stream ciphers Panama, Sosemanuk, Salsa20, XSalsa20
AES and AES candidates AES (Rijndael), RC6, MARS, Twofish, Serpent, AES and AES candidates AES (Rijndael), RC6, MARS, Twofish, Serpent,
CAST-256 CAST-256
IDEA, Triple-DES (DES-EDE2 and DES-EDE3), IDEA, Triple-DES (DES-EDE2 and DES-EDE3),
other block ciphers Camellia, SEED, RC5, Blowfish, TEA, XTEA, other block ciphers Camellia, SEED, RC5, Blowfish, TEA, XTEA,
Skipjack, SHACAL-2 Skipjack, SHACAL-2
block cipher modes of operation ECB, CBC, CBC ciphertext stealing (CTS), block cipher modes of operation ECB, CBC, CBC ciphertext stealing (CTS),
CFB, OFB, counter mode (CTR) CFB, OFB, counter mode (CTR)
message authentication codes VMAC, HMAC, CMAC, CBC-MAC, DMAC, message authentication codes VMAC, HMAC, CMAC, CBC-MAC, DMAC,
Two-Track-MAC Two-Track-MAC
SHA-1, SHA-2 (SHA-224, SHA-256, SHA-384, and SHA-1, SHA-2 (SHA-224, SHA-256, SHA-384, and
hash functions SHA-512), Tiger, WHIRLPOOL, RIPEMD-128, hash functions SHA-512), Tiger, WHIRLPOOL, RIPEMD-128,
RIPEMD-256, RIPEMD-160, RIPEMD-320 RIPEMD-256, RIPEMD-160, RIPEMD-320
RSA, DSA, ElGamal, Nyberg-Rueppel (NR), RSA, DSA, ElGamal, Nyberg-Rueppel (NR),
public-key cryptography Rabin, Rabin-Williams (RW), LUC, LUCELG, public-key cryptography Rabin, Rabin-Williams (RW), LUC, LUCELG,
DLIES (variants of DHAES), ESIGN DLIES (variants of DHAES), ESIGN
padding schemes for public-key PKCS#1 v2.0, OAEP, PSS, PSSR, IEEE P1363 padding schemes for public-key PKCS#1 v2.0, OAEP, PSS, PSSR, IEEE P1363
systems EMSA2 and EMSA5 systems EMSA2 and EMSA5
Diffie-Hellman (DH), Unified Diffie-Hellman Diffie-Hellman (DH), Unified Diffie-Hellman
key agreement schemes (DH2), Menezes-Qu-Vanstone (MQV), LUCDIF, key agreement schemes (DH2), Menezes-Qu-Vanstone (MQV), LUCDIF,
XTR-DH XTR-DH
elliptic curve cryptography ECDSA, ECNR, ECIES, ECDH, ECMQV elliptic curve cryptography ECDSA, ECNR, ECIES, ECDH, ECMQV
insecure or obsolescent MD2, MD4, MD5, Panama Hash, DES, ARC4, SEAL insecure or obsolescent MD2, MD4, MD5, Panama Hash, DES, ARC4, SEAL
algorithms retained for backwards 3.0, WAKE, WAKE-OFB, DESX (DES-XEX3), RC2, algorithms retained for backwards 3.0, WAKE, WAKE-OFB, DESX (DES-XEX3), RC2,
compatibility and historical SAFER, 3-WAY, GOST, SHARK, CAST-128, Square compatibility and historical SAFER, 3-WAY, GOST, SHARK, CAST-128, Square
value value
Other features include: Other features include:
* pseudo random number generators (PRNG): ANSI X9.17 appendix C, RandomPool * pseudo random number generators (PRNG): ANSI X9.17 appendix C, RandomPool
* password based key derivation functions: PBKDF1 and PBKDF2 from PKCS #5, * password based key derivation functions: PBKDF1 and PBKDF2 from PKCS #5,
PBKDF from PKCS #12 appendix B PBKDF from PKCS #12 appendix B
* Shamir's secret sharing scheme and Rabin's information dispersal algorithm * Shamir's secret sharing scheme and Rabin's information dispersal algorithm
(IDA) (IDA)
* fast multi-precision integer (bignum) and polynomial operations * fast multi-precision integer (bignum) and polynomial operations
* finite field arithmetics, including GF(p) and GF(2^n) * finite field arithmetics, including GF(p) and GF(2^n)
* prime number generation and verification * prime number generation and verification
* useful non-cryptographic algorithms * useful non-cryptographic algorithms
+ DEFLATE (RFC 1951) compression/decompression with gzip (RFC 1952) and + DEFLATE (RFC 1951) compression/decompression with gzip (RFC 1952) and
zlib (RFC 1950) format support zlib (RFC 1950) format support
+ hex, base-32, and base-64 coding/decoding + hex, base-32, and base-64 coding/decoding
+ 32-bit CRC and Adler32 checksum + 32-bit CRC and Adler32 checksum
* class wrappers for these operating system features (optional): * class wrappers for these operating system features (optional):
+ high resolution timers on Windows, Unix, and Mac OS + high resolution timers on Windows, Unix, and Mac OS
+ Berkeley and Windows style sockets + Berkeley and Windows style sockets
+ Windows named pipes + Windows named pipes
+ /dev/random, /dev/urandom, /dev/srandom + /dev/random, /dev/urandom, /dev/srandom
+ Microsoft's CryptGenRandom on Windows + Microsoft's CryptGenRandom on Windows
* A high level interface for most of the above, using a filter/pipeline * A high level interface for most of the above, using a filter/pipeline
metaphor metaphor
* benchmarks and validation testing * benchmarks and validation testing
* x86, x86-64 (x64), MMX, and SSE2 assembly code for the most commonly used * x86, x86-64 (x64), MMX, and SSE2 assembly code for the most commonly used
algorithms, with run-time CPU feature detection and code selection algorithms, with run-time CPU feature detection and code selection
* some versions are available in FIPS 140-2 validated form * some versions are available in FIPS 140-2 validated form
You are welcome to use it for any purpose without paying me, but see You are welcome to use it for any purpose without paying me, but see
License.txt for the fine print. License.txt for the fine print.
The following compilers are supported for this release. Please visit The following compilers are supported for this release. Please visit
http://www.cryptopp.com the most up to date build instructions and porting notes. http://www.cryptopp.com the most up to date build instructions and porting notes.
* MSVC 6.0 - 2008 * MSVC 6.0 - 2008
* GCC 3.3 - 4.3 * GCC 3.3 - 4.3
* C++Builder 2009 * C++Builder 2009
* Intel C++ Compiler 9 - 11 * Intel C++ Compiler 9 - 11
* Sun Studio 12 (CC 5.9) * Sun Studio 12 (CC 5.9)
*** Important Usage Notes *** *** Important Usage Notes ***
1. If a constructor for A takes a pointer to an object B (except primitive 1. If a constructor for A takes a pointer to an object B (except primitive
types such as int and char), then A owns B and will delete B at A's types such as int and char), then A owns B and will delete B at A's
destruction. If a constructor for A takes a reference to an object B, destruction. If a constructor for A takes a reference to an object B,
then the caller retains ownership of B and should not destroy it until then the caller retains ownership of B and should not destroy it until
A no longer needs it. A no longer needs it.
2. Crypto++ is thread safe at the class level. This means you can use 2. Crypto++ is thread safe at the class level. This means you can use
Crypto++ safely in a multithreaded application, but you must provide Crypto++ safely in a multithreaded application, but you must provide
synchronization when multiple threads access a common Crypto++ object. synchronization when multiple threads access a common Crypto++ object.
*** MSVC-Specific Information *** *** MSVC-Specific Information ***
On Windows, Crypto++ can be compiled into 3 forms: a static library On Windows, Crypto++ can be compiled into 3 forms: a static library
including all algorithms, a DLL with only FIPS Approved algorithms, and including all algorithms, a DLL with only FIPS Approved algorithms, and
a static library with only algorithms not in the DLL. a static library with only algorithms not in the DLL.
(FIPS Approved means Approved according to the FIPS 140-2 standard.) (FIPS Approved means Approved according to the FIPS 140-2 standard.)
The DLL may be used by itself, or it may be used together with the second The DLL may be used by itself, or it may be used together with the second
form of the static library. MSVC project files are included to build form of the static library. MSVC project files are included to build
all three forms, and sample applications using each of the three forms all three forms, and sample applications using each of the three forms
are also included. are also included.
To compile Crypto++ with MSVC, open the "cryptest.dsw" (for MSVC 6 and MSVC .NET To compile Crypto++ with MSVC, open the "cryptest.dsw" (for MSVC 6 and MSVC .NET
2003) or "cryptest.sln" (for MSVC .NET 2005) workspace file and build one or 2003) or "cryptest.sln" (for MSVC .NET 2005) workspace file and build one or
more of the following projects: more of the following projects:
cryptdll - This builds the DLL. Please note that if you wish to use Crypto++ cryptdll - This builds the DLL. Please note that if you wish to use Crypto++
as a FIPS validated module, you must use a pre-built DLL that has undergone as a FIPS validated module, you must use a pre-built DLL that has undergone
the FIPS validation process instead of building your own. the FIPS validation process instead of building your own.
dlltest - This builds a sample application that only uses the DLL. dlltest - This builds a sample application that only uses the DLL.
cryptest Non-DLL-Import Configuration - This builds the full static library cryptest Non-DLL-Import Configuration - This builds the full static library
along with a full test driver. along with a full test driver.
cryptest DLL-Import Configuration - This builds a static library containing cryptest DLL-Import Configuration - This builds a static library containing
only algorithms not in the DLL, along with a full test driver that uses only algorithms not in the DLL, along with a full test driver that uses
both the DLL and the static library. both the DLL and the static library.
To use the Crypto++ DLL in your application, #include "dll.h" before including To use the Crypto++ DLL in your application, #include "dll.h" before including
any other Crypto++ header files, and place the DLL in the same directory as any other Crypto++ header files, and place the DLL in the same directory as
your .exe file. dll.h includes the line #pragma comment(lib, "cryptopp") your .exe file. dll.h includes the line #pragma comment(lib, "cryptopp")
so you don't have to explicitly list the import library in your project so you don't have to explicitly list the import library in your project
settings. To use a static library form of Crypto++, specify it as settings. To use a static library form of Crypto++, specify it as
an additional library to link with in your project settings. an additional library to link with in your project settings.
In either case you should check the compiler options to In either case you should check the compiler options to
make sure that the library and your application are using the same C++ make sure that the library and your application are using the same C++
run-time libraries and calling conventions. run-time libraries and calling conventions.
*** DLL Memory Management *** *** DLL Memory Management ***
Because it's possible for the Crypto++ DLL to delete objects allocated Because it's possible for the Crypto++ DLL to delete objects allocated
by the calling application, they must use the same C++ memory heap. Three by the calling application, they must use the same C++ memory heap. Three
methods are provided to achieve this. methods are provided to achieve this.
1. The calling application can tell Crypto++ what heap to use. This method 1. The calling application can tell Crypto++ what heap to use. This method
is required when the calling application uses a non-standard heap. is required when the calling application uses a non-standard heap.
2. Crypto++ can tell the calling application what heap to use. This method 2. Crypto++ can tell the calling application what heap to use. This method
is required when the calling application uses a statically linked C++ Run is required when the calling application uses a statically linked C++ Run
Time Library. (Method 1 does not work in this case because the Crypto++ DLL Time Library. (Method 1 does not work in this case because the Crypto++ DLL
is initialized before the calling application's heap is initialized.) is initialized before the calling application's heap is initialized.)
3. Crypto++ can automatically use the heap provided by the calling application's 3. Crypto++ can automatically use the heap provided by the calling application's
dynamically linked C++ Run Time Library. The calling application must dynamically linked C++ Run Time Library. The calling application must
make sure that the dynamically linked C++ Run Time Library is initialized make sure that the dynamically linked C++ Run Time Library is initialized
before Crypto++ is loaded. (At this time it is not clear if it is possible before Crypto++ is loaded. (At this time it is not clear if it is possible
to control the order in which DLLs are initialized on Windows 9x machines, to control the order in which DLLs are initialized on Windows 9x machines,
so it might be best to avoid using this method.) so it might be best to avoid using this method.)
When Crypto++ attaches to a new process, it searches all modules loaded When Crypto++ attaches to a new process, it searches all modules loaded
into the process space for exported functions "GetNewAndDeleteForCryptoPP" into the process space for exported functions "GetNewAndDeleteForCryptoPP"
and "SetNewAndDeleteFromCryptoPP". If one of these functions is found, and "SetNewAndDeleteFromCryptoPP". If one of these functions is found,
Crypto++ uses methods 1 or 2, respectively, by calling the function. Crypto++ uses methods 1 or 2, respectively, by calling the function.
Otherwise, method 3 is used. Otherwise, method 3 is used.
*** GCC-Specific Information *** *** GCC-Specific Information ***
A makefile is included for you to compile Crypto++ with GCC. Make sure A makefile is included for you to compile Crypto++ with GCC. Make sure
you are using GNU Make and GNU ld. The make process will produce two files, you are using GNU Make and GNU ld. The make process will produce two files,
libcryptopp.a and cryptest.exe. Run "cryptest.exe v" for the validation libcryptopp.a and cryptest.exe. Run "cryptest.exe v" for the validation
suite. suite.
*** Documentation and Support *** *** Documentation and Support ***
Crypto++ is documented through inline comments in header files, which are Crypto++ is documented through inline comments in header files, which are
processed through Doxygen to produce an HTML reference manual. You can find processed through Doxygen to produce an HTML reference manual. You can find
a link to the manual from http://www.cryptopp.com. Also at that site is a link to the manual from http://www.cryptopp.com. Also at that site is
the Crypto++ FAQ, which you should browse through before attempting to the Crypto++ FAQ, which you should browse through before attempting to
use this library, because it will likely answer many of questions that use this library, because it will likely answer many of questions that
may come up. may come up.
If you run into any problems, please try the Crypto++ mailing list. If you run into any problems, please try the Crypto++ mailing list.
The subscription information and the list archive are available on The subscription information and the list archive are available on
http://www.cryptopp.com. You can also email me directly by visiting http://www.cryptopp.com. You can also email me directly by visiting
http://www.weidai.com, but you will probably get a faster response through http://www.weidai.com, but you will probably get a faster response through
the mailing list. the mailing list.
*** History *** *** History ***
1.0 - First public release. Withdrawn at the request of RSA DSI. 1.0 - First public release. Withdrawn at the request of RSA DSI.
- included Blowfish, BBS, DES, DH, Diamond, DSA, ElGamal, IDEA, - included Blowfish, BBS, DES, DH, Diamond, DSA, ElGamal, IDEA,
MD5, RC4, RC5, RSA, SHA, WAKE, secret sharing, DEFLATE compression MD5, RC4, RC5, RSA, SHA, WAKE, secret sharing, DEFLATE compression
- had a serious bug in the RSA key generation code. - had a serious bug in the RSA key generation code.
1.1 - Removed RSA, RC4, RC5 1.1 - Removed RSA, RC4, RC5
- Disabled calls to RSAREF's non-public functions - Disabled calls to RSAREF's non-public functions
- Minor bugs fixed - Minor bugs fixed
2.0 - a completely new, faster multiprecision integer class 2.0 - a completely new, faster multiprecision integer class
- added MD5-MAC, HAVAL, 3-WAY, TEA, SAFER, LUC, Rabin, BlumGoldwasser, - added MD5-MAC, HAVAL, 3-WAY, TEA, SAFER, LUC, Rabin, BlumGoldwasser,
elliptic curve algorithms elliptic curve algorithms
- added the Lucas strong probable primality test - added the Lucas strong probable primality test
- ElGamal encryption and signature schemes modified to avoid weaknesses - ElGamal encryption and signature schemes modified to avoid weaknesses
- Diamond changed to Diamond2 because of key schedule weakness - Diamond changed to Diamond2 because of key schedule weakness
- fixed bug in WAKE key setup - fixed bug in WAKE key setup
- SHS class renamed to SHA - SHS class renamed to SHA
- lots of miscellaneous optimizations - lots of miscellaneous optimizations
2.1 - added Tiger, HMAC, GOST, RIPE-MD160, LUCELG, LUCDIF, XOR-MAC, 2.1 - added Tiger, HMAC, GOST, RIPE-MD160, LUCELG, LUCDIF, XOR-MAC,
OAEP, PSSR, SHARK OAEP, PSSR, SHARK
- added precomputation to DH, ElGamal, DSA, and elliptic curve algorithms - added precomputation to DH, ElGamal, DSA, and elliptic curve algorithms
- added back RC5 and a new RSA - added back RC5 and a new RSA
- optimizations in elliptic curves over GF(p) - optimizations in elliptic curves over GF(p)
- changed Rabin to use OAEP and PSSR - changed Rabin to use OAEP and PSSR
- changed many classes to allow copy constructors to work correctly - changed many classes to allow copy constructors to work correctly
- improved exception generation and handling - improved exception generation and handling
2.2 - added SEAL, CAST-128, Square 2.2 - added SEAL, CAST-128, Square
- fixed bug in HAVAL (padding problem) - fixed bug in HAVAL (padding problem)
- fixed bug in triple-DES (decryption order was reversed) - fixed bug in triple-DES (decryption order was reversed)
- fixed bug in RC5 (couldn't handle key length not a multiple of 4) - fixed bug in RC5 (couldn't handle key length not a multiple of 4)
- changed HMAC to conform to RFC-2104 (which is not compatible - changed HMAC to conform to RFC-2104 (which is not compatible
with the original HMAC) with the original HMAC)
- changed secret sharing and information dispersal to use GF(2^32) - changed secret sharing and information dispersal to use GF(2^32)
instead of GF(65521) instead of GF(65521)
- removed zero knowledge prover/verifier for graph isomorphism - removed zero knowledge prover/verifier for graph isomorphism
- removed several utility classes in favor of the C++ standard library - removed several utility classes in favor of the C++ standard library
2.3 - ported to EGCS 2.3 - ported to EGCS
- fixed incomplete workaround of min/max conflict in MSVC - fixed incomplete workaround of min/max conflict in MSVC
3.0 - placed all names into the "CryptoPP" namespace 3.0 - placed all names into the "CryptoPP" namespace
- added MD2, RC2, RC6, MARS, RW, DH2, MQV, ECDHC, CBC-CTS - added MD2, RC2, RC6, MARS, RW, DH2, MQV, ECDHC, CBC-CTS
- added abstract base classes PK_SimpleKeyAgreementDomain and - added abstract base classes PK_SimpleKeyAgreementDomain and
PK_AuthenticatedKeyAgreementDomain PK_AuthenticatedKeyAgreementDomain
- changed DH and LUCDIF to implement the PK_SimpleKeyAgreementDomain - changed DH and LUCDIF to implement the PK_SimpleKeyAgreementDomain
interface and to perform domain parameter and key validation interface and to perform domain parameter and key validation
- changed interfaces of PK_Signer and PK_Verifier to sign and verify - changed interfaces of PK_Signer and PK_Verifier to sign and verify
messages instead of message digests messages instead of message digests
- changed OAEP to conform to PKCS#1 v2.0 - changed OAEP to conform to PKCS#1 v2.0
- changed benchmark code to produce HTML tables as output - changed benchmark code to produce HTML tables as output
- changed PSSR to track IEEE P1363a - changed PSSR to track IEEE P1363a
- renamed ElGamalSignature to NR and changed it to track IEEE P1363 - renamed ElGamalSignature to NR and changed it to track IEEE P1363
- renamed ECKEP to ECMQVC and changed it to track IEEE P1363 - renamed ECKEP to ECMQVC and changed it to track IEEE P1363
- renamed several other classes for clarity - renamed several other classes for clarity
- removed support for calling RSAREF - removed support for calling RSAREF
- removed option to compile old SHA (SHA-0) - removed option to compile old SHA (SHA-0)
- removed option not to throw exceptions - removed option not to throw exceptions
3.1 - added ARC4, Rijndael, Twofish, Serpent, CBC-MAC, DMAC 3.1 - added ARC4, Rijndael, Twofish, Serpent, CBC-MAC, DMAC
- added interface for querying supported key lengths of symmetric ciphers - added interface for querying supported key lengths of symmetric ciphers
and MACs and MACs
- added sample code for RSA signature and verification - added sample code for RSA signature and verification
- changed CBC-CTS to be compatible with RFC 2040 - changed CBC-CTS to be compatible with RFC 2040
- updated SEAL to version 3.0 of the cipher specification - updated SEAL to version 3.0 of the cipher specification
- optimized multiprecision squaring and elliptic curves over GF(p) - optimized multiprecision squaring and elliptic curves over GF(p)
- fixed bug in MARS key setup - fixed bug in MARS key setup
- fixed bug with attaching objects to Deflator - fixed bug with attaching objects to Deflator
3.2 - added DES-XEX3, ECDSA, DefaultEncryptorWithMAC 3.2 - added DES-XEX3, ECDSA, DefaultEncryptorWithMAC
- renamed DES-EDE to DES-EDE2 and TripleDES to DES-EDE3 - renamed DES-EDE to DES-EDE2 and TripleDES to DES-EDE3
- optimized ARC4 - optimized ARC4
- generalized DSA to allow keys longer than 1024 bits - generalized DSA to allow keys longer than 1024 bits
- fixed bugs in GF2N and ModularArithmetic that can cause calculation errors - fixed bugs in GF2N and ModularArithmetic that can cause calculation errors
- fixed crashing bug in Inflator when given invalid inputs - fixed crashing bug in Inflator when given invalid inputs
- fixed endian bug in Serpent - fixed endian bug in Serpent
- fixed padding bug in Tiger - fixed padding bug in Tiger
4.0 - added Skipjack, CAST-256, Panama, SHA-2 (SHA-256, SHA-384, and SHA-512), 4.0 - added Skipjack, CAST-256, Panama, SHA-2 (SHA-256, SHA-384, and SHA-512),
and XTR-DH and XTR-DH
- added a faster variant of Rabin's Information Dispersal Algorithm (IDA) - added a faster variant of Rabin's Information Dispersal Algorithm (IDA)
- added class wrappers for these operating system features: - added class wrappers for these operating system features:
- high resolution timers on Windows, Unix, and MacOS - high resolution timers on Windows, Unix, and MacOS
- Berkeley and Windows style sockets - Berkeley and Windows style sockets
- Windows named pipes - Windows named pipes
- /dev/random and /dev/urandom on Linux and FreeBSD - /dev/random and /dev/urandom on Linux and FreeBSD
- Microsoft's CryptGenRandom on Windows - Microsoft's CryptGenRandom on Windows
- added support for SEC 1 elliptic curve key format and compressed points - added support for SEC 1 elliptic curve key format and compressed points
- added support for X.509 public key format (subjectPublicKeyInfo) for - added support for X.509 public key format (subjectPublicKeyInfo) for
RSA, DSA, and elliptic curve schemes RSA, DSA, and elliptic curve schemes
- added support for DER and OpenPGP signature format for DSA - added support for DER and OpenPGP signature format for DSA
- added support for ZLIB compressed data format (RFC 1950) - added support for ZLIB compressed data format (RFC 1950)
- changed elliptic curve encryption to use ECIES (as defined in SEC 1) - changed elliptic curve encryption to use ECIES (as defined in SEC 1)
- changed MARS key schedule to reflect the latest specification - changed MARS key schedule to reflect the latest specification
- changed BufferedTransformation interface to support multiple channels - changed BufferedTransformation interface to support multiple channels
and messages and messages
- changed CAST and SHA-1 implementations to use public domain source code - changed CAST and SHA-1 implementations to use public domain source code
- fixed bug in StringSource - fixed bug in StringSource
- optmized multi-precision integer code for better performance - optmized multi-precision integer code for better performance
4.1 - added more support for the recommended elliptic curve parameters in SEC 2 4.1 - added more support for the recommended elliptic curve parameters in SEC 2
- added Panama MAC, MARC4 - added Panama MAC, MARC4
- added IV stealing feature to CTS mode - added IV stealing feature to CTS mode
- added support for PKCS #8 private key format for RSA, DSA, and elliptic - added support for PKCS #8 private key format for RSA, DSA, and elliptic
curve schemes curve schemes
- changed Deflate, MD5, Rijndael, and Twofish to use public domain code - changed Deflate, MD5, Rijndael, and Twofish to use public domain code
- fixed a bug with flushing compressed streams - fixed a bug with flushing compressed streams
- fixed a bug with decompressing stored blocks - fixed a bug with decompressing stored blocks
- fixed a bug with EC point decompression using non-trinomial basis - fixed a bug with EC point decompression using non-trinomial basis
- fixed a bug in NetworkSource::GeneralPump() - fixed a bug in NetworkSource::GeneralPump()
- fixed a performance issue with EC over GF(p) decryption - fixed a performance issue with EC over GF(p) decryption
- fixed syntax to allow GCC to compile without -fpermissive - fixed syntax to allow GCC to compile without -fpermissive
- relaxed some restrictions in the license - relaxed some restrictions in the license
4.2 - added support for longer HMAC keys 4.2 - added support for longer HMAC keys
- added MD4 (which is not secure so use for compatibility purposes only) - added MD4 (which is not secure so use for compatibility purposes only)
- added compatibility fixes/workarounds for STLport 4.5, GCC 3.0.2, - added compatibility fixes/workarounds for STLport 4.5, GCC 3.0.2,
and MSVC 7.0 and MSVC 7.0
- changed MD2 to use public domain code - changed MD2 to use public domain code
- fixed a bug with decompressing multiple messages with the same object - fixed a bug with decompressing multiple messages with the same object
- fixed a bug in CBC-MAC with MACing multiple messages with the same object - fixed a bug in CBC-MAC with MACing multiple messages with the same object
- fixed a bug in RC5 and RC6 with zero-length keys - fixed a bug in RC5 and RC6 with zero-length keys
- fixed a bug in Adler32 where incorrect checksum may be generated - fixed a bug in Adler32 where incorrect checksum may be generated
5.0 - added ESIGN, DLIES, WAKE-OFB, PBKDF1 and PBKDF2 from PKCS #5 5.0 - added ESIGN, DLIES, WAKE-OFB, PBKDF1 and PBKDF2 from PKCS #5
- added key validation for encryption and signature public/private keys - added key validation for encryption and signature public/private keys
- renamed StreamCipher interface to SymmetricCipher, which is now implemented - renamed StreamCipher interface to SymmetricCipher, which is now implemented
by both stream ciphers and block cipher modes including ECB and CBC by both stream ciphers and block cipher modes including ECB and CBC
- added keying interfaces to support resetting of keys and IVs without - added keying interfaces to support resetting of keys and IVs without
having to destroy and recreate objects having to destroy and recreate objects
- changed filter interface to support non-blocking input/output - changed filter interface to support non-blocking input/output
- changed SocketSource and SocketSink to use overlapped I/O on Microsoft Windows - changed SocketSource and SocketSink to use overlapped I/O on Microsoft Windows
- grouped related classes inside structs to help templates, for example - grouped related classes inside structs to help templates, for example
AESEncryption and AESDecryption are now AES::Encryption and AES::Decryption AESEncryption and AESDecryption are now AES::Encryption and AES::Decryption
- where possible, typedefs have been added to improve backwards - where possible, typedefs have been added to improve backwards
compatibility when the CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY macro is defined compatibility when the CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY macro is defined
- changed Serpent, HAVAL and IDEA to use public domain code - changed Serpent, HAVAL and IDEA to use public domain code
- implemented SSE2 optimizations for Integer operations - implemented SSE2 optimizations for Integer operations
- fixed a bug in HMAC::TruncatedFinal() - fixed a bug in HMAC::TruncatedFinal()
- fixed SKIPJACK byte ordering following NIST clarification dated 5/9/02 - fixed SKIPJACK byte ordering following NIST clarification dated 5/9/02
5.01 - added known answer test for X9.17 RNG in FIPS 140 power-up self test 5.01 - added known answer test for X9.17 RNG in FIPS 140 power-up self test
- submitted to NIST/CSE, but not publicly released - submitted to NIST/CSE, but not publicly released
5.02 - changed EDC test to MAC integrity check using HMAC/SHA1 5.02 - changed EDC test to MAC integrity check using HMAC/SHA1
- improved performance of integrity check - improved performance of integrity check
- added blinding to defend against RSA timing attack - added blinding to defend against RSA timing attack
5.03 - created DLL version of Crypto++ for FIPS 140-2 validation 5.03 - created DLL version of Crypto++ for FIPS 140-2 validation
- fixed vulnerabilities in GetNextIV for CTR and OFB modes - fixed vulnerabilities in GetNextIV for CTR and OFB modes
5.0.4 - Removed DES, SHA-256, SHA-384, SHA-512 from DLL 5.0.4 - Removed DES, SHA-256, SHA-384, SHA-512 from DLL
5.1 - added PSS padding and changed PSSR to track IEEE P1363a draft standard 5.1 - added PSS padding and changed PSSR to track IEEE P1363a draft standard
- added blinding for RSA and Rabin to defend against timing attacks - added blinding for RSA and Rabin to defend against timing attacks
on decryption operations on decryption operations
- changed signing and decryption APIs to support the above - changed signing and decryption APIs to support the above
- changed WaitObjectContainer to allow waiting for more than 64 - changed WaitObjectContainer to allow waiting for more than 64
objects at a time on Win32 platforms objects at a time on Win32 platforms
- fixed a bug in CBC and ECB modes with processing non-aligned data - fixed a bug in CBC and ECB modes with processing non-aligned data
- fixed standard conformance bugs in DLIES (DHAES mode) and RW/EMSA2 - fixed standard conformance bugs in DLIES (DHAES mode) and RW/EMSA2
signature scheme (these fixes are not backwards compatible) signature scheme (these fixes are not backwards compatible)
- fixed a number of compiler warnings, minor bugs, and portability problems - fixed a number of compiler warnings, minor bugs, and portability problems
- removed Sapphire - removed Sapphire
5.2 - merged in changes for 5.01 - 5.0.4 5.2 - merged in changes for 5.01 - 5.0.4
- added support for using encoding parameters and key derivation parameters - added support for using encoding parameters and key derivation parameters
with public key encryption (implemented by OAEP and DL/ECIES) with public key encryption (implemented by OAEP and DL/ECIES)
- added Camellia, SHACAL-2, Two-Track-MAC, Whirlpool, RIPEMD-320, - added Camellia, SHACAL-2, Two-Track-MAC, Whirlpool, RIPEMD-320,
RIPEMD-128, RIPEMD-256, Base-32 coding, FIPS variant of CFB mode RIPEMD-128, RIPEMD-256, Base-32 coding, FIPS variant of CFB mode
- added ThreadUserTimer for timing thread CPU usage - added ThreadUserTimer for timing thread CPU usage
- added option for password-based key derivation functions - added option for password-based key derivation functions
to iterate until a mimimum elapsed thread CPU time is reached to iterate until a mimimum elapsed thread CPU time is reached
- added option (on by default) for DEFLATE compression to detect - added option (on by default) for DEFLATE compression to detect
uncompressible files and process them more quickly uncompressible files and process them more quickly
- improved compatibility and performance on 64-bit platforms, - improved compatibility and performance on 64-bit platforms,
including Alpha, IA-64, x86-64, PPC64, Sparc64, and MIPS64 including Alpha, IA-64, x86-64, PPC64, Sparc64, and MIPS64
- fixed ONE_AND_ZEROS_PADDING to use 0x80 instead 0x01 as padding. - fixed ONE_AND_ZEROS_PADDING to use 0x80 instead 0x01 as padding.
- fixed encoding/decoding of PKCS #8 privateKeyInfo to properly - fixed encoding/decoding of PKCS #8 privateKeyInfo to properly
handle optional attributes handle optional attributes
5.2.1 - fixed bug in the "dlltest" DLL testing program 5.2.1 - fixed bug in the "dlltest" DLL testing program
- fixed compiling with STLport using VC .NET - fixed compiling with STLport using VC .NET
- fixed compiling with -fPIC using GCC - fixed compiling with -fPIC using GCC
- fixed compiling with -msse2 on systems without memalign() - fixed compiling with -msse2 on systems without memalign()
- fixed inability to instantiate PanamaMAC - fixed inability to instantiate PanamaMAC
- fixed problems with inline documentation - fixed problems with inline documentation
5.2.2 - added SHA-224 5.2.2 - added SHA-224
- put SHA-256, SHA-384, SHA-512, RSASSA-PSS into DLL - put SHA-256, SHA-384, SHA-512, RSASSA-PSS into DLL
5.2.3 - fixed issues with FIPS algorithm test vectors 5.2.3 - fixed issues with FIPS algorithm test vectors
- put RSASSA-ISO into DLL - put RSASSA-ISO into DLL
5.3 - ported to MSVC 2005 with support for x86-64 5.3 - ported to MSVC 2005 with support for x86-64
- added defense against AES timing attacks, and more AES test vectors - added defense against AES timing attacks, and more AES test vectors
- changed StaticAlgorithmName() of Rijndael to "AES", CTR to "CTR" - changed StaticAlgorithmName() of Rijndael to "AES", CTR to "CTR"
5.4 - added Salsa20 5.4 - added Salsa20
- updated Whirlpool to version 3.0 - updated Whirlpool to version 3.0
- ported to GCC 4.1, Sun C++ 5.8, and Borland C++Builder 2006 - ported to GCC 4.1, Sun C++ 5.8, and Borland C++Builder 2006
5.5 - added VMAC and Sosemanuk (with x86-64 and SSE2 assembly) 5.5 - added VMAC and Sosemanuk (with x86-64 and SSE2 assembly)
- improved speed of integer arithmetic, AES, SHA-512, Tiger, Salsa20, - improved speed of integer arithmetic, AES, SHA-512, Tiger, Salsa20,
Whirlpool, and PANAMA cipher using assembly (x86-64, MMX, SSE2) Whirlpool, and PANAMA cipher using assembly (x86-64, MMX, SSE2)
- optimized Camellia and added defense against timing attacks - optimized Camellia and added defense against timing attacks
- updated benchmarks code to show cycles per byte and to time key/IV setup - updated benchmarks code to show cycles per byte and to time key/IV setup
- started using OpenMP for increased multi-core speed - started using OpenMP for increased multi-core speed
- enabled GCC optimization flags by default in GNUmakefile - enabled GCC optimization flags by default in GNUmakefile
- added blinding and computational error checking for RW signing - added blinding and computational error checking for RW signing
- changed RandomPool, X917RNG, GetNextIV, DSA/NR/ECDSA/ECNR to reduce - changed RandomPool, X917RNG, GetNextIV, DSA/NR/ECDSA/ECNR to reduce
the risk of reusing random numbers and IVs after virtual machine state the risk of reusing random numbers and IVs after virtual machine state
rollback rollback
- changed default FIPS mode RNG from AutoSeededX917RNG<DES_EDE3> to - changed default FIPS mode RNG from AutoSeededX917RNG<DES_EDE3> to
AutoSeededX917RNG<AES> AutoSeededX917RNG<AES>
- fixed PANAMA cipher interface to accept 256-bit key and 256-bit IV - fixed PANAMA cipher interface to accept 256-bit key and 256-bit IV
- moved MD2, MD4, MD5, PanamaHash, ARC4, WAKE_CFB into the namespace "Weak" - moved MD2, MD4, MD5, PanamaHash, ARC4, WAKE_CFB into the namespace "Weak"
- removed HAVAL, MD5-MAC, XMAC - removed HAVAL, MD5-MAC, XMAC
5.5.1 - fixed VMAC validation failure on 32-bit big-endian machines 5.5.1 - fixed VMAC validation failure on 32-bit big-endian machines
5.5.2 - ported x64 assembly language code for AES, Salsa20, Sosemanuk, and Panama 5.5.2 - ported x64 assembly language code for AES, Salsa20, Sosemanuk, and Panama
to MSVC 2005 (using MASM since MSVC doesn't support inline assembly on x64) to MSVC 2005 (using MASM since MSVC doesn't support inline assembly on x64)
- fixed Salsa20 initialization crash on non-SSE2 machines - fixed Salsa20 initialization crash on non-SSE2 machines
- fixed Whirlpool crash on Pentium 2 machines - fixed Whirlpool crash on Pentium 2 machines
- fixed possible branch prediction analysis (BPA) vulnerability in - fixed possible branch prediction analysis (BPA) vulnerability in
MontgomeryReduce(), which may affect security of RSA, RW, LUC MontgomeryReduce(), which may affect security of RSA, RW, LUC
- fixed link error with MSVC 2003 when using "debug DLL" form of runtime library - fixed link error with MSVC 2003 when using "debug DLL" form of runtime library
- fixed crash in SSE2_Add on P4 machines when compiled with - fixed crash in SSE2_Add on P4 machines when compiled with
MSVC 6.0 SP5 with Processor Pack MSVC 6.0 SP5 with Processor Pack
- ported to MSVC 2008, GCC 4.2, Sun CC 5.9, Intel C++ Compiler 10.0, - ported to MSVC 2008, GCC 4.2, Sun CC 5.9, Intel C++ Compiler 10.0,
and Borland C++Builder 2007 and Borland C++Builder 2007
5.6 - added AuthenticatedSymmetricCipher interface class and Filter wrappers 5.6 - added AuthenticatedSymmetricCipher interface class and Filter wrappers
- added CCM, GCM (with SSE2 assembly), EAX, CMAC, XSalsa20, and SEED - added CCM, GCM (with SSE2 assembly), EAX, CMAC, XSalsa20, and SEED
- added support for variable length IVs - added support for variable length IVs
- improved AES and SHA-256 speed on x86 and x64 - improved AES and SHA-256 speed on x86 and x64
- fixed incorrect VMAC computation on message lengths - fixed incorrect VMAC computation on message lengths
that are >64 mod 128 (x86 assembly version is not affected) that are >64 mod 128 (x86 assembly version is not affected)
- fixed compiler error in vmac.cpp on x86 with GCC -fPIC - fixed compiler error in vmac.cpp on x86 with GCC -fPIC
- fixed run-time validation error on x86-64 with GCC 4.3.2 -O2 - fixed run-time validation error on x86-64 with GCC 4.3.2 -O2
- fixed HashFilter bug when putMessage=true - fixed HashFilter bug when putMessage=true
- removed WORD64_AVAILABLE; compiler support for 64-bit int is now required - removed WORD64_AVAILABLE; compiler support for 64-bit int is now required
- ported to GCC 4.3, C++Builder 2009, Sun CC 5.10, Intel C++ Compiler 11 - ported to GCC 4.3, C++Builder 2009, Sun CC 5.10, Intel C++ Compiler 11
Written by Wei Dai Written by Wei Dai

View file

@ -1,462 +1,462 @@
#ifndef CRYPTOPP_CONFIG_H #ifndef CRYPTOPP_CONFIG_H
#define CRYPTOPP_CONFIG_H #define CRYPTOPP_CONFIG_H
//// Bitcoin: disable SSE2 on 32-bit //// Bitcoin: disable SSE2 on 32-bit
#if !defined(_M_X64) && !defined(__x86_64__) #if !defined(_M_X64) && !defined(__x86_64__)
#define CRYPTOPP_DISABLE_SSE2 1 #define CRYPTOPP_DISABLE_SSE2 1
#endif #endif
//////////// end of Bitcoin changes //////////// end of Bitcoin changes
// ***************** Important Settings ******************** // ***************** Important Settings ********************
// define this if running on a big-endian CPU // define this if running on a big-endian CPU
#if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__))) #if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__)))
# define IS_BIG_ENDIAN # define IS_BIG_ENDIAN
#endif #endif
// define this if running on a little-endian CPU // define this if running on a little-endian CPU
// big endian will be assumed if IS_LITTLE_ENDIAN is not defined // big endian will be assumed if IS_LITTLE_ENDIAN is not defined
#ifndef IS_BIG_ENDIAN #ifndef IS_BIG_ENDIAN
# define IS_LITTLE_ENDIAN # define IS_LITTLE_ENDIAN
#endif #endif
// define this if you want to disable all OS-dependent features, // define this if you want to disable all OS-dependent features,
// such as sockets and OS-provided random number generators // such as sockets and OS-provided random number generators
// #define NO_OS_DEPENDENCE // #define NO_OS_DEPENDENCE
// Define this to use features provided by Microsoft's CryptoAPI. // Define this to use features provided by Microsoft's CryptoAPI.
// Currently the only feature used is random number generation. // Currently the only feature used is random number generation.
// This macro will be ignored if NO_OS_DEPENDENCE is defined. // This macro will be ignored if NO_OS_DEPENDENCE is defined.
#define USE_MS_CRYPTOAPI #define USE_MS_CRYPTOAPI
// Define this to 1 to enforce the requirement in FIPS 186-2 Change Notice 1 that only 1024 bit moduli be used // Define this to 1 to enforce the requirement in FIPS 186-2 Change Notice 1 that only 1024 bit moduli be used
#ifndef DSA_1024_BIT_MODULUS_ONLY #ifndef DSA_1024_BIT_MODULUS_ONLY
# define DSA_1024_BIT_MODULUS_ONLY 1 # define DSA_1024_BIT_MODULUS_ONLY 1
#endif #endif
// ***************** Less Important Settings *************** // ***************** Less Important Settings ***************
// define this to retain (as much as possible) old deprecated function and class names // define this to retain (as much as possible) old deprecated function and class names
// #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY // #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
#define GZIP_OS_CODE 0 #define GZIP_OS_CODE 0
// Try this if your CPU has 256K internal cache or a slow multiply instruction // Try this if your CPU has 256K internal cache or a slow multiply instruction
// and you want a (possibly) faster IDEA implementation using log tables // and you want a (possibly) faster IDEA implementation using log tables
// #define IDEA_LARGECACHE // #define IDEA_LARGECACHE
// Define this if, for the linear congruential RNG, you want to use // Define this if, for the linear congruential RNG, you want to use
// the original constants as specified in S.K. Park and K.W. Miller's // the original constants as specified in S.K. Park and K.W. Miller's
// CACM paper. // CACM paper.
// #define LCRNG_ORIGINAL_NUMBERS // #define LCRNG_ORIGINAL_NUMBERS
// choose which style of sockets to wrap (mostly useful for cygwin which has both) // choose which style of sockets to wrap (mostly useful for cygwin which has both)
#define PREFER_BERKELEY_STYLE_SOCKETS #define PREFER_BERKELEY_STYLE_SOCKETS
// #define PREFER_WINDOWS_STYLE_SOCKETS // #define PREFER_WINDOWS_STYLE_SOCKETS
// set the name of Rijndael cipher, was "Rijndael" before version 5.3 // set the name of Rijndael cipher, was "Rijndael" before version 5.3
#define CRYPTOPP_RIJNDAEL_NAME "AES" #define CRYPTOPP_RIJNDAEL_NAME "AES"
// ***************** Important Settings Again ******************** // ***************** Important Settings Again ********************
// But the defaults should be ok. // But the defaults should be ok.
// namespace support is now required // namespace support is now required
#ifdef NO_NAMESPACE #ifdef NO_NAMESPACE
# error namespace support is now required # error namespace support is now required
#endif #endif
// Define this to workaround a Microsoft CryptoAPI bug where // Define this to workaround a Microsoft CryptoAPI bug where
// each call to CryptAcquireContext causes a 100 KB memory leak. // each call to CryptAcquireContext causes a 100 KB memory leak.
// Defining this will cause Crypto++ to make only one call to CryptAcquireContext. // Defining this will cause Crypto++ to make only one call to CryptAcquireContext.
#define WORKAROUND_MS_BUG_Q258000 #define WORKAROUND_MS_BUG_Q258000
#ifdef CRYPTOPP_DOXYGEN_PROCESSING #ifdef CRYPTOPP_DOXYGEN_PROCESSING
// Avoid putting "CryptoPP::" in front of everything in Doxygen output // Avoid putting "CryptoPP::" in front of everything in Doxygen output
# define CryptoPP # define CryptoPP
# define NAMESPACE_BEGIN(x) # define NAMESPACE_BEGIN(x)
# define NAMESPACE_END # define NAMESPACE_END
// Get Doxygen to generate better documentation for these typedefs // Get Doxygen to generate better documentation for these typedefs
# define DOCUMENTED_TYPEDEF(x, y) class y : public x {}; # define DOCUMENTED_TYPEDEF(x, y) class y : public x {};
#else #else
# define NAMESPACE_BEGIN(x) namespace x { # define NAMESPACE_BEGIN(x) namespace x {
# define NAMESPACE_END } # define NAMESPACE_END }
# define DOCUMENTED_TYPEDEF(x, y) typedef x y; # define DOCUMENTED_TYPEDEF(x, y) typedef x y;
#endif #endif
#define ANONYMOUS_NAMESPACE_BEGIN namespace { #define ANONYMOUS_NAMESPACE_BEGIN namespace {
#define USING_NAMESPACE(x) using namespace x; #define USING_NAMESPACE(x) using namespace x;
#define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x { #define DOCUMENTED_NAMESPACE_BEGIN(x) namespace x {
#define DOCUMENTED_NAMESPACE_END } #define DOCUMENTED_NAMESPACE_END }
// What is the type of the third parameter to bind? // What is the type of the third parameter to bind?
// For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int. // For Unix, the new standard is ::socklen_t (typically unsigned int), and the old standard is int.
// Unfortunately there is no way to tell whether or not socklen_t is defined. // Unfortunately there is no way to tell whether or not socklen_t is defined.
// To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile. // To work around this, TYPE_OF_SOCKLEN_T is a macro so that you can change it from the makefile.
#ifndef TYPE_OF_SOCKLEN_T #ifndef TYPE_OF_SOCKLEN_T
# if defined(_WIN32) || defined(__CYGWIN__) # if defined(_WIN32) || defined(__CYGWIN__)
# define TYPE_OF_SOCKLEN_T int # define TYPE_OF_SOCKLEN_T int
# else # else
# define TYPE_OF_SOCKLEN_T ::socklen_t # define TYPE_OF_SOCKLEN_T ::socklen_t
# endif # endif
#endif #endif
#if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS) #if defined(__CYGWIN__) && defined(PREFER_WINDOWS_STYLE_SOCKETS)
# define __USE_W32_SOCKETS # define __USE_W32_SOCKETS
#endif #endif
typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
typedef unsigned short word16; typedef unsigned short word16;
typedef unsigned int word32; typedef unsigned int word32;
#if defined(_MSC_VER) || defined(__BORLANDC__) #if defined(_MSC_VER) || defined(__BORLANDC__)
typedef unsigned __int64 word64; typedef unsigned __int64 word64;
#define W64LIT(x) x##ui64 #define W64LIT(x) x##ui64
#else #else
typedef unsigned long long word64; typedef unsigned long long word64;
#define W64LIT(x) x##ULL #define W64LIT(x) x##ULL
#endif #endif
// define large word type, used for file offsets and such // define large word type, used for file offsets and such
typedef word64 lword; typedef word64 lword;
const lword LWORD_MAX = W64LIT(0xffffffffffffffff); const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
#ifdef __GNUC__ #ifdef __GNUC__
#define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif #endif
// define hword, word, and dword. these are used for multiprecision integer arithmetic // define hword, word, and dword. these are used for multiprecision integer arithmetic
// Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
#if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__)) #if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__))
typedef word32 hword; typedef word32 hword;
typedef word64 word; typedef word64 word;
#else #else
#define CRYPTOPP_NATIVE_DWORD_AVAILABLE #define CRYPTOPP_NATIVE_DWORD_AVAILABLE
#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__) #if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__)) && CRYPTOPP_GCC_VERSION >= 30400
// GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3 // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
// mode(TI) division broken on amd64 with GCC earlier than GCC 3.4 // mode(TI) division broken on amd64 with GCC earlier than GCC 3.4
typedef word32 hword; typedef word32 hword;
typedef word64 word; typedef word64 word;
typedef __uint128_t dword; typedef __uint128_t dword;
typedef __uint128_t word128; typedef __uint128_t word128;
#define CRYPTOPP_WORD128_AVAILABLE #define CRYPTOPP_WORD128_AVAILABLE
#else #else
// if we're here, it means we're on a 64-bit CPU but we don't have a way to obtain 128-bit multiplication results // if we're here, it means we're on a 64-bit CPU but we don't have a way to obtain 128-bit multiplication results
typedef word16 hword; typedef word16 hword;
typedef word32 word; typedef word32 word;
typedef word64 dword; typedef word64 dword;
#endif #endif
#else #else
// being here means the native register size is probably 32 bits or less // being here means the native register size is probably 32 bits or less
#define CRYPTOPP_BOOL_SLOW_WORD64 1 #define CRYPTOPP_BOOL_SLOW_WORD64 1
typedef word16 hword; typedef word16 hword;
typedef word32 word; typedef word32 word;
typedef word64 dword; typedef word64 dword;
#endif #endif
#endif #endif
#ifndef CRYPTOPP_BOOL_SLOW_WORD64 #ifndef CRYPTOPP_BOOL_SLOW_WORD64
#define CRYPTOPP_BOOL_SLOW_WORD64 0 #define CRYPTOPP_BOOL_SLOW_WORD64 0
#endif #endif
const unsigned int WORD_SIZE = sizeof(word); const unsigned int WORD_SIZE = sizeof(word);
const unsigned int WORD_BITS = WORD_SIZE * 8; const unsigned int WORD_BITS = WORD_SIZE * 8;
NAMESPACE_END NAMESPACE_END
#ifndef CRYPTOPP_L1_CACHE_LINE_SIZE #ifndef CRYPTOPP_L1_CACHE_LINE_SIZE
// This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks. // This should be a lower bound on the L1 cache line size. It's used for defense against timing attacks.
#if defined(_M_X64) || defined(__x86_64__) #if defined(_M_X64) || defined(__x86_64__)
#define CRYPTOPP_L1_CACHE_LINE_SIZE 64 #define CRYPTOPP_L1_CACHE_LINE_SIZE 64
#else #else
// L1 cache line size is 32 on Pentium III and earlier // L1 cache line size is 32 on Pentium III and earlier
#define CRYPTOPP_L1_CACHE_LINE_SIZE 32 #define CRYPTOPP_L1_CACHE_LINE_SIZE 32
#endif #endif
#endif #endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if _MSC_VER == 1200 #if _MSC_VER == 1200
#include <malloc.h> #include <malloc.h>
#endif #endif
#if _MSC_VER > 1200 || defined(_mm_free) #if _MSC_VER > 1200 || defined(_mm_free)
#define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
#else #else
#define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack #define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
#endif #endif
#endif #endif
#ifndef CRYPTOPP_ALIGN_DATA #ifndef CRYPTOPP_ALIGN_DATA
#if defined(CRYPTOPP_MSVC6PP_OR_LATER) #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
#define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x)) #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x))) #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
#else #else
#define CRYPTOPP_ALIGN_DATA(x) #define CRYPTOPP_ALIGN_DATA(x)
#endif #endif
#endif #endif
#ifndef CRYPTOPP_SECTION_ALIGN16 #ifndef CRYPTOPP_SECTION_ALIGN16
#if defined(__GNUC__) && !defined(__APPLE__) #if defined(__GNUC__) && !defined(__APPLE__)
// the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on // the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
#define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16"))) #define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
#else #else
#define CRYPTOPP_SECTION_ALIGN16 #define CRYPTOPP_SECTION_ALIGN16
#endif #endif
#endif #endif
#if defined(_MSC_VER) || defined(__fastcall) #if defined(_MSC_VER) || defined(__fastcall)
#define CRYPTOPP_FASTCALL __fastcall #define CRYPTOPP_FASTCALL __fastcall
#else #else
#define CRYPTOPP_FASTCALL #define CRYPTOPP_FASTCALL
#endif #endif
// VC60 workaround: it doesn't allow typename in some places // VC60 workaround: it doesn't allow typename in some places
#if defined(_MSC_VER) && (_MSC_VER < 1300) #if defined(_MSC_VER) && (_MSC_VER < 1300)
#define CPP_TYPENAME #define CPP_TYPENAME
#else #else
#define CPP_TYPENAME typename #define CPP_TYPENAME typename
#endif #endif
// VC60 workaround: can't cast unsigned __int64 to float or double // VC60 workaround: can't cast unsigned __int64 to float or double
#if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER) #if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER)
#define CRYPTOPP_VC6_INT64 (__int64) #define CRYPTOPP_VC6_INT64 (__int64)
#else #else
#define CRYPTOPP_VC6_INT64 #define CRYPTOPP_VC6_INT64
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#define CRYPTOPP_NO_VTABLE __declspec(novtable) #define CRYPTOPP_NO_VTABLE __declspec(novtable)
#else #else
#define CRYPTOPP_NO_VTABLE #define CRYPTOPP_NO_VTABLE
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
// 4231: nonstandard extension used : 'extern' before template explicit instantiation // 4231: nonstandard extension used : 'extern' before template explicit instantiation
// 4250: dominance // 4250: dominance
// 4251: member needs to have dll-interface // 4251: member needs to have dll-interface
// 4275: base needs to have dll-interface // 4275: base needs to have dll-interface
// 4660: explicitly instantiating a class that's already implicitly instantiated // 4660: explicitly instantiating a class that's already implicitly instantiated
// 4661: no suitable definition provided for explicit template instantiation request // 4661: no suitable definition provided for explicit template instantiation request
// 4786: identifer was truncated in debug information // 4786: identifer was truncated in debug information
// 4355: 'this' : used in base member initializer list // 4355: 'this' : used in base member initializer list
// 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
# pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355 4910) # pragma warning(disable: 4231 4250 4251 4275 4660 4661 4786 4355 4910)
#endif #endif
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// 8037: non-const function called for const object. needed to work around BCB2006 bug // 8037: non-const function called for const object. needed to work around BCB2006 bug
# pragma warn -8037 # pragma warn -8037
#endif #endif
#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION) #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
#define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION #define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
#endif #endif
#ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION #ifndef CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
#define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
#endif #endif
#ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings #ifdef CRYPTOPP_DISABLE_X86ASM // for backwards compatibility: this macro had both meanings
#define CRYPTOPP_DISABLE_ASM #define CRYPTOPP_DISABLE_ASM
#define CRYPTOPP_DISABLE_SSE2 #define CRYPTOPP_DISABLE_SSE2
#endif #endif
#if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))) #if !defined(CRYPTOPP_DISABLE_ASM) && ((defined(_MSC_VER) && defined(_M_IX86)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))))
#define CRYPTOPP_X86_ASM_AVAILABLE #define CRYPTOPP_X86_ASM_AVAILABLE
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300) #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300)
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
#else #else
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0 #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
#endif #endif
// SSSE3 was actually introduced in GNU as 2.17, which was released 6/23/2006, but we can't tell what version of binutils is installed. // SSSE3 was actually introduced in GNU as 2.17, which was released 6/23/2006, but we can't tell what version of binutils is installed.
// GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version. // GCC 4.1.2 was released on 2/13/2007, so we'll use that as a proxy for the binutils version.
#if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102) #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1400 || CRYPTOPP_GCC_VERSION >= 40102)
#define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1 #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
#else #else
#define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0 #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
#endif #endif
#endif #endif
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64) #if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
#define CRYPTOPP_X64_MASM_AVAILABLE #define CRYPTOPP_X64_MASM_AVAILABLE
#endif #endif
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__) #if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
#define CRYPTOPP_X64_ASM_AVAILABLE #define CRYPTOPP_X64_ASM_AVAILABLE
#endif #endif
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1 #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
#else #else
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0 #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
#endif #endif
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
#define CRYPTOPP_BOOL_ALIGN16_ENABLED 1 #define CRYPTOPP_BOOL_ALIGN16_ENABLED 1
#else #else
#define CRYPTOPP_BOOL_ALIGN16_ENABLED 0 #define CRYPTOPP_BOOL_ALIGN16_ENABLED 0
#endif #endif
// how to allocate 16-byte aligned memory (for SSE2) // how to allocate 16-byte aligned memory (for SSE2)
#if defined(CRYPTOPP_MSVC6PP_OR_LATER) #if defined(CRYPTOPP_MSVC6PP_OR_LATER)
#define CRYPTOPP_MM_MALLOC_AVAILABLE #define CRYPTOPP_MM_MALLOC_AVAILABLE
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define CRYPTOPP_MALLOC_ALIGNMENT_IS_16 #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16
#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__) #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
#define CRYPTOPP_MEMALIGN_AVAILABLE #define CRYPTOPP_MEMALIGN_AVAILABLE
#else #else
#define CRYPTOPP_NO_ALIGNED_ALLOC #define CRYPTOPP_NO_ALIGNED_ALLOC
#endif #endif
// how to disable inlining // how to disable inlining
#if defined(_MSC_VER) && _MSC_VER >= 1300 #if defined(_MSC_VER) && _MSC_VER >= 1300
# define CRYPTOPP_NOINLINE_DOTDOTDOT # define CRYPTOPP_NOINLINE_DOTDOTDOT
# define CRYPTOPP_NOINLINE __declspec(noinline) # define CRYPTOPP_NOINLINE __declspec(noinline)
#elif defined(__GNUC__) #elif defined(__GNUC__)
# define CRYPTOPP_NOINLINE_DOTDOTDOT # define CRYPTOPP_NOINLINE_DOTDOTDOT
# define CRYPTOPP_NOINLINE __attribute__((noinline)) # define CRYPTOPP_NOINLINE __attribute__((noinline))
#else #else
# define CRYPTOPP_NOINLINE_DOTDOTDOT ... # define CRYPTOPP_NOINLINE_DOTDOTDOT ...
# define CRYPTOPP_NOINLINE # define CRYPTOPP_NOINLINE
#endif #endif
// how to declare class constants // how to declare class constants
#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) #if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER)
# define CRYPTOPP_CONSTANT(x) enum {x}; # define CRYPTOPP_CONSTANT(x) enum {x};
#else #else
# define CRYPTOPP_CONSTANT(x) static const int x; # define CRYPTOPP_CONSTANT(x) static const int x;
#endif #endif
#if defined(_M_X64) || defined(__x86_64__) #if defined(_M_X64) || defined(__x86_64__)
#define CRYPTOPP_BOOL_X64 1 #define CRYPTOPP_BOOL_X64 1
#else #else
#define CRYPTOPP_BOOL_X64 0 #define CRYPTOPP_BOOL_X64 0
#endif #endif
// see http://predef.sourceforge.net/prearch.html // see http://predef.sourceforge.net/prearch.html
#if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) #if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)
#define CRYPTOPP_BOOL_X86 1 #define CRYPTOPP_BOOL_X86 1
#else #else
#define CRYPTOPP_BOOL_X86 0 #define CRYPTOPP_BOOL_X86 0
#endif #endif
#if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || defined(__powerpc__) #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || defined(__powerpc__)
#define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
#endif #endif
#define CRYPTOPP_VERSION 560 #define CRYPTOPP_VERSION 560
// ***************** determine availability of OS features ******************** // ***************** determine availability of OS features ********************
#ifndef NO_OS_DEPENDENCE #ifndef NO_OS_DEPENDENCE
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
#define CRYPTOPP_WIN32_AVAILABLE #define CRYPTOPP_WIN32_AVAILABLE
#endif #endif
#if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun) #if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) || defined(__sun)
#define CRYPTOPP_UNIX_AVAILABLE #define CRYPTOPP_UNIX_AVAILABLE
#endif #endif
#if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE) #if defined(CRYPTOPP_WIN32_AVAILABLE) || defined(CRYPTOPP_UNIX_AVAILABLE)
# define HIGHRES_TIMER_AVAILABLE # define HIGHRES_TIMER_AVAILABLE
#endif #endif
#ifdef CRYPTOPP_UNIX_AVAILABLE #ifdef CRYPTOPP_UNIX_AVAILABLE
# define HAS_BERKELEY_STYLE_SOCKETS # define HAS_BERKELEY_STYLE_SOCKETS
#endif #endif
#ifdef CRYPTOPP_WIN32_AVAILABLE #ifdef CRYPTOPP_WIN32_AVAILABLE
# define HAS_WINDOWS_STYLE_SOCKETS # define HAS_WINDOWS_STYLE_SOCKETS
#endif #endif
#if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS)) #if defined(HIGHRES_TIMER_AVAILABLE) && (defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(HAS_WINDOWS_STYLE_SOCKETS))
# define SOCKETS_AVAILABLE # define SOCKETS_AVAILABLE
#endif #endif
#if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS)) #if defined(HAS_WINDOWS_STYLE_SOCKETS) && (!defined(HAS_BERKELEY_STYLE_SOCKETS) || defined(PREFER_WINDOWS_STYLE_SOCKETS))
# define USE_WINDOWS_STYLE_SOCKETS # define USE_WINDOWS_STYLE_SOCKETS
#else #else
# define USE_BERKELEY_STYLE_SOCKETS # define USE_BERKELEY_STYLE_SOCKETS
#endif #endif
#if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS) #if defined(HIGHRES_TIMER_AVAILABLE) && defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(USE_BERKELEY_STYLE_SOCKETS)
# define WINDOWS_PIPES_AVAILABLE # define WINDOWS_PIPES_AVAILABLE
#endif #endif
#if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI) #if defined(CRYPTOPP_WIN32_AVAILABLE) && defined(USE_MS_CRYPTOAPI)
# define NONBLOCKING_RNG_AVAILABLE # define NONBLOCKING_RNG_AVAILABLE
# define OS_RNG_AVAILABLE # define OS_RNG_AVAILABLE
#endif #endif
#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
# define NONBLOCKING_RNG_AVAILABLE # define NONBLOCKING_RNG_AVAILABLE
# define BLOCKING_RNG_AVAILABLE # define BLOCKING_RNG_AVAILABLE
# define OS_RNG_AVAILABLE # define OS_RNG_AVAILABLE
# define HAS_PTHREADS # define HAS_PTHREADS
# define THREADS_AVAILABLE # define THREADS_AVAILABLE
#endif #endif
#ifdef CRYPTOPP_WIN32_AVAILABLE #ifdef CRYPTOPP_WIN32_AVAILABLE
# define HAS_WINTHREADS # define HAS_WINTHREADS
# define THREADS_AVAILABLE # define THREADS_AVAILABLE
#endif #endif
#endif // NO_OS_DEPENDENCE #endif // NO_OS_DEPENDENCE
// ***************** DLL related ******************** // ***************** DLL related ********************
#ifdef CRYPTOPP_WIN32_AVAILABLE #ifdef CRYPTOPP_WIN32_AVAILABLE
#ifdef CRYPTOPP_EXPORTS #ifdef CRYPTOPP_EXPORTS
#define CRYPTOPP_IS_DLL #define CRYPTOPP_IS_DLL
#define CRYPTOPP_DLL __declspec(dllexport) #define CRYPTOPP_DLL __declspec(dllexport)
#elif defined(CRYPTOPP_IMPORTS) #elif defined(CRYPTOPP_IMPORTS)
#define CRYPTOPP_IS_DLL #define CRYPTOPP_IS_DLL
#define CRYPTOPP_DLL __declspec(dllimport) #define CRYPTOPP_DLL __declspec(dllimport)
#else #else
#define CRYPTOPP_DLL #define CRYPTOPP_DLL
#endif #endif
#define CRYPTOPP_API __cdecl #define CRYPTOPP_API __cdecl
#else // CRYPTOPP_WIN32_AVAILABLE #else // CRYPTOPP_WIN32_AVAILABLE
#define CRYPTOPP_DLL #define CRYPTOPP_DLL
#define CRYPTOPP_API #define CRYPTOPP_API
#endif // CRYPTOPP_WIN32_AVAILABLE #endif // CRYPTOPP_WIN32_AVAILABLE
#if defined(__MWERKS__) #if defined(__MWERKS__)
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
#elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
#else #else
#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
#endif #endif
#if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS) #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
#define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL #define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
#else #else
#define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS #define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
#endif #endif
#if defined(__MWERKS__) #if defined(__MWERKS__)
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
#elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
#else #else
#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
#endif #endif
#if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS) #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
#define CRYPTOPP_STATIC_TEMPLATE_CLASS template class #define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
#else #else
#define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS #define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
#endif #endif
#endif #endif

View file

@ -1,199 +1,199 @@
// cpu.cpp - written and placed in the public domain by Wei Dai // cpu.cpp - written and placed in the public domain by Wei Dai
#include "pch.h" #include "pch.h"
#ifndef CRYPTOPP_IMPORTS #ifndef CRYPTOPP_IMPORTS
#include "cpu.h" #include "cpu.h"
#include "misc.h" #include "misc.h"
#include <algorithm> #include <algorithm>
#ifdef __GNUC__ #ifdef __GNUC__
#include <signal.h> #include <signal.h>
#include <setjmp.h> #include <setjmp.h>
#endif #endif
#ifdef CRYPTOPP_MSVC6PP_OR_LATER #ifdef CRYPTOPP_MSVC6PP_OR_LATER
#include <emmintrin.h> #include <emmintrin.h>
#endif #endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#ifdef CRYPTOPP_X86_ASM_AVAILABLE #ifdef CRYPTOPP_X86_ASM_AVAILABLE
#ifndef _MSC_VER #ifndef _MSC_VER
typedef void (*SigHandler)(int); typedef void (*SigHandler)(int);
static jmp_buf s_jmpNoCPUID; static jmp_buf s_jmpNoCPUID;
static void SigIllHandlerCPUID(int) static void SigIllHandlerCPUID(int)
{ {
longjmp(s_jmpNoCPUID, 1); longjmp(s_jmpNoCPUID, 1);
} }
#endif #endif
bool CpuId(word32 input, word32 *output) bool CpuId(word32 input, word32 *output)
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
__try __try
{ {
__asm __asm
{ {
mov eax, input mov eax, input
cpuid cpuid
mov edi, output mov edi, output
mov [edi], eax mov [edi], eax
mov [edi+4], ebx mov [edi+4], ebx
mov [edi+8], ecx mov [edi+8], ecx
mov [edi+12], edx mov [edi+12], edx
} }
} }
__except (1) __except (1)
{ {
return false; return false;
} }
return true; return true;
#else #else
SigHandler oldHandler = signal(SIGILL, SigIllHandlerCPUID); SigHandler oldHandler = signal(SIGILL, SigIllHandlerCPUID);
if (oldHandler == SIG_ERR) if (oldHandler == SIG_ERR)
return false; return false;
bool result = true; bool result = true;
if (setjmp(s_jmpNoCPUID)) if (setjmp(s_jmpNoCPUID))
result = false; result = false;
else else
{ {
__asm__ __asm__
( (
// save ebx in case -fPIC is being used // save ebx in case -fPIC is being used
#if CRYPTOPP_BOOL_X86 #if CRYPTOPP_BOOL_X86
"push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx" "push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx"
#else #else
"pushq %%rbx; cpuid; mov %%ebx, %%edi; popq %%rbx" "pushq %%rbx; cpuid; mov %%ebx, %%edi; popq %%rbx"
#endif #endif
: "=a" (output[0]), "=D" (output[1]), "=c" (output[2]), "=d" (output[3]) : "=a" (output[0]), "=D" (output[1]), "=c" (output[2]), "=d" (output[3])
: "a" (input) : "a" (input)
); );
} }
signal(SIGILL, oldHandler); signal(SIGILL, oldHandler);
return result; return result;
#endif #endif
} }
#ifndef _MSC_VER #ifndef _MSC_VER
static jmp_buf s_jmpNoSSE2; static jmp_buf s_jmpNoSSE2;
static void SigIllHandlerSSE2(int) static void SigIllHandlerSSE2(int)
{ {
longjmp(s_jmpNoSSE2, 1); longjmp(s_jmpNoSSE2, 1);
} }
#endif #endif
#elif _MSC_VER >= 1400 && CRYPTOPP_BOOL_X64 #elif _MSC_VER >= 1400 && CRYPTOPP_BOOL_X64
bool CpuId(word32 input, word32 *output) bool CpuId(word32 input, word32 *output)
{ {
__cpuid((int *)output, input); __cpuid((int *)output, input);
return true; return true;
} }
#endif #endif
#ifdef CRYPTOPP_CPUID_AVAILABLE #ifdef CRYPTOPP_CPUID_AVAILABLE
static bool TrySSE2() static bool TrySSE2()
{ {
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64
return true; return true;
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
__try __try
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
AS2(por xmm0, xmm0) // executing SSE2 instruction AS2(por xmm0, xmm0) // executing SSE2 instruction
#elif CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #elif CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
__mm128i x = _mm_setzero_si128(); __mm128i x = _mm_setzero_si128();
return _mm_cvtsi128_si32(x) == 0; return _mm_cvtsi128_si32(x) == 0;
#endif #endif
} }
__except (1) __except (1)
{ {
return false; return false;
} }
return true; return true;
#elif defined(__GNUC__) #elif defined(__GNUC__)
SigHandler oldHandler = signal(SIGILL, SigIllHandlerSSE2); SigHandler oldHandler = signal(SIGILL, SigIllHandlerSSE2);
if (oldHandler == SIG_ERR) if (oldHandler == SIG_ERR)
return false; return false;
bool result = true; bool result = true;
if (setjmp(s_jmpNoSSE2)) if (setjmp(s_jmpNoSSE2))
result = false; result = false;
else else
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
__asm __volatile ("por %xmm0, %xmm0"); __asm __volatile ("por %xmm0, %xmm0");
#elif CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #elif CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
__mm128i x = _mm_setzero_si128(); __mm128i x = _mm_setzero_si128();
result = _mm_cvtsi128_si32(x) == 0; result = _mm_cvtsi128_si32(x) == 0;
#endif #endif
} }
signal(SIGILL, oldHandler); signal(SIGILL, oldHandler);
return result; return result;
#else #else
return false; return false;
#endif #endif
} }
bool g_x86DetectionDone = false; bool g_x86DetectionDone = false;
bool g_hasISSE = false, g_hasSSE2 = false, g_hasSSSE3 = false, g_hasMMX = false, g_isP4 = false; bool g_hasISSE = false, g_hasSSE2 = false, g_hasSSSE3 = false, g_hasMMX = false, g_isP4 = false;
word32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; word32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
void DetectX86Features() void DetectX86Features()
{ {
word32 cpuid[4], cpuid1[4]; word32 cpuid[4], cpuid1[4];
if (!CpuId(0, cpuid)) if (!CpuId(0, cpuid))
return; return;
if (!CpuId(1, cpuid1)) if (!CpuId(1, cpuid1))
return; return;
g_hasMMX = (cpuid1[3] & (1 << 23)) != 0; g_hasMMX = (cpuid1[3] & (1 << 23)) != 0;
if ((cpuid1[3] & (1 << 26)) != 0) if ((cpuid1[3] & (1 << 26)) != 0)
g_hasSSE2 = TrySSE2(); g_hasSSE2 = TrySSE2();
g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9)); g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9));
if ((cpuid1[3] & (1 << 25)) != 0) if ((cpuid1[3] & (1 << 25)) != 0)
g_hasISSE = true; g_hasISSE = true;
else else
{ {
word32 cpuid2[4]; word32 cpuid2[4];
CpuId(0x080000000, cpuid2); CpuId(0x080000000, cpuid2);
if (cpuid2[0] >= 0x080000001) if (cpuid2[0] >= 0x080000001)
{ {
CpuId(0x080000001, cpuid2); CpuId(0x080000001, cpuid2);
g_hasISSE = (cpuid2[3] & (1 << 22)) != 0; g_hasISSE = (cpuid2[3] & (1 << 22)) != 0;
} }
} }
std::swap(cpuid[2], cpuid[3]); std::swap(cpuid[2], cpuid[3]);
if (memcmp(cpuid+1, "GenuineIntel", 12) == 0) if (memcmp(cpuid+1, "GenuineIntel", 12) == 0)
{ {
g_isP4 = ((cpuid1[0] >> 8) & 0xf) == 0xf; g_isP4 = ((cpuid1[0] >> 8) & 0xf) == 0xf;
g_cacheLineSize = 8 * GETBYTE(cpuid1[1], 1); g_cacheLineSize = 8 * GETBYTE(cpuid1[1], 1);
} }
else if (memcmp(cpuid+1, "AuthenticAMD", 12) == 0) else if (memcmp(cpuid+1, "AuthenticAMD", 12) == 0)
{ {
CpuId(0x80000005, cpuid); CpuId(0x80000005, cpuid);
g_cacheLineSize = GETBYTE(cpuid[2], 0); g_cacheLineSize = GETBYTE(cpuid[2], 0);
} }
if (!g_cacheLineSize) if (!g_cacheLineSize)
g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
g_x86DetectionDone = true; g_x86DetectionDone = true;
} }
#endif #endif
NAMESPACE_END NAMESPACE_END
#endif #endif

View file

@ -1,263 +1,263 @@
#ifndef CRYPTOPP_CPU_H #ifndef CRYPTOPP_CPU_H
#define CRYPTOPP_CPU_H #define CRYPTOPP_CPU_H
#ifdef CRYPTOPP_GENERATE_X64_MASM #ifdef CRYPTOPP_GENERATE_X64_MASM
#define CRYPTOPP_X86_ASM_AVAILABLE #define CRYPTOPP_X86_ASM_AVAILABLE
#define CRYPTOPP_BOOL_X64 1 #define CRYPTOPP_BOOL_X64 1
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1 #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
#define NAMESPACE_END #define NAMESPACE_END
#else #else
#include "config.h" #include "config.h"
#ifdef CRYPTOPP_MSVC6PP_OR_LATER #ifdef CRYPTOPP_MSVC6PP_OR_LATER
#include <emmintrin.h> #include <emmintrin.h>
#endif #endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || (_MSC_VER >= 1400 && CRYPTOPP_BOOL_X64) #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || (_MSC_VER >= 1400 && CRYPTOPP_BOOL_X64)
#define CRYPTOPP_CPUID_AVAILABLE #define CRYPTOPP_CPUID_AVAILABLE
// these should not be used directly // these should not be used directly
extern CRYPTOPP_DLL bool g_x86DetectionDone; extern CRYPTOPP_DLL bool g_x86DetectionDone;
extern CRYPTOPP_DLL bool g_hasSSE2; extern CRYPTOPP_DLL bool g_hasSSE2;
extern CRYPTOPP_DLL bool g_hasISSE; extern CRYPTOPP_DLL bool g_hasISSE;
extern CRYPTOPP_DLL bool g_hasMMX; extern CRYPTOPP_DLL bool g_hasMMX;
extern CRYPTOPP_DLL bool g_hasSSSE3; extern CRYPTOPP_DLL bool g_hasSSSE3;
extern CRYPTOPP_DLL bool g_isP4; extern CRYPTOPP_DLL bool g_isP4;
extern CRYPTOPP_DLL word32 g_cacheLineSize; extern CRYPTOPP_DLL word32 g_cacheLineSize;
CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features(); CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features();
CRYPTOPP_DLL bool CRYPTOPP_API CpuId(word32 input, word32 *output); CRYPTOPP_DLL bool CRYPTOPP_API CpuId(word32 input, word32 *output);
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64
inline bool HasSSE2() {return true;} inline bool HasSSE2() {return true;}
inline bool HasISSE() {return true;} inline bool HasISSE() {return true;}
inline bool HasMMX() {return true;} inline bool HasMMX() {return true;}
#else #else
inline bool HasSSE2() inline bool HasSSE2()
{ {
if (!g_x86DetectionDone) if (!g_x86DetectionDone)
DetectX86Features(); DetectX86Features();
return g_hasSSE2; return g_hasSSE2;
} }
inline bool HasISSE() inline bool HasISSE()
{ {
if (!g_x86DetectionDone) if (!g_x86DetectionDone)
DetectX86Features(); DetectX86Features();
return g_hasISSE; return g_hasISSE;
} }
inline bool HasMMX() inline bool HasMMX()
{ {
if (!g_x86DetectionDone) if (!g_x86DetectionDone)
DetectX86Features(); DetectX86Features();
return g_hasMMX; return g_hasMMX;
} }
#endif #endif
inline bool HasSSSE3() inline bool HasSSSE3()
{ {
if (!g_x86DetectionDone) if (!g_x86DetectionDone)
DetectX86Features(); DetectX86Features();
return g_hasSSSE3; return g_hasSSSE3;
} }
inline bool IsP4() inline bool IsP4()
{ {
if (!g_x86DetectionDone) if (!g_x86DetectionDone)
DetectX86Features(); DetectX86Features();
return g_isP4; return g_isP4;
} }
inline int GetCacheLineSize() inline int GetCacheLineSize()
{ {
if (!g_x86DetectionDone) if (!g_x86DetectionDone)
DetectX86Features(); DetectX86Features();
return g_cacheLineSize; return g_cacheLineSize;
} }
#else #else
inline int GetCacheLineSize() inline int GetCacheLineSize()
{ {
return CRYPTOPP_L1_CACHE_LINE_SIZE; return CRYPTOPP_L1_CACHE_LINE_SIZE;
} }
inline bool HasSSSE3() {return false;} inline bool HasSSSE3() {return false;}
inline bool IsP4() {return false;} inline bool IsP4() {return false;}
// assume MMX and SSE2 if intrinsics are enabled // assume MMX and SSE2 if intrinsics are enabled
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_X64
inline bool HasSSE2() {return true;} inline bool HasSSE2() {return true;}
inline bool HasISSE() {return true;} inline bool HasISSE() {return true;}
inline bool HasMMX() {return true;} inline bool HasMMX() {return true;}
#else #else
inline bool HasSSE2() {return false;} inline bool HasSSE2() {return false;}
inline bool HasISSE() {return false;} inline bool HasISSE() {return false;}
inline bool HasMMX() {return false;} inline bool HasMMX() {return false;}
#endif #endif
#endif // #ifdef CRYPTOPP_X86_ASM_AVAILABLE || _MSC_VER >= 1400 #endif // #ifdef CRYPTOPP_X86_ASM_AVAILABLE || _MSC_VER >= 1400
#endif #endif
#ifdef CRYPTOPP_GENERATE_X64_MASM #ifdef CRYPTOPP_GENERATE_X64_MASM
#define AS1(x) x*newline* #define AS1(x) x*newline*
#define AS2(x, y) x, y*newline* #define AS2(x, y) x, y*newline*
#define AS3(x, y, z) x, y, z*newline* #define AS3(x, y, z) x, y, z*newline*
#define ASS(x, y, a, b, c, d) x, y, a*64+b*16+c*4+d*newline* #define ASS(x, y, a, b, c, d) x, y, a*64+b*16+c*4+d*newline*
#define ASL(x) label##x:*newline* #define ASL(x) label##x:*newline*
#define ASJ(x, y, z) x label##y*newline* #define ASJ(x, y, z) x label##y*newline*
#define ASC(x, y) x label##y*newline* #define ASC(x, y) x label##y*newline*
#define AS_HEX(y) 0##y##h #define AS_HEX(y) 0##y##h
#elif defined(__GNUC__) #elif defined(__GNUC__)
// define these in two steps to allow arguments to be expanded // define these in two steps to allow arguments to be expanded
#define GNU_AS1(x) #x ";" #define GNU_AS1(x) #x ";"
#define GNU_AS2(x, y) #x ", " #y ";" #define GNU_AS2(x, y) #x ", " #y ";"
#define GNU_AS3(x, y, z) #x ", " #y ", " #z ";" #define GNU_AS3(x, y, z) #x ", " #y ", " #z ";"
#define GNU_ASL(x) "\n" #x ":" #define GNU_ASL(x) "\n" #x ":"
#define GNU_ASJ(x, y, z) #x " " #y #z ";" #define GNU_ASJ(x, y, z) #x " " #y #z ";"
#define AS1(x) GNU_AS1(x) #define AS1(x) GNU_AS1(x)
#define AS2(x, y) GNU_AS2(x, y) #define AS2(x, y) GNU_AS2(x, y)
#define AS3(x, y, z) GNU_AS3(x, y, z) #define AS3(x, y, z) GNU_AS3(x, y, z)
#define ASS(x, y, a, b, c, d) #x ", " #y ", " #a "*64+" #b "*16+" #c "*4+" #d ";" #define ASS(x, y, a, b, c, d) #x ", " #y ", " #a "*64+" #b "*16+" #c "*4+" #d ";"
#define ASL(x) GNU_ASL(x) #define ASL(x) GNU_ASL(x)
#define ASJ(x, y, z) GNU_ASJ(x, y, z) #define ASJ(x, y, z) GNU_ASJ(x, y, z)
#define ASC(x, y) #x " " #y ";" #define ASC(x, y) #x " " #y ";"
#define CRYPTOPP_NAKED #define CRYPTOPP_NAKED
#define AS_HEX(y) 0x##y #define AS_HEX(y) 0x##y
#else #else
#define AS1(x) __asm {x} #define AS1(x) __asm {x}
#define AS2(x, y) __asm {x, y} #define AS2(x, y) __asm {x, y}
#define AS3(x, y, z) __asm {x, y, z} #define AS3(x, y, z) __asm {x, y, z}
#define ASS(x, y, a, b, c, d) __asm {x, y, _MM_SHUFFLE(a, b, c, d)} #define ASS(x, y, a, b, c, d) __asm {x, y, _MM_SHUFFLE(a, b, c, d)}
#define ASL(x) __asm {label##x:} #define ASL(x) __asm {label##x:}
#define ASJ(x, y, z) __asm {x label##y} #define ASJ(x, y, z) __asm {x label##y}
#define ASC(x, y) __asm {x label##y} #define ASC(x, y) __asm {x label##y}
#define CRYPTOPP_NAKED __declspec(naked) #define CRYPTOPP_NAKED __declspec(naked)
#define AS_HEX(y) 0x##y #define AS_HEX(y) 0x##y
#endif #endif
#define IF0(y) #define IF0(y)
#define IF1(y) y #define IF1(y) y
#ifdef CRYPTOPP_GENERATE_X64_MASM #ifdef CRYPTOPP_GENERATE_X64_MASM
#define ASM_MOD(x, y) ((x) MOD (y)) #define ASM_MOD(x, y) ((x) MOD (y))
#define XMMWORD_PTR XMMWORD PTR #define XMMWORD_PTR XMMWORD PTR
#else #else
// GNU assembler doesn't seem to have mod operator // GNU assembler doesn't seem to have mod operator
#define ASM_MOD(x, y) ((x)-((x)/(y))*(y)) #define ASM_MOD(x, y) ((x)-((x)/(y))*(y))
// GAS 2.15 doesn't support XMMWORD PTR. it seems necessary only for MASM // GAS 2.15 doesn't support XMMWORD PTR. it seems necessary only for MASM
#define XMMWORD_PTR #define XMMWORD_PTR
#endif #endif
#if CRYPTOPP_BOOL_X86 #if CRYPTOPP_BOOL_X86
#define AS_REG_1 ecx #define AS_REG_1 ecx
#define AS_REG_2 edx #define AS_REG_2 edx
#define AS_REG_3 esi #define AS_REG_3 esi
#define AS_REG_4 edi #define AS_REG_4 edi
#define AS_REG_5 eax #define AS_REG_5 eax
#define AS_REG_6 ebx #define AS_REG_6 ebx
#define AS_REG_7 ebp #define AS_REG_7 ebp
#define AS_REG_1d ecx #define AS_REG_1d ecx
#define AS_REG_2d edx #define AS_REG_2d edx
#define AS_REG_3d esi #define AS_REG_3d esi
#define AS_REG_4d edi #define AS_REG_4d edi
#define AS_REG_5d eax #define AS_REG_5d eax
#define AS_REG_6d ebx #define AS_REG_6d ebx
#define AS_REG_7d ebp #define AS_REG_7d ebp
#define WORD_SZ 4 #define WORD_SZ 4
#define WORD_REG(x) e##x #define WORD_REG(x) e##x
#define WORD_PTR DWORD PTR #define WORD_PTR DWORD PTR
#define AS_PUSH_IF86(x) AS1(push e##x) #define AS_PUSH_IF86(x) AS1(push e##x)
#define AS_POP_IF86(x) AS1(pop e##x) #define AS_POP_IF86(x) AS1(pop e##x)
#define AS_JCXZ jecxz #define AS_JCXZ jecxz
#elif CRYPTOPP_BOOL_X64 #elif CRYPTOPP_BOOL_X64
#ifdef CRYPTOPP_GENERATE_X64_MASM #ifdef CRYPTOPP_GENERATE_X64_MASM
#define AS_REG_1 rcx #define AS_REG_1 rcx
#define AS_REG_2 rdx #define AS_REG_2 rdx
#define AS_REG_3 r8 #define AS_REG_3 r8
#define AS_REG_4 r9 #define AS_REG_4 r9
#define AS_REG_5 rax #define AS_REG_5 rax
#define AS_REG_6 r10 #define AS_REG_6 r10
#define AS_REG_7 r11 #define AS_REG_7 r11
#define AS_REG_1d ecx #define AS_REG_1d ecx
#define AS_REG_2d edx #define AS_REG_2d edx
#define AS_REG_3d r8d #define AS_REG_3d r8d
#define AS_REG_4d r9d #define AS_REG_4d r9d
#define AS_REG_5d eax #define AS_REG_5d eax
#define AS_REG_6d r10d #define AS_REG_6d r10d
#define AS_REG_7d r11d #define AS_REG_7d r11d
#else #else
#define AS_REG_1 rdi #define AS_REG_1 rdi
#define AS_REG_2 rsi #define AS_REG_2 rsi
#define AS_REG_3 rdx #define AS_REG_3 rdx
#define AS_REG_4 rcx #define AS_REG_4 rcx
#define AS_REG_5 r8 #define AS_REG_5 r8
#define AS_REG_6 r9 #define AS_REG_6 r9
#define AS_REG_7 r10 #define AS_REG_7 r10
#define AS_REG_1d edi #define AS_REG_1d edi
#define AS_REG_2d esi #define AS_REG_2d esi
#define AS_REG_3d edx #define AS_REG_3d edx
#define AS_REG_4d ecx #define AS_REG_4d ecx
#define AS_REG_5d r8d #define AS_REG_5d r8d
#define AS_REG_6d r9d #define AS_REG_6d r9d
#define AS_REG_7d r10d #define AS_REG_7d r10d
#endif #endif
#define WORD_SZ 8 #define WORD_SZ 8
#define WORD_REG(x) r##x #define WORD_REG(x) r##x
#define WORD_PTR QWORD PTR #define WORD_PTR QWORD PTR
#define AS_PUSH_IF86(x) #define AS_PUSH_IF86(x)
#define AS_POP_IF86(x) #define AS_POP_IF86(x)
#define AS_JCXZ jrcxz #define AS_JCXZ jrcxz
#endif #endif
// helper macro for stream cipher output // helper macro for stream cipher output
#define AS_XMM_OUTPUT4(labelPrefix, inputPtr, outputPtr, x0, x1, x2, x3, t, p0, p1, p2, p3, increment)\ #define AS_XMM_OUTPUT4(labelPrefix, inputPtr, outputPtr, x0, x1, x2, x3, t, p0, p1, p2, p3, increment)\
AS2( test inputPtr, inputPtr)\ AS2( test inputPtr, inputPtr)\
ASC( jz, labelPrefix##3)\ ASC( jz, labelPrefix##3)\
AS2( test inputPtr, 15)\ AS2( test inputPtr, 15)\
ASC( jnz, labelPrefix##7)\ ASC( jnz, labelPrefix##7)\
AS2( pxor xmm##x0, [inputPtr+p0*16])\ AS2( pxor xmm##x0, [inputPtr+p0*16])\
AS2( pxor xmm##x1, [inputPtr+p1*16])\ AS2( pxor xmm##x1, [inputPtr+p1*16])\
AS2( pxor xmm##x2, [inputPtr+p2*16])\ AS2( pxor xmm##x2, [inputPtr+p2*16])\
AS2( pxor xmm##x3, [inputPtr+p3*16])\ AS2( pxor xmm##x3, [inputPtr+p3*16])\
AS2( add inputPtr, increment*16)\ AS2( add inputPtr, increment*16)\
ASC( jmp, labelPrefix##3)\ ASC( jmp, labelPrefix##3)\
ASL(labelPrefix##7)\ ASL(labelPrefix##7)\
AS2( movdqu xmm##t, [inputPtr+p0*16])\ AS2( movdqu xmm##t, [inputPtr+p0*16])\
AS2( pxor xmm##x0, xmm##t)\ AS2( pxor xmm##x0, xmm##t)\
AS2( movdqu xmm##t, [inputPtr+p1*16])\ AS2( movdqu xmm##t, [inputPtr+p1*16])\
AS2( pxor xmm##x1, xmm##t)\ AS2( pxor xmm##x1, xmm##t)\
AS2( movdqu xmm##t, [inputPtr+p2*16])\ AS2( movdqu xmm##t, [inputPtr+p2*16])\
AS2( pxor xmm##x2, xmm##t)\ AS2( pxor xmm##x2, xmm##t)\
AS2( movdqu xmm##t, [inputPtr+p3*16])\ AS2( movdqu xmm##t, [inputPtr+p3*16])\
AS2( pxor xmm##x3, xmm##t)\ AS2( pxor xmm##x3, xmm##t)\
AS2( add inputPtr, increment*16)\ AS2( add inputPtr, increment*16)\
ASL(labelPrefix##3)\ ASL(labelPrefix##3)\
AS2( test outputPtr, 15)\ AS2( test outputPtr, 15)\
ASC( jnz, labelPrefix##8)\ ASC( jnz, labelPrefix##8)\
AS2( movdqa [outputPtr+p0*16], xmm##x0)\ AS2( movdqa [outputPtr+p0*16], xmm##x0)\
AS2( movdqa [outputPtr+p1*16], xmm##x1)\ AS2( movdqa [outputPtr+p1*16], xmm##x1)\
AS2( movdqa [outputPtr+p2*16], xmm##x2)\ AS2( movdqa [outputPtr+p2*16], xmm##x2)\
AS2( movdqa [outputPtr+p3*16], xmm##x3)\ AS2( movdqa [outputPtr+p3*16], xmm##x3)\
ASC( jmp, labelPrefix##9)\ ASC( jmp, labelPrefix##9)\
ASL(labelPrefix##8)\ ASL(labelPrefix##8)\
AS2( movdqu [outputPtr+p0*16], xmm##x0)\ AS2( movdqu [outputPtr+p0*16], xmm##x0)\
AS2( movdqu [outputPtr+p1*16], xmm##x1)\ AS2( movdqu [outputPtr+p1*16], xmm##x1)\
AS2( movdqu [outputPtr+p2*16], xmm##x2)\ AS2( movdqu [outputPtr+p2*16], xmm##x2)\
AS2( movdqu [outputPtr+p3*16], xmm##x3)\ AS2( movdqu [outputPtr+p3*16], xmm##x3)\
ASL(labelPrefix##9)\ ASL(labelPrefix##9)\
AS2( add outputPtr, increment*16) AS2( add outputPtr, increment*16)
NAMESPACE_END NAMESPACE_END
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -1,29 +1,29 @@
#ifndef CRYPTOPP_ITERHASH_H #ifndef CRYPTOPP_ITERHASH_H
#define CRYPTOPP_ITERHASH_H #define CRYPTOPP_ITERHASH_H
#include "secblock.h" #include "secblock.h"
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
// *** trimmed down dependency from iterhash.h *** // *** trimmed down dependency from iterhash.h ***
template <class T_HashWordType, class T_Endianness, unsigned int T_BlockSize, unsigned int T_StateSize, class T_Transform, unsigned int T_DigestSize = 0, bool T_StateAligned = false> template <class T_HashWordType, class T_Endianness, unsigned int T_BlockSize, unsigned int T_StateSize, class T_Transform, unsigned int T_DigestSize = 0, bool T_StateAligned = false>
class CRYPTOPP_NO_VTABLE IteratedHashWithStaticTransform class CRYPTOPP_NO_VTABLE IteratedHashWithStaticTransform
{ {
public: public:
CRYPTOPP_CONSTANT(DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize) CRYPTOPP_CONSTANT(DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize)
unsigned int DigestSize() const {return DIGESTSIZE;}; unsigned int DigestSize() const {return DIGESTSIZE;};
typedef T_HashWordType HashWordType; typedef T_HashWordType HashWordType;
CRYPTOPP_CONSTANT(BLOCKSIZE = T_BlockSize) CRYPTOPP_CONSTANT(BLOCKSIZE = T_BlockSize)
protected: protected:
IteratedHashWithStaticTransform() {this->Init();} IteratedHashWithStaticTransform() {this->Init();}
void HashEndianCorrectedBlock(const T_HashWordType *data) {T_Transform::Transform(this->m_state, data);} void HashEndianCorrectedBlock(const T_HashWordType *data) {T_Transform::Transform(this->m_state, data);}
void Init() {T_Transform::InitState(this->m_state);} void Init() {T_Transform::InitState(this->m_state);}
T_HashWordType* StateBuf() {return this->m_state;} T_HashWordType* StateBuf() {return this->m_state;}
FixedSizeAlignedSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType), T_StateAligned> m_state; FixedSizeAlignedSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType), T_StateAligned> m_state;
}; };
NAMESPACE_END NAMESPACE_END
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -1,21 +1,21 @@
#ifndef CRYPTOPP_PCH_H #ifndef CRYPTOPP_PCH_H
#define CRYPTOPP_PCH_H #define CRYPTOPP_PCH_H
#ifdef CRYPTOPP_GENERATE_X64_MASM #ifdef CRYPTOPP_GENERATE_X64_MASM
#include "cpu.h" #include "cpu.h"
#else #else
#include "config.h" #include "config.h"
#ifdef USE_PRECOMPILED_HEADERS #ifdef USE_PRECOMPILED_HEADERS
#include "simple.h" #include "simple.h"
#include "secblock.h" #include "secblock.h"
#include "misc.h" #include "misc.h"
#include "smartptr.h" #include "smartptr.h"
#endif #endif
#endif #endif
#endif #endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,63 +1,63 @@
#ifndef CRYPTOPP_SHA_H #ifndef CRYPTOPP_SHA_H
#define CRYPTOPP_SHA_H #define CRYPTOPP_SHA_H
#include "iterhash.h" #include "iterhash.h"
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
/// <a href="http://www.weidai.com/scan-mirror/md.html#SHA-1">SHA-1</a> /// <a href="http://www.weidai.com/scan-mirror/md.html#SHA-1">SHA-1</a>
class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 20, SHA1> class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 20, SHA1>
{ {
public: public:
static void CRYPTOPP_API InitState(HashWordType *state); static void CRYPTOPP_API InitState(HashWordType *state);
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data); static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";} static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
}; };
typedef SHA1 SHA; // for backwards compatibility typedef SHA1 SHA; // for backwards compatibility
//! implements the SHA-256 standard //! implements the SHA-256 standard
class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, true> class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, true>
{ {
public: public:
#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
size_t HashMultipleBlocks(const word32 *input, size_t length); size_t HashMultipleBlocks(const word32 *input, size_t length);
#endif #endif
static void CRYPTOPP_API InitState(HashWordType *state); static void CRYPTOPP_API InitState(HashWordType *state);
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data); static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";} static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
}; };
//! implements the SHA-224 standard //! implements the SHA-224 standard
class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, true> class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, true>
{ {
public: public:
#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
size_t HashMultipleBlocks(const word32 *input, size_t length); size_t HashMultipleBlocks(const word32 *input, size_t length);
#endif #endif
static void CRYPTOPP_API InitState(HashWordType *state); static void CRYPTOPP_API InitState(HashWordType *state);
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);} static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);}
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";} static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
}; };
//! implements the SHA-512 standard //! implements the SHA-512 standard
class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, CRYPTOPP_BOOL_X86> class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, CRYPTOPP_BOOL_X86>
{ {
public: public:
static void CRYPTOPP_API InitState(HashWordType *state); static void CRYPTOPP_API InitState(HashWordType *state);
static void CRYPTOPP_API Transform(word64 *digest, const word64 *data); static void CRYPTOPP_API Transform(word64 *digest, const word64 *data);
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";} static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
}; };
//! implements the SHA-384 standard //! implements the SHA-384 standard
class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, CRYPTOPP_BOOL_X86> class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, CRYPTOPP_BOOL_X86>
{ {
public: public:
static void CRYPTOPP_API InitState(HashWordType *state); static void CRYPTOPP_API InitState(HashWordType *state);
static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);} static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);}
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";} static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
}; };
NAMESPACE_END NAMESPACE_END
#endif #endif

View file

@ -1 +1 @@

View file

@ -1,223 +1,223 @@
#ifndef CRYPTOPP_SMARTPTR_H #ifndef CRYPTOPP_SMARTPTR_H
#define CRYPTOPP_SMARTPTR_H #define CRYPTOPP_SMARTPTR_H
#include "config.h" #include "config.h"
#include <algorithm> #include <algorithm>
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
template <class T> class simple_ptr template <class T> class simple_ptr
{ {
public: public:
simple_ptr() : m_p(NULL) {} simple_ptr() : m_p(NULL) {}
~simple_ptr() {delete m_p;} ~simple_ptr() {delete m_p;}
T *m_p; T *m_p;
}; };
template <class T> class member_ptr template <class T> class member_ptr
{ {
public: public:
explicit member_ptr(T *p = NULL) : m_p(p) {} explicit member_ptr(T *p = NULL) : m_p(p) {}
~member_ptr(); ~member_ptr();
const T& operator*() const { return *m_p; } const T& operator*() const { return *m_p; }
T& operator*() { return *m_p; } T& operator*() { return *m_p; }
const T* operator->() const { return m_p; } const T* operator->() const { return m_p; }
T* operator->() { return m_p; } T* operator->() { return m_p; }
const T* get() const { return m_p; } const T* get() const { return m_p; }
T* get() { return m_p; } T* get() { return m_p; }
T* release() T* release()
{ {
T *old_p = m_p; T *old_p = m_p;
m_p = 0; m_p = 0;
return old_p; return old_p;
} }
void reset(T *p = 0); void reset(T *p = 0);
protected: protected:
member_ptr(const member_ptr<T>& rhs); // copy not allowed member_ptr(const member_ptr<T>& rhs); // copy not allowed
void operator=(const member_ptr<T>& rhs); // assignment not allowed void operator=(const member_ptr<T>& rhs); // assignment not allowed
T *m_p; T *m_p;
}; };
template <class T> member_ptr<T>::~member_ptr() {delete m_p;} template <class T> member_ptr<T>::~member_ptr() {delete m_p;}
template <class T> void member_ptr<T>::reset(T *p) {delete m_p; m_p = p;} template <class T> void member_ptr<T>::reset(T *p) {delete m_p; m_p = p;}
// ******************************************************** // ********************************************************
template<class T> class value_ptr : public member_ptr<T> template<class T> class value_ptr : public member_ptr<T>
{ {
public: public:
value_ptr(const T &obj) : member_ptr<T>(new T(obj)) {} value_ptr(const T &obj) : member_ptr<T>(new T(obj)) {}
value_ptr(T *p = NULL) : member_ptr<T>(p) {} value_ptr(T *p = NULL) : member_ptr<T>(p) {}
value_ptr(const value_ptr<T>& rhs) value_ptr(const value_ptr<T>& rhs)
: member_ptr<T>(rhs.m_p ? new T(*rhs.m_p) : NULL) {} : member_ptr<T>(rhs.m_p ? new T(*rhs.m_p) : NULL) {}
value_ptr<T>& operator=(const value_ptr<T>& rhs); value_ptr<T>& operator=(const value_ptr<T>& rhs);
bool operator==(const value_ptr<T>& rhs) bool operator==(const value_ptr<T>& rhs)
{ {
return (!this->m_p && !rhs.m_p) || (this->m_p && rhs.m_p && *this->m_p == *rhs.m_p); return (!this->m_p && !rhs.m_p) || (this->m_p && rhs.m_p && *this->m_p == *rhs.m_p);
} }
}; };
template <class T> value_ptr<T>& value_ptr<T>::operator=(const value_ptr<T>& rhs) template <class T> value_ptr<T>& value_ptr<T>::operator=(const value_ptr<T>& rhs)
{ {
T *old_p = this->m_p; T *old_p = this->m_p;
this->m_p = rhs.m_p ? new T(*rhs.m_p) : NULL; this->m_p = rhs.m_p ? new T(*rhs.m_p) : NULL;
delete old_p; delete old_p;
return *this; return *this;
} }
// ******************************************************** // ********************************************************
template<class T> class clonable_ptr : public member_ptr<T> template<class T> class clonable_ptr : public member_ptr<T>
{ {
public: public:
clonable_ptr(const T &obj) : member_ptr<T>(obj.Clone()) {} clonable_ptr(const T &obj) : member_ptr<T>(obj.Clone()) {}
clonable_ptr(T *p = NULL) : member_ptr<T>(p) {} clonable_ptr(T *p = NULL) : member_ptr<T>(p) {}
clonable_ptr(const clonable_ptr<T>& rhs) clonable_ptr(const clonable_ptr<T>& rhs)
: member_ptr<T>(rhs.m_p ? rhs.m_p->Clone() : NULL) {} : member_ptr<T>(rhs.m_p ? rhs.m_p->Clone() : NULL) {}
clonable_ptr<T>& operator=(const clonable_ptr<T>& rhs); clonable_ptr<T>& operator=(const clonable_ptr<T>& rhs);
}; };
template <class T> clonable_ptr<T>& clonable_ptr<T>::operator=(const clonable_ptr<T>& rhs) template <class T> clonable_ptr<T>& clonable_ptr<T>::operator=(const clonable_ptr<T>& rhs)
{ {
T *old_p = this->m_p; T *old_p = this->m_p;
this->m_p = rhs.m_p ? rhs.m_p->Clone() : NULL; this->m_p = rhs.m_p ? rhs.m_p->Clone() : NULL;
delete old_p; delete old_p;
return *this; return *this;
} }
// ******************************************************** // ********************************************************
template<class T> class counted_ptr template<class T> class counted_ptr
{ {
public: public:
explicit counted_ptr(T *p = 0); explicit counted_ptr(T *p = 0);
counted_ptr(const T &r) : m_p(0) {attach(r);} counted_ptr(const T &r) : m_p(0) {attach(r);}
counted_ptr(const counted_ptr<T>& rhs); counted_ptr(const counted_ptr<T>& rhs);
~counted_ptr(); ~counted_ptr();
const T& operator*() const { return *m_p; } const T& operator*() const { return *m_p; }
T& operator*() { return *m_p; } T& operator*() { return *m_p; }
const T* operator->() const { return m_p; } const T* operator->() const { return m_p; }
T* operator->() { return get(); } T* operator->() { return get(); }
const T* get() const { return m_p; } const T* get() const { return m_p; }
T* get(); T* get();
void attach(const T &p); void attach(const T &p);
counted_ptr<T> & operator=(const counted_ptr<T>& rhs); counted_ptr<T> & operator=(const counted_ptr<T>& rhs);
private: private:
T *m_p; T *m_p;
}; };
template <class T> counted_ptr<T>::counted_ptr(T *p) template <class T> counted_ptr<T>::counted_ptr(T *p)
: m_p(p) : m_p(p)
{ {
if (m_p) if (m_p)
m_p->m_referenceCount = 1; m_p->m_referenceCount = 1;
} }
template <class T> counted_ptr<T>::counted_ptr(const counted_ptr<T>& rhs) template <class T> counted_ptr<T>::counted_ptr(const counted_ptr<T>& rhs)
: m_p(rhs.m_p) : m_p(rhs.m_p)
{ {
if (m_p) if (m_p)
m_p->m_referenceCount++; m_p->m_referenceCount++;
} }
template <class T> counted_ptr<T>::~counted_ptr() template <class T> counted_ptr<T>::~counted_ptr()
{ {
if (m_p && --m_p->m_referenceCount == 0) if (m_p && --m_p->m_referenceCount == 0)
delete m_p; delete m_p;
} }
template <class T> void counted_ptr<T>::attach(const T &r) template <class T> void counted_ptr<T>::attach(const T &r)
{ {
if (m_p && --m_p->m_referenceCount == 0) if (m_p && --m_p->m_referenceCount == 0)
delete m_p; delete m_p;
if (r.m_referenceCount == 0) if (r.m_referenceCount == 0)
{ {
m_p = r.clone(); m_p = r.clone();
m_p->m_referenceCount = 1; m_p->m_referenceCount = 1;
} }
else else
{ {
m_p = const_cast<T *>(&r); m_p = const_cast<T *>(&r);
m_p->m_referenceCount++; m_p->m_referenceCount++;
} }
} }
template <class T> T* counted_ptr<T>::get() template <class T> T* counted_ptr<T>::get()
{ {
if (m_p && m_p->m_referenceCount > 1) if (m_p && m_p->m_referenceCount > 1)
{ {
T *temp = m_p->clone(); T *temp = m_p->clone();
m_p->m_referenceCount--; m_p->m_referenceCount--;
m_p = temp; m_p = temp;
m_p->m_referenceCount = 1; m_p->m_referenceCount = 1;
} }
return m_p; return m_p;
} }
template <class T> counted_ptr<T> & counted_ptr<T>::operator=(const counted_ptr<T>& rhs) template <class T> counted_ptr<T> & counted_ptr<T>::operator=(const counted_ptr<T>& rhs)
{ {
if (m_p != rhs.m_p) if (m_p != rhs.m_p)
{ {
if (m_p && --m_p->m_referenceCount == 0) if (m_p && --m_p->m_referenceCount == 0)
delete m_p; delete m_p;
m_p = rhs.m_p; m_p = rhs.m_p;
if (m_p) if (m_p)
m_p->m_referenceCount++; m_p->m_referenceCount++;
} }
return *this; return *this;
} }
// ******************************************************** // ********************************************************
template <class T> class vector_member_ptrs template <class T> class vector_member_ptrs
{ {
public: public:
vector_member_ptrs(size_t size=0) vector_member_ptrs(size_t size=0)
: m_size(size), m_ptr(new member_ptr<T>[size]) {} : m_size(size), m_ptr(new member_ptr<T>[size]) {}
~vector_member_ptrs() ~vector_member_ptrs()
{delete [] this->m_ptr;} {delete [] this->m_ptr;}
member_ptr<T>& operator[](size_t index) member_ptr<T>& operator[](size_t index)
{assert(index<this->m_size); return this->m_ptr[index];} {assert(index<this->m_size); return this->m_ptr[index];}
const member_ptr<T>& operator[](size_t index) const const member_ptr<T>& operator[](size_t index) const
{assert(index<this->m_size); return this->m_ptr[index];} {assert(index<this->m_size); return this->m_ptr[index];}
size_t size() const {return this->m_size;} size_t size() const {return this->m_size;}
void resize(size_t newSize) void resize(size_t newSize)
{ {
member_ptr<T> *newPtr = new member_ptr<T>[newSize]; member_ptr<T> *newPtr = new member_ptr<T>[newSize];
for (size_t i=0; i<this->m_size && i<newSize; i++) for (size_t i=0; i<this->m_size && i<newSize; i++)
newPtr[i].reset(this->m_ptr[i].release()); newPtr[i].reset(this->m_ptr[i].release());
delete [] this->m_ptr; delete [] this->m_ptr;
this->m_size = newSize; this->m_size = newSize;
this->m_ptr = newPtr; this->m_ptr = newPtr;
} }
private: private:
vector_member_ptrs(const vector_member_ptrs<T> &c); // copy not allowed vector_member_ptrs(const vector_member_ptrs<T> &c); // copy not allowed
void operator=(const vector_member_ptrs<T> &x); // assignment not allowed void operator=(const vector_member_ptrs<T> &x); // assignment not allowed
size_t m_size; size_t m_size;
member_ptr<T> *m_ptr; member_ptr<T> *m_ptr;
}; };
NAMESPACE_END NAMESPACE_END
#endif #endif

View file

@ -1,27 +1,27 @@
#ifndef CRYPTOPP_STDCPP_H #ifndef CRYPTOPP_STDCPP_H
#define CRYPTOPP_STDCPP_H #define CRYPTOPP_STDCPP_H
#include <stddef.h> #include <stddef.h>
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
#include <memory> #include <memory>
#include <string> #include <string>
#include <exception> #include <exception>
#include <typeinfo> #include <typeinfo>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <string.h> // CodeWarrior doesn't have memory.h #include <string.h> // CodeWarrior doesn't have memory.h
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <vector> #include <vector>
// re-disable this // re-disable this
#pragma warning(disable: 4231) #pragma warning(disable: 4231)
#endif #endif
#if defined(_MSC_VER) && defined(_CRTAPI1) #if defined(_MSC_VER) && defined(_CRTAPI1)
#define CRYPTOPP_MSVCRT6 #define CRYPTOPP_MSVCRT6
#endif #endif
#endif #endif

1610
db.cpp

File diff suppressed because it is too large Load diff

812
db.h
View file

@ -1,406 +1,406 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
class CTransaction; class CTransaction;
class CTxIndex; class CTxIndex;
class CDiskBlockIndex; class CDiskBlockIndex;
class CDiskTxPos; class CDiskTxPos;
class COutPoint; class COutPoint;
class CUser; class CUser;
class CReview; class CReview;
class CAddress; class CAddress;
class CWalletTx; class CWalletTx;
extern map<string, string> mapAddressBook; extern map<string, string> mapAddressBook;
extern CCriticalSection cs_mapAddressBook; extern CCriticalSection cs_mapAddressBook;
extern vector<unsigned char> vchDefaultKey; extern vector<unsigned char> vchDefaultKey;
extern bool fClient; extern bool fClient;
extern int nBestHeight; extern int nBestHeight;
extern unsigned int nWalletDBUpdated; extern unsigned int nWalletDBUpdated;
extern DbEnv dbenv; extern DbEnv dbenv;
extern void DBFlush(bool fShutdown); extern void DBFlush(bool fShutdown);
class CDB class CDB
{ {
protected: protected:
Db* pdb; Db* pdb;
string strFile; string strFile;
vector<DbTxn*> vTxn; vector<DbTxn*> vTxn;
bool fReadOnly; bool fReadOnly;
explicit CDB(const char* pszFile, const char* pszMode="r+"); explicit CDB(const char* pszFile, const char* pszMode="r+");
~CDB() { Close(); } ~CDB() { Close(); }
public: public:
void Close(); void Close();
private: private:
CDB(const CDB&); CDB(const CDB&);
void operator=(const CDB&); void operator=(const CDB&);
protected: protected:
template<typename K, typename T> template<typename K, typename T>
bool Read(const K& key, T& value) bool Read(const K& key, T& value)
{ {
if (!pdb) if (!pdb)
return false; return false;
// Key // Key
CDataStream ssKey(SER_DISK); CDataStream ssKey(SER_DISK);
ssKey.reserve(1000); ssKey.reserve(1000);
ssKey << key; ssKey << key;
Dbt datKey(&ssKey[0], ssKey.size()); Dbt datKey(&ssKey[0], ssKey.size());
// Read // Read
Dbt datValue; Dbt datValue;
datValue.set_flags(DB_DBT_MALLOC); datValue.set_flags(DB_DBT_MALLOC);
int ret = pdb->get(GetTxn(), &datKey, &datValue, 0); int ret = pdb->get(GetTxn(), &datKey, &datValue, 0);
memset(datKey.get_data(), 0, datKey.get_size()); memset(datKey.get_data(), 0, datKey.get_size());
if (datValue.get_data() == NULL) if (datValue.get_data() == NULL)
return false; return false;
// Unserialize value // Unserialize value
CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK); CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK);
ssValue >> value; ssValue >> value;
// Clear and free memory // Clear and free memory
memset(datValue.get_data(), 0, datValue.get_size()); memset(datValue.get_data(), 0, datValue.get_size());
free(datValue.get_data()); free(datValue.get_data());
return (ret == 0); return (ret == 0);
} }
template<typename K, typename T> template<typename K, typename T>
bool Write(const K& key, const T& value, bool fOverwrite=true) bool Write(const K& key, const T& value, bool fOverwrite=true)
{ {
if (!pdb) if (!pdb)
return false; return false;
if (fReadOnly) if (fReadOnly)
assert(("Write called on database in read-only mode", false)); assert(("Write called on database in read-only mode", false));
// Key // Key
CDataStream ssKey(SER_DISK); CDataStream ssKey(SER_DISK);
ssKey.reserve(1000); ssKey.reserve(1000);
ssKey << key; ssKey << key;
Dbt datKey(&ssKey[0], ssKey.size()); Dbt datKey(&ssKey[0], ssKey.size());
// Value // Value
CDataStream ssValue(SER_DISK); CDataStream ssValue(SER_DISK);
ssValue.reserve(10000); ssValue.reserve(10000);
ssValue << value; ssValue << value;
Dbt datValue(&ssValue[0], ssValue.size()); Dbt datValue(&ssValue[0], ssValue.size());
// Write // Write
int ret = pdb->put(GetTxn(), &datKey, &datValue, (fOverwrite ? 0 : DB_NOOVERWRITE)); int ret = pdb->put(GetTxn(), &datKey, &datValue, (fOverwrite ? 0 : DB_NOOVERWRITE));
// Clear memory in case it was a private key // Clear memory in case it was a private key
memset(datKey.get_data(), 0, datKey.get_size()); memset(datKey.get_data(), 0, datKey.get_size());
memset(datValue.get_data(), 0, datValue.get_size()); memset(datValue.get_data(), 0, datValue.get_size());
return (ret == 0); return (ret == 0);
} }
template<typename K> template<typename K>
bool Erase(const K& key) bool Erase(const K& key)
{ {
if (!pdb) if (!pdb)
return false; return false;
if (fReadOnly) if (fReadOnly)
assert(("Erase called on database in read-only mode", false)); assert(("Erase called on database in read-only mode", false));
// Key // Key
CDataStream ssKey(SER_DISK); CDataStream ssKey(SER_DISK);
ssKey.reserve(1000); ssKey.reserve(1000);
ssKey << key; ssKey << key;
Dbt datKey(&ssKey[0], ssKey.size()); Dbt datKey(&ssKey[0], ssKey.size());
// Erase // Erase
int ret = pdb->del(GetTxn(), &datKey, 0); int ret = pdb->del(GetTxn(), &datKey, 0);
// Clear memory // Clear memory
memset(datKey.get_data(), 0, datKey.get_size()); memset(datKey.get_data(), 0, datKey.get_size());
return (ret == 0 || ret == DB_NOTFOUND); return (ret == 0 || ret == DB_NOTFOUND);
} }
template<typename K> template<typename K>
bool Exists(const K& key) bool Exists(const K& key)
{ {
if (!pdb) if (!pdb)
return false; return false;
// Key // Key
CDataStream ssKey(SER_DISK); CDataStream ssKey(SER_DISK);
ssKey.reserve(1000); ssKey.reserve(1000);
ssKey << key; ssKey << key;
Dbt datKey(&ssKey[0], ssKey.size()); Dbt datKey(&ssKey[0], ssKey.size());
// Exists // Exists
int ret = pdb->exists(GetTxn(), &datKey, 0); int ret = pdb->exists(GetTxn(), &datKey, 0);
// Clear memory // Clear memory
memset(datKey.get_data(), 0, datKey.get_size()); memset(datKey.get_data(), 0, datKey.get_size());
return (ret == 0); return (ret == 0);
} }
Dbc* GetCursor() Dbc* GetCursor()
{ {
if (!pdb) if (!pdb)
return NULL; return NULL;
Dbc* pcursor = NULL; Dbc* pcursor = NULL;
int ret = pdb->cursor(NULL, &pcursor, 0); int ret = pdb->cursor(NULL, &pcursor, 0);
if (ret != 0) if (ret != 0)
return NULL; return NULL;
return pcursor; return pcursor;
} }
int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags=DB_NEXT) int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags=DB_NEXT)
{ {
// Read at cursor // Read at cursor
Dbt datKey; Dbt datKey;
if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE)
{ {
datKey.set_data(&ssKey[0]); datKey.set_data(&ssKey[0]);
datKey.set_size(ssKey.size()); datKey.set_size(ssKey.size());
} }
Dbt datValue; Dbt datValue;
if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE)
{ {
datValue.set_data(&ssValue[0]); datValue.set_data(&ssValue[0]);
datValue.set_size(ssValue.size()); datValue.set_size(ssValue.size());
} }
datKey.set_flags(DB_DBT_MALLOC); datKey.set_flags(DB_DBT_MALLOC);
datValue.set_flags(DB_DBT_MALLOC); datValue.set_flags(DB_DBT_MALLOC);
int ret = pcursor->get(&datKey, &datValue, fFlags); int ret = pcursor->get(&datKey, &datValue, fFlags);
if (ret != 0) if (ret != 0)
return ret; return ret;
else if (datKey.get_data() == NULL || datValue.get_data() == NULL) else if (datKey.get_data() == NULL || datValue.get_data() == NULL)
return 99999; return 99999;
// Convert to streams // Convert to streams
ssKey.SetType(SER_DISK); ssKey.SetType(SER_DISK);
ssKey.clear(); ssKey.clear();
ssKey.write((char*)datKey.get_data(), datKey.get_size()); ssKey.write((char*)datKey.get_data(), datKey.get_size());
ssValue.SetType(SER_DISK); ssValue.SetType(SER_DISK);
ssValue.clear(); ssValue.clear();
ssValue.write((char*)datValue.get_data(), datValue.get_size()); ssValue.write((char*)datValue.get_data(), datValue.get_size());
// Clear and free memory // Clear and free memory
memset(datKey.get_data(), 0, datKey.get_size()); memset(datKey.get_data(), 0, datKey.get_size());
memset(datValue.get_data(), 0, datValue.get_size()); memset(datValue.get_data(), 0, datValue.get_size());
free(datKey.get_data()); free(datKey.get_data());
free(datValue.get_data()); free(datValue.get_data());
return 0; return 0;
} }
DbTxn* GetTxn() DbTxn* GetTxn()
{ {
if (!vTxn.empty()) if (!vTxn.empty())
return vTxn.back(); return vTxn.back();
else else
return NULL; return NULL;
} }
public: public:
bool TxnBegin() bool TxnBegin()
{ {
if (!pdb) if (!pdb)
return false; return false;
DbTxn* ptxn = NULL; DbTxn* ptxn = NULL;
int ret = dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_NOSYNC); int ret = dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_NOSYNC);
if (!ptxn || ret != 0) if (!ptxn || ret != 0)
return false; return false;
vTxn.push_back(ptxn); vTxn.push_back(ptxn);
return true; return true;
} }
bool TxnCommit() bool TxnCommit()
{ {
if (!pdb) if (!pdb)
return false; return false;
if (vTxn.empty()) if (vTxn.empty())
return false; return false;
int ret = vTxn.back()->commit(0); int ret = vTxn.back()->commit(0);
vTxn.pop_back(); vTxn.pop_back();
return (ret == 0); return (ret == 0);
} }
bool TxnAbort() bool TxnAbort()
{ {
if (!pdb) if (!pdb)
return false; return false;
if (vTxn.empty()) if (vTxn.empty())
return false; return false;
int ret = vTxn.back()->abort(); int ret = vTxn.back()->abort();
vTxn.pop_back(); vTxn.pop_back();
return (ret == 0); return (ret == 0);
} }
bool ReadVersion(int& nVersion) bool ReadVersion(int& nVersion)
{ {
nVersion = 0; nVersion = 0;
return Read(string("version"), nVersion); return Read(string("version"), nVersion);
} }
bool WriteVersion(int nVersion) bool WriteVersion(int nVersion)
{ {
return Write(string("version"), nVersion); return Write(string("version"), nVersion);
} }
}; };
class CTxDB : public CDB class CTxDB : public CDB
{ {
public: public:
CTxDB(const char* pszMode="r+") : CDB(!fClient ? "blkindex.dat" : NULL, pszMode) { } CTxDB(const char* pszMode="r+") : CDB(!fClient ? "blkindex.dat" : NULL, pszMode) { }
private: private:
CTxDB(const CTxDB&); CTxDB(const CTxDB&);
void operator=(const CTxDB&); void operator=(const CTxDB&);
public: public:
bool ReadTxIndex(uint256 hash, CTxIndex& txindex); bool ReadTxIndex(uint256 hash, CTxIndex& txindex);
bool UpdateTxIndex(uint256 hash, const CTxIndex& txindex); bool UpdateTxIndex(uint256 hash, const CTxIndex& txindex);
bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight); bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight);
bool EraseTxIndex(const CTransaction& tx); bool EraseTxIndex(const CTransaction& tx);
bool ContainsTx(uint256 hash); bool ContainsTx(uint256 hash);
bool ReadOwnerTxes(uint160 hash160, int nHeight, vector<CTransaction>& vtx); bool ReadOwnerTxes(uint160 hash160, int nHeight, vector<CTransaction>& vtx);
bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex); bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex);
bool ReadDiskTx(uint256 hash, CTransaction& tx); bool ReadDiskTx(uint256 hash, CTransaction& tx);
bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex); bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex);
bool ReadDiskTx(COutPoint outpoint, CTransaction& tx); bool ReadDiskTx(COutPoint outpoint, CTransaction& tx);
bool WriteBlockIndex(const CDiskBlockIndex& blockindex); bool WriteBlockIndex(const CDiskBlockIndex& blockindex);
bool EraseBlockIndex(uint256 hash); bool EraseBlockIndex(uint256 hash);
bool ReadHashBestChain(uint256& hashBestChain); bool ReadHashBestChain(uint256& hashBestChain);
bool WriteHashBestChain(uint256 hashBestChain); bool WriteHashBestChain(uint256 hashBestChain);
bool ReadBestInvalidWork(CBigNum& bnBestInvalidWork); bool ReadBestInvalidWork(CBigNum& bnBestInvalidWork);
bool WriteBestInvalidWork(CBigNum bnBestInvalidWork); bool WriteBestInvalidWork(CBigNum bnBestInvalidWork);
bool LoadBlockIndex(); bool LoadBlockIndex();
}; };
class CAddrDB : public CDB class CAddrDB : public CDB
{ {
public: public:
CAddrDB(const char* pszMode="r+") : CDB("addr.dat", pszMode) { } CAddrDB(const char* pszMode="r+") : CDB("addr.dat", pszMode) { }
private: private:
CAddrDB(const CAddrDB&); CAddrDB(const CAddrDB&);
void operator=(const CAddrDB&); void operator=(const CAddrDB&);
public: public:
bool WriteAddress(const CAddress& addr); bool WriteAddress(const CAddress& addr);
bool LoadAddresses(); bool LoadAddresses();
}; };
bool LoadAddresses(); bool LoadAddresses();
class CWalletDB : public CDB class CWalletDB : public CDB
{ {
public: public:
CWalletDB(const char* pszMode="r+") : CDB("wallet.dat", pszMode) { } CWalletDB(const char* pszMode="r+") : CDB("wallet.dat", pszMode) { }
private: private:
CWalletDB(const CWalletDB&); CWalletDB(const CWalletDB&);
void operator=(const CWalletDB&); void operator=(const CWalletDB&);
public: public:
bool ReadName(const string& strAddress, string& strName) bool ReadName(const string& strAddress, string& strName)
{ {
strName = ""; strName = "";
return Read(make_pair(string("name"), strAddress), strName); return Read(make_pair(string("name"), strAddress), strName);
} }
bool WriteName(const string& strAddress, const string& strName) bool WriteName(const string& strAddress, const string& strName)
{ {
CRITICAL_BLOCK(cs_mapAddressBook) CRITICAL_BLOCK(cs_mapAddressBook)
mapAddressBook[strAddress] = strName; mapAddressBook[strAddress] = strName;
nWalletDBUpdated++; nWalletDBUpdated++;
return Write(make_pair(string("name"), strAddress), strName); return Write(make_pair(string("name"), strAddress), strName);
} }
bool EraseName(const string& strAddress) bool EraseName(const string& strAddress)
{ {
// This should only be used for sending addresses, never for receiving addresses, // This should only be used for sending addresses, never for receiving addresses,
// receiving addresses must always have an address book entry if they're not change return. // receiving addresses must always have an address book entry if they're not change return.
CRITICAL_BLOCK(cs_mapAddressBook) CRITICAL_BLOCK(cs_mapAddressBook)
mapAddressBook.erase(strAddress); mapAddressBook.erase(strAddress);
nWalletDBUpdated++; nWalletDBUpdated++;
return Erase(make_pair(string("name"), strAddress)); return Erase(make_pair(string("name"), strAddress));
} }
bool ReadTx(uint256 hash, CWalletTx& wtx) bool ReadTx(uint256 hash, CWalletTx& wtx)
{ {
return Read(make_pair(string("tx"), hash), wtx); return Read(make_pair(string("tx"), hash), wtx);
} }
bool WriteTx(uint256 hash, const CWalletTx& wtx) bool WriteTx(uint256 hash, const CWalletTx& wtx)
{ {
nWalletDBUpdated++; nWalletDBUpdated++;
return Write(make_pair(string("tx"), hash), wtx); return Write(make_pair(string("tx"), hash), wtx);
} }
bool EraseTx(uint256 hash) bool EraseTx(uint256 hash)
{ {
nWalletDBUpdated++; nWalletDBUpdated++;
return Erase(make_pair(string("tx"), hash)); return Erase(make_pair(string("tx"), hash));
} }
bool ReadKey(const vector<unsigned char>& vchPubKey, CPrivKey& vchPrivKey) bool ReadKey(const vector<unsigned char>& vchPubKey, CPrivKey& vchPrivKey)
{ {
vchPrivKey.clear(); vchPrivKey.clear();
return Read(make_pair(string("key"), vchPubKey), vchPrivKey); return Read(make_pair(string("key"), vchPubKey), vchPrivKey);
} }
bool WriteKey(const vector<unsigned char>& vchPubKey, const CPrivKey& vchPrivKey) bool WriteKey(const vector<unsigned char>& vchPubKey, const CPrivKey& vchPrivKey)
{ {
nWalletDBUpdated++; nWalletDBUpdated++;
return Write(make_pair(string("key"), vchPubKey), vchPrivKey, false); return Write(make_pair(string("key"), vchPubKey), vchPrivKey, false);
} }
bool ReadDefaultKey(vector<unsigned char>& vchPubKey) bool ReadDefaultKey(vector<unsigned char>& vchPubKey)
{ {
vchPubKey.clear(); vchPubKey.clear();
return Read(string("defaultkey"), vchPubKey); return Read(string("defaultkey"), vchPubKey);
} }
bool WriteDefaultKey(const vector<unsigned char>& vchPubKey) bool WriteDefaultKey(const vector<unsigned char>& vchPubKey)
{ {
vchDefaultKey = vchPubKey; vchDefaultKey = vchPubKey;
nWalletDBUpdated++; nWalletDBUpdated++;
return Write(string("defaultkey"), vchPubKey); return Write(string("defaultkey"), vchPubKey);
} }
template<typename T> template<typename T>
bool ReadSetting(const string& strKey, T& value) bool ReadSetting(const string& strKey, T& value)
{ {
return Read(make_pair(string("setting"), strKey), value); return Read(make_pair(string("setting"), strKey), value);
} }
template<typename T> template<typename T>
bool WriteSetting(const string& strKey, const T& value) bool WriteSetting(const string& strKey, const T& value)
{ {
nWalletDBUpdated++; nWalletDBUpdated++;
return Write(make_pair(string("setting"), strKey), value); return Write(make_pair(string("setting"), strKey), value);
} }
bool LoadWallet(); bool LoadWallet();
}; };
bool LoadWallet(bool& fFirstRunRet); bool LoadWallet(bool& fFirstRunRet);
inline bool SetAddressBookName(const string& strAddress, const string& strName) inline bool SetAddressBookName(const string& strAddress, const string& strName)
{ {
return CWalletDB().WriteName(strAddress, strName); return CWalletDB().WriteName(strAddress, strName);
} }

288
headers.h
View file

@ -1,144 +1,144 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4786) #pragma warning(disable:4786)
#pragma warning(disable:4804) #pragma warning(disable:4804)
#pragma warning(disable:4805) #pragma warning(disable:4805)
#pragma warning(disable:4717) #pragma warning(disable:4717)
#endif #endif
#ifdef _WIN32_WINNT #ifdef _WIN32_WINNT
#undef _WIN32_WINNT #undef _WIN32_WINNT
#endif #endif
#define _WIN32_WINNT 0x0400 #define _WIN32_WINNT 0x0400
#ifdef _WIN32_IE #ifdef _WIN32_IE
#undef _WIN32_IE #undef _WIN32_IE
#endif #endif
#define _WIN32_IE 0x0400 #define _WIN32_IE 0x0400
#define WIN32_LEAN_AND_MEAN 1 #define WIN32_LEAN_AND_MEAN 1
#define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h #define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h
#if (defined(__unix__) || defined(unix)) && !defined(USG) #if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h> // to get BSD define #include <sys/param.h> // to get BSD define
#endif #endif
#ifdef __WXMAC_OSX__ #ifdef __WXMAC_OSX__
#ifndef BSD #ifndef BSD
#define BSD 1 #define BSD 1
#endif #endif
#endif #endif
#ifdef GUI #ifdef GUI
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/snglinst.h> #include <wx/snglinst.h>
#include <wx/utils.h> #include <wx/utils.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
#include <wx/taskbar.h> #include <wx/taskbar.h>
#endif #endif
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/ecdsa.h> #include <openssl/ecdsa.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <openssl/ripemd.h> #include <openssl/ripemd.h>
#include <db_cxx.h> #include <db_cxx.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <limits.h> #include <limits.h>
#include <float.h> #include <float.h>
#include <assert.h> #include <assert.h>
#include <memory> #include <memory>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <list> #include <list>
#include <deque> #include <deque>
#include <map> #include <map>
#include <set> #include <set>
#include <algorithm> #include <algorithm>
#include <numeric> #include <numeric>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp> #include <boost/tuple/tuple_comparison.hpp>
#include <boost/tuple/tuple_io.hpp> #include <boost/tuple/tuple_io.hpp>
#include <boost/array.hpp> #include <boost/array.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp> #include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp> #include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp> #include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/program_options/detail/config_file.hpp> #include <boost/program_options/detail/config_file.hpp>
#include <boost/program_options/parsers.hpp> #include <boost/program_options/parsers.hpp>
#ifdef __WXMSW__ #ifdef __WXMSW__
#include <windows.h> #include <windows.h>
#include <winsock2.h> #include <winsock2.h>
#include <mswsock.h> #include <mswsock.h>
#include <shlobj.h> #include <shlobj.h>
#include <shlwapi.h> #include <shlwapi.h>
#include <io.h> #include <io.h>
#include <process.h> #include <process.h>
#include <malloc.h> #include <malloc.h>
#else #else
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <net/if.h> #include <net/if.h>
#include <ifaddrs.h> #include <ifaddrs.h>
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#ifdef BSD #ifdef BSD
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#pragma hdrstop #pragma hdrstop
using namespace std; using namespace std;
using namespace boost; using namespace boost;
#include "strlcpy.h" #include "strlcpy.h"
#include "serialize.h" #include "serialize.h"
#include "uint256.h" #include "uint256.h"
#include "util.h" #include "util.h"
#include "key.h" #include "key.h"
#include "bignum.h" #include "bignum.h"
#include "base58.h" #include "base58.h"
#include "script.h" #include "script.h"
#include "db.h" #include "db.h"
#include "net.h" #include "net.h"
#include "irc.h" #include "irc.h"
#include "main.h" #include "main.h"
#include "rpc.h" #include "rpc.h"
#ifdef GUI #ifdef GUI
#include "uibase.h" #include "uibase.h"
#include "ui.h" #include "ui.h"
#else #else
#include "noui.h" #include "noui.h"
#endif #endif
#include "init.h" #include "init.h"
#include "xpm/addressbook16.xpm" #include "xpm/addressbook16.xpm"
#include "xpm/addressbook20.xpm" #include "xpm/addressbook20.xpm"
#include "xpm/bitcoin16.xpm" #include "xpm/bitcoin16.xpm"
#include "xpm/bitcoin20.xpm" #include "xpm/bitcoin20.xpm"
#include "xpm/bitcoin32.xpm" #include "xpm/bitcoin32.xpm"
#include "xpm/bitcoin48.xpm" #include "xpm/bitcoin48.xpm"
#include "xpm/bitcoin80.xpm" #include "xpm/bitcoin80.xpm"
#include "xpm/check.xpm" #include "xpm/check.xpm"
#include "xpm/send16.xpm" #include "xpm/send16.xpm"
#include "xpm/send16noshadow.xpm" #include "xpm/send16noshadow.xpm"
#include "xpm/send20.xpm" #include "xpm/send20.xpm"
#include "xpm/about.xpm" #include "xpm/about.xpm"

810
init.cpp
View file

@ -1,405 +1,405 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "headers.h" #include "headers.h"
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //
// Shutdown // Shutdown
// //
void ExitTimeout(void* parg) void ExitTimeout(void* parg)
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
Sleep(5000); Sleep(5000);
ExitProcess(0); ExitProcess(0);
#endif #endif
} }
void Shutdown(void* parg) void Shutdown(void* parg)
{ {
static CCriticalSection cs_Shutdown; static CCriticalSection cs_Shutdown;
static bool fTaken; static bool fTaken;
bool fFirstThread; bool fFirstThread;
CRITICAL_BLOCK(cs_Shutdown) CRITICAL_BLOCK(cs_Shutdown)
{ {
fFirstThread = !fTaken; fFirstThread = !fTaken;
fTaken = true; fTaken = true;
} }
static bool fExit; static bool fExit;
if (fFirstThread) if (fFirstThread)
{ {
fShutdown = true; fShutdown = true;
nTransactionsUpdated++; nTransactionsUpdated++;
DBFlush(false); DBFlush(false);
StopNode(); StopNode();
DBFlush(true); DBFlush(true);
CreateThread(ExitTimeout, NULL); CreateThread(ExitTimeout, NULL);
Sleep(50); Sleep(50);
printf("Bitcoin exiting\n\n"); printf("Bitcoin exiting\n\n");
fExit = true; fExit = true;
exit(0); exit(0);
} }
else else
{ {
while (!fExit) while (!fExit)
Sleep(500); Sleep(500);
Sleep(100); Sleep(100);
ExitThread(0); ExitThread(0);
} }
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //
// Start // Start
// //
#ifndef GUI #ifndef GUI
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
if (!IsSwitchChar(argv[i][0])) if (!IsSwitchChar(argv[i][0]))
fCommandLine = true; fCommandLine = true;
fDaemon = !fCommandLine; fDaemon = !fCommandLine;
#ifdef __WXGTK__ #ifdef __WXGTK__
if (!fCommandLine) if (!fCommandLine)
{ {
// Daemonize // Daemonize
pid_t pid = fork(); pid_t pid = fork();
if (pid < 0) if (pid < 0)
{ {
fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno); fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno);
return 1; return 1;
} }
if (pid > 0) if (pid > 0)
pthread_exit((void*)0); pthread_exit((void*)0);
} }
#endif #endif
if (!AppInit(argc, argv)) if (!AppInit(argc, argv))
return 1; return 1;
while (!fShutdown) while (!fShutdown)
Sleep(1000000); Sleep(1000000);
return 0; return 0;
} }
#endif #endif
bool AppInit(int argc, char* argv[]) bool AppInit(int argc, char* argv[])
{ {
bool fRet = false; bool fRet = false;
try try
{ {
fRet = AppInit2(argc, argv); fRet = AppInit2(argc, argv);
} }
catch (std::exception& e) { catch (std::exception& e) {
PrintException(&e, "AppInit()"); PrintException(&e, "AppInit()");
} catch (...) { } catch (...) {
PrintException(NULL, "AppInit()"); PrintException(NULL, "AppInit()");
} }
if (!fRet) if (!fRet)
Shutdown(NULL); Shutdown(NULL);
return fRet; return fRet;
} }
bool AppInit2(int argc, char* argv[]) bool AppInit2(int argc, char* argv[])
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
// Turn off microsoft heap dump noise // Turn off microsoft heap dump noise
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0)); _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
#endif #endif
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400
// Disable confusing "helpful" text message on abort, ctrl-c // Disable confusing "helpful" text message on abort, ctrl-c
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif #endif
#ifndef __WXMSW__ #ifndef __WXMSW__
umask(077); umask(077);
#endif #endif
// //
// Parameters // Parameters
// //
ParseParameters(argc, argv); ParseParameters(argc, argv);
if (mapArgs.count("-datadir")) if (mapArgs.count("-datadir"))
{ {
filesystem::path pathDataDir = filesystem::system_complete(mapArgs["-datadir"]); filesystem::path pathDataDir = filesystem::system_complete(mapArgs["-datadir"]);
strlcpy(pszSetDataDir, pathDataDir.string().c_str(), sizeof(pszSetDataDir)); strlcpy(pszSetDataDir, pathDataDir.string().c_str(), sizeof(pszSetDataDir));
} }
ReadConfigFile(mapArgs, mapMultiArgs); // Must be done after processing datadir ReadConfigFile(mapArgs, mapMultiArgs); // Must be done after processing datadir
if (mapArgs.count("-?") || mapArgs.count("--help")) if (mapArgs.count("-?") || mapArgs.count("--help"))
{ {
string strUsage = string() + string strUsage = string() +
_("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" + _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +
" bitcoin [options] \t " + "\n" + " bitcoin [options] \t " + "\n" +
" bitcoin [options] <command> [params]\t " + _("Send command to -server or bitcoind\n") + " bitcoin [options] <command> [params]\t " + _("Send command to -server or bitcoind\n") +
" bitcoin [options] help \t\t " + _("List commands\n") + " bitcoin [options] help \t\t " + _("List commands\n") +
" bitcoin [options] help <command> \t\t " + _("Get help for a command\n") + " bitcoin [options] help <command> \t\t " + _("Get help for a command\n") +
_("Options:\n") + _("Options:\n") +
" -conf=<file> \t " + _("Specify configuration file (default: bitcoin.conf)\n") + " -conf=<file> \t " + _("Specify configuration file (default: bitcoin.conf)\n") +
" -gen \t " + _("Generate coins\n") + " -gen \t " + _("Generate coins\n") +
" -gen=0 \t " + _("Don't generate coins\n") + " -gen=0 \t " + _("Don't generate coins\n") +
" -min \t " + _("Start minimized\n") + " -min \t " + _("Start minimized\n") +
" -datadir=<dir> \t " + _("Specify data directory\n") + " -datadir=<dir> \t " + _("Specify data directory\n") +
" -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") + " -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") +
" -addnode=<ip> \t " + _("Add a node to connect to\n") + " -addnode=<ip> \t " + _("Add a node to connect to\n") +
" -connect=<ip> \t " + _("Connect only to the specified node\n") + " -connect=<ip> \t " + _("Connect only to the specified node\n") +
" -server \t " + _("Accept command line and JSON-RPC commands\n") + " -server \t " + _("Accept command line and JSON-RPC commands\n") +
" -daemon \t " + _("Run in the background as a daemon and accept commands\n") + " -daemon \t " + _("Run in the background as a daemon and accept commands\n") +
" -? \t " + _("This help message\n"); " -? \t " + _("This help message\n");
#if defined(__WXMSW__) && defined(GUI) #if defined(__WXMSW__) && defined(GUI)
// Tabs make the columns line up in the message box // Tabs make the columns line up in the message box
wxMessageBox(strUsage, "Bitcoin", wxOK); wxMessageBox(strUsage, "Bitcoin", wxOK);
#else #else
// Remove tabs // Remove tabs
strUsage.erase(std::remove(strUsage.begin(), strUsage.end(), '\t'), strUsage.end()); strUsage.erase(std::remove(strUsage.begin(), strUsage.end(), '\t'), strUsage.end());
fprintf(stderr, "%s", strUsage.c_str()); fprintf(stderr, "%s", strUsage.c_str());
#endif #endif
return false; return false;
} }
if (mapArgs.count("-debug")) if (mapArgs.count("-debug"))
fDebug = true; fDebug = true;
if (mapArgs.count("-printtodebugger")) if (mapArgs.count("-printtodebugger"))
fPrintToDebugger = true; fPrintToDebugger = true;
if (fCommandLine) if (fCommandLine)
{ {
int ret = CommandLineRPC(argc, argv); int ret = CommandLineRPC(argc, argv);
exit(ret); exit(ret);
} }
if (!fDebug && !pszSetDataDir[0]) if (!fDebug && !pszSetDataDir[0])
ShrinkDebugFile(); ShrinkDebugFile();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Bitcoin version %d.%d.%d%s beta\n", VERSION/10000, (VERSION/100)%100, VERSION%100, pszSubVer); printf("Bitcoin version %d.%d.%d%s beta\n", VERSION/10000, (VERSION/100)%100, VERSION%100, pszSubVer);
#ifdef GUI #ifdef GUI
printf("OS version %s\n", ((string)wxGetOsDescription()).c_str()); printf("OS version %s\n", ((string)wxGetOsDescription()).c_str());
printf("System default language is %d %s\n", g_locale.GetSystemLanguage(), ((string)g_locale.GetSysName()).c_str()); printf("System default language is %d %s\n", g_locale.GetSystemLanguage(), ((string)g_locale.GetSysName()).c_str());
printf("Language file %s (%s)\n", (string("locale/") + (string)g_locale.GetCanonicalName() + "/LC_MESSAGES/bitcoin.mo").c_str(), ((string)g_locale.GetLocale()).c_str()); printf("Language file %s (%s)\n", (string("locale/") + (string)g_locale.GetCanonicalName() + "/LC_MESSAGES/bitcoin.mo").c_str(), ((string)g_locale.GetLocale()).c_str());
#endif #endif
printf("Default data directory %s\n", GetDefaultDataDir().c_str()); printf("Default data directory %s\n", GetDefaultDataDir().c_str());
if (mapArgs.count("-loadblockindextest")) if (mapArgs.count("-loadblockindextest"))
{ {
CTxDB txdb("r"); CTxDB txdb("r");
txdb.LoadBlockIndex(); txdb.LoadBlockIndex();
PrintBlockTree(); PrintBlockTree();
return false; return false;
} }
// //
// Limit to single instance per user // Limit to single instance per user
// Required to protect the database files if we're going to keep deleting log.* // Required to protect the database files if we're going to keep deleting log.*
// //
#if defined(__WXMSW__) && defined(GUI) #if defined(__WXMSW__) && defined(GUI)
// todo: wxSingleInstanceChecker wasn't working on Linux, never deleted its lock file // todo: wxSingleInstanceChecker wasn't working on Linux, never deleted its lock file
// maybe should go by whether successfully bind port 8333 instead // maybe should go by whether successfully bind port 8333 instead
wxString strMutexName = wxString("bitcoin_running.") + getenv("HOMEPATH"); wxString strMutexName = wxString("bitcoin_running.") + getenv("HOMEPATH");
for (int i = 0; i < strMutexName.size(); i++) for (int i = 0; i < strMutexName.size(); i++)
if (!isalnum(strMutexName[i])) if (!isalnum(strMutexName[i]))
strMutexName[i] = '.'; strMutexName[i] = '.';
wxSingleInstanceChecker* psingleinstancechecker = new wxSingleInstanceChecker(strMutexName); wxSingleInstanceChecker* psingleinstancechecker = new wxSingleInstanceChecker(strMutexName);
if (psingleinstancechecker->IsAnotherRunning()) if (psingleinstancechecker->IsAnotherRunning())
{ {
printf("Existing instance found\n"); printf("Existing instance found\n");
unsigned int nStart = GetTime(); unsigned int nStart = GetTime();
loop loop
{ {
// TODO: find out how to do this in Linux, or replace with wxWidgets commands // TODO: find out how to do this in Linux, or replace with wxWidgets commands
// Show the previous instance and exit // Show the previous instance and exit
HWND hwndPrev = FindWindowA("wxWindowClassNR", "Bitcoin"); HWND hwndPrev = FindWindowA("wxWindowClassNR", "Bitcoin");
if (hwndPrev) if (hwndPrev)
{ {
if (IsIconic(hwndPrev)) if (IsIconic(hwndPrev))
ShowWindow(hwndPrev, SW_RESTORE); ShowWindow(hwndPrev, SW_RESTORE);
SetForegroundWindow(hwndPrev); SetForegroundWindow(hwndPrev);
return false; return false;
} }
if (GetTime() > nStart + 60) if (GetTime() > nStart + 60)
return false; return false;
// Resume this instance if the other exits // Resume this instance if the other exits
delete psingleinstancechecker; delete psingleinstancechecker;
Sleep(1000); Sleep(1000);
psingleinstancechecker = new wxSingleInstanceChecker(strMutexName); psingleinstancechecker = new wxSingleInstanceChecker(strMutexName);
if (!psingleinstancechecker->IsAnotherRunning()) if (!psingleinstancechecker->IsAnotherRunning())
break; break;
} }
} }
#endif #endif
// Bind to the port early so we can tell if another instance is already running. // Bind to the port early so we can tell if another instance is already running.
// This is a backup to wxSingleInstanceChecker, which doesn't work on Linux. // This is a backup to wxSingleInstanceChecker, which doesn't work on Linux.
string strErrors; string strErrors;
if (!BindListenPort(strErrors)) if (!BindListenPort(strErrors))
{ {
wxMessageBox(strErrors, "Bitcoin"); wxMessageBox(strErrors, "Bitcoin");
return false; return false;
} }
// //
// Load data files // Load data files
// //
if (fDaemon) if (fDaemon)
fprintf(stdout, "bitcoin server starting\n"); fprintf(stdout, "bitcoin server starting\n");
strErrors = ""; strErrors = "";
int64 nStart; int64 nStart;
printf("Loading addresses...\n"); printf("Loading addresses...\n");
nStart = GetTimeMillis(); nStart = GetTimeMillis();
if (!LoadAddresses()) if (!LoadAddresses())
strErrors += _("Error loading addr.dat \n"); strErrors += _("Error loading addr.dat \n");
printf(" addresses %15"PRI64d"ms\n", GetTimeMillis() - nStart); printf(" addresses %15"PRI64d"ms\n", GetTimeMillis() - nStart);
printf("Loading block index...\n"); printf("Loading block index...\n");
nStart = GetTimeMillis(); nStart = GetTimeMillis();
if (!LoadBlockIndex()) if (!LoadBlockIndex())
strErrors += _("Error loading blkindex.dat \n"); strErrors += _("Error loading blkindex.dat \n");
printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart); printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
printf("Loading wallet...\n"); printf("Loading wallet...\n");
nStart = GetTimeMillis(); nStart = GetTimeMillis();
bool fFirstRun; bool fFirstRun;
if (!LoadWallet(fFirstRun)) if (!LoadWallet(fFirstRun))
strErrors += _("Error loading wallet.dat \n"); strErrors += _("Error loading wallet.dat \n");
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart); printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
printf("Done loading\n"); printf("Done loading\n");
//// debug print //// debug print
printf("mapBlockIndex.size() = %d\n", mapBlockIndex.size()); printf("mapBlockIndex.size() = %d\n", mapBlockIndex.size());
printf("nBestHeight = %d\n", nBestHeight); printf("nBestHeight = %d\n", nBestHeight);
printf("mapKeys.size() = %d\n", mapKeys.size()); printf("mapKeys.size() = %d\n", mapKeys.size());
printf("mapPubKeys.size() = %d\n", mapPubKeys.size()); printf("mapPubKeys.size() = %d\n", mapPubKeys.size());
printf("mapWallet.size() = %d\n", mapWallet.size()); printf("mapWallet.size() = %d\n", mapWallet.size());
printf("mapAddressBook.size() = %d\n", mapAddressBook.size()); printf("mapAddressBook.size() = %d\n", mapAddressBook.size());
if (!strErrors.empty()) if (!strErrors.empty())
{ {
wxMessageBox(strErrors, "Bitcoin"); wxMessageBox(strErrors, "Bitcoin");
return false; return false;
} }
// Add wallet transactions that aren't already in a block to mapTransactions // Add wallet transactions that aren't already in a block to mapTransactions
ReacceptWalletTransactions(); ReacceptWalletTransactions();
// //
// Parameters // Parameters
// //
if (mapArgs.count("-printblockindex") || mapArgs.count("-printblocktree")) if (mapArgs.count("-printblockindex") || mapArgs.count("-printblocktree"))
{ {
PrintBlockTree(); PrintBlockTree();
return false; return false;
} }
if (mapArgs.count("-printblock")) if (mapArgs.count("-printblock"))
{ {
string strMatch = mapArgs["-printblock"]; string strMatch = mapArgs["-printblock"];
int nFound = 0; int nFound = 0;
for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
{ {
uint256 hash = (*mi).first; uint256 hash = (*mi).first;
if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0) if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0)
{ {
CBlockIndex* pindex = (*mi).second; CBlockIndex* pindex = (*mi).second;
CBlock block; CBlock block;
block.ReadFromDisk(pindex); block.ReadFromDisk(pindex);
block.BuildMerkleTree(); block.BuildMerkleTree();
block.print(); block.print();
printf("\n"); printf("\n");
nFound++; nFound++;
} }
} }
if (nFound == 0) if (nFound == 0)
printf("No blocks matching %s were found\n", strMatch.c_str()); printf("No blocks matching %s were found\n", strMatch.c_str());
return false; return false;
} }
if (mapArgs.count("-gen")) if (mapArgs.count("-gen"))
{ {
if (mapArgs["-gen"].empty()) if (mapArgs["-gen"].empty())
fGenerateBitcoins = true; fGenerateBitcoins = true;
else else
fGenerateBitcoins = (atoi(mapArgs["-gen"].c_str()) != 0); fGenerateBitcoins = (atoi(mapArgs["-gen"].c_str()) != 0);
} }
if (mapArgs.count("-proxy")) if (mapArgs.count("-proxy"))
{ {
fUseProxy = true; fUseProxy = true;
addrProxy = CAddress(mapArgs["-proxy"]); addrProxy = CAddress(mapArgs["-proxy"]);
if (!addrProxy.IsValid()) if (!addrProxy.IsValid())
{ {
wxMessageBox(_("Invalid -proxy address"), "Bitcoin"); wxMessageBox(_("Invalid -proxy address"), "Bitcoin");
return false; return false;
} }
} }
if (mapArgs.count("-addnode")) if (mapArgs.count("-addnode"))
{ {
foreach(string strAddr, mapMultiArgs["-addnode"]) foreach(string strAddr, mapMultiArgs["-addnode"])
{ {
CAddress addr(strAddr, NODE_NETWORK); CAddress addr(strAddr, NODE_NETWORK);
addr.nTime = 0; // so it won't relay unless successfully connected addr.nTime = 0; // so it won't relay unless successfully connected
if (addr.IsValid()) if (addr.IsValid())
AddAddress(addr); AddAddress(addr);
} }
} }
if (mapArgs.count("-paytxfee")) if (mapArgs.count("-paytxfee"))
{ {
if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee)) if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee))
{ {
wxMessageBox(_("Invalid amount for -paytxfee=<amount>"), "Bitcoin"); wxMessageBox(_("Invalid amount for -paytxfee=<amount>"), "Bitcoin");
return false; return false;
} }
if (nTransactionFee > 1 * COIN) if (nTransactionFee > 1 * COIN)
wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin"); wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin");
} }
// //
// Create the main window and start the node // Create the main window and start the node
// //
#ifdef GUI #ifdef GUI
if (!fDaemon) if (!fDaemon)
CreateMainWindow(); CreateMainWindow();
#endif #endif
if (!CheckDiskSpace()) if (!CheckDiskSpace())
return false; return false;
RandAddSeedPerfmon(); RandAddSeedPerfmon();
if (!CreateThread(StartNode, NULL)) if (!CreateThread(StartNode, NULL))
wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin"); wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin");
if (mapArgs.count("-server") || fDaemon) if (mapArgs.count("-server") || fDaemon)
CreateThread(ThreadRPCServer, NULL); CreateThread(ThreadRPCServer, NULL);
#if defined(__WXMSW__) && defined(GUI) #if defined(__WXMSW__) && defined(GUI)
if (fFirstRun) if (fFirstRun)
SetStartOnSystemStartup(true); SetStartOnSystemStartup(true);
#endif #endif
return true; return true;
} }

14
init.h
View file

@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
void Shutdown(void* parg); void Shutdown(void* parg);
bool AppInit(int argc, char* argv[]); bool AppInit(int argc, char* argv[]);
bool AppInit2(int argc, char* argv[]); bool AppInit2(int argc, char* argv[]);

656
irc.cpp
View file

@ -1,328 +1,328 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "headers.h" #include "headers.h"
int nGotIRCAddresses = 0; int nGotIRCAddresses = 0;
#pragma pack(push, 1) #pragma pack(push, 1)
struct ircaddr struct ircaddr
{ {
int ip; int ip;
short port; short port;
}; };
#pragma pack(pop) #pragma pack(pop)
string EncodeAddress(const CAddress& addr) string EncodeAddress(const CAddress& addr)
{ {
struct ircaddr tmp; struct ircaddr tmp;
tmp.ip = addr.ip; tmp.ip = addr.ip;
tmp.port = addr.port; tmp.port = addr.port;
vector<unsigned char> vch(UBEGIN(tmp), UEND(tmp)); vector<unsigned char> vch(UBEGIN(tmp), UEND(tmp));
return string("u") + EncodeBase58Check(vch); return string("u") + EncodeBase58Check(vch);
} }
bool DecodeAddress(string str, CAddress& addr) bool DecodeAddress(string str, CAddress& addr)
{ {
vector<unsigned char> vch; vector<unsigned char> vch;
if (!DecodeBase58Check(str.substr(1), vch)) if (!DecodeBase58Check(str.substr(1), vch))
return false; return false;
struct ircaddr tmp; struct ircaddr tmp;
if (vch.size() != sizeof(tmp)) if (vch.size() != sizeof(tmp))
return false; return false;
memcpy(&tmp, &vch[0], sizeof(tmp)); memcpy(&tmp, &vch[0], sizeof(tmp));
addr = CAddress(tmp.ip, tmp.port, NODE_NETWORK); addr = CAddress(tmp.ip, tmp.port, NODE_NETWORK);
return true; return true;
} }
static bool Send(SOCKET hSocket, const char* pszSend) static bool Send(SOCKET hSocket, const char* pszSend)
{ {
if (strstr(pszSend, "PONG") != pszSend) if (strstr(pszSend, "PONG") != pszSend)
printf("IRC SENDING: %s\n", pszSend); printf("IRC SENDING: %s\n", pszSend);
const char* psz = pszSend; const char* psz = pszSend;
const char* pszEnd = psz + strlen(psz); const char* pszEnd = psz + strlen(psz);
while (psz < pszEnd) while (psz < pszEnd)
{ {
int ret = send(hSocket, psz, pszEnd - psz, MSG_NOSIGNAL); int ret = send(hSocket, psz, pszEnd - psz, MSG_NOSIGNAL);
if (ret < 0) if (ret < 0)
return false; return false;
psz += ret; psz += ret;
} }
return true; return true;
} }
bool RecvLine(SOCKET hSocket, string& strLine) bool RecvLine(SOCKET hSocket, string& strLine)
{ {
strLine = ""; strLine = "";
loop loop
{ {
char c; char c;
int nBytes = recv(hSocket, &c, 1, 0); int nBytes = recv(hSocket, &c, 1, 0);
if (nBytes > 0) if (nBytes > 0)
{ {
if (c == '\n') if (c == '\n')
continue; continue;
if (c == '\r') if (c == '\r')
return true; return true;
strLine += c; strLine += c;
if (strLine.size() >= 9000) if (strLine.size() >= 9000)
return true; return true;
} }
else if (nBytes <= 0) else if (nBytes <= 0)
{ {
if (!strLine.empty()) if (!strLine.empty())
return true; return true;
// socket closed // socket closed
printf("IRC socket closed\n"); printf("IRC socket closed\n");
return false; return false;
} }
else else
{ {
// socket error // socket error
int nErr = WSAGetLastError(); int nErr = WSAGetLastError();
if (nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) if (nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
{ {
printf("IRC recv failed: %d\n", nErr); printf("IRC recv failed: %d\n", nErr);
return false; return false;
} }
} }
} }
} }
bool RecvLineIRC(SOCKET hSocket, string& strLine) bool RecvLineIRC(SOCKET hSocket, string& strLine)
{ {
loop loop
{ {
bool fRet = RecvLine(hSocket, strLine); bool fRet = RecvLine(hSocket, strLine);
if (fRet) if (fRet)
{ {
if (fShutdown) if (fShutdown)
return false; return false;
vector<string> vWords; vector<string> vWords;
ParseString(strLine, ' ', vWords); ParseString(strLine, ' ', vWords);
if (vWords.size() >= 1 && vWords[0] == "PING") if (vWords.size() >= 1 && vWords[0] == "PING")
{ {
strLine[1] = 'O'; strLine[1] = 'O';
strLine += '\r'; strLine += '\r';
Send(hSocket, strLine.c_str()); Send(hSocket, strLine.c_str());
continue; continue;
} }
} }
return fRet; return fRet;
} }
} }
int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL) int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL)
{ {
loop loop
{ {
string strLine; string strLine;
if (!RecvLineIRC(hSocket, strLine)) if (!RecvLineIRC(hSocket, strLine))
return 0; return 0;
printf("IRC %s\n", strLine.c_str()); printf("IRC %s\n", strLine.c_str());
if (psz1 && strLine.find(psz1) != -1) if (psz1 && strLine.find(psz1) != -1)
return 1; return 1;
if (psz2 && strLine.find(psz2) != -1) if (psz2 && strLine.find(psz2) != -1)
return 2; return 2;
if (psz3 && strLine.find(psz3) != -1) if (psz3 && strLine.find(psz3) != -1)
return 3; return 3;
} }
} }
bool Wait(int nSeconds) bool Wait(int nSeconds)
{ {
if (fShutdown) if (fShutdown)
return false; return false;
printf("IRC waiting %d seconds to reconnect\n", nSeconds); printf("IRC waiting %d seconds to reconnect\n", nSeconds);
for (int i = 0; i < nSeconds; i++) for (int i = 0; i < nSeconds; i++)
{ {
if (fShutdown) if (fShutdown)
return false; return false;
Sleep(1000); Sleep(1000);
} }
return true; return true;
} }
void ThreadIRCSeed(void* parg) void ThreadIRCSeed(void* parg)
{ {
if (mapArgs.count("-connect")) if (mapArgs.count("-connect"))
return; return;
if (mapArgs.count("-noirc")) if (mapArgs.count("-noirc"))
return; return;
printf("ThreadIRCSeed started\n"); printf("ThreadIRCSeed started\n");
int nErrorWait = 10; int nErrorWait = 10;
int nRetryWait = 10; int nRetryWait = 10;
bool fNameInUse = false; bool fNameInUse = false;
bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); bool fTOR = (fUseProxy && addrProxy.port == htons(9050));
while (!fShutdown) while (!fShutdown)
{ {
//CAddress addrConnect("216.155.130.130:6667"); // chat.freenode.net //CAddress addrConnect("216.155.130.130:6667"); // chat.freenode.net
CAddress addrConnect("92.243.23.21:6667"); // irc.lfnet.org CAddress addrConnect("92.243.23.21:6667"); // irc.lfnet.org
if (!fTOR) if (!fTOR)
{ {
//struct hostent* phostent = gethostbyname("chat.freenode.net"); //struct hostent* phostent = gethostbyname("chat.freenode.net");
struct hostent* phostent = gethostbyname("irc.lfnet.org"); struct hostent* phostent = gethostbyname("irc.lfnet.org");
if (phostent && phostent->h_addr_list && phostent->h_addr_list[0]) if (phostent && phostent->h_addr_list && phostent->h_addr_list[0])
addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(6667)); addrConnect = CAddress(*(u_long*)phostent->h_addr_list[0], htons(6667));
} }
SOCKET hSocket; SOCKET hSocket;
if (!ConnectSocket(addrConnect, hSocket)) if (!ConnectSocket(addrConnect, hSocket))
{ {
printf("IRC connect failed\n"); printf("IRC connect failed\n");
nErrorWait = nErrorWait * 11 / 10; nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60)) if (Wait(nErrorWait += 60))
continue; continue;
else else
return; return;
} }
if (!RecvUntil(hSocket, "Found your hostname", "using your IP address instead", "Couldn't look up your hostname")) if (!RecvUntil(hSocket, "Found your hostname", "using your IP address instead", "Couldn't look up your hostname"))
{ {
closesocket(hSocket); closesocket(hSocket);
hSocket = INVALID_SOCKET; hSocket = INVALID_SOCKET;
nErrorWait = nErrorWait * 11 / 10; nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60)) if (Wait(nErrorWait += 60))
continue; continue;
else else
return; return;
} }
string strMyName; string strMyName;
if (addrLocalHost.IsRoutable() && !fUseProxy && !fNameInUse) if (addrLocalHost.IsRoutable() && !fUseProxy && !fNameInUse)
strMyName = EncodeAddress(addrLocalHost); strMyName = EncodeAddress(addrLocalHost);
else else
strMyName = strprintf("x%u", GetRand(1000000000)); strMyName = strprintf("x%u", GetRand(1000000000));
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str()); Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());
int nRet = RecvUntil(hSocket, " 004 ", " 433 "); int nRet = RecvUntil(hSocket, " 004 ", " 433 ");
if (nRet != 1) if (nRet != 1)
{ {
closesocket(hSocket); closesocket(hSocket);
hSocket = INVALID_SOCKET; hSocket = INVALID_SOCKET;
if (nRet == 2) if (nRet == 2)
{ {
printf("IRC name already in use\n"); printf("IRC name already in use\n");
fNameInUse = true; fNameInUse = true;
Wait(10); Wait(10);
continue; continue;
} }
nErrorWait = nErrorWait * 11 / 10; nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60)) if (Wait(nErrorWait += 60))
continue; continue;
else else
return; return;
} }
Sleep(500); Sleep(500);
Send(hSocket, "JOIN #bitcoin\r"); Send(hSocket, "JOIN #bitcoin\r");
Send(hSocket, "WHO #bitcoin\r"); Send(hSocket, "WHO #bitcoin\r");
int64 nStart = GetTime(); int64 nStart = GetTime();
string strLine; string strLine;
while (!fShutdown && RecvLineIRC(hSocket, strLine)) while (!fShutdown && RecvLineIRC(hSocket, strLine))
{ {
if (strLine.empty() || strLine.size() > 900 || strLine[0] != ':') if (strLine.empty() || strLine.size() > 900 || strLine[0] != ':')
continue; continue;
vector<string> vWords; vector<string> vWords;
ParseString(strLine, ' ', vWords); ParseString(strLine, ' ', vWords);
if (vWords.size() < 2) if (vWords.size() < 2)
continue; continue;
char pszName[10000]; char pszName[10000];
pszName[0] = '\0'; pszName[0] = '\0';
if (vWords[1] == "352" && vWords.size() >= 8) if (vWords[1] == "352" && vWords.size() >= 8)
{ {
// index 7 is limited to 16 characters // index 7 is limited to 16 characters
// could get full length name at index 10, but would be different from join messages // could get full length name at index 10, but would be different from join messages
strlcpy(pszName, vWords[7].c_str(), sizeof(pszName)); strlcpy(pszName, vWords[7].c_str(), sizeof(pszName));
printf("IRC got who\n"); printf("IRC got who\n");
} }
if (vWords[1] == "JOIN" && vWords[0].size() > 1) if (vWords[1] == "JOIN" && vWords[0].size() > 1)
{ {
// :username!username@50000007.F000000B.90000002.IP JOIN :#channelname // :username!username@50000007.F000000B.90000002.IP JOIN :#channelname
strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName)); strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName));
if (strchr(pszName, '!')) if (strchr(pszName, '!'))
*strchr(pszName, '!') = '\0'; *strchr(pszName, '!') = '\0';
printf("IRC got join\n"); printf("IRC got join\n");
} }
if (pszName[0] == 'u') if (pszName[0] == 'u')
{ {
CAddress addr; CAddress addr;
if (DecodeAddress(pszName, addr)) if (DecodeAddress(pszName, addr))
{ {
addr.nTime = GetAdjustedTime() - 51 * 60; addr.nTime = GetAdjustedTime() - 51 * 60;
if (AddAddress(addr)) if (AddAddress(addr))
printf("IRC got new address\n"); printf("IRC got new address\n");
nGotIRCAddresses++; nGotIRCAddresses++;
} }
else else
{ {
printf("IRC decode failed\n"); printf("IRC decode failed\n");
} }
} }
} }
closesocket(hSocket); closesocket(hSocket);
hSocket = INVALID_SOCKET; hSocket = INVALID_SOCKET;
// IRC usually blocks TOR, so only try once // IRC usually blocks TOR, so only try once
if (fTOR) if (fTOR)
return; return;
if (GetTime() - nStart > 20 * 60) if (GetTime() - nStart > 20 * 60)
{ {
nErrorWait /= 3; nErrorWait /= 3;
nRetryWait /= 3; nRetryWait /= 3;
} }
nRetryWait = nRetryWait * 11 / 10; nRetryWait = nRetryWait * 11 / 10;
if (!Wait(nRetryWait += 60)) if (!Wait(nRetryWait += 60))
return; return;
} }
} }
#ifdef TEST #ifdef TEST
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
WSADATA wsadata; WSADATA wsadata;
if (WSAStartup(MAKEWORD(2,2), &wsadata) != NO_ERROR) if (WSAStartup(MAKEWORD(2,2), &wsadata) != NO_ERROR)
{ {
printf("Error at WSAStartup()\n"); printf("Error at WSAStartup()\n");
return false; return false;
} }
ThreadIRCSeed(NULL); ThreadIRCSeed(NULL);
WSACleanup(); WSACleanup();
return 0; return 0;
} }
#endif #endif

16
irc.h
View file

@ -1,8 +1,8 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
bool RecvLine(SOCKET hSocket, string& strLine); bool RecvLine(SOCKET hSocket, string& strLine);
void ThreadIRCSeed(void* parg); void ThreadIRCSeed(void* parg);
extern int nGotIRCAddresses; extern int nGotIRCAddresses;

View file

@ -1,24 +1,24 @@
The MIT License The MIT License
Copyright (c) 2007 - 2009 John W. Wilkinson Copyright (c) 2007 - 2009 John W. Wilkinson
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following Software is furnished to do so, subject to the following
conditions: conditions:
The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE. OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,18 +1,18 @@
#ifndef JSON_SPIRIT #ifndef JSON_SPIRIT
#define JSON_SPIRIT #define JSON_SPIRIT
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#if defined(_MSC_VER) && (_MSC_VER >= 1020) #if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once # pragma once
#endif #endif
#include "json_spirit_value.h" #include "json_spirit_value.h"
#include "json_spirit_reader.h" #include "json_spirit_reader.h"
#include "json_spirit_writer.h" #include "json_spirit_writer.h"
#include "json_spirit_utils.h" #include "json_spirit_utils.h"
#endif #endif

View file

@ -1,54 +1,54 @@
#ifndef JSON_SPIRIT_ERROR_POSITION #ifndef JSON_SPIRIT_ERROR_POSITION
#define JSON_SPIRIT_ERROR_POSITION #define JSON_SPIRIT_ERROR_POSITION
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#if defined(_MSC_VER) && (_MSC_VER >= 1020) #if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once # pragma once
#endif #endif
#include <string> #include <string>
namespace json_spirit namespace json_spirit
{ {
// An Error_position exception is thrown by the "read_or_throw" functions below on finding an error. // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error.
// Note the "read_or_throw" functions are around 3 times slower than the standard functions "read" // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read"
// functions that return a bool. // functions that return a bool.
// //
struct Error_position struct Error_position
{ {
Error_position(); Error_position();
Error_position( unsigned int line, unsigned int column, const std::string& reason ); Error_position( unsigned int line, unsigned int column, const std::string& reason );
bool operator==( const Error_position& lhs ) const; bool operator==( const Error_position& lhs ) const;
unsigned int line_; unsigned int line_;
unsigned int column_; unsigned int column_;
std::string reason_; std::string reason_;
}; };
inline Error_position::Error_position() inline Error_position::Error_position()
: line_( 0 ) : line_( 0 )
, column_( 0 ) , column_( 0 )
{ {
} }
inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason ) inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason )
: line_( line ) : line_( line )
, column_( column ) , column_( column )
, reason_( reason ) , reason_( reason )
{ {
} }
inline bool Error_position::operator==( const Error_position& lhs ) const inline bool Error_position::operator==( const Error_position& lhs ) const
{ {
if( this == &lhs ) return true; if( this == &lhs ) return true;
return ( reason_ == lhs.reason_ ) && return ( reason_ == lhs.reason_ ) &&
( line_ == lhs.line_ ) && ( line_ == lhs.line_ ) &&
( column_ == lhs.column_ ); ( column_ == lhs.column_ );
} }
} }
#endif #endif

View file

@ -1,137 +1,137 @@
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#include "json_spirit_reader.h" #include "json_spirit_reader.h"
#include "json_spirit_reader_template.h" #include "json_spirit_reader_template.h"
using namespace json_spirit; using namespace json_spirit;
bool json_spirit::read( const std::string& s, Value& value ) bool json_spirit::read( const std::string& s, Value& value )
{ {
return read_string( s, value ); return read_string( s, value );
} }
void json_spirit::read_or_throw( const std::string& s, Value& value ) void json_spirit::read_or_throw( const std::string& s, Value& value )
{ {
read_string_or_throw( s, value ); read_string_or_throw( s, value );
} }
bool json_spirit::read( std::istream& is, Value& value ) bool json_spirit::read( std::istream& is, Value& value )
{ {
return read_stream( is, value ); return read_stream( is, value );
} }
void json_spirit::read_or_throw( std::istream& is, Value& value ) void json_spirit::read_or_throw( std::istream& is, Value& value )
{ {
read_stream_or_throw( is, value ); read_stream_or_throw( is, value );
} }
bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ) bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
{ {
return read_range( begin, end, value ); return read_range( begin, end, value );
} }
void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ) void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
{ {
begin = read_range_or_throw( begin, end, value ); begin = read_range_or_throw( begin, end, value );
} }
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
bool json_spirit::read( const std::wstring& s, wValue& value ) bool json_spirit::read( const std::wstring& s, wValue& value )
{ {
return read_string( s, value ); return read_string( s, value );
} }
void json_spirit::read_or_throw( const std::wstring& s, wValue& value ) void json_spirit::read_or_throw( const std::wstring& s, wValue& value )
{ {
read_string_or_throw( s, value ); read_string_or_throw( s, value );
} }
bool json_spirit::read( std::wistream& is, wValue& value ) bool json_spirit::read( std::wistream& is, wValue& value )
{ {
return read_stream( is, value ); return read_stream( is, value );
} }
void json_spirit::read_or_throw( std::wistream& is, wValue& value ) void json_spirit::read_or_throw( std::wistream& is, wValue& value )
{ {
read_stream_or_throw( is, value ); read_stream_or_throw( is, value );
} }
bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ) bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
{ {
return read_range( begin, end, value ); return read_range( begin, end, value );
} }
void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ) void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
{ {
begin = read_range_or_throw( begin, end, value ); begin = read_range_or_throw( begin, end, value );
} }
#endif #endif
bool json_spirit::read( const std::string& s, mValue& value ) bool json_spirit::read( const std::string& s, mValue& value )
{ {
return read_string( s, value ); return read_string( s, value );
} }
void json_spirit::read_or_throw( const std::string& s, mValue& value ) void json_spirit::read_or_throw( const std::string& s, mValue& value )
{ {
read_string_or_throw( s, value ); read_string_or_throw( s, value );
} }
bool json_spirit::read( std::istream& is, mValue& value ) bool json_spirit::read( std::istream& is, mValue& value )
{ {
return read_stream( is, value ); return read_stream( is, value );
} }
void json_spirit::read_or_throw( std::istream& is, mValue& value ) void json_spirit::read_or_throw( std::istream& is, mValue& value )
{ {
read_stream_or_throw( is, value ); read_stream_or_throw( is, value );
} }
bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ) bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
{ {
return read_range( begin, end, value ); return read_range( begin, end, value );
} }
void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ) void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
{ {
begin = read_range_or_throw( begin, end, value ); begin = read_range_or_throw( begin, end, value );
} }
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
bool json_spirit::read( const std::wstring& s, wmValue& value ) bool json_spirit::read( const std::wstring& s, wmValue& value )
{ {
return read_string( s, value ); return read_string( s, value );
} }
void json_spirit::read_or_throw( const std::wstring& s, wmValue& value ) void json_spirit::read_or_throw( const std::wstring& s, wmValue& value )
{ {
read_string_or_throw( s, value ); read_string_or_throw( s, value );
} }
bool json_spirit::read( std::wistream& is, wmValue& value ) bool json_spirit::read( std::wistream& is, wmValue& value )
{ {
return read_stream( is, value ); return read_stream( is, value );
} }
void json_spirit::read_or_throw( std::wistream& is, wmValue& value ) void json_spirit::read_or_throw( std::wistream& is, wmValue& value )
{ {
read_stream_or_throw( is, value ); read_stream_or_throw( is, value );
} }
bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ) bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
{ {
return read_range( begin, end, value ); return read_range( begin, end, value );
} }
void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ) void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
{ {
begin = read_range_or_throw( begin, end, value ); begin = read_range_or_throw( begin, end, value );
} }
#endif #endif

View file

@ -1,62 +1,62 @@
#ifndef JSON_SPIRIT_READER #ifndef JSON_SPIRIT_READER
#define JSON_SPIRIT_READER #define JSON_SPIRIT_READER
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#if defined(_MSC_VER) && (_MSC_VER >= 1020) #if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once # pragma once
#endif #endif
#include "json_spirit_value.h" #include "json_spirit_value.h"
#include "json_spirit_error_position.h" #include "json_spirit_error_position.h"
#include <iostream> #include <iostream>
namespace json_spirit namespace json_spirit
{ {
// functions to reads a JSON values // functions to reads a JSON values
bool read( const std::string& s, Value& value ); bool read( const std::string& s, Value& value );
bool read( std::istream& is, Value& value ); bool read( std::istream& is, Value& value );
bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
void read_or_throw( const std::string& s, Value& value ); void read_or_throw( const std::string& s, Value& value );
void read_or_throw( std::istream& is, Value& value ); void read_or_throw( std::istream& is, Value& value );
void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
bool read( const std::wstring& s, wValue& value ); bool read( const std::wstring& s, wValue& value );
bool read( std::wistream& is, wValue& value ); bool read( std::wistream& is, wValue& value );
bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
void read_or_throw( const std::wstring& s, wValue& value ); void read_or_throw( const std::wstring& s, wValue& value );
void read_or_throw( std::wistream& is, wValue& value ); void read_or_throw( std::wistream& is, wValue& value );
void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
#endif #endif
bool read( const std::string& s, mValue& value ); bool read( const std::string& s, mValue& value );
bool read( std::istream& is, mValue& value ); bool read( std::istream& is, mValue& value );
bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
void read_or_throw( const std::string& s, mValue& value ); void read_or_throw( const std::string& s, mValue& value );
void read_or_throw( std::istream& is, mValue& value ); void read_or_throw( std::istream& is, mValue& value );
void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
bool read( const std::wstring& s, wmValue& value ); bool read( const std::wstring& s, wmValue& value );
bool read( std::wistream& is, wmValue& value ); bool read( std::wistream& is, wmValue& value );
bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
void read_or_throw( const std::wstring& s, wmValue& value ); void read_or_throw( const std::wstring& s, wmValue& value );
void read_or_throw( std::wistream& is, wmValue& value ); void read_or_throw( std::wistream& is, wmValue& value );
void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
#endif #endif
} }
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -1,70 +1,70 @@
#ifndef JSON_SPIRIT_READ_STREAM #ifndef JSON_SPIRIT_READ_STREAM
#define JSON_SPIRIT_READ_STREAM #define JSON_SPIRIT_READ_STREAM
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#if defined(_MSC_VER) && (_MSC_VER >= 1020) #if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once # pragma once
#endif #endif
#include "json_spirit_reader_template.h" #include "json_spirit_reader_template.h"
namespace json_spirit namespace json_spirit
{ {
// these classes allows you to read multiple top level contiguous values from a stream, // these classes allows you to read multiple top level contiguous values from a stream,
// the normal stream read functions have a bug that prevent multiple top level values // the normal stream read functions have a bug that prevent multiple top level values
// from being read unless they are separated by spaces // from being read unless they are separated by spaces
template< class Istream_type, class Value_type > template< class Istream_type, class Value_type >
class Stream_reader class Stream_reader
{ {
public: public:
Stream_reader( Istream_type& is ) Stream_reader( Istream_type& is )
: iters_( is ) : iters_( is )
{ {
} }
bool read_next( Value_type& value ) bool read_next( Value_type& value )
{ {
return read_range( iters_.begin_, iters_.end_, value ); return read_range( iters_.begin_, iters_.end_, value );
} }
private: private:
typedef Multi_pass_iters< Istream_type > Mp_iters; typedef Multi_pass_iters< Istream_type > Mp_iters;
Mp_iters iters_; Mp_iters iters_;
}; };
template< class Istream_type, class Value_type > template< class Istream_type, class Value_type >
class Stream_reader_thrower class Stream_reader_thrower
{ {
public: public:
Stream_reader_thrower( Istream_type& is ) Stream_reader_thrower( Istream_type& is )
: iters_( is ) : iters_( is )
, posn_begin_( iters_.begin_, iters_.end_ ) , posn_begin_( iters_.begin_, iters_.end_ )
, posn_end_( iters_.end_, iters_.end_ ) , posn_end_( iters_.end_, iters_.end_ )
{ {
} }
void read_next( Value_type& value ) void read_next( Value_type& value )
{ {
posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value ); posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value );
} }
private: private:
typedef Multi_pass_iters< Istream_type > Mp_iters; typedef Multi_pass_iters< Istream_type > Mp_iters;
typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t; typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t;
Mp_iters iters_; Mp_iters iters_;
Posn_iter_t posn_begin_, posn_end_; Posn_iter_t posn_begin_, posn_end_;
}; };
} }
#endif #endif

View file

@ -1,61 +1,61 @@
#ifndef JSON_SPIRIT_UTILS #ifndef JSON_SPIRIT_UTILS
#define JSON_SPIRIT_UTILS #define JSON_SPIRIT_UTILS
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#if defined(_MSC_VER) && (_MSC_VER >= 1020) #if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once # pragma once
#endif #endif
#include "json_spirit_value.h" #include "json_spirit_value.h"
#include <map> #include <map>
namespace json_spirit namespace json_spirit
{ {
template< class Obj_t, class Map_t > template< class Obj_t, class Map_t >
void obj_to_map( const Obj_t& obj, Map_t& mp_obj ) void obj_to_map( const Obj_t& obj, Map_t& mp_obj )
{ {
mp_obj.clear(); mp_obj.clear();
for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i ) for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i )
{ {
mp_obj[ i->name_ ] = i->value_; mp_obj[ i->name_ ] = i->value_;
} }
} }
template< class Obj_t, class Map_t > template< class Obj_t, class Map_t >
void map_to_obj( const Map_t& mp_obj, Obj_t& obj ) void map_to_obj( const Map_t& mp_obj, Obj_t& obj )
{ {
obj.clear(); obj.clear();
for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i ) for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i )
{ {
obj.push_back( typename Obj_t::value_type( i->first, i->second ) ); obj.push_back( typename Obj_t::value_type( i->first, i->second ) );
} }
} }
typedef std::map< std::string, Value > Mapped_obj; typedef std::map< std::string, Value > Mapped_obj;
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
typedef std::map< std::wstring, wValue > wMapped_obj; typedef std::map< std::wstring, wValue > wMapped_obj;
#endif #endif
template< class Object_type, class String_type > template< class Object_type, class String_type >
const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name ) const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name )
{ {
for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i ) for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i )
{ {
if( i->name_ == name ) if( i->name_ == name )
{ {
return i->value_; return i->value_;
} }
} }
return Object_type::value_type::Value_type::null; return Object_type::value_type::Value_type::null;
} }
} }
#endif #endif

View file

@ -1,8 +1,8 @@
/* Copyright (c) 2007 John W Wilkinson /* Copyright (c) 2007 John W Wilkinson
This source code can be used for any purpose as long as This source code can be used for any purpose as long as
this comment is retained. */ this comment is retained. */
// json spirit version 2.00 // json spirit version 2.00
#include "json_spirit_value.h" #include "json_spirit_value.h"

File diff suppressed because it is too large Load diff

View file

@ -1,95 +1,95 @@
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#include "json_spirit_writer.h" #include "json_spirit_writer.h"
#include "json_spirit_writer_template.h" #include "json_spirit_writer_template.h"
void json_spirit::write( const Value& value, std::ostream& os ) void json_spirit::write( const Value& value, std::ostream& os )
{ {
write_stream( value, os, false ); write_stream( value, os, false );
} }
void json_spirit::write_formatted( const Value& value, std::ostream& os ) void json_spirit::write_formatted( const Value& value, std::ostream& os )
{ {
write_stream( value, os, true ); write_stream( value, os, true );
} }
std::string json_spirit::write( const Value& value ) std::string json_spirit::write( const Value& value )
{ {
return write_string( value, false ); return write_string( value, false );
} }
std::string json_spirit::write_formatted( const Value& value ) std::string json_spirit::write_formatted( const Value& value )
{ {
return write_string( value, true ); return write_string( value, true );
} }
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
void json_spirit::write( const wValue& value, std::wostream& os ) void json_spirit::write( const wValue& value, std::wostream& os )
{ {
write_stream( value, os, false ); write_stream( value, os, false );
} }
void json_spirit::write_formatted( const wValue& value, std::wostream& os ) void json_spirit::write_formatted( const wValue& value, std::wostream& os )
{ {
write_stream( value, os, true ); write_stream( value, os, true );
} }
std::wstring json_spirit::write( const wValue& value ) std::wstring json_spirit::write( const wValue& value )
{ {
return write_string( value, false ); return write_string( value, false );
} }
std::wstring json_spirit::write_formatted( const wValue& value ) std::wstring json_spirit::write_formatted( const wValue& value )
{ {
return write_string( value, true ); return write_string( value, true );
} }
#endif #endif
void json_spirit::write( const mValue& value, std::ostream& os ) void json_spirit::write( const mValue& value, std::ostream& os )
{ {
write_stream( value, os, false ); write_stream( value, os, false );
} }
void json_spirit::write_formatted( const mValue& value, std::ostream& os ) void json_spirit::write_formatted( const mValue& value, std::ostream& os )
{ {
write_stream( value, os, true ); write_stream( value, os, true );
} }
std::string json_spirit::write( const mValue& value ) std::string json_spirit::write( const mValue& value )
{ {
return write_string( value, false ); return write_string( value, false );
} }
std::string json_spirit::write_formatted( const mValue& value ) std::string json_spirit::write_formatted( const mValue& value )
{ {
return write_string( value, true ); return write_string( value, true );
} }
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
void json_spirit::write( const wmValue& value, std::wostream& os ) void json_spirit::write( const wmValue& value, std::wostream& os )
{ {
write_stream( value, os, false ); write_stream( value, os, false );
} }
void json_spirit::write_formatted( const wmValue& value, std::wostream& os ) void json_spirit::write_formatted( const wmValue& value, std::wostream& os )
{ {
write_stream( value, os, true ); write_stream( value, os, true );
} }
std::wstring json_spirit::write( const wmValue& value ) std::wstring json_spirit::write( const wmValue& value )
{ {
return write_string( value, false ); return write_string( value, false );
} }
std::wstring json_spirit::write_formatted( const wmValue& value ) std::wstring json_spirit::write_formatted( const wmValue& value )
{ {
return write_string( value, true ); return write_string( value, true );
} }
#endif #endif

View file

@ -1,50 +1,50 @@
#ifndef JSON_SPIRIT_WRITER #ifndef JSON_SPIRIT_WRITER
#define JSON_SPIRIT_WRITER #define JSON_SPIRIT_WRITER
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#if defined(_MSC_VER) && (_MSC_VER >= 1020) #if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once # pragma once
#endif #endif
#include "json_spirit_value.h" #include "json_spirit_value.h"
#include <iostream> #include <iostream>
namespace json_spirit namespace json_spirit
{ {
// functions to convert JSON Values to text, // functions to convert JSON Values to text,
// the "formatted" versions add whitespace to format the output nicely // the "formatted" versions add whitespace to format the output nicely
void write ( const Value& value, std::ostream& os ); void write ( const Value& value, std::ostream& os );
void write_formatted( const Value& value, std::ostream& os ); void write_formatted( const Value& value, std::ostream& os );
std::string write ( const Value& value ); std::string write ( const Value& value );
std::string write_formatted( const Value& value ); std::string write_formatted( const Value& value );
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
void write ( const wValue& value, std::wostream& os ); void write ( const wValue& value, std::wostream& os );
void write_formatted( const wValue& value, std::wostream& os ); void write_formatted( const wValue& value, std::wostream& os );
std::wstring write ( const wValue& value ); std::wstring write ( const wValue& value );
std::wstring write_formatted( const wValue& value ); std::wstring write_formatted( const wValue& value );
#endif #endif
void write ( const mValue& value, std::ostream& os ); void write ( const mValue& value, std::ostream& os );
void write_formatted( const mValue& value, std::ostream& os ); void write_formatted( const mValue& value, std::ostream& os );
std::string write ( const mValue& value ); std::string write ( const mValue& value );
std::string write_formatted( const mValue& value ); std::string write_formatted( const mValue& value );
#ifndef BOOST_NO_STD_WSTRING #ifndef BOOST_NO_STD_WSTRING
void write ( const wmValue& value, std::wostream& os ); void write ( const wmValue& value, std::wostream& os );
void write_formatted( const wmValue& value, std::wostream& os ); void write_formatted( const wmValue& value, std::wostream& os );
std::wstring write ( const wmValue& value ); std::wstring write ( const wmValue& value );
std::wstring write_formatted( const wmValue& value ); std::wstring write_formatted( const wmValue& value );
#endif #endif
} }
#endif #endif

View file

@ -1,248 +1,248 @@
#ifndef JSON_SPIRIT_WRITER_TEMPLATE #ifndef JSON_SPIRIT_WRITER_TEMPLATE
#define JSON_SPIRIT_WRITER_TEMPLATE #define JSON_SPIRIT_WRITER_TEMPLATE
// Copyright John W. Wilkinson 2007 - 2009. // Copyright John W. Wilkinson 2007 - 2009.
// Distributed under the MIT License, see accompanying file LICENSE.txt // Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.03 // json spirit version 4.03
#include "json_spirit_value.h" #include "json_spirit_value.h"
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
namespace json_spirit namespace json_spirit
{ {
inline char to_hex_char( unsigned int c ) inline char to_hex_char( unsigned int c )
{ {
assert( c <= 0xF ); assert( c <= 0xF );
const char ch = static_cast< char >( c ); const char ch = static_cast< char >( c );
if( ch < 10 ) return '0' + ch; if( ch < 10 ) return '0' + ch;
return 'A' - 10 + ch; return 'A' - 10 + ch;
} }
template< class String_type > template< class String_type >
String_type non_printable_to_string( unsigned int c ) String_type non_printable_to_string( unsigned int c )
{ {
typedef typename String_type::value_type Char_type; typedef typename String_type::value_type Char_type;
String_type result( 6, '\\' ); String_type result( 6, '\\' );
result[1] = 'u'; result[1] = 'u';
result[ 5 ] = to_hex_char( c & 0x000F ); c >>= 4; result[ 5 ] = to_hex_char( c & 0x000F ); c >>= 4;
result[ 4 ] = to_hex_char( c & 0x000F ); c >>= 4; result[ 4 ] = to_hex_char( c & 0x000F ); c >>= 4;
result[ 3 ] = to_hex_char( c & 0x000F ); c >>= 4; result[ 3 ] = to_hex_char( c & 0x000F ); c >>= 4;
result[ 2 ] = to_hex_char( c & 0x000F ); result[ 2 ] = to_hex_char( c & 0x000F );
return result; return result;
} }
template< typename Char_type, class String_type > template< typename Char_type, class String_type >
bool add_esc_char( Char_type c, String_type& s ) bool add_esc_char( Char_type c, String_type& s )
{ {
switch( c ) switch( c )
{ {
case '"': s += to_str< String_type >( "\\\"" ); return true; case '"': s += to_str< String_type >( "\\\"" ); return true;
case '\\': s += to_str< String_type >( "\\\\" ); return true; case '\\': s += to_str< String_type >( "\\\\" ); return true;
case '\b': s += to_str< String_type >( "\\b" ); return true; case '\b': s += to_str< String_type >( "\\b" ); return true;
case '\f': s += to_str< String_type >( "\\f" ); return true; case '\f': s += to_str< String_type >( "\\f" ); return true;
case '\n': s += to_str< String_type >( "\\n" ); return true; case '\n': s += to_str< String_type >( "\\n" ); return true;
case '\r': s += to_str< String_type >( "\\r" ); return true; case '\r': s += to_str< String_type >( "\\r" ); return true;
case '\t': s += to_str< String_type >( "\\t" ); return true; case '\t': s += to_str< String_type >( "\\t" ); return true;
} }
return false; return false;
} }
template< class String_type > template< class String_type >
String_type add_esc_chars( const String_type& s ) String_type add_esc_chars( const String_type& s )
{ {
typedef typename String_type::const_iterator Iter_type; typedef typename String_type::const_iterator Iter_type;
typedef typename String_type::value_type Char_type; typedef typename String_type::value_type Char_type;
String_type result; String_type result;
const Iter_type end( s.end() ); const Iter_type end( s.end() );
for( Iter_type i = s.begin(); i != end; ++i ) for( Iter_type i = s.begin(); i != end; ++i )
{ {
const Char_type c( *i ); const Char_type c( *i );
if( add_esc_char( c, result ) ) continue; if( add_esc_char( c, result ) ) continue;
const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c ); const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c );
if( iswprint( unsigned_c ) ) if( iswprint( unsigned_c ) )
{ {
result += c; result += c;
} }
else else
{ {
result += non_printable_to_string< String_type >( unsigned_c ); result += non_printable_to_string< String_type >( unsigned_c );
} }
} }
return result; return result;
} }
// this class generates the JSON text, // this class generates the JSON text,
// it keeps track of the indentation level etc. // it keeps track of the indentation level etc.
// //
template< class Value_type, class Ostream_type > template< class Value_type, class Ostream_type >
class Generator class Generator
{ {
typedef typename Value_type::Config_type Config_type; typedef typename Value_type::Config_type Config_type;
typedef typename Config_type::String_type String_type; typedef typename Config_type::String_type String_type;
typedef typename Config_type::Object_type Object_type; typedef typename Config_type::Object_type Object_type;
typedef typename Config_type::Array_type Array_type; typedef typename Config_type::Array_type Array_type;
typedef typename String_type::value_type Char_type; typedef typename String_type::value_type Char_type;
typedef typename Object_type::value_type Obj_member_type; typedef typename Object_type::value_type Obj_member_type;
public: public:
Generator( const Value_type& value, Ostream_type& os, bool pretty ) Generator( const Value_type& value, Ostream_type& os, bool pretty )
: os_( os ) : os_( os )
, indentation_level_( 0 ) , indentation_level_( 0 )
, pretty_( pretty ) , pretty_( pretty )
{ {
output( value ); output( value );
} }
private: private:
void output( const Value_type& value ) void output( const Value_type& value )
{ {
switch( value.type() ) switch( value.type() )
{ {
case obj_type: output( value.get_obj() ); break; case obj_type: output( value.get_obj() ); break;
case array_type: output( value.get_array() ); break; case array_type: output( value.get_array() ); break;
case str_type: output( value.get_str() ); break; case str_type: output( value.get_str() ); break;
case bool_type: output( value.get_bool() ); break; case bool_type: output( value.get_bool() ); break;
case int_type: output_int( value ); break; case int_type: output_int( value ); break;
/// Bitcoin: Added std::fixed and changed precision from 16 to 8 /// Bitcoin: Added std::fixed and changed precision from 16 to 8
case real_type: os_ << std::showpoint << std::fixed << std::setprecision(8) case real_type: os_ << std::showpoint << std::fixed << std::setprecision(8)
<< value.get_real(); break; << value.get_real(); break;
case null_type: os_ << "null"; break; case null_type: os_ << "null"; break;
default: assert( false ); default: assert( false );
} }
} }
void output( const Object_type& obj ) void output( const Object_type& obj )
{ {
output_array_or_obj( obj, '{', '}' ); output_array_or_obj( obj, '{', '}' );
} }
void output( const Array_type& arr ) void output( const Array_type& arr )
{ {
output_array_or_obj( arr, '[', ']' ); output_array_or_obj( arr, '[', ']' );
} }
void output( const Obj_member_type& member ) void output( const Obj_member_type& member )
{ {
output( Config_type::get_name( member ) ); space(); output( Config_type::get_name( member ) ); space();
os_ << ':'; space(); os_ << ':'; space();
output( Config_type::get_value( member ) ); output( Config_type::get_value( member ) );
} }
void output_int( const Value_type& value ) void output_int( const Value_type& value )
{ {
if( value.is_uint64() ) if( value.is_uint64() )
{ {
os_ << value.get_uint64(); os_ << value.get_uint64();
} }
else else
{ {
os_ << value.get_int64(); os_ << value.get_int64();
} }
} }
void output( const String_type& s ) void output( const String_type& s )
{ {
os_ << '"' << add_esc_chars( s ) << '"'; os_ << '"' << add_esc_chars( s ) << '"';
} }
void output( bool b ) void output( bool b )
{ {
os_ << to_str< String_type >( b ? "true" : "false" ); os_ << to_str< String_type >( b ? "true" : "false" );
} }
template< class T > template< class T >
void output_array_or_obj( const T& t, Char_type start_char, Char_type end_char ) void output_array_or_obj( const T& t, Char_type start_char, Char_type end_char )
{ {
os_ << start_char; new_line(); os_ << start_char; new_line();
++indentation_level_; ++indentation_level_;
for( typename T::const_iterator i = t.begin(); i != t.end(); ++i ) for( typename T::const_iterator i = t.begin(); i != t.end(); ++i )
{ {
indent(); output( *i ); indent(); output( *i );
typename T::const_iterator next = i; typename T::const_iterator next = i;
if( ++next != t.end()) if( ++next != t.end())
{ {
os_ << ','; os_ << ',';
} }
new_line(); new_line();
} }
--indentation_level_; --indentation_level_;
indent(); os_ << end_char; indent(); os_ << end_char;
} }
void indent() void indent()
{ {
if( !pretty_ ) return; if( !pretty_ ) return;
for( int i = 0; i < indentation_level_; ++i ) for( int i = 0; i < indentation_level_; ++i )
{ {
os_ << " "; os_ << " ";
} }
} }
void space() void space()
{ {
if( pretty_ ) os_ << ' '; if( pretty_ ) os_ << ' ';
} }
void new_line() void new_line()
{ {
if( pretty_ ) os_ << '\n'; if( pretty_ ) os_ << '\n';
} }
Generator& operator=( const Generator& ); // to prevent "assignment operator could not be generated" warning Generator& operator=( const Generator& ); // to prevent "assignment operator could not be generated" warning
Ostream_type& os_; Ostream_type& os_;
int indentation_level_; int indentation_level_;
bool pretty_; bool pretty_;
}; };
template< class Value_type, class Ostream_type > template< class Value_type, class Ostream_type >
void write_stream( const Value_type& value, Ostream_type& os, bool pretty ) void write_stream( const Value_type& value, Ostream_type& os, bool pretty )
{ {
Generator< Value_type, Ostream_type >( value, os, pretty ); Generator< Value_type, Ostream_type >( value, os, pretty );
} }
template< class Value_type > template< class Value_type >
typename Value_type::String_type write_string( const Value_type& value, bool pretty ) typename Value_type::String_type write_string( const Value_type& value, bool pretty )
{ {
typedef typename Value_type::String_type::value_type Char_type; typedef typename Value_type::String_type::value_type Char_type;
std::basic_ostringstream< Char_type > os; std::basic_ostringstream< Char_type > os;
write_stream( value, os, pretty ); write_stream( value, os, pretty );
return os.str(); return os.str();
} }
} }
#endif #endif

336
key.h
View file

@ -1,168 +1,168 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
// secp160k1 // secp160k1
// const unsigned int PRIVATE_KEY_SIZE = 192; // const unsigned int PRIVATE_KEY_SIZE = 192;
// const unsigned int PUBLIC_KEY_SIZE = 41; // const unsigned int PUBLIC_KEY_SIZE = 41;
// const unsigned int SIGNATURE_SIZE = 48; // const unsigned int SIGNATURE_SIZE = 48;
// //
// secp192k1 // secp192k1
// const unsigned int PRIVATE_KEY_SIZE = 222; // const unsigned int PRIVATE_KEY_SIZE = 222;
// const unsigned int PUBLIC_KEY_SIZE = 49; // const unsigned int PUBLIC_KEY_SIZE = 49;
// const unsigned int SIGNATURE_SIZE = 57; // const unsigned int SIGNATURE_SIZE = 57;
// //
// secp224k1 // secp224k1
// const unsigned int PRIVATE_KEY_SIZE = 250; // const unsigned int PRIVATE_KEY_SIZE = 250;
// const unsigned int PUBLIC_KEY_SIZE = 57; // const unsigned int PUBLIC_KEY_SIZE = 57;
// const unsigned int SIGNATURE_SIZE = 66; // const unsigned int SIGNATURE_SIZE = 66;
// //
// secp256k1: // secp256k1:
// const unsigned int PRIVATE_KEY_SIZE = 279; // const unsigned int PRIVATE_KEY_SIZE = 279;
// const unsigned int PUBLIC_KEY_SIZE = 65; // const unsigned int PUBLIC_KEY_SIZE = 65;
// const unsigned int SIGNATURE_SIZE = 72; // const unsigned int SIGNATURE_SIZE = 72;
// //
// see www.keylength.com // see www.keylength.com
// script supports up to 75 for single byte push // script supports up to 75 for single byte push
class key_error : public std::runtime_error class key_error : public std::runtime_error
{ {
public: public:
explicit key_error(const std::string& str) : std::runtime_error(str) {} explicit key_error(const std::string& str) : std::runtime_error(str) {}
}; };
// secure_allocator is defined in serialize.h // secure_allocator is defined in serialize.h
typedef vector<unsigned char, secure_allocator<unsigned char> > CPrivKey; typedef vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;
class CKey class CKey
{ {
protected: protected:
EC_KEY* pkey; EC_KEY* pkey;
bool fSet; bool fSet;
public: public:
CKey() CKey()
{ {
pkey = EC_KEY_new_by_curve_name(NID_secp256k1); pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
if (pkey == NULL) if (pkey == NULL)
throw key_error("CKey::CKey() : EC_KEY_new_by_curve_name failed"); throw key_error("CKey::CKey() : EC_KEY_new_by_curve_name failed");
fSet = false; fSet = false;
} }
CKey(const CKey& b) CKey(const CKey& b)
{ {
pkey = EC_KEY_dup(b.pkey); pkey = EC_KEY_dup(b.pkey);
if (pkey == NULL) if (pkey == NULL)
throw key_error("CKey::CKey(const CKey&) : EC_KEY_dup failed"); throw key_error("CKey::CKey(const CKey&) : EC_KEY_dup failed");
fSet = b.fSet; fSet = b.fSet;
} }
CKey& operator=(const CKey& b) CKey& operator=(const CKey& b)
{ {
if (!EC_KEY_copy(pkey, b.pkey)) if (!EC_KEY_copy(pkey, b.pkey))
throw key_error("CKey::operator=(const CKey&) : EC_KEY_copy failed"); throw key_error("CKey::operator=(const CKey&) : EC_KEY_copy failed");
fSet = b.fSet; fSet = b.fSet;
return (*this); return (*this);
} }
~CKey() ~CKey()
{ {
EC_KEY_free(pkey); EC_KEY_free(pkey);
} }
bool IsNull() const bool IsNull() const
{ {
return !fSet; return !fSet;
} }
void MakeNewKey() void MakeNewKey()
{ {
if (!EC_KEY_generate_key(pkey)) if (!EC_KEY_generate_key(pkey))
throw key_error("CKey::MakeNewKey() : EC_KEY_generate_key failed"); throw key_error("CKey::MakeNewKey() : EC_KEY_generate_key failed");
fSet = true; fSet = true;
} }
bool SetPrivKey(const CPrivKey& vchPrivKey) bool SetPrivKey(const CPrivKey& vchPrivKey)
{ {
const unsigned char* pbegin = &vchPrivKey[0]; const unsigned char* pbegin = &vchPrivKey[0];
if (!d2i_ECPrivateKey(&pkey, &pbegin, vchPrivKey.size())) if (!d2i_ECPrivateKey(&pkey, &pbegin, vchPrivKey.size()))
return false; return false;
fSet = true; fSet = true;
return true; return true;
} }
CPrivKey GetPrivKey() const CPrivKey GetPrivKey() const
{ {
unsigned int nSize = i2d_ECPrivateKey(pkey, NULL); unsigned int nSize = i2d_ECPrivateKey(pkey, NULL);
if (!nSize) if (!nSize)
throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey failed"); throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey failed");
CPrivKey vchPrivKey(nSize, 0); CPrivKey vchPrivKey(nSize, 0);
unsigned char* pbegin = &vchPrivKey[0]; unsigned char* pbegin = &vchPrivKey[0];
if (i2d_ECPrivateKey(pkey, &pbegin) != nSize) if (i2d_ECPrivateKey(pkey, &pbegin) != nSize)
throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey returned unexpected size"); throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey returned unexpected size");
return vchPrivKey; return vchPrivKey;
} }
bool SetPubKey(const vector<unsigned char>& vchPubKey) bool SetPubKey(const vector<unsigned char>& vchPubKey)
{ {
const unsigned char* pbegin = &vchPubKey[0]; const unsigned char* pbegin = &vchPubKey[0];
if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size())) if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size()))
return false; return false;
fSet = true; fSet = true;
return true; return true;
} }
vector<unsigned char> GetPubKey() const vector<unsigned char> GetPubKey() const
{ {
unsigned int nSize = i2o_ECPublicKey(pkey, NULL); unsigned int nSize = i2o_ECPublicKey(pkey, NULL);
if (!nSize) if (!nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed"); throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");
vector<unsigned char> vchPubKey(nSize, 0); vector<unsigned char> vchPubKey(nSize, 0);
unsigned char* pbegin = &vchPubKey[0]; unsigned char* pbegin = &vchPubKey[0];
if (i2o_ECPublicKey(pkey, &pbegin) != nSize) if (i2o_ECPublicKey(pkey, &pbegin) != nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size"); throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size");
return vchPubKey; return vchPubKey;
} }
bool Sign(uint256 hash, vector<unsigned char>& vchSig) bool Sign(uint256 hash, vector<unsigned char>& vchSig)
{ {
vchSig.clear(); vchSig.clear();
unsigned char pchSig[10000]; unsigned char pchSig[10000];
unsigned int nSize = 0; unsigned int nSize = 0;
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey)) if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey))
return false; return false;
vchSig.resize(nSize); vchSig.resize(nSize);
memcpy(&vchSig[0], pchSig, nSize); memcpy(&vchSig[0], pchSig, nSize);
return true; return true;
} }
bool Verify(uint256 hash, const vector<unsigned char>& vchSig) bool Verify(uint256 hash, const vector<unsigned char>& vchSig)
{ {
// -1 = error, 0 = bad sig, 1 = good // -1 = error, 0 = bad sig, 1 = good
if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1) if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1)
return false; return false;
return true; return true;
} }
static bool Sign(const CPrivKey& vchPrivKey, uint256 hash, vector<unsigned char>& vchSig) static bool Sign(const CPrivKey& vchPrivKey, uint256 hash, vector<unsigned char>& vchSig)
{ {
CKey key; CKey key;
if (!key.SetPrivKey(vchPrivKey)) if (!key.SetPrivKey(vchPrivKey))
return false; return false;
return key.Sign(hash, vchSig); return key.Sign(hash, vchSig);
} }
static bool Verify(const vector<unsigned char>& vchPubKey, uint256 hash, const vector<unsigned char>& vchSig) static bool Verify(const vector<unsigned char>& vchPubKey, uint256 hash, const vector<unsigned char>& vchSig)
{ {
CKey key; CKey key;
if (!key.SetPubKey(vchPubKey)) if (!key.SetPubKey(vchPubKey))
return false; return false;
return key.Verify(hash, vchSig); return key.Verify(hash, vchSig);
} }
}; };

View file

@ -1,19 +1,19 @@
Copyright (c) 2009-2010 Satoshi Nakamoto Copyright (c) 2009-2010 Satoshi Nakamoto
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.

6762
main.cpp

File diff suppressed because it is too large Load diff

3378
main.h

File diff suppressed because it is too large Load diff

View file

@ -1,77 +1,77 @@
# Copyright (c) 2009-2010 Satoshi Nakamoto # Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying # Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php. # file license.txt or http://www.opensource.org/licenses/mit-license.php.
INCLUDEPATHS= \ INCLUDEPATHS= \
-I"/boost" \ -I"/boost" \
-I"/db/build_unix" \ -I"/db/build_unix" \
-I"/openssl/include" \ -I"/openssl/include" \
-I"/wxwidgets/lib/gcc_lib/mswud" \ -I"/wxwidgets/lib/gcc_lib/mswud" \
-I"/wxwidgets/include" -I"/wxwidgets/include"
LIBPATHS= \ LIBPATHS= \
-L"/boost/stage/lib" \ -L"/boost/stage/lib" \
-L"/db/build_unix" \ -L"/db/build_unix" \
-L"/openssl/out" \ -L"/openssl/out" \
-L"/wxwidgets/lib/gcc_lib" -L"/wxwidgets/lib/gcc_lib"
WXLIBS= \ WXLIBS= \
-l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd -l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd
LIBS= \ LIBS= \
-l libboost_system-mgw34-mt-d \ -l libboost_system-mgw34-mt-d \
-l libboost_filesystem-mgw34-mt-d \ -l libboost_filesystem-mgw34-mt-d \
-l libboost_program_options-mgw34-mt-d \ -l libboost_program_options-mgw34-mt-d \
-l libboost_thread-mgw34-mt-d \ -l libboost_thread-mgw34-mt-d \
-l db_cxx \ -l db_cxx \
-l eay32 \ -l eay32 \
-l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi
DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH
DEBUGFLAGS=-g -D__WXDEBUG__ DEBUGFLAGS=-g -D__WXDEBUG__
CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h
OBJS= \ OBJS= \
obj/util.o \ obj/util.o \
obj/script.o \ obj/script.o \
obj/db.o \ obj/db.o \
obj/net.o \ obj/net.o \
obj/irc.o \ obj/irc.o \
obj/main.o \ obj/main.o \
obj/rpc.o \ obj/rpc.o \
obj/init.o \ obj/init.o \
cryptopp/obj/sha.o \ cryptopp/obj/sha.o \
cryptopp/obj/cpu.o cryptopp/obj/cpu.o
all: bitcoin.exe all: bitcoin.exe
obj/%.o: %.cpp $(HEADERS) obj/%.o: %.cpp $(HEADERS)
g++ -c $(CFLAGS) -DGUI -o $@ $< g++ -c $(CFLAGS) -DGUI -o $@ $<
cryptopp/obj/%.o: cryptopp/%.cpp cryptopp/obj/%.o: cryptopp/%.cpp
g++ -c $(CFLAGS) -O3 -DCRYPTOPP_X86_ASM_AVAILABLE -o $@ $< g++ -c $(CFLAGS) -O3 -DCRYPTOPP_X86_ASM_AVAILABLE -o $@ $<
obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp
windres $(DEFS) $(INCLUDEPATHS) -o $@ -i $< windres $(DEFS) $(INCLUDEPATHS) -o $@ -i $<
bitcoin.exe: $(OBJS) obj/ui.o obj/uibase.o obj/ui_res.o bitcoin.exe: $(OBJS) obj/ui.o obj/uibase.o obj/ui_res.o
g++ $(CFLAGS) -mwindows -Wl,--subsystem,windows -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS) g++ $(CFLAGS) -mwindows -Wl,--subsystem,windows -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)
obj/nogui/%.o: %.cpp $(HEADERS) obj/nogui/%.o: %.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) obj/ui_res.o bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) obj/ui_res.o
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
clean: clean:
-del /Q obj\* -del /Q obj\*
-del /Q obj\nogui\* -del /Q obj\nogui\*
-del /Q cryptopp\obj\* -del /Q cryptopp\obj\*
-del /Q headers.h.gch -del /Q headers.h.gch

View file

@ -1,72 +1,72 @@
# Copyright (c) 2009-2010 Satoshi Nakamoto # Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying # Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php. # file license.txt or http://www.opensource.org/licenses/mit-license.php.
# Mac OS X makefile for bitcoin # Mac OS X makefile for bitcoin
# Laszlo Hanyecz (solar@heliacal.net) # Laszlo Hanyecz (solar@heliacal.net)
CXX=llvm-g++ CXX=llvm-g++
DEPSDIR=/Users/macosuser/bitcoin/deps DEPSDIR=/Users/macosuser/bitcoin/deps
INCLUDEPATHS= \ INCLUDEPATHS= \
-I"$(DEPSDIR)/include" -I"$(DEPSDIR)/include"
LIBPATHS= \ LIBPATHS= \
-L"$(DEPSDIR)/lib" -L"$(DEPSDIR)/lib"
WXLIBS=$(shell $(DEPSDIR)/bin/wx-config --libs --static) WXLIBS=$(shell $(DEPSDIR)/bin/wx-config --libs --static)
LIBS= -dead_strip \ LIBS= -dead_strip \
$(DEPSDIR)/lib/libdb_cxx-4.8.a \ $(DEPSDIR)/lib/libdb_cxx-4.8.a \
$(DEPSDIR)/lib/libboost_system.a \ $(DEPSDIR)/lib/libboost_system.a \
$(DEPSDIR)/lib/libboost_filesystem.a \ $(DEPSDIR)/lib/libboost_filesystem.a \
$(DEPSDIR)/lib/libboost_program_options.a \ $(DEPSDIR)/lib/libboost_program_options.a \
$(DEPSDIR)/lib/libboost_thread.a \ $(DEPSDIR)/lib/libboost_thread.a \
$(DEPSDIR)/lib/libcrypto.a $(DEPSDIR)/lib/libcrypto.a
DEFS=$(shell $(DEPSDIR)/bin/wx-config --cxxflags) -D__WXMAC_OSX__ -DNOPCH -DMSG_NOSIGNAL=0 DEFS=$(shell $(DEPSDIR)/bin/wx-config --cxxflags) -D__WXMAC_OSX__ -DNOPCH -DMSG_NOSIGNAL=0
DEBUGFLAGS=-g -DwxDEBUG_LEVEL=0 DEBUGFLAGS=-g -DwxDEBUG_LEVEL=0
# ppc doesn't work because we don't support big-endian # ppc doesn't work because we don't support big-endian
CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h
OBJS= \ OBJS= \
obj/util.o \ obj/util.o \
obj/script.o \ obj/script.o \
obj/db.o \ obj/db.o \
obj/net.o \ obj/net.o \
obj/irc.o \ obj/irc.o \
obj/main.o \ obj/main.o \
obj/rpc.o \ obj/rpc.o \
obj/init.o \ obj/init.o \
cryptopp/obj/sha.o \ cryptopp/obj/sha.o \
cryptopp/obj/cpu.o cryptopp/obj/cpu.o
all: bitcoin all: bitcoin
obj/%.o: %.cpp $(HEADERS) obj/%.o: %.cpp $(HEADERS)
$(CXX) -c $(CFLAGS) -DGUI -o $@ $< $(CXX) -c $(CFLAGS) -DGUI -o $@ $<
cryptopp/obj/%.o: cryptopp/%.cpp cryptopp/obj/%.o: cryptopp/%.cpp
$(CXX) -c $(CFLAGS) -O3 -DCRYPTOPP_DISABLE_ASM -o $@ $< $(CXX) -c $(CFLAGS) -O3 -DCRYPTOPP_DISABLE_ASM -o $@ $<
bitcoin: $(OBJS) obj/ui.o obj/uibase.o bitcoin: $(OBJS) obj/ui.o obj/uibase.o
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)
obj/nogui/%.o: %.cpp $(HEADERS) obj/nogui/%.o: %.cpp $(HEADERS)
$(CXX) -c $(CFLAGS) -o $@ $< $(CXX) -c $(CFLAGS) -o $@ $<
bitcoind: $(OBJS:obj/%=obj/nogui/%) bitcoind: $(OBJS:obj/%=obj/nogui/%)
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
clean: clean:
-rm -f bitcoin bitcoind -rm -f bitcoin bitcoind
-rm -f obj/*.o -rm -f obj/*.o
-rm -f obj/nogui/*.o -rm -f obj/nogui/*.o
-rm -f cryptopp/obj/*.o -rm -f cryptopp/obj/*.o

View file

@ -1,74 +1,74 @@
# Copyright (c) 2009-2010 Satoshi Nakamoto # Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying # Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php. # file license.txt or http://www.opensource.org/licenses/mit-license.php.
INCLUDEPATHS= \ INCLUDEPATHS= \
-I"/usr/local/include/wx-2.9" \ -I"/usr/local/include/wx-2.9" \
-I"/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9" -I"/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9"
WXLIBS= \ WXLIBS= \
-Wl,-Bstatic \ -Wl,-Bstatic \
-l wx_gtk2ud-2.9 \ -l wx_gtk2ud-2.9 \
-Wl,-Bdynamic \ -Wl,-Bdynamic \
-l gtk-x11-2.0 -l SM -l gtk-x11-2.0 -l SM
# for boost 1.37, add -mt to the boost libraries # for boost 1.37, add -mt to the boost libraries
LIBS= \ LIBS= \
-Wl,-Bstatic \ -Wl,-Bstatic \
-l boost_system \ -l boost_system \
-l boost_filesystem \ -l boost_filesystem \
-l boost_program_options \ -l boost_program_options \
-l boost_thread \ -l boost_thread \
-l db_cxx \ -l db_cxx \
-l crypto \ -l crypto \
-Wl,-Bdynamic \ -Wl,-Bdynamic \
-l gthread-2.0 -l gthread-2.0
DEFS=-D__WXGTK__ -DNOPCH -DFOURWAYSSE2 DEFS=-D__WXGTK__ -DNOPCH -DFOURWAYSSE2
DEBUGFLAGS=-g -D__WXDEBUG__ DEBUGFLAGS=-g -D__WXDEBUG__
CFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) CFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h
OBJS= \ OBJS= \
obj/util.o \ obj/util.o \
obj/script.o \ obj/script.o \
obj/db.o \ obj/db.o \
obj/net.o \ obj/net.o \
obj/irc.o \ obj/irc.o \
obj/main.o \ obj/main.o \
obj/rpc.o \ obj/rpc.o \
obj/init.o \ obj/init.o \
cryptopp/obj/sha.o \ cryptopp/obj/sha.o \
cryptopp/obj/cpu.o cryptopp/obj/cpu.o
all: bitcoin all: bitcoin
obj/%.o: %.cpp $(HEADERS) obj/%.o: %.cpp $(HEADERS)
g++ -c $(CFLAGS) -DGUI -o $@ $< g++ -c $(CFLAGS) -DGUI -o $@ $<
cryptopp/obj/%.o: cryptopp/%.cpp cryptopp/obj/%.o: cryptopp/%.cpp
g++ -c $(CFLAGS) -O3 -o $@ $< g++ -c $(CFLAGS) -O3 -o $@ $<
obj/sha256.o: sha256.cpp obj/sha256.o: sha256.cpp
g++ -c $(CFLAGS) -msse2 -O3 -march=amdfam10 -o $@ $< g++ -c $(CFLAGS) -msse2 -O3 -march=amdfam10 -o $@ $<
bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha256.o bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha256.o
g++ $(CFLAGS) -o $@ $^ $(WXLIBS) $(LIBS) g++ $(CFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)
obj/nogui/%.o: %.cpp $(HEADERS) obj/nogui/%.o: %.cpp $(HEADERS)
g++ -c $(CFLAGS) -o $@ $< g++ -c $(CFLAGS) -o $@ $<
bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha256.o bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha256.o
g++ $(CFLAGS) -o $@ $^ $(LIBS) g++ $(CFLAGS) -o $@ $^ $(LIBS)
clean: clean:
-rm -f obj/*.o -rm -f obj/*.o
-rm -f obj/nogui/*.o -rm -f obj/nogui/*.o
-rm -f cryptopp/obj/*.o -rm -f cryptopp/obj/*.o
-rm -f headers.h.gch -rm -f headers.h.gch

View file

@ -1,116 +1,116 @@
# Copyright (c) 2009-2010 Satoshi Nakamoto # Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying # Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php. # file license.txt or http://www.opensource.org/licenses/mit-license.php.
INCLUDEPATHS= \ INCLUDEPATHS= \
/I"/boost" \ /I"/boost" \
/I"/db/build_windows" \ /I"/db/build_windows" \
/I"/openssl/include" \ /I"/openssl/include" \
/I"/wxwidgets/lib/vc_lib/mswud" \ /I"/wxwidgets/lib/vc_lib/mswud" \
/I"/wxwidgets/include" /I"/wxwidgets/include"
LIBPATHS= \ LIBPATHS= \
/LIBPATH:"/boost/stage/lib" \ /LIBPATH:"/boost/stage/lib" \
/LIBPATH:"/db/build_windows/debug" \ /LIBPATH:"/db/build_windows/debug" \
/LIBPATH:"/openssl/out" \ /LIBPATH:"/openssl/out" \
/LIBPATH:"/wxwidgets/lib/vc_lib" /LIBPATH:"/wxwidgets/lib/vc_lib"
WXLIBS=wxmsw29ud_html.lib wxmsw29ud_core.lib wxmsw29ud_adv.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib WXLIBS=wxmsw29ud_html.lib wxmsw29ud_core.lib wxmsw29ud_adv.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib
LIBS= \ LIBS= \
libboost_system-vc80-mt-gd.lib \ libboost_system-vc80-mt-gd.lib \
libboost_filesystem-vc80-mt-gd.lib \ libboost_filesystem-vc80-mt-gd.lib \
libboost_program_options-vc80-mt-gd.lib \ libboost_program_options-vc80-mt-gd.lib \
libboost_thread-vc80-mt-gd.lib \ libboost_thread-vc80-mt-gd.lib \
libdb47sd.lib \ libdb47sd.lib \
libeay32.lib \ libeay32.lib \
kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib
DEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH DEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH
DEBUGFLAGS=/Zi /D__WXDEBUG__ DEBUGFLAGS=/Zi /D__WXDEBUG__
CFLAGS=/c /nologo /MDd /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) CFLAGS=/c /nologo /MDd /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h
OBJS= \ OBJS= \
obj\util.obj \ obj\util.obj \
obj\script.obj \ obj\script.obj \
obj\db.obj \ obj\db.obj \
obj\net.obj \ obj\net.obj \
obj\irc.obj \ obj\irc.obj \
obj\main.obj \ obj\main.obj \
obj\rpc.obj \ obj\rpc.obj \
obj\init.obj \ obj\init.obj \
cryptopp\obj\sha.obj \ cryptopp\obj\sha.obj \
cryptopp\obj\cpu.obj cryptopp\obj\cpu.obj
all: bitcoin.exe all: bitcoin.exe
.cpp{obj}.obj: .cpp{obj}.obj:
cl $(CFLAGS) /DGUI /Fo$@ %s cl $(CFLAGS) /DGUI /Fo$@ %s
obj\util.obj: $(HEADERS) obj\util.obj: $(HEADERS)
obj\script.obj: $(HEADERS) obj\script.obj: $(HEADERS)
obj\db.obj: $(HEADERS) obj\db.obj: $(HEADERS)
obj\net.obj: $(HEADERS) obj\net.obj: $(HEADERS)
obj\irc.obj: $(HEADERS) obj\irc.obj: $(HEADERS)
obj\main.obj: $(HEADERS) obj\main.obj: $(HEADERS)
obj\rpc.obj: $(HEADERS) obj\rpc.obj: $(HEADERS)
obj\init.obj: $(HEADERS) obj\init.obj: $(HEADERS)
obj\ui.obj: $(HEADERS) obj\ui.obj: $(HEADERS)
obj\uibase.obj: $(HEADERS) obj\uibase.obj: $(HEADERS)
cryptopp\obj\sha.obj: cryptopp\sha.cpp cryptopp\obj\sha.obj: cryptopp\sha.cpp
cl $(CFLAGS) /O2 /DCRYPTOPP_DISABLE_ASM /Fo$@ %s cl $(CFLAGS) /O2 /DCRYPTOPP_DISABLE_ASM /Fo$@ %s
cryptopp\obj\cpu.obj: cryptopp\cpu.cpp cryptopp\obj\cpu.obj: cryptopp\cpu.cpp
cl $(CFLAGS) /O2 /DCRYPTOPP_DISABLE_ASM /Fo$@ %s cl $(CFLAGS) /O2 /DCRYPTOPP_DISABLE_ASM /Fo$@ %s
obj\ui.res: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp obj\ui.res: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp
rc $(INCLUDEPATHS) $(DEFS) /Fo$@ %s rc $(INCLUDEPATHS) $(DEFS) /Fo$@ %s
bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\ui.res bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\ui.res
link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS) link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS)
.cpp{obj\nogui}.obj: .cpp{obj\nogui}.obj:
cl $(CFLAGS) /Fo$@ %s cl $(CFLAGS) /Fo$@ %s
obj\nogui\util.obj: $(HEADERS) obj\nogui\util.obj: $(HEADERS)
obj\nogui\script.obj: $(HEADERS) obj\nogui\script.obj: $(HEADERS)
obj\nogui\db.obj: $(HEADERS) obj\nogui\db.obj: $(HEADERS)
obj\nogui\net.obj: $(HEADERS) obj\nogui\net.obj: $(HEADERS)
obj\nogui\irc.obj: $(HEADERS) obj\nogui\irc.obj: $(HEADERS)
obj\nogui\main.obj: $(HEADERS) obj\nogui\main.obj: $(HEADERS)
obj\nogui\rpc.obj: $(HEADERS) obj\nogui\rpc.obj: $(HEADERS)
obj\nogui\init.obj: $(HEADERS) obj\nogui\init.obj: $(HEADERS)
bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\ui.res bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\ui.res
link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS) link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)
clean: clean:
-del /Q obj\* -del /Q obj\*
-del /Q obj\nogui\* -del /Q obj\nogui\*
-del /Q cryptopp\obj\* -del /Q cryptopp\obj\*
-del /Q *.ilk -del /Q *.ilk
-del /Q *.pdb -del /Q *.pdb

2932
net.cpp

File diff suppressed because it is too large Load diff

2110
net.h

File diff suppressed because it is too large Load diff

124
noui.h
View file

@ -1,62 +1,62 @@
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
typedef void wxWindow; typedef void wxWindow;
#define wxYES 0x00000002 #define wxYES 0x00000002
#define wxOK 0x00000004 #define wxOK 0x00000004
#define wxNO 0x00000008 #define wxNO 0x00000008
#define wxYES_NO (wxYES|wxNO) #define wxYES_NO (wxYES|wxNO)
#define wxCANCEL 0x00000010 #define wxCANCEL 0x00000010
#define wxAPPLY 0x00000020 #define wxAPPLY 0x00000020
#define wxCLOSE 0x00000040 #define wxCLOSE 0x00000040
#define wxOK_DEFAULT 0x00000000 #define wxOK_DEFAULT 0x00000000
#define wxYES_DEFAULT 0x00000000 #define wxYES_DEFAULT 0x00000000
#define wxNO_DEFAULT 0x00000080 #define wxNO_DEFAULT 0x00000080
#define wxCANCEL_DEFAULT 0x80000000 #define wxCANCEL_DEFAULT 0x80000000
#define wxICON_EXCLAMATION 0x00000100 #define wxICON_EXCLAMATION 0x00000100
#define wxICON_HAND 0x00000200 #define wxICON_HAND 0x00000200
#define wxICON_WARNING wxICON_EXCLAMATION #define wxICON_WARNING wxICON_EXCLAMATION
#define wxICON_ERROR wxICON_HAND #define wxICON_ERROR wxICON_HAND
#define wxICON_QUESTION 0x00000400 #define wxICON_QUESTION 0x00000400
#define wxICON_INFORMATION 0x00000800 #define wxICON_INFORMATION 0x00000800
#define wxICON_STOP wxICON_HAND #define wxICON_STOP wxICON_HAND
#define wxICON_ASTERISK wxICON_INFORMATION #define wxICON_ASTERISK wxICON_INFORMATION
#define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800) #define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800)
#define wxFORWARD 0x00001000 #define wxFORWARD 0x00001000
#define wxBACKWARD 0x00002000 #define wxBACKWARD 0x00002000
#define wxRESET 0x00004000 #define wxRESET 0x00004000
#define wxHELP 0x00008000 #define wxHELP 0x00008000
#define wxMORE 0x00010000 #define wxMORE 0x00010000
#define wxSETUP 0x00020000 #define wxSETUP 0x00020000
inline int MyMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1) inline int MyMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
{ {
printf("%s: %s\n", caption.c_str(), message.c_str()); printf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str()); fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
return 4; return 4;
} }
#define wxMessageBox MyMessageBox #define wxMessageBox MyMessageBox
inline int ThreadSafeMessageBox(const string& message, const string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1) inline int ThreadSafeMessageBox(const string& message, const string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
{ {
return MyMessageBox(message, caption, style, parent, x, y); return MyMessageBox(message, caption, style, parent, x, y);
} }
inline bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent) inline bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent)
{ {
return true; return true;
} }
inline void CalledSetStatusBar(const string& strText, int nField) inline void CalledSetStatusBar(const string& strText, int nField)
{ {
} }
inline void UIThreadCall(boost::function0<void> fn) inline void UIThreadCall(boost::function0<void> fn)
{ {
} }
inline void MainFrameRepaint() inline void MainFrameRepaint()
{ {
} }

2404
rpc.cpp

File diff suppressed because it is too large Load diff

12
rpc.h
View file

@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
void ThreadRPCServer(void* parg); void ThreadRPCServer(void* parg);
int CommandLineRPC(int argc, char *argv[]); int CommandLineRPC(int argc, char *argv[]);

2396
script.cpp

File diff suppressed because it is too large Load diff

1330
script.h

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,423 +1,423 @@
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
#ifdef FOURWAYSSE2 #ifdef FOURWAYSSE2
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <xmmintrin.h> #include <xmmintrin.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#define NPAR 32 #define NPAR 32
static const unsigned int sha256_consts[] = { static const unsigned int sha256_consts[] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, /* 0 */ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, /* 0 */
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, /* 8 */ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, /* 8 */
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, /* 16 */ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, /* 16 */
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, /* 24 */ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, /* 24 */
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, /* 32 */ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, /* 32 */
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, /* 40 */ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, /* 40 */
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, /* 48 */ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, /* 48 */
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, /* 56 */ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, /* 56 */
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
}; };
static inline __m128i Ch(const __m128i b, const __m128i c, const __m128i d) { static inline __m128i Ch(const __m128i b, const __m128i c, const __m128i d) {
return (b & c) ^ (~b & d); return (b & c) ^ (~b & d);
} }
static inline __m128i Maj(const __m128i b, const __m128i c, const __m128i d) { static inline __m128i Maj(const __m128i b, const __m128i c, const __m128i d) {
return (b & c) ^ (b & d) ^ (c & d); return (b & c) ^ (b & d) ^ (c & d);
} }
static inline __m128i ROTR(__m128i x, const int n) { static inline __m128i ROTR(__m128i x, const int n) {
return _mm_srli_epi32(x, n) | _mm_slli_epi32(x, 32 - n); return _mm_srli_epi32(x, n) | _mm_slli_epi32(x, 32 - n);
} }
static inline __m128i SHR(__m128i x, const int n) { static inline __m128i SHR(__m128i x, const int n) {
return _mm_srli_epi32(x, n); return _mm_srli_epi32(x, n);
} }
/* SHA256 Functions */ /* SHA256 Functions */
#define BIGSIGMA0_256(x) (ROTR((x), 2) ^ ROTR((x), 13) ^ ROTR((x), 22)) #define BIGSIGMA0_256(x) (ROTR((x), 2) ^ ROTR((x), 13) ^ ROTR((x), 22))
#define BIGSIGMA1_256(x) (ROTR((x), 6) ^ ROTR((x), 11) ^ ROTR((x), 25)) #define BIGSIGMA1_256(x) (ROTR((x), 6) ^ ROTR((x), 11) ^ ROTR((x), 25))
#define SIGMA0_256(x) (ROTR((x), 7) ^ ROTR((x), 18) ^ SHR((x), 3)) #define SIGMA0_256(x) (ROTR((x), 7) ^ ROTR((x), 18) ^ SHR((x), 3))
#define SIGMA1_256(x) (ROTR((x), 17) ^ ROTR((x), 19) ^ SHR((x), 10)) #define SIGMA1_256(x) (ROTR((x), 17) ^ ROTR((x), 19) ^ SHR((x), 10))
static inline unsigned int store32(const __m128i x, int i) { static inline unsigned int store32(const __m128i x, int i) {
union { unsigned int ret[4]; __m128i x; } box; union { unsigned int ret[4]; __m128i x; } box;
box.x = x; box.x = x;
return box.ret[i]; return box.ret[i];
} }
static inline void store_epi32(const __m128i x, unsigned int *x0, unsigned int *x1, unsigned int *x2, unsigned int *x3) { static inline void store_epi32(const __m128i x, unsigned int *x0, unsigned int *x1, unsigned int *x2, unsigned int *x3) {
union { unsigned int ret[4]; __m128i x; } box; union { unsigned int ret[4]; __m128i x; } box;
box.x = x; box.x = x;
*x0 = box.ret[3]; *x1 = box.ret[2]; *x2 = box.ret[1]; *x3 = box.ret[0]; *x0 = box.ret[3]; *x1 = box.ret[2]; *x2 = box.ret[1]; *x3 = box.ret[0];
} }
#define add4(x0, x1, x2, x3) _mm_add_epi32(_mm_add_epi32(_mm_add_epi32(x0, x1), x2), x3) #define add4(x0, x1, x2, x3) _mm_add_epi32(_mm_add_epi32(_mm_add_epi32(x0, x1), x2), x3)
#define add5(x0, x1, x2, x3, x4) _mm_add_epi32(add4(x0, x1, x2, x3), x4) #define add5(x0, x1, x2, x3, x4) _mm_add_epi32(add4(x0, x1, x2, x3), x4)
#define SHA256ROUND(a, b, c, d, e, f, g, h, i, w) \ #define SHA256ROUND(a, b, c, d, e, f, g, h, i, w) \
T1 = add5(h, BIGSIGMA1_256(e), Ch(e, f, g), _mm_set1_epi32(sha256_consts[i]), w); \ T1 = add5(h, BIGSIGMA1_256(e), Ch(e, f, g), _mm_set1_epi32(sha256_consts[i]), w); \
d = _mm_add_epi32(d, T1); \ d = _mm_add_epi32(d, T1); \
h = _mm_add_epi32(T1, _mm_add_epi32(BIGSIGMA0_256(a), Maj(a, b, c))); h = _mm_add_epi32(T1, _mm_add_epi32(BIGSIGMA0_256(a), Maj(a, b, c)));
static inline void dumpreg(__m128i x, char *msg) { static inline void dumpreg(__m128i x, char *msg) {
union { unsigned int ret[4]; __m128i x; } box; union { unsigned int ret[4]; __m128i x; } box;
box.x = x ; box.x = x ;
printf("%s %08x %08x %08x %08x\n", msg, box.ret[0], box.ret[1], box.ret[2], box.ret[3]); printf("%s %08x %08x %08x %08x\n", msg, box.ret[0], box.ret[1], box.ret[2], box.ret[3]);
} }
#if 1 #if 1
#define dumpstate(i) printf("%s: %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", \ #define dumpstate(i) printf("%s: %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", \
__func__, store32(w0, i), store32(a, i), store32(b, i), store32(c, i), store32(d, i), store32(e, i), store32(f, i), store32(g, i), store32(h, i)); __func__, store32(w0, i), store32(a, i), store32(b, i), store32(c, i), store32(d, i), store32(e, i), store32(f, i), store32(g, i), store32(h, i));
#else #else
#define dumpstate() #define dumpstate()
#endif #endif
void Double_BlockSHA256(const void* pin, void* pad, const void *pre, unsigned int thash[9][NPAR], const void *init) void Double_BlockSHA256(const void* pin, void* pad, const void *pre, unsigned int thash[9][NPAR], const void *init)
{ {
unsigned int* In = (unsigned int*)pin; unsigned int* In = (unsigned int*)pin;
unsigned int* Pad = (unsigned int*)pad; unsigned int* Pad = (unsigned int*)pad;
unsigned int* hPre = (unsigned int*)pre; unsigned int* hPre = (unsigned int*)pre;
unsigned int* hInit = (unsigned int*)init; unsigned int* hInit = (unsigned int*)init;
unsigned int i, j, k; unsigned int i, j, k;
/* vectors used in calculation */ /* vectors used in calculation */
__m128i w0, w1, w2, w3, w4, w5, w6, w7; __m128i w0, w1, w2, w3, w4, w5, w6, w7;
__m128i w8, w9, w10, w11, w12, w13, w14, w15; __m128i w8, w9, w10, w11, w12, w13, w14, w15;
__m128i T1; __m128i T1;
__m128i a, b, c, d, e, f, g, h; __m128i a, b, c, d, e, f, g, h;
__m128i nonce; __m128i nonce;
/* nonce offset for vector */ /* nonce offset for vector */
__m128i offset = _mm_set_epi32(0x00000003, 0x00000002, 0x00000001, 0x00000000); __m128i offset = _mm_set_epi32(0x00000003, 0x00000002, 0x00000001, 0x00000000);
for(k = 0; k<NPAR; k+=4) { for(k = 0; k<NPAR; k+=4) {
w0 = _mm_set1_epi32(In[0]); w0 = _mm_set1_epi32(In[0]);
w1 = _mm_set1_epi32(In[1]); w1 = _mm_set1_epi32(In[1]);
w2 = _mm_set1_epi32(In[2]); w2 = _mm_set1_epi32(In[2]);
//w3 = _mm_set1_epi32(In[3]); nonce will be later hacked into the hash //w3 = _mm_set1_epi32(In[3]); nonce will be later hacked into the hash
w4 = _mm_set1_epi32(In[4]); w4 = _mm_set1_epi32(In[4]);
w5 = _mm_set1_epi32(In[5]); w5 = _mm_set1_epi32(In[5]);
w6 = _mm_set1_epi32(In[6]); w6 = _mm_set1_epi32(In[6]);
w7 = _mm_set1_epi32(In[7]); w7 = _mm_set1_epi32(In[7]);
w8 = _mm_set1_epi32(In[8]); w8 = _mm_set1_epi32(In[8]);
w9 = _mm_set1_epi32(In[9]); w9 = _mm_set1_epi32(In[9]);
w10 = _mm_set1_epi32(In[10]); w10 = _mm_set1_epi32(In[10]);
w11 = _mm_set1_epi32(In[11]); w11 = _mm_set1_epi32(In[11]);
w12 = _mm_set1_epi32(In[12]); w12 = _mm_set1_epi32(In[12]);
w13 = _mm_set1_epi32(In[13]); w13 = _mm_set1_epi32(In[13]);
w14 = _mm_set1_epi32(In[14]); w14 = _mm_set1_epi32(In[14]);
w15 = _mm_set1_epi32(In[15]); w15 = _mm_set1_epi32(In[15]);
/* hack nonce into lowest byte of w3 */ /* hack nonce into lowest byte of w3 */
nonce = _mm_set1_epi32(In[3]); nonce = _mm_set1_epi32(In[3]);
nonce = _mm_add_epi32(nonce, offset); nonce = _mm_add_epi32(nonce, offset);
nonce = _mm_add_epi32(nonce, _mm_set1_epi32(k)); nonce = _mm_add_epi32(nonce, _mm_set1_epi32(k));
w3 = nonce; w3 = nonce;
a = _mm_set1_epi32(hPre[0]); a = _mm_set1_epi32(hPre[0]);
b = _mm_set1_epi32(hPre[1]); b = _mm_set1_epi32(hPre[1]);
c = _mm_set1_epi32(hPre[2]); c = _mm_set1_epi32(hPre[2]);
d = _mm_set1_epi32(hPre[3]); d = _mm_set1_epi32(hPre[3]);
e = _mm_set1_epi32(hPre[4]); e = _mm_set1_epi32(hPre[4]);
f = _mm_set1_epi32(hPre[5]); f = _mm_set1_epi32(hPre[5]);
g = _mm_set1_epi32(hPre[6]); g = _mm_set1_epi32(hPre[6]);
h = _mm_set1_epi32(hPre[7]); h = _mm_set1_epi32(hPre[7]);
SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0); SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0);
SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1); SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1);
SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2); SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2);
SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3); SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3);
SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4); SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4);
SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5); SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5);
SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6); SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6);
SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7); SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7);
SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8); SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8);
SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9); SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9);
SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10); SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10);
SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11); SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11);
SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12); SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12);
SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13); SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13);
SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14); SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14);
SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15); SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15);
w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0); w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);
SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0); SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0);
w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1); w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);
SHA256ROUND(h, a, b, c, d, e, f, g, 17, w1); SHA256ROUND(h, a, b, c, d, e, f, g, 17, w1);
w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2); w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);
SHA256ROUND(g, h, a, b, c, d, e, f, 18, w2); SHA256ROUND(g, h, a, b, c, d, e, f, 18, w2);
w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3); w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);
SHA256ROUND(f, g, h, a, b, c, d, e, 19, w3); SHA256ROUND(f, g, h, a, b, c, d, e, 19, w3);
w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4); w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);
SHA256ROUND(e, f, g, h, a, b, c, d, 20, w4); SHA256ROUND(e, f, g, h, a, b, c, d, 20, w4);
w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5); w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);
SHA256ROUND(d, e, f, g, h, a, b, c, 21, w5); SHA256ROUND(d, e, f, g, h, a, b, c, 21, w5);
w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6); w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);
SHA256ROUND(c, d, e, f, g, h, a, b, 22, w6); SHA256ROUND(c, d, e, f, g, h, a, b, 22, w6);
w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7); w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);
SHA256ROUND(b, c, d, e, f, g, h, a, 23, w7); SHA256ROUND(b, c, d, e, f, g, h, a, 23, w7);
w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8); w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);
SHA256ROUND(a, b, c, d, e, f, g, h, 24, w8); SHA256ROUND(a, b, c, d, e, f, g, h, 24, w8);
w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9); w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);
SHA256ROUND(h, a, b, c, d, e, f, g, 25, w9); SHA256ROUND(h, a, b, c, d, e, f, g, 25, w9);
w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10); w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);
SHA256ROUND(g, h, a, b, c, d, e, f, 26, w10); SHA256ROUND(g, h, a, b, c, d, e, f, 26, w10);
w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11); w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);
SHA256ROUND(f, g, h, a, b, c, d, e, 27, w11); SHA256ROUND(f, g, h, a, b, c, d, e, 27, w11);
w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12); w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);
SHA256ROUND(e, f, g, h, a, b, c, d, 28, w12); SHA256ROUND(e, f, g, h, a, b, c, d, 28, w12);
w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13); w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);
SHA256ROUND(d, e, f, g, h, a, b, c, 29, w13); SHA256ROUND(d, e, f, g, h, a, b, c, 29, w13);
w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14); w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);
SHA256ROUND(c, d, e, f, g, h, a, b, 30, w14); SHA256ROUND(c, d, e, f, g, h, a, b, 30, w14);
w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15); w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);
SHA256ROUND(b, c, d, e, f, g, h, a, 31, w15); SHA256ROUND(b, c, d, e, f, g, h, a, 31, w15);
w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0); w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);
SHA256ROUND(a, b, c, d, e, f, g, h, 32, w0); SHA256ROUND(a, b, c, d, e, f, g, h, 32, w0);
w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1); w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);
SHA256ROUND(h, a, b, c, d, e, f, g, 33, w1); SHA256ROUND(h, a, b, c, d, e, f, g, 33, w1);
w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2); w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);
SHA256ROUND(g, h, a, b, c, d, e, f, 34, w2); SHA256ROUND(g, h, a, b, c, d, e, f, 34, w2);
w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3); w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);
SHA256ROUND(f, g, h, a, b, c, d, e, 35, w3); SHA256ROUND(f, g, h, a, b, c, d, e, 35, w3);
w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4); w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);
SHA256ROUND(e, f, g, h, a, b, c, d, 36, w4); SHA256ROUND(e, f, g, h, a, b, c, d, 36, w4);
w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5); w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);
SHA256ROUND(d, e, f, g, h, a, b, c, 37, w5); SHA256ROUND(d, e, f, g, h, a, b, c, 37, w5);
w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6); w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);
SHA256ROUND(c, d, e, f, g, h, a, b, 38, w6); SHA256ROUND(c, d, e, f, g, h, a, b, 38, w6);
w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7); w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);
SHA256ROUND(b, c, d, e, f, g, h, a, 39, w7); SHA256ROUND(b, c, d, e, f, g, h, a, 39, w7);
w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8); w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);
SHA256ROUND(a, b, c, d, e, f, g, h, 40, w8); SHA256ROUND(a, b, c, d, e, f, g, h, 40, w8);
w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9); w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);
SHA256ROUND(h, a, b, c, d, e, f, g, 41, w9); SHA256ROUND(h, a, b, c, d, e, f, g, 41, w9);
w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10); w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);
SHA256ROUND(g, h, a, b, c, d, e, f, 42, w10); SHA256ROUND(g, h, a, b, c, d, e, f, 42, w10);
w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11); w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);
SHA256ROUND(f, g, h, a, b, c, d, e, 43, w11); SHA256ROUND(f, g, h, a, b, c, d, e, 43, w11);
w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12); w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);
SHA256ROUND(e, f, g, h, a, b, c, d, 44, w12); SHA256ROUND(e, f, g, h, a, b, c, d, 44, w12);
w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13); w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);
SHA256ROUND(d, e, f, g, h, a, b, c, 45, w13); SHA256ROUND(d, e, f, g, h, a, b, c, 45, w13);
w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14); w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);
SHA256ROUND(c, d, e, f, g, h, a, b, 46, w14); SHA256ROUND(c, d, e, f, g, h, a, b, 46, w14);
w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15); w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);
SHA256ROUND(b, c, d, e, f, g, h, a, 47, w15); SHA256ROUND(b, c, d, e, f, g, h, a, 47, w15);
w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0); w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);
SHA256ROUND(a, b, c, d, e, f, g, h, 48, w0); SHA256ROUND(a, b, c, d, e, f, g, h, 48, w0);
w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1); w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);
SHA256ROUND(h, a, b, c, d, e, f, g, 49, w1); SHA256ROUND(h, a, b, c, d, e, f, g, 49, w1);
w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2); w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);
SHA256ROUND(g, h, a, b, c, d, e, f, 50, w2); SHA256ROUND(g, h, a, b, c, d, e, f, 50, w2);
w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3); w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);
SHA256ROUND(f, g, h, a, b, c, d, e, 51, w3); SHA256ROUND(f, g, h, a, b, c, d, e, 51, w3);
w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4); w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);
SHA256ROUND(e, f, g, h, a, b, c, d, 52, w4); SHA256ROUND(e, f, g, h, a, b, c, d, 52, w4);
w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5); w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);
SHA256ROUND(d, e, f, g, h, a, b, c, 53, w5); SHA256ROUND(d, e, f, g, h, a, b, c, 53, w5);
w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6); w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);
SHA256ROUND(c, d, e, f, g, h, a, b, 54, w6); SHA256ROUND(c, d, e, f, g, h, a, b, 54, w6);
w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7); w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);
SHA256ROUND(b, c, d, e, f, g, h, a, 55, w7); SHA256ROUND(b, c, d, e, f, g, h, a, 55, w7);
w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8); w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);
SHA256ROUND(a, b, c, d, e, f, g, h, 56, w8); SHA256ROUND(a, b, c, d, e, f, g, h, 56, w8);
w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9); w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);
SHA256ROUND(h, a, b, c, d, e, f, g, 57, w9); SHA256ROUND(h, a, b, c, d, e, f, g, 57, w9);
w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10); w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);
SHA256ROUND(g, h, a, b, c, d, e, f, 58, w10); SHA256ROUND(g, h, a, b, c, d, e, f, 58, w10);
w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11); w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);
SHA256ROUND(f, g, h, a, b, c, d, e, 59, w11); SHA256ROUND(f, g, h, a, b, c, d, e, 59, w11);
w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12); w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);
SHA256ROUND(e, f, g, h, a, b, c, d, 60, w12); SHA256ROUND(e, f, g, h, a, b, c, d, 60, w12);
w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13); w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);
SHA256ROUND(d, e, f, g, h, a, b, c, 61, w13); SHA256ROUND(d, e, f, g, h, a, b, c, 61, w13);
w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14); w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);
SHA256ROUND(c, d, e, f, g, h, a, b, 62, w14); SHA256ROUND(c, d, e, f, g, h, a, b, 62, w14);
w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15); w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);
SHA256ROUND(b, c, d, e, f, g, h, a, 63, w15); SHA256ROUND(b, c, d, e, f, g, h, a, 63, w15);
#define store_load(x, i, dest) \ #define store_load(x, i, dest) \
T1 = _mm_set1_epi32((hPre)[i]); \ T1 = _mm_set1_epi32((hPre)[i]); \
dest = _mm_add_epi32(T1, x); dest = _mm_add_epi32(T1, x);
store_load(a, 0, w0); store_load(a, 0, w0);
store_load(b, 1, w1); store_load(b, 1, w1);
store_load(c, 2, w2); store_load(c, 2, w2);
store_load(d, 3, w3); store_load(d, 3, w3);
store_load(e, 4, w4); store_load(e, 4, w4);
store_load(f, 5, w5); store_load(f, 5, w5);
store_load(g, 6, w6); store_load(g, 6, w6);
store_load(h, 7, w7); store_load(h, 7, w7);
w8 = _mm_set1_epi32(Pad[8]); w8 = _mm_set1_epi32(Pad[8]);
w9 = _mm_set1_epi32(Pad[9]); w9 = _mm_set1_epi32(Pad[9]);
w10 = _mm_set1_epi32(Pad[10]); w10 = _mm_set1_epi32(Pad[10]);
w11 = _mm_set1_epi32(Pad[11]); w11 = _mm_set1_epi32(Pad[11]);
w12 = _mm_set1_epi32(Pad[12]); w12 = _mm_set1_epi32(Pad[12]);
w13 = _mm_set1_epi32(Pad[13]); w13 = _mm_set1_epi32(Pad[13]);
w14 = _mm_set1_epi32(Pad[14]); w14 = _mm_set1_epi32(Pad[14]);
w15 = _mm_set1_epi32(Pad[15]); w15 = _mm_set1_epi32(Pad[15]);
a = _mm_set1_epi32(hInit[0]); a = _mm_set1_epi32(hInit[0]);
b = _mm_set1_epi32(hInit[1]); b = _mm_set1_epi32(hInit[1]);
c = _mm_set1_epi32(hInit[2]); c = _mm_set1_epi32(hInit[2]);
d = _mm_set1_epi32(hInit[3]); d = _mm_set1_epi32(hInit[3]);
e = _mm_set1_epi32(hInit[4]); e = _mm_set1_epi32(hInit[4]);
f = _mm_set1_epi32(hInit[5]); f = _mm_set1_epi32(hInit[5]);
g = _mm_set1_epi32(hInit[6]); g = _mm_set1_epi32(hInit[6]);
h = _mm_set1_epi32(hInit[7]); h = _mm_set1_epi32(hInit[7]);
SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0); SHA256ROUND(a, b, c, d, e, f, g, h, 0, w0);
SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1); SHA256ROUND(h, a, b, c, d, e, f, g, 1, w1);
SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2); SHA256ROUND(g, h, a, b, c, d, e, f, 2, w2);
SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3); SHA256ROUND(f, g, h, a, b, c, d, e, 3, w3);
SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4); SHA256ROUND(e, f, g, h, a, b, c, d, 4, w4);
SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5); SHA256ROUND(d, e, f, g, h, a, b, c, 5, w5);
SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6); SHA256ROUND(c, d, e, f, g, h, a, b, 6, w6);
SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7); SHA256ROUND(b, c, d, e, f, g, h, a, 7, w7);
SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8); SHA256ROUND(a, b, c, d, e, f, g, h, 8, w8);
SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9); SHA256ROUND(h, a, b, c, d, e, f, g, 9, w9);
SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10); SHA256ROUND(g, h, a, b, c, d, e, f, 10, w10);
SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11); SHA256ROUND(f, g, h, a, b, c, d, e, 11, w11);
SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12); SHA256ROUND(e, f, g, h, a, b, c, d, 12, w12);
SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13); SHA256ROUND(d, e, f, g, h, a, b, c, 13, w13);
SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14); SHA256ROUND(c, d, e, f, g, h, a, b, 14, w14);
SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15); SHA256ROUND(b, c, d, e, f, g, h, a, 15, w15);
w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0); w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);
SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0); SHA256ROUND(a, b, c, d, e, f, g, h, 16, w0);
w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1); w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);
SHA256ROUND(h, a, b, c, d, e, f, g, 17, w1); SHA256ROUND(h, a, b, c, d, e, f, g, 17, w1);
w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2); w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);
SHA256ROUND(g, h, a, b, c, d, e, f, 18, w2); SHA256ROUND(g, h, a, b, c, d, e, f, 18, w2);
w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3); w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);
SHA256ROUND(f, g, h, a, b, c, d, e, 19, w3); SHA256ROUND(f, g, h, a, b, c, d, e, 19, w3);
w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4); w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);
SHA256ROUND(e, f, g, h, a, b, c, d, 20, w4); SHA256ROUND(e, f, g, h, a, b, c, d, 20, w4);
w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5); w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);
SHA256ROUND(d, e, f, g, h, a, b, c, 21, w5); SHA256ROUND(d, e, f, g, h, a, b, c, 21, w5);
w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6); w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);
SHA256ROUND(c, d, e, f, g, h, a, b, 22, w6); SHA256ROUND(c, d, e, f, g, h, a, b, 22, w6);
w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7); w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);
SHA256ROUND(b, c, d, e, f, g, h, a, 23, w7); SHA256ROUND(b, c, d, e, f, g, h, a, 23, w7);
w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8); w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);
SHA256ROUND(a, b, c, d, e, f, g, h, 24, w8); SHA256ROUND(a, b, c, d, e, f, g, h, 24, w8);
w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9); w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);
SHA256ROUND(h, a, b, c, d, e, f, g, 25, w9); SHA256ROUND(h, a, b, c, d, e, f, g, 25, w9);
w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10); w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);
SHA256ROUND(g, h, a, b, c, d, e, f, 26, w10); SHA256ROUND(g, h, a, b, c, d, e, f, 26, w10);
w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11); w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);
SHA256ROUND(f, g, h, a, b, c, d, e, 27, w11); SHA256ROUND(f, g, h, a, b, c, d, e, 27, w11);
w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12); w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);
SHA256ROUND(e, f, g, h, a, b, c, d, 28, w12); SHA256ROUND(e, f, g, h, a, b, c, d, 28, w12);
w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13); w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);
SHA256ROUND(d, e, f, g, h, a, b, c, 29, w13); SHA256ROUND(d, e, f, g, h, a, b, c, 29, w13);
w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14); w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);
SHA256ROUND(c, d, e, f, g, h, a, b, 30, w14); SHA256ROUND(c, d, e, f, g, h, a, b, 30, w14);
w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15); w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);
SHA256ROUND(b, c, d, e, f, g, h, a, 31, w15); SHA256ROUND(b, c, d, e, f, g, h, a, 31, w15);
w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0); w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);
SHA256ROUND(a, b, c, d, e, f, g, h, 32, w0); SHA256ROUND(a, b, c, d, e, f, g, h, 32, w0);
w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1); w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);
SHA256ROUND(h, a, b, c, d, e, f, g, 33, w1); SHA256ROUND(h, a, b, c, d, e, f, g, 33, w1);
w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2); w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);
SHA256ROUND(g, h, a, b, c, d, e, f, 34, w2); SHA256ROUND(g, h, a, b, c, d, e, f, 34, w2);
w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3); w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);
SHA256ROUND(f, g, h, a, b, c, d, e, 35, w3); SHA256ROUND(f, g, h, a, b, c, d, e, 35, w3);
w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4); w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);
SHA256ROUND(e, f, g, h, a, b, c, d, 36, w4); SHA256ROUND(e, f, g, h, a, b, c, d, 36, w4);
w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5); w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);
SHA256ROUND(d, e, f, g, h, a, b, c, 37, w5); SHA256ROUND(d, e, f, g, h, a, b, c, 37, w5);
w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6); w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);
SHA256ROUND(c, d, e, f, g, h, a, b, 38, w6); SHA256ROUND(c, d, e, f, g, h, a, b, 38, w6);
w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7); w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);
SHA256ROUND(b, c, d, e, f, g, h, a, 39, w7); SHA256ROUND(b, c, d, e, f, g, h, a, 39, w7);
w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8); w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);
SHA256ROUND(a, b, c, d, e, f, g, h, 40, w8); SHA256ROUND(a, b, c, d, e, f, g, h, 40, w8);
w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9); w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);
SHA256ROUND(h, a, b, c, d, e, f, g, 41, w9); SHA256ROUND(h, a, b, c, d, e, f, g, 41, w9);
w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10); w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);
SHA256ROUND(g, h, a, b, c, d, e, f, 42, w10); SHA256ROUND(g, h, a, b, c, d, e, f, 42, w10);
w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11); w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);
SHA256ROUND(f, g, h, a, b, c, d, e, 43, w11); SHA256ROUND(f, g, h, a, b, c, d, e, 43, w11);
w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12); w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);
SHA256ROUND(e, f, g, h, a, b, c, d, 44, w12); SHA256ROUND(e, f, g, h, a, b, c, d, 44, w12);
w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13); w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);
SHA256ROUND(d, e, f, g, h, a, b, c, 45, w13); SHA256ROUND(d, e, f, g, h, a, b, c, 45, w13);
w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14); w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);
SHA256ROUND(c, d, e, f, g, h, a, b, 46, w14); SHA256ROUND(c, d, e, f, g, h, a, b, 46, w14);
w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15); w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);
SHA256ROUND(b, c, d, e, f, g, h, a, 47, w15); SHA256ROUND(b, c, d, e, f, g, h, a, 47, w15);
w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0); w0 = add4(SIGMA1_256(w14), w9, SIGMA0_256(w1), w0);
SHA256ROUND(a, b, c, d, e, f, g, h, 48, w0); SHA256ROUND(a, b, c, d, e, f, g, h, 48, w0);
w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1); w1 = add4(SIGMA1_256(w15), w10, SIGMA0_256(w2), w1);
SHA256ROUND(h, a, b, c, d, e, f, g, 49, w1); SHA256ROUND(h, a, b, c, d, e, f, g, 49, w1);
w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2); w2 = add4(SIGMA1_256(w0), w11, SIGMA0_256(w3), w2);
SHA256ROUND(g, h, a, b, c, d, e, f, 50, w2); SHA256ROUND(g, h, a, b, c, d, e, f, 50, w2);
w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3); w3 = add4(SIGMA1_256(w1), w12, SIGMA0_256(w4), w3);
SHA256ROUND(f, g, h, a, b, c, d, e, 51, w3); SHA256ROUND(f, g, h, a, b, c, d, e, 51, w3);
w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4); w4 = add4(SIGMA1_256(w2), w13, SIGMA0_256(w5), w4);
SHA256ROUND(e, f, g, h, a, b, c, d, 52, w4); SHA256ROUND(e, f, g, h, a, b, c, d, 52, w4);
w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5); w5 = add4(SIGMA1_256(w3), w14, SIGMA0_256(w6), w5);
SHA256ROUND(d, e, f, g, h, a, b, c, 53, w5); SHA256ROUND(d, e, f, g, h, a, b, c, 53, w5);
w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6); w6 = add4(SIGMA1_256(w4), w15, SIGMA0_256(w7), w6);
SHA256ROUND(c, d, e, f, g, h, a, b, 54, w6); SHA256ROUND(c, d, e, f, g, h, a, b, 54, w6);
w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7); w7 = add4(SIGMA1_256(w5), w0, SIGMA0_256(w8), w7);
SHA256ROUND(b, c, d, e, f, g, h, a, 55, w7); SHA256ROUND(b, c, d, e, f, g, h, a, 55, w7);
w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8); w8 = add4(SIGMA1_256(w6), w1, SIGMA0_256(w9), w8);
SHA256ROUND(a, b, c, d, e, f, g, h, 56, w8); SHA256ROUND(a, b, c, d, e, f, g, h, 56, w8);
w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9); w9 = add4(SIGMA1_256(w7), w2, SIGMA0_256(w10), w9);
SHA256ROUND(h, a, b, c, d, e, f, g, 57, w9); SHA256ROUND(h, a, b, c, d, e, f, g, 57, w9);
w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10); w10 = add4(SIGMA1_256(w8), w3, SIGMA0_256(w11), w10);
SHA256ROUND(g, h, a, b, c, d, e, f, 58, w10); SHA256ROUND(g, h, a, b, c, d, e, f, 58, w10);
w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11); w11 = add4(SIGMA1_256(w9), w4, SIGMA0_256(w12), w11);
SHA256ROUND(f, g, h, a, b, c, d, e, 59, w11); SHA256ROUND(f, g, h, a, b, c, d, e, 59, w11);
w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12); w12 = add4(SIGMA1_256(w10), w5, SIGMA0_256(w13), w12);
SHA256ROUND(e, f, g, h, a, b, c, d, 60, w12); SHA256ROUND(e, f, g, h, a, b, c, d, 60, w12);
w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13); w13 = add4(SIGMA1_256(w11), w6, SIGMA0_256(w14), w13);
SHA256ROUND(d, e, f, g, h, a, b, c, 61, w13); SHA256ROUND(d, e, f, g, h, a, b, c, 61, w13);
w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14); w14 = add4(SIGMA1_256(w12), w7, SIGMA0_256(w15), w14);
SHA256ROUND(c, d, e, f, g, h, a, b, 62, w14); SHA256ROUND(c, d, e, f, g, h, a, b, 62, w14);
w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15); w15 = add4(SIGMA1_256(w13), w8, SIGMA0_256(w0), w15);
SHA256ROUND(b, c, d, e, f, g, h, a, 63, w15); SHA256ROUND(b, c, d, e, f, g, h, a, 63, w15);
/* store resulsts directly in thash */ /* store resulsts directly in thash */
#define store_2(x,i) \ #define store_2(x,i) \
w0 = _mm_set1_epi32(hInit[i]); \ w0 = _mm_set1_epi32(hInit[i]); \
*(__m128i *)&(thash)[i][0+k] = _mm_add_epi32(w0, x); *(__m128i *)&(thash)[i][0+k] = _mm_add_epi32(w0, x);
store_2(a, 0); store_2(a, 0);
store_2(b, 1); store_2(b, 1);
store_2(c, 2); store_2(c, 2);
store_2(d, 3); store_2(d, 3);
store_2(e, 4); store_2(e, 4);
store_2(f, 5); store_2(f, 5);
store_2(g, 6); store_2(g, 6);
store_2(h, 7); store_2(h, 7);
*(__m128i *)&(thash)[8][0+k] = nonce; *(__m128i *)&(thash)[8][0+k] = nonce;
} }
} }
#endif // FOURWAYSSE2 #endif // FOURWAYSSE2

168
strlcpy.h
View file

@ -1,84 +1,84 @@
/* /*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies. * copyright notice and this permission notice appear in all copies.
* *
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* /*
* Copy src to string dst of size siz. At most siz-1 characters * Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0). * will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred. * Returns strlen(src); if retval >= siz, truncation occurred.
*/ */
inline size_t strlcpy(char *dst, const char *src, size_t siz) inline size_t strlcpy(char *dst, const char *src, size_t siz)
{ {
char *d = dst; char *d = dst;
const char *s = src; const char *s = src;
size_t n = siz; size_t n = siz;
/* Copy as many bytes as will fit */ /* Copy as many bytes as will fit */
if (n != 0) if (n != 0)
{ {
while (--n != 0) while (--n != 0)
{ {
if ((*d++ = *s++) == '\0') if ((*d++ = *s++) == '\0')
break; break;
} }
} }
/* Not enough room in dst, add NUL and traverse rest of src */ /* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) if (n == 0)
{ {
if (siz != 0) if (siz != 0)
*d = '\0'; /* NUL-terminate dst */ *d = '\0'; /* NUL-terminate dst */
while (*s++) while (*s++)
; ;
} }
return(s - src - 1); /* count does not include NUL */ return(s - src - 1); /* count does not include NUL */
} }
/* /*
* Appends src to string dst of size siz (unlike strncat, siz is the * Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters * full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz <= strlen(dst)). * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
* Returns strlen(src) + MIN(siz, strlen(initial dst)). * Returns strlen(src) + MIN(siz, strlen(initial dst)).
* If retval >= siz, truncation occurred. * If retval >= siz, truncation occurred.
*/ */
inline size_t strlcat(char *dst, const char *src, size_t siz) inline size_t strlcat(char *dst, const char *src, size_t siz)
{ {
char *d = dst; char *d = dst;
const char *s = src; const char *s = src;
size_t n = siz; size_t n = siz;
size_t dlen; size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */ /* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0') while (n-- != 0 && *d != '\0')
d++; d++;
dlen = d - dst; dlen = d - dst;
n = siz - dlen; n = siz - dlen;
if (n == 0) if (n == 0)
return(dlen + strlen(s)); return(dlen + strlen(s));
while (*s != '\0') while (*s != '\0')
{ {
if (n != 1) if (n != 1)
{ {
*d++ = *s; *d++ = *s;
n--; n--;
} }
s++; s++;
} }
*d = '\0'; *d = '\0';
return(dlen + (s - src)); /* count does not include NUL */ return(dlen + (s - src)); /* count does not include NUL */
} }

5816
ui.cpp

File diff suppressed because it is too large Load diff

692
ui.h
View file

@ -1,346 +1,346 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php. // file license.txt or http://www.opensource.org/licenses/mit-license.php.
DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1) DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)
extern wxLocale g_locale; extern wxLocale g_locale;
void HandleCtrlA(wxKeyEvent& event); void HandleCtrlA(wxKeyEvent& event);
string FormatTxStatus(const CWalletTx& wtx); string FormatTxStatus(const CWalletTx& wtx);
void UIThreadCall(boost::function0<void>); void UIThreadCall(boost::function0<void>);
int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1); int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent); bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);
void CalledSetStatusBar(const string& strText, int nField); void CalledSetStatusBar(const string& strText, int nField);
void MainFrameRepaint(); void MainFrameRepaint();
void CreateMainWindow(); void CreateMainWindow();
void SetStartOnSystemStartup(bool fAutoStart); void SetStartOnSystemStartup(bool fAutoStart);
inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1) inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
{ {
#ifdef GUI #ifdef GUI
if (!fDaemon) if (!fDaemon)
return wxMessageBox(message, caption, style, parent, x, y); return wxMessageBox(message, caption, style, parent, x, y);
#endif #endif
printf("wxMessageBox %s: %s\n", string(caption).c_str(), string(message).c_str()); printf("wxMessageBox %s: %s\n", string(caption).c_str(), string(message).c_str());
fprintf(stderr, "%s: %s\n", string(caption).c_str(), string(message).c_str()); fprintf(stderr, "%s: %s\n", string(caption).c_str(), string(message).c_str());
return wxOK; return wxOK;
} }
#define wxMessageBox MyMessageBox #define wxMessageBox MyMessageBox
class CMainFrame : public CMainFrameBase class CMainFrame : public CMainFrameBase
{ {
protected: protected:
// Event handlers // Event handlers
void OnNotebookPageChanged(wxNotebookEvent& event); void OnNotebookPageChanged(wxNotebookEvent& event);
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnIconize(wxIconizeEvent& event); void OnIconize(wxIconizeEvent& event);
void OnMouseEvents(wxMouseEvent& event); void OnMouseEvents(wxMouseEvent& event);
void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); } void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnPaintListCtrl(wxPaintEvent& event); void OnPaintListCtrl(wxPaintEvent& event);
void OnMenuFileExit(wxCommandEvent& event); void OnMenuFileExit(wxCommandEvent& event);
void OnMenuOptionsGenerate(wxCommandEvent& event); void OnMenuOptionsGenerate(wxCommandEvent& event);
void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event); void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
void OnMenuOptionsChangeYourAddress(wxCommandEvent& event); void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);
void OnMenuOptionsOptions(wxCommandEvent& event); void OnMenuOptionsOptions(wxCommandEvent& event);
void OnMenuHelpAbout(wxCommandEvent& event); void OnMenuHelpAbout(wxCommandEvent& event);
void OnButtonSend(wxCommandEvent& event); void OnButtonSend(wxCommandEvent& event);
void OnButtonAddressBook(wxCommandEvent& event); void OnButtonAddressBook(wxCommandEvent& event);
void OnSetFocusAddress(wxFocusEvent& event); void OnSetFocusAddress(wxFocusEvent& event);
void OnMouseEventsAddress(wxMouseEvent& event); void OnMouseEventsAddress(wxMouseEvent& event);
void OnButtonNew(wxCommandEvent& event); void OnButtonNew(wxCommandEvent& event);
void OnButtonCopy(wxCommandEvent& event); void OnButtonCopy(wxCommandEvent& event);
void OnListColBeginDrag(wxListEvent& event); void OnListColBeginDrag(wxListEvent& event);
void OnListItemActivated(wxListEvent& event); void OnListItemActivated(wxListEvent& event);
void OnListItemActivatedProductsSent(wxListEvent& event); void OnListItemActivatedProductsSent(wxListEvent& event);
void OnListItemActivatedOrdersSent(wxListEvent& event); void OnListItemActivatedOrdersSent(wxListEvent& event);
void OnListItemActivatedOrdersReceived(wxListEvent& event); void OnListItemActivatedOrdersReceived(wxListEvent& event);
public: public:
/** Constructor */ /** Constructor */
CMainFrame(wxWindow* parent); CMainFrame(wxWindow* parent);
~CMainFrame(); ~CMainFrame();
// Custom // Custom
enum enum
{ {
ALL = 0, ALL = 0,
SENTRECEIVED = 1, SENTRECEIVED = 1,
SENT = 2, SENT = 2,
RECEIVED = 3, RECEIVED = 3,
}; };
int nPage; int nPage;
wxListCtrl* m_listCtrl; wxListCtrl* m_listCtrl;
bool fShowGenerated; bool fShowGenerated;
bool fShowSent; bool fShowSent;
bool fShowReceived; bool fShowReceived;
bool fRefreshListCtrl; bool fRefreshListCtrl;
bool fRefreshListCtrlRunning; bool fRefreshListCtrlRunning;
bool fOnSetFocusAddress; bool fOnSetFocusAddress;
unsigned int nListViewUpdated; unsigned int nListViewUpdated;
bool fRefresh; bool fRefresh;
void OnUIThreadCall(wxCommandEvent& event); void OnUIThreadCall(wxCommandEvent& event);
int GetSortIndex(const string& strSort); int GetSortIndex(const string& strSort);
void InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str1, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5); void InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str1, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5);
bool DeleteLine(uint256 hashKey); bool DeleteLine(uint256 hashKey);
bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1); bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
void RefreshListCtrl(); void RefreshListCtrl();
void RefreshStatusColumn(); void RefreshStatusColumn();
}; };
class CTxDetailsDialog : public CTxDetailsDialogBase class CTxDetailsDialog : public CTxDetailsDialogBase
{ {
protected: protected:
// Event handlers // Event handlers
void OnButtonOK(wxCommandEvent& event); void OnButtonOK(wxCommandEvent& event);
public: public:
/** Constructor */ /** Constructor */
CTxDetailsDialog(wxWindow* parent, CWalletTx wtx); CTxDetailsDialog(wxWindow* parent, CWalletTx wtx);
// State // State
CWalletTx wtx; CWalletTx wtx;
}; };
class COptionsDialog : public COptionsDialogBase class COptionsDialog : public COptionsDialogBase
{ {
protected: protected:
// Event handlers // Event handlers
void OnListBox(wxCommandEvent& event); void OnListBox(wxCommandEvent& event);
void OnKillFocusTransactionFee(wxFocusEvent& event); void OnKillFocusTransactionFee(wxFocusEvent& event);
void OnCheckBoxLimitProcessors(wxCommandEvent& event); void OnCheckBoxLimitProcessors(wxCommandEvent& event);
void OnCheckBoxUseProxy(wxCommandEvent& event); void OnCheckBoxUseProxy(wxCommandEvent& event);
void OnKillFocusProxy(wxFocusEvent& event); void OnKillFocusProxy(wxFocusEvent& event);
void OnButtonOK(wxCommandEvent& event); void OnButtonOK(wxCommandEvent& event);
void OnButtonCancel(wxCommandEvent& event); void OnButtonCancel(wxCommandEvent& event);
void OnButtonApply(wxCommandEvent& event); void OnButtonApply(wxCommandEvent& event);
public: public:
/** Constructor */ /** Constructor */
COptionsDialog(wxWindow* parent); COptionsDialog(wxWindow* parent);
// Custom // Custom
bool fTmpStartOnSystemStartup; bool fTmpStartOnSystemStartup;
bool fTmpMinimizeOnClose; bool fTmpMinimizeOnClose;
void SelectPage(int nPage); void SelectPage(int nPage);
CAddress GetProxyAddr(); CAddress GetProxyAddr();
}; };
class CAboutDialog : public CAboutDialogBase class CAboutDialog : public CAboutDialogBase
{ {
protected: protected:
// Event handlers // Event handlers
void OnButtonOK(wxCommandEvent& event); void OnButtonOK(wxCommandEvent& event);
public: public:
/** Constructor */ /** Constructor */
CAboutDialog(wxWindow* parent); CAboutDialog(wxWindow* parent);
}; };
class CSendDialog : public CSendDialogBase class CSendDialog : public CSendDialogBase
{ {
protected: protected:
// Event handlers // Event handlers
void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); } void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }
void OnTextAddress(wxCommandEvent& event); void OnTextAddress(wxCommandEvent& event);
void OnKillFocusAmount(wxFocusEvent& event); void OnKillFocusAmount(wxFocusEvent& event);
void OnButtonAddressBook(wxCommandEvent& event); void OnButtonAddressBook(wxCommandEvent& event);
void OnButtonPaste(wxCommandEvent& event); void OnButtonPaste(wxCommandEvent& event);
void OnButtonSend(wxCommandEvent& event); void OnButtonSend(wxCommandEvent& event);
void OnButtonCancel(wxCommandEvent& event); void OnButtonCancel(wxCommandEvent& event);
public: public:
/** Constructor */ /** Constructor */
CSendDialog(wxWindow* parent, const wxString& strAddress=""); CSendDialog(wxWindow* parent, const wxString& strAddress="");
// Custom // Custom
bool fEnabledPrev; bool fEnabledPrev;
string strFromSave; string strFromSave;
string strMessageSave; string strMessageSave;
}; };
class CSendingDialog : public CSendingDialogBase class CSendingDialog : public CSendingDialogBase
{ {
public: public:
// Event handlers // Event handlers
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnButtonOK(wxCommandEvent& event); void OnButtonOK(wxCommandEvent& event);
void OnButtonCancel(wxCommandEvent& event); void OnButtonCancel(wxCommandEvent& event);
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
public: public:
/** Constructor */ /** Constructor */
CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn); CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 nPriceIn, const CWalletTx& wtxIn);
~CSendingDialog(); ~CSendingDialog();
// State // State
CAddress addr; CAddress addr;
int64 nPrice; int64 nPrice;
CWalletTx wtx; CWalletTx wtx;
wxDateTime start; wxDateTime start;
char pszStatus[10000]; char pszStatus[10000];
bool fCanCancel; bool fCanCancel;
bool fAbort; bool fAbort;
bool fSuccess; bool fSuccess;
bool fUIDone; bool fUIDone;
bool fWorkDone; bool fWorkDone;
void Close(); void Close();
void Repaint(); void Repaint();
bool Status(); bool Status();
bool Status(const string& str); bool Status(const string& str);
bool Error(const string& str); bool Error(const string& str);
void StartTransfer(); void StartTransfer();
void OnReply2(CDataStream& vRecv); void OnReply2(CDataStream& vRecv);
void OnReply3(CDataStream& vRecv); void OnReply3(CDataStream& vRecv);
}; };
void SendingDialogStartTransfer(void* parg); void SendingDialogStartTransfer(void* parg);
void SendingDialogOnReply2(void* parg, CDataStream& vRecv); void SendingDialogOnReply2(void* parg, CDataStream& vRecv);
void SendingDialogOnReply3(void* parg, CDataStream& vRecv); void SendingDialogOnReply3(void* parg, CDataStream& vRecv);
class CAddressBookDialog : public CAddressBookDialogBase class CAddressBookDialog : public CAddressBookDialogBase
{ {
protected: protected:
// Event handlers // Event handlers
void OnNotebookPageChanged(wxNotebookEvent& event); void OnNotebookPageChanged(wxNotebookEvent& event);
void OnListEndLabelEdit(wxListEvent& event); void OnListEndLabelEdit(wxListEvent& event);
void OnListItemSelected(wxListEvent& event); void OnListItemSelected(wxListEvent& event);
void OnListItemActivated(wxListEvent& event); void OnListItemActivated(wxListEvent& event);
void OnButtonDelete(wxCommandEvent& event); void OnButtonDelete(wxCommandEvent& event);
void OnButtonCopy(wxCommandEvent& event); void OnButtonCopy(wxCommandEvent& event);
void OnButtonEdit(wxCommandEvent& event); void OnButtonEdit(wxCommandEvent& event);
void OnButtonNew(wxCommandEvent& event); void OnButtonNew(wxCommandEvent& event);
void OnButtonOK(wxCommandEvent& event); void OnButtonOK(wxCommandEvent& event);
void OnButtonCancel(wxCommandEvent& event); void OnButtonCancel(wxCommandEvent& event);
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
public: public:
/** Constructor */ /** Constructor */
CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn); CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
// Custom // Custom
enum enum
{ {
SENDING = 0, SENDING = 0,
RECEIVING = 1, RECEIVING = 1,
}; };
int nPage; int nPage;
wxListCtrl* m_listCtrl; wxListCtrl* m_listCtrl;
bool fDuringSend; bool fDuringSend;
wxString GetAddress(); wxString GetAddress();
wxString GetSelectedAddress(); wxString GetSelectedAddress();
wxString GetSelectedSendingAddress(); wxString GetSelectedSendingAddress();
wxString GetSelectedReceivingAddress(); wxString GetSelectedReceivingAddress();
bool CheckIfMine(const string& strAddress, const string& strTitle); bool CheckIfMine(const string& strAddress, const string& strTitle);
}; };
class CGetTextFromUserDialog : public CGetTextFromUserDialogBase class CGetTextFromUserDialog : public CGetTextFromUserDialogBase
{ {
protected: protected:
// Event handlers // Event handlers
void OnButtonOK(wxCommandEvent& event) { EndModal(true); } void OnButtonOK(wxCommandEvent& event) { EndModal(true); }
void OnButtonCancel(wxCommandEvent& event) { EndModal(false); } void OnButtonCancel(wxCommandEvent& event) { EndModal(false); }
void OnClose(wxCloseEvent& event) { EndModal(false); } void OnClose(wxCloseEvent& event) { EndModal(false); }
void OnKeyDown(wxKeyEvent& event) void OnKeyDown(wxKeyEvent& event)
{ {
if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER) if (event.GetKeyCode() == '\r' || event.GetKeyCode() == WXK_NUMPAD_ENTER)
EndModal(true); EndModal(true);
else else
HandleCtrlA(event); HandleCtrlA(event);
} }
public: public:
/** Constructor */ /** Constructor */
CGetTextFromUserDialog(wxWindow* parent, CGetTextFromUserDialog(wxWindow* parent,
const string& strCaption, const string& strCaption,
const string& strMessage1, const string& strMessage1,
const string& strValue1="", const string& strValue1="",
const string& strMessage2="", const string& strMessage2="",
const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption) const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)
{ {
int x = GetSize().GetWidth(); int x = GetSize().GetWidth();
int y = GetSize().GetHeight(); int y = GetSize().GetHeight();
m_staticTextMessage1->SetLabel(strMessage1); m_staticTextMessage1->SetLabel(strMessage1);
m_textCtrl1->SetValue(strValue1); m_textCtrl1->SetValue(strValue1);
y += wxString(strMessage1).Freq('\n') * 14; y += wxString(strMessage1).Freq('\n') * 14;
if (!strMessage2.empty()) if (!strMessage2.empty())
{ {
m_staticTextMessage2->Show(true); m_staticTextMessage2->Show(true);
m_staticTextMessage2->SetLabel(strMessage2); m_staticTextMessage2->SetLabel(strMessage2);
m_textCtrl2->Show(true); m_textCtrl2->Show(true);
m_textCtrl2->SetValue(strValue2); m_textCtrl2->SetValue(strValue2);
y += 46 + wxString(strMessage2).Freq('\n') * 14; y += 46 + wxString(strMessage2).Freq('\n') * 14;
} }
#ifndef __WXMSW__ #ifndef __WXMSW__
x *= 1.14; x *= 1.14;
y *= 1.14; y *= 1.14;
#endif #endif
SetSize(x, y); SetSize(x, y);
} }
// Custom // Custom
string GetValue() { return (string)m_textCtrl1->GetValue(); } string GetValue() { return (string)m_textCtrl1->GetValue(); }
string GetValue1() { return (string)m_textCtrl1->GetValue(); } string GetValue1() { return (string)m_textCtrl1->GetValue(); }
string GetValue2() { return (string)m_textCtrl2->GetValue(); } string GetValue2() { return (string)m_textCtrl2->GetValue(); }
}; };
class CMyTaskBarIcon : public wxTaskBarIcon class CMyTaskBarIcon : public wxTaskBarIcon
{ {
protected: protected:
// Event handlers // Event handlers
void OnLeftButtonDClick(wxTaskBarIconEvent& event); void OnLeftButtonDClick(wxTaskBarIconEvent& event);
void OnMenuRestore(wxCommandEvent& event); void OnMenuRestore(wxCommandEvent& event);
void OnMenuOptions(wxCommandEvent& event); void OnMenuOptions(wxCommandEvent& event);
void OnUpdateUIGenerate(wxUpdateUIEvent& event); void OnUpdateUIGenerate(wxUpdateUIEvent& event);
void OnMenuGenerate(wxCommandEvent& event); void OnMenuGenerate(wxCommandEvent& event);
void OnMenuExit(wxCommandEvent& event); void OnMenuExit(wxCommandEvent& event);
public: public:
CMyTaskBarIcon() : wxTaskBarIcon() CMyTaskBarIcon() : wxTaskBarIcon()
{ {
Show(true); Show(true);
} }
void Show(bool fShow=true); void Show(bool fShow=true);
void Hide(); void Hide();
void Restore(); void Restore();
void UpdateTooltip(); void UpdateTooltip();
virtual wxMenu* CreatePopupMenu(); virtual wxMenu* CreatePopupMenu();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

2146
uibase.cpp

File diff suppressed because it is too large Load diff

844
uibase.h
View file

@ -1,422 +1,422 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008) // C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __uibase__ #ifndef __uibase__
#define __uibase__ #define __uibase__
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/bitmap.h> #include <wx/bitmap.h>
#include <wx/image.h> #include <wx/image.h>
#include <wx/icon.h> #include <wx/icon.h>
#include <wx/menu.h> #include <wx/menu.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/toolbar.h> #include <wx/toolbar.h>
#include <wx/statusbr.h> #include <wx/statusbr.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/choice.h> #include <wx/choice.h>
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/notebook.h> #include <wx/notebook.h>
#include <wx/frame.h> #include <wx/frame.h>
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include <wx/dialog.h> #include <wx/dialog.h>
#include <wx/listbox.h> #include <wx/listbox.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
#include <wx/scrolwin.h> #include <wx/scrolwin.h>
#include <wx/statbmp.h> #include <wx/statbmp.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#define wxID_MAINFRAME 1000 #define wxID_MAINFRAME 1000
#define wxID_OPTIONSGENERATEBITCOINS 1001 #define wxID_OPTIONSGENERATEBITCOINS 1001
#define wxID_BUTTONSEND 1002 #define wxID_BUTTONSEND 1002
#define wxID_BUTTONRECEIVE 1003 #define wxID_BUTTONRECEIVE 1003
#define wxID_TEXTCTRLADDRESS 1004 #define wxID_TEXTCTRLADDRESS 1004
#define wxID_BUTTONNEW 1005 #define wxID_BUTTONNEW 1005
#define wxID_BUTTONCOPY 1006 #define wxID_BUTTONCOPY 1006
#define wxID_TRANSACTIONFEE 1007 #define wxID_TRANSACTIONFEE 1007
#define wxID_PROXYIP 1008 #define wxID_PROXYIP 1008
#define wxID_PROXYPORT 1009 #define wxID_PROXYPORT 1009
#define wxID_TEXTCTRLPAYTO 1010 #define wxID_TEXTCTRLPAYTO 1010
#define wxID_BUTTONPASTE 1011 #define wxID_BUTTONPASTE 1011
#define wxID_BUTTONADDRESSBOOK 1012 #define wxID_BUTTONADDRESSBOOK 1012
#define wxID_TEXTCTRLAMOUNT 1013 #define wxID_TEXTCTRLAMOUNT 1013
#define wxID_CHOICETRANSFERTYPE 1014 #define wxID_CHOICETRANSFERTYPE 1014
#define wxID_LISTCTRL 1015 #define wxID_LISTCTRL 1015
#define wxID_BUTTONRENAME 1016 #define wxID_BUTTONRENAME 1016
#define wxID_PANELSENDING 1017 #define wxID_PANELSENDING 1017
#define wxID_LISTCTRLSENDING 1018 #define wxID_LISTCTRLSENDING 1018
#define wxID_PANELRECEIVING 1019 #define wxID_PANELRECEIVING 1019
#define wxID_LISTCTRLRECEIVING 1020 #define wxID_LISTCTRLRECEIVING 1020
#define wxID_BUTTONDELETE 1021 #define wxID_BUTTONDELETE 1021
#define wxID_BUTTONEDIT 1022 #define wxID_BUTTONEDIT 1022
#define wxID_TEXTCTRL 1023 #define wxID_TEXTCTRL 1023
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class CMainFrameBase /// Class CMainFrameBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class CMainFrameBase : public wxFrame class CMainFrameBase : public wxFrame
{ {
private: private:
protected: protected:
wxMenuBar* m_menubar; wxMenuBar* m_menubar;
wxMenu* m_menuFile; wxMenu* m_menuFile;
wxMenu* m_menuHelp; wxMenu* m_menuHelp;
wxToolBar* m_toolBar; wxToolBar* m_toolBar;
wxStaticText* m_staticText32; wxStaticText* m_staticText32;
wxButton* m_buttonNew; wxButton* m_buttonNew;
wxButton* m_buttonCopy; wxButton* m_buttonCopy;
wxStaticText* m_staticText41; wxStaticText* m_staticText41;
wxStaticText* m_staticTextBalance; wxStaticText* m_staticTextBalance;
wxChoice* m_choiceFilter; wxChoice* m_choiceFilter;
wxNotebook* m_notebook; wxNotebook* m_notebook;
wxPanel* m_panel9; wxPanel* m_panel9;
wxPanel* m_panel91; wxPanel* m_panel91;
wxPanel* m_panel92; wxPanel* m_panel92;
wxPanel* m_panel93; wxPanel* m_panel93;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }
virtual void OnIconize( wxIconizeEvent& event ){ event.Skip(); } virtual void OnIconize( wxIconizeEvent& event ){ event.Skip(); }
virtual void OnIdle( wxIdleEvent& event ){ event.Skip(); } virtual void OnIdle( wxIdleEvent& event ){ event.Skip(); }
virtual void OnMouseEvents( wxMouseEvent& event ){ event.Skip(); } virtual void OnMouseEvents( wxMouseEvent& event ){ event.Skip(); }
virtual void OnPaint( wxPaintEvent& event ){ event.Skip(); } virtual void OnPaint( wxPaintEvent& event ){ event.Skip(); }
virtual void OnMenuFileExit( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuFileExit( wxCommandEvent& event ){ event.Skip(); }
virtual void OnMenuOptionsGenerate( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuOptionsGenerate( wxCommandEvent& event ){ event.Skip(); }
virtual void OnUpdateUIOptionsGenerate( wxUpdateUIEvent& event ){ event.Skip(); } virtual void OnUpdateUIOptionsGenerate( wxUpdateUIEvent& event ){ event.Skip(); }
virtual void OnMenuOptionsChangeYourAddress( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuOptionsChangeYourAddress( wxCommandEvent& event ){ event.Skip(); }
virtual void OnMenuOptionsOptions( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuOptionsOptions( wxCommandEvent& event ){ event.Skip(); }
virtual void OnMenuHelpAbout( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuHelpAbout( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonSend( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonSend( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonAddressBook( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonAddressBook( wxCommandEvent& event ){ event.Skip(); }
virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); } virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }
virtual void OnMouseEventsAddress( wxMouseEvent& event ){ event.Skip(); } virtual void OnMouseEventsAddress( wxMouseEvent& event ){ event.Skip(); }
virtual void OnSetFocusAddress( wxFocusEvent& event ){ event.Skip(); } virtual void OnSetFocusAddress( wxFocusEvent& event ){ event.Skip(); }
virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }
virtual void OnNotebookPageChanged( wxNotebookEvent& event ){ event.Skip(); } virtual void OnNotebookPageChanged( wxNotebookEvent& event ){ event.Skip(); }
virtual void OnListColBeginDrag( wxListEvent& event ){ event.Skip(); } virtual void OnListColBeginDrag( wxListEvent& event ){ event.Skip(); }
virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); } virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }
virtual void OnPaintListCtrl( wxPaintEvent& event ){ event.Skip(); } virtual void OnPaintListCtrl( wxPaintEvent& event ){ event.Skip(); }
public: public:
wxMenu* m_menuOptions; wxMenu* m_menuOptions;
wxStatusBar* m_statusBar; wxStatusBar* m_statusBar;
wxTextCtrl* m_textCtrlAddress; wxTextCtrl* m_textCtrlAddress;
wxListCtrl* m_listCtrlAll; wxListCtrl* m_listCtrlAll;
wxListCtrl* m_listCtrlSentReceived; wxListCtrl* m_listCtrlSentReceived;
wxListCtrl* m_listCtrlSent; wxListCtrl* m_listCtrlSent;
wxListCtrl* m_listCtrlReceived; wxListCtrl* m_listCtrlReceived;
CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = _("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 723,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = _("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 723,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
~CMainFrameBase(); ~CMainFrameBase();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class CTxDetailsDialogBase /// Class CTxDetailsDialogBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class CTxDetailsDialogBase : public wxDialog class CTxDetailsDialogBase : public wxDialog
{ {
private: private:
protected: protected:
wxHtmlWindow* m_htmlWin; wxHtmlWindow* m_htmlWin;
wxButton* m_buttonOK; wxButton* m_buttonOK;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }
public: public:
CTxDetailsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Transaction Details"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 620,450 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); CTxDetailsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Transaction Details"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 620,450 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~CTxDetailsDialogBase(); ~CTxDetailsDialogBase();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class COptionsDialogBase /// Class COptionsDialogBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class COptionsDialogBase : public wxDialog class COptionsDialogBase : public wxDialog
{ {
private: private:
protected: protected:
wxListBox* m_listBox; wxListBox* m_listBox;
wxScrolledWindow* m_scrolledWindow; wxScrolledWindow* m_scrolledWindow;
wxPanel* m_panelMain; wxPanel* m_panelMain;
wxStaticText* m_staticText32; wxStaticText* m_staticText32;
wxStaticText* m_staticText31; wxStaticText* m_staticText31;
wxTextCtrl* m_textCtrlTransactionFee; wxTextCtrl* m_textCtrlTransactionFee;
wxCheckBox* m_checkBoxLimitProcessors; wxCheckBox* m_checkBoxLimitProcessors;
wxSpinCtrl* m_spinCtrlLimitProcessors; wxSpinCtrl* m_spinCtrlLimitProcessors;
wxStaticText* m_staticText35; wxStaticText* m_staticText35;
wxCheckBox* m_checkBoxStartOnSystemStartup; wxCheckBox* m_checkBoxStartOnSystemStartup;
wxCheckBox* m_checkBoxMinimizeToTray; wxCheckBox* m_checkBoxMinimizeToTray;
wxCheckBox* m_checkBoxMinimizeOnClose; wxCheckBox* m_checkBoxMinimizeOnClose;
wxCheckBox* m_checkBoxUseProxy; wxCheckBox* m_checkBoxUseProxy;
wxStaticText* m_staticTextProxyIP; wxStaticText* m_staticTextProxyIP;
wxTextCtrl* m_textCtrlProxyIP; wxTextCtrl* m_textCtrlProxyIP;
wxStaticText* m_staticTextProxyPort; wxStaticText* m_staticTextProxyPort;
wxTextCtrl* m_textCtrlProxyPort; wxTextCtrl* m_textCtrlProxyPort;
wxPanel* m_panelTest2; wxPanel* m_panelTest2;
wxStaticText* m_staticText321; wxStaticText* m_staticText321;
wxStaticText* m_staticText69; wxStaticText* m_staticText69;
wxButton* m_buttonOK; wxButton* m_buttonOK;
wxButton* m_buttonCancel; wxButton* m_buttonCancel;
wxButton* m_buttonApply; wxButton* m_buttonApply;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnListBox( wxCommandEvent& event ){ event.Skip(); } virtual void OnListBox( wxCommandEvent& event ){ event.Skip(); }
virtual void OnKillFocusTransactionFee( wxFocusEvent& event ){ event.Skip(); } virtual void OnKillFocusTransactionFee( wxFocusEvent& event ){ event.Skip(); }
virtual void OnCheckBoxLimitProcessors( wxCommandEvent& event ){ event.Skip(); } virtual void OnCheckBoxLimitProcessors( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCheckBoxMinimizeToTray( wxCommandEvent& event ){ event.Skip(); } virtual void OnCheckBoxMinimizeToTray( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCheckBoxUseProxy( wxCommandEvent& event ){ event.Skip(); } virtual void OnCheckBoxUseProxy( wxCommandEvent& event ){ event.Skip(); }
virtual void OnKillFocusProxy( wxFocusEvent& event ){ event.Skip(); } virtual void OnKillFocusProxy( wxFocusEvent& event ){ event.Skip(); }
virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonApply( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonApply( wxCommandEvent& event ){ event.Skip(); }
public: public:
COptionsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 540,360 ), long style = wxDEFAULT_DIALOG_STYLE ); COptionsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 540,360 ), long style = wxDEFAULT_DIALOG_STYLE );
~COptionsDialogBase(); ~COptionsDialogBase();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class CAboutDialogBase /// Class CAboutDialogBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class CAboutDialogBase : public wxDialog class CAboutDialogBase : public wxDialog
{ {
private: private:
protected: protected:
wxStaticBitmap* m_bitmap; wxStaticBitmap* m_bitmap;
wxStaticText* m_staticText40; wxStaticText* m_staticText40;
wxStaticText* m_staticTextMain; wxStaticText* m_staticTextMain;
wxButton* m_buttonOK; wxButton* m_buttonOK;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }
public: public:
wxStaticText* m_staticTextVersion; wxStaticText* m_staticTextVersion;
CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,333 ), long style = wxDEFAULT_DIALOG_STYLE ); CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,333 ), long style = wxDEFAULT_DIALOG_STYLE );
~CAboutDialogBase(); ~CAboutDialogBase();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class CSendDialogBase /// Class CSendDialogBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class CSendDialogBase : public wxDialog class CSendDialogBase : public wxDialog
{ {
private: private:
protected: protected:
wxStaticText* m_staticTextInstructions; wxStaticText* m_staticTextInstructions;
wxStaticBitmap* m_bitmapCheckMark; wxStaticBitmap* m_bitmapCheckMark;
wxStaticText* m_staticText36; wxStaticText* m_staticText36;
wxTextCtrl* m_textCtrlAddress; wxTextCtrl* m_textCtrlAddress;
wxButton* m_buttonPaste; wxButton* m_buttonPaste;
wxButton* m_buttonAddress; wxButton* m_buttonAddress;
wxStaticText* m_staticText19; wxStaticText* m_staticText19;
wxTextCtrl* m_textCtrlAmount; wxTextCtrl* m_textCtrlAmount;
wxStaticText* m_staticText20; wxStaticText* m_staticText20;
wxChoice* m_choiceTransferType; wxChoice* m_choiceTransferType;
wxStaticText* m_staticTextFrom; wxStaticText* m_staticTextFrom;
wxTextCtrl* m_textCtrlFrom; wxTextCtrl* m_textCtrlFrom;
wxStaticText* m_staticTextMessage; wxStaticText* m_staticTextMessage;
wxTextCtrl* m_textCtrlMessage; wxTextCtrl* m_textCtrlMessage;
wxButton* m_buttonSend; wxButton* m_buttonSend;
wxButton* m_buttonCancel; wxButton* m_buttonCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); } virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }
virtual void OnTextAddress( wxCommandEvent& event ){ event.Skip(); } virtual void OnTextAddress( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonPaste( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonPaste( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonAddressBook( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonAddressBook( wxCommandEvent& event ){ event.Skip(); }
virtual void OnKillFocusAmount( wxFocusEvent& event ){ event.Skip(); } virtual void OnKillFocusAmount( wxFocusEvent& event ){ event.Skip(); }
virtual void OnButtonSend( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonSend( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }
public: public:
CSendDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 675,298 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); CSendDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 675,298 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~CSendDialogBase(); ~CSendDialogBase();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class CSendingDialogBase /// Class CSendingDialogBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class CSendingDialogBase : public wxDialog class CSendingDialogBase : public wxDialog
{ {
private: private:
protected: protected:
wxStaticText* m_staticTextSending; wxStaticText* m_staticTextSending;
wxTextCtrl* m_textCtrlStatus; wxTextCtrl* m_textCtrlStatus;
wxButton* m_buttonOK; wxButton* m_buttonOK;
wxButton* m_buttonCancel; wxButton* m_buttonCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }
virtual void OnPaint( wxPaintEvent& event ){ event.Skip(); } virtual void OnPaint( wxPaintEvent& event ){ event.Skip(); }
virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }
public: public:
CSendingDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Sending..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 442,151 ), long style = wxDEFAULT_DIALOG_STYLE ); CSendingDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Sending..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 442,151 ), long style = wxDEFAULT_DIALOG_STYLE );
~CSendingDialogBase(); ~CSendingDialogBase();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class CYourAddressDialogBase /// Class CYourAddressDialogBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class CYourAddressDialogBase : public wxDialog class CYourAddressDialogBase : public wxDialog
{ {
private: private:
protected: protected:
wxStaticText* m_staticText45; wxStaticText* m_staticText45;
wxListCtrl* m_listCtrl; wxListCtrl* m_listCtrl;
wxButton* m_buttonRename; wxButton* m_buttonRename;
wxButton* m_buttonNew; wxButton* m_buttonNew;
wxButton* m_buttonCopy; wxButton* m_buttonCopy;
wxButton* m_buttonOK; wxButton* m_buttonOK;
wxButton* m_buttonCancel; wxButton* m_buttonCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }
virtual void OnListEndLabelEdit( wxListEvent& event ){ event.Skip(); } virtual void OnListEndLabelEdit( wxListEvent& event ){ event.Skip(); }
virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); } virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }
virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); } virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); }
virtual void OnButtonRename( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonRename( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }
public: public:
CYourAddressDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Your Bitcoin Addresses"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); CYourAddressDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Your Bitcoin Addresses"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~CYourAddressDialogBase(); ~CYourAddressDialogBase();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class CAddressBookDialogBase /// Class CAddressBookDialogBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class CAddressBookDialogBase : public wxDialog class CAddressBookDialogBase : public wxDialog
{ {
private: private:
protected: protected:
wxNotebook* m_notebook; wxNotebook* m_notebook;
wxPanel* m_panelSending; wxPanel* m_panelSending;
wxStaticText* m_staticText55; wxStaticText* m_staticText55;
wxListCtrl* m_listCtrlSending; wxListCtrl* m_listCtrlSending;
wxPanel* m_panelReceiving; wxPanel* m_panelReceiving;
wxStaticText* m_staticText45; wxStaticText* m_staticText45;
wxListCtrl* m_listCtrlReceiving; wxListCtrl* m_listCtrlReceiving;
wxButton* m_buttonDelete; wxButton* m_buttonDelete;
wxButton* m_buttonCopy; wxButton* m_buttonCopy;
wxButton* m_buttonEdit; wxButton* m_buttonEdit;
wxButton* m_buttonNew; wxButton* m_buttonNew;
wxButton* m_buttonOK; wxButton* m_buttonOK;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }
virtual void OnNotebookPageChanged( wxNotebookEvent& event ){ event.Skip(); } virtual void OnNotebookPageChanged( wxNotebookEvent& event ){ event.Skip(); }
virtual void OnListEndLabelEdit( wxListEvent& event ){ event.Skip(); } virtual void OnListEndLabelEdit( wxListEvent& event ){ event.Skip(); }
virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); } virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }
virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); } virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); }
virtual void OnButtonDelete( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonDelete( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonEdit( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonEdit( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }
public: public:
wxButton* m_buttonCancel; wxButton* m_buttonCancel;
CAddressBookDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Address Book"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); CAddressBookDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Address Book"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~CAddressBookDialogBase(); ~CAddressBookDialogBase();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class CGetTextFromUserDialogBase /// Class CGetTextFromUserDialogBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class CGetTextFromUserDialogBase : public wxDialog class CGetTextFromUserDialogBase : public wxDialog
{ {
private: private:
protected: protected:
wxStaticText* m_staticTextMessage1; wxStaticText* m_staticTextMessage1;
wxTextCtrl* m_textCtrl1; wxTextCtrl* m_textCtrl1;
wxStaticText* m_staticTextMessage2; wxStaticText* m_staticTextMessage2;
wxTextCtrl* m_textCtrl2; wxTextCtrl* m_textCtrl2;
wxButton* m_buttonOK; wxButton* m_buttonOK;
wxButton* m_buttonCancel; wxButton* m_buttonCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }
virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); } virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }
virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }
public: public:
CGetTextFromUserDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 440,138 ), long style = wxDEFAULT_DIALOG_STYLE ); CGetTextFromUserDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 440,138 ), long style = wxDEFAULT_DIALOG_STYLE );
~CGetTextFromUserDialogBase(); ~CGetTextFromUserDialogBase();
}; };
#endif //__uibase__ #endif //__uibase__

1514
uint256.h

File diff suppressed because it is too large Load diff

1524
util.cpp

File diff suppressed because it is too large Load diff

1178
util.h

File diff suppressed because it is too large Load diff