diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 9cb60d8f65..0189ffb794 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/app/main/DBInit.cpp b/src/ripple/app/main/DBInit.cpp index 1107c4941a..1e07ed5f6d 100644 --- a/src/ripple/app/main/DBInit.cpp +++ b/src/ripple/app/main/DBInit.cpp @@ -116,9 +116,7 @@ const char* WalletDBInit[] = "CREATE TABLE IF NOT EXISTS NodeIdentity ( \ PublicKey CHARACTER(53), \ - PrivateKey CHARACTER(52), \ - Dh512 TEXT, \ - Dh1024 TEXT \ + PrivateKey CHARACTER(52) \ );", // Miscellaneous persistent information diff --git a/src/ripple/app/main/LocalCredentials.cpp b/src/ripple/app/main/LocalCredentials.cpp index 1760446f50..32d5d6f9a9 100644 --- a/src/ripple/app/main/LocalCredentials.cpp +++ b/src/ripple/app/main/LocalCredentials.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -94,21 +93,15 @@ bool LocalCredentials::nodeIdentityCreate () RippleAddress naNodePublic = RippleAddress::createNodePublic (naSeed); RippleAddress naNodePrivate = RippleAddress::createNodePrivate (naSeed); - // Make new key. - std::string strDh512 (getRawDHParams (512)); - - std::string strDh1024 = strDh512; - // // Store the node information // auto db = getApp().getWalletDB ().checkoutDb (); - *db << str (boost::format ("INSERT INTO NodeIdentity (PublicKey,PrivateKey,Dh512,Dh1024) VALUES ('%s','%s',%s,%s);") - % naNodePublic.humanNodePublic () - % naNodePrivate.humanNodePrivate () - % sqlEscape (strDh512) - % sqlEscape (strDh1024)); + *db << str (boost::format ( + "INSERT INTO NodeIdentity (PublicKey,PrivateKey) VALUES ('%s','%s');") + % naNodePublic.humanNodePublic () + % naNodePrivate.humanNodePrivate ()); if (!getConfig ().QUIET) std::cerr << "NodeIdentity: Created." << std::endl; diff --git a/src/ripple/basics/impl/make_SSLContext.cpp b/src/ripple/basics/impl/make_SSLContext.cpp index 450dc661bb..d3abcf7e6b 100644 --- a/src/ripple/basics/impl/make_SSLContext.cpp +++ b/src/ripple/basics/impl/make_SSLContext.cpp @@ -194,6 +194,104 @@ make_DH(std::string const& params) return dh_ptr(dh); } +/** Retrieve the raw DH parameters for the requested key size. + + The result is in the binary format expected by the OpenSSL function + d2i_DHparams and may contain nulls. Use size to determine the actual size. + + If the result is empty, the key size is unsupported. As of June 11, 2015, + OpenSSL never passes anything other than 512 or 1024. +*/ +static +std::string +getRawDHParams (int keySize) +{ + std::string params; + + switch (keySize) + { + case 512: + { + // These are the DH parameters that OpenCoin has chosen for Ripple + // + std::uint8_t const raw512 [] = { + 0x30, 0x46, 0x02, 0x41, 0x00, 0x98, 0x15, 0xd2, 0xd0, 0x08, 0x32, 0xda, + 0xaa, 0xac, 0xc4, 0x71, 0xa3, 0x1b, 0x11, 0xf0, 0x6c, 0x62, 0xb2, 0x35, + 0x8a, 0x10, 0x92, 0xc6, 0x0a, 0xa3, 0x84, 0x7e, 0xaf, 0x17, 0x29, 0x0b, + 0x70, 0xef, 0x07, 0x4f, 0xfc, 0x9d, 0x6d, 0x87, 0x99, 0x19, 0x09, 0x5b, + 0x6e, 0xdb, 0x57, 0x72, 0x4a, 0x7e, 0xcd, 0xaf, 0xbd, 0x3a, 0x97, 0x55, + 0x51, 0x77, 0x5a, 0x34, 0x7c, 0xe8, 0xc5, 0x71, 0x63, 0x02, 0x01, 0x02 + }; + + params.resize (sizeof (raw512)); + std::copy (raw512, raw512 + sizeof (raw512), params.begin ()); + break; + } + + case 1024: + { + // These are the DH parameters that Ripple Labs has chosen for Ripple + // + std::uint8_t const raw1024 [] = { + 0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0x86, 0xb1, 0x85, 0x36, 0x3d, + 0xbc, 0x0b, 0x03, 0xa5, 0xde, 0x53, 0x23, 0x4c, 0x59, 0xd4, 0x2b, 0x2e, + 0x88, 0xdf, 0x83, 0x8e, 0xab, 0xe9, 0xc9, 0x0f, 0x20, 0x5c, 0x3e, 0x8d, + 0x0e, 0x2c, 0xff, 0xcf, 0x3a, 0xfa, 0x71, 0x67, 0xb2, 0x90, 0xb5, 0x9e, + 0x13, 0x9f, 0xa3, 0x70, 0xb2, 0xdf, 0x8d, 0xa4, 0x91, 0xfb, 0x26, 0xe0, + 0x95, 0xd2, 0xf9, 0x3b, 0xa5, 0x1f, 0xe4, 0x88, 0x0f, 0x65, 0xfc, 0x8e, + 0x58, 0x47, 0x8c, 0x77, 0x93, 0x8c, 0x2d, 0x2a, 0xfa, 0x50, 0xb4, 0xc5, + 0x29, 0xba, 0x65, 0xc4, 0x39, 0xeb, 0x8a, 0xc5, 0x93, 0x39, 0xf9, 0x3c, + 0x15, 0x1e, 0x95, 0x82, 0x0d, 0x02, 0xff, 0x92, 0x4c, 0xc5, 0x07, 0x76, + 0x62, 0xaf, 0xdc, 0xc0, 0x96, 0x95, 0xcf, 0x61, 0x51, 0x17, 0x7c, 0x02, + 0x81, 0xdb, 0xc2, 0x6b, 0x07, 0x03, 0x96, 0x39, 0xcc, 0xde, 0xc9, 0xcd, + 0x5d, 0x77, 0x3b, 0x02, 0x01, 0x02 + }; + params.resize (sizeof (raw1024)); + std::copy (raw1024, raw1024 + sizeof (raw1024), params.begin ()); + break; + } + + case 2048: + { + // These are the DH parameters that Ripple Labs has chosen for Ripple + // + std::uint8_t const raw2048 [] = { + 0x30, 0x82, 0x01, 0x08, 0x02, 0x82, 0x01, 0x01, 0x00, 0x8f, 0xca, 0x66, + 0x85, 0x33, 0xcb, 0xcf, 0x36, 0x27, 0xb2, 0x4c, 0xb8, 0x50, 0xb8, 0xf9, + 0x53, 0xf8, 0xb9, 0x2d, 0x1c, 0xa2, 0xad, 0x86, 0x58, 0x29, 0x3b, 0x88, + 0x3e, 0xf5, 0x65, 0xb8, 0xda, 0x22, 0xf4, 0x8b, 0x21, 0x12, 0x18, 0xf7, + 0x16, 0xcd, 0x7c, 0xc7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xaa, 0x52, 0xa2, 0xdb, 0xb6, 0xf5, 0xa1, + 0x88, 0x85, 0xa1, 0xd5, 0x87, 0xb8, 0x07, 0xd3, 0x97, 0xbe, 0x37, 0x74, + 0x72, 0xf1, 0xa8, 0x29, 0xf1, 0xa7, 0x7d, 0x19, 0xc3, 0x27, 0x09, 0xcf, + 0x23, 0x02, 0x01, 0x02 + }; + params.resize (sizeof (raw2048)); + std::copy (raw2048, raw2048 + sizeof (raw2048), params.begin ()); + break; + } + + default: + break; + }; + + return params; +} + static DH* getDH (int keyLength) @@ -429,95 +527,6 @@ initAuthenticated (boost::asio::ssl::context& context, } // openssl //------------------------------------------------------------------------------ -std::string -getRawDHParams (int keySize) -{ - std::string params; - - switch (keySize) - { - case 512: - { - // These are the DH parameters that OpenCoin has chosen for Ripple - // - std::uint8_t const raw512 [] = { - 0x30, 0x46, 0x02, 0x41, 0x00, 0x98, 0x15, 0xd2, 0xd0, 0x08, 0x32, 0xda, - 0xaa, 0xac, 0xc4, 0x71, 0xa3, 0x1b, 0x11, 0xf0, 0x6c, 0x62, 0xb2, 0x35, - 0x8a, 0x10, 0x92, 0xc6, 0x0a, 0xa3, 0x84, 0x7e, 0xaf, 0x17, 0x29, 0x0b, - 0x70, 0xef, 0x07, 0x4f, 0xfc, 0x9d, 0x6d, 0x87, 0x99, 0x19, 0x09, 0x5b, - 0x6e, 0xdb, 0x57, 0x72, 0x4a, 0x7e, 0xcd, 0xaf, 0xbd, 0x3a, 0x97, 0x55, - 0x51, 0x77, 0x5a, 0x34, 0x7c, 0xe8, 0xc5, 0x71, 0x63, 0x02, 0x01, 0x02 - }; - - params.resize (sizeof (raw512)); - std::copy (raw512, raw512 + sizeof (raw512), params.begin ()); - break; - } - - case 1024: - { - // These are the DH parameters that Ripple Labs has chosen for Ripple - // - std::uint8_t const raw1024 [] = { - 0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0x86, 0xb1, 0x85, 0x36, 0x3d, - 0xbc, 0x0b, 0x03, 0xa5, 0xde, 0x53, 0x23, 0x4c, 0x59, 0xd4, 0x2b, 0x2e, - 0x88, 0xdf, 0x83, 0x8e, 0xab, 0xe9, 0xc9, 0x0f, 0x20, 0x5c, 0x3e, 0x8d, - 0x0e, 0x2c, 0xff, 0xcf, 0x3a, 0xfa, 0x71, 0x67, 0xb2, 0x90, 0xb5, 0x9e, - 0x13, 0x9f, 0xa3, 0x70, 0xb2, 0xdf, 0x8d, 0xa4, 0x91, 0xfb, 0x26, 0xe0, - 0x95, 0xd2, 0xf9, 0x3b, 0xa5, 0x1f, 0xe4, 0x88, 0x0f, 0x65, 0xfc, 0x8e, - 0x58, 0x47, 0x8c, 0x77, 0x93, 0x8c, 0x2d, 0x2a, 0xfa, 0x50, 0xb4, 0xc5, - 0x29, 0xba, 0x65, 0xc4, 0x39, 0xeb, 0x8a, 0xc5, 0x93, 0x39, 0xf9, 0x3c, - 0x15, 0x1e, 0x95, 0x82, 0x0d, 0x02, 0xff, 0x92, 0x4c, 0xc5, 0x07, 0x76, - 0x62, 0xaf, 0xdc, 0xc0, 0x96, 0x95, 0xcf, 0x61, 0x51, 0x17, 0x7c, 0x02, - 0x81, 0xdb, 0xc2, 0x6b, 0x07, 0x03, 0x96, 0x39, 0xcc, 0xde, 0xc9, 0xcd, - 0x5d, 0x77, 0x3b, 0x02, 0x01, 0x02 - }; - params.resize (sizeof (raw1024)); - std::copy (raw1024, raw1024 + sizeof (raw1024), params.begin ()); - break; - } - - case 2048: - { - // These are the DH parameters that Ripple Labs has chosen for Ripple - // - std::uint8_t const raw2048 [] = { - 0x30, 0x82, 0x01, 0x08, 0x02, 0x82, 0x01, 0x01, 0x00, 0x8f, 0xca, 0x66, - 0x85, 0x33, 0xcb, 0xcf, 0x36, 0x27, 0xb2, 0x4c, 0xb8, 0x50, 0xb8, 0xf9, - 0x53, 0xf8, 0xb9, 0x2d, 0x1c, 0xa2, 0xad, 0x86, 0x58, 0x29, 0x3b, 0x88, - 0x3e, 0xf5, 0x65,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a, 0x5c, 0xc2, 0x91, 0xb9, 0x2b, 0xf8, 0x17, - 0x8d, 0xed, 0x44, 0xaa, 0x47, 0xaa, 0x52, 0xa2, 0xdb, 0xb6, 0xf5, 0xa1, - 0x88, 0x85, 0xa1, 0xd5, 0x87, 0xb8, 0x07, 0xd3, 0x97, 0xbe, 0x37, 0x74, - 0x72, 0xf1, 0xa8, 0x29, 0xf1, 0xa7, 0x7d, 0x19, 0xc3, 0x27, 0x09, 0xcf, - 0x23, 0x02, 0x01, 0x02 - }; - params.resize (sizeof (raw2048)); - std::copy (raw2048, raw2048 + sizeof (raw2048), params.begin ()); - break; - } - - default: - break; - }; - - return params; -} - std::shared_ptr make_SSLContext() { diff --git a/src/ripple/basics/make_SSLContext.h b/src/ripple/basics/make_SSLContext.h index 8ef97cc5ef..e22948f437 100644 --- a/src/ripple/basics/make_SSLContext.h +++ b/src/ripple/basics/make_SSLContext.h @@ -26,15 +26,6 @@ namespace ripple { -/** Retrieve raw DH parameters. - This is in the format expected by the OpenSSL function d2i_DHparams. - The vector is binary. An empty vector means the key size is unsupported. - @note The string may contain nulls in the middle. Use size() to - determine the actual size. -*/ -std::string -getRawDHParams(int keySize); - /** Create a self-signed SSL context that allows anonymous Diffie Hellman. */ std::shared_ptr make_SSLContext();