From 3907b4101a1794fa1d3cf2f3d659deb1c5f10921 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 11 May 2016 15:12:38 -0400 Subject: [PATCH] include openssl through OPENSSL macro --- Crypto.cpp | 14 ++++----- Crypto.h | 12 +++++--- CryptoConst.cpp | 73 ---------------------------------------------- CryptoConst.h | 38 ------------------------ Datagram.cpp | 3 +- Destination.cpp | 4 +-- Family.cpp | 6 ++-- Garlic.cpp | 5 ++-- I2NPProtocol.cpp | 2 -- I2NPProtocol.h | 2 +- I2PControl.cpp | 5 ++-- I2PControl.h | 2 +- Identity.cpp | 3 -- NTCPSession.cpp | 4 +-- NetDb.cpp | 2 +- Reseed.cpp | 10 +++---- SSUSession.cpp | 4 +-- Signature.h | 14 ++++----- Streaming.cpp | 2 +- Transports.cpp | 1 - Tunnel.cpp | 2 +- TunnelConfig.h | 1 - TunnelEndpoint.cpp | 2 +- TunnelGateway.cpp | 3 +- TunnelPool.cpp | 1 - 25 files changed, 47 insertions(+), 168 deletions(-) delete mode 100644 CryptoConst.cpp delete mode 100644 CryptoConst.h diff --git a/Crypto.cpp b/Crypto.cpp index 742296f5..ff68ff6a 100644 --- a/Crypto.cpp +++ b/Crypto.cpp @@ -3,15 +3,15 @@ #include #include #include -#include -#include -#include -#include -#include +#include "Crypto.h" +#include OPENSSL(sha.h) +#include OPENSSL(dh.h) +#include OPENSSL(md5.h) +#include OPENSSL(rand.h) +#include OPENSSL(crypto.h) #include "TunnelBase.h" -#include +#include OPENSSL(ssl.h) #include "Log.h" -#include "Crypto.h" namespace i2p { diff --git a/Crypto.h b/Crypto.h index e333940e..7b580c94 100644 --- a/Crypto.h +++ b/Crypto.h @@ -1,12 +1,16 @@ #ifndef CRYPTO_H__ #define CRYPTO_H__ +#define OPENSSL(file) + #include #include -#include -#include -#include -#include +#include OPENSSL(bn.h) +#include OPENSSL(dh.h) +#include OPENSSL(aes.h) +#include OPENSSL(dsa.h) +#include OPENSSL(sha.h) +#include OPENSSL(rand.h) #include "Base.h" namespace i2p diff --git a/CryptoConst.cpp b/CryptoConst.cpp deleted file mode 100644 index a8868988..00000000 --- a/CryptoConst.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include "CryptoConst.h" - -namespace i2p -{ -namespace crypto -{ - const uint8_t elgp_[256]= - { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, - 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, - 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, - 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, - 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, - 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, - 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, - 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, 0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, - 0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, - 0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, - 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, 0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, - 0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, - 0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, - 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, 0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, - 0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, - 0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - }; - - const uint8_t dsap_[128]= - { - 0x9c, 0x05, 0xb2, 0xaa, 0x96, 0x0d, 0x9b, 0x97, 0xb8, 0x93, 0x19, 0x63, 0xc9, 0xcc, 0x9e, 0x8c, - 0x30, 0x26, 0xe9, 0xb8, 0xed, 0x92, 0xfa, 0xd0, 0xa6, 0x9c, 0xc8, 0x86, 0xd5, 0xbf, 0x80, 0x15, - 0xfc, 0xad, 0xae, 0x31, 0xa0, 0xad, 0x18, 0xfa, 0xb3, 0xf0, 0x1b, 0x00, 0xa3, 0x58, 0xde, 0x23, - 0x76, 0x55, 0xc4, 0x96, 0x4a, 0xfa, 0xa2, 0xb3, 0x37, 0xe9, 0x6a, 0xd3, 0x16, 0xb9, 0xfb, 0x1c, - 0xc5, 0x64, 0xb5, 0xae, 0xc5, 0xb6, 0x9a, 0x9f, 0xf6, 0xc3, 0xe4, 0x54, 0x87, 0x07, 0xfe, 0xf8, - 0x50, 0x3d, 0x91, 0xdd, 0x86, 0x02, 0xe8, 0x67, 0xe6, 0xd3, 0x5d, 0x22, 0x35, 0xc1, 0x86, 0x9c, - 0xe2, 0x47, 0x9c, 0x3b, 0x9d, 0x54, 0x01, 0xde, 0x04, 0xe0, 0x72, 0x7f, 0xb3, 0x3d, 0x65, 0x11, - 0x28, 0x5d, 0x4c, 0xf2, 0x95, 0x38, 0xd9, 0xe3, 0xb6, 0x05, 0x1f, 0x5b, 0x22, 0xcc, 0x1c, 0x93 - }; - - const uint8_t dsaq_[20]= - { - 0xa5, 0xdf, 0xc2, 0x8f, 0xef, 0x4c, 0xa1, 0xe2, 0x86, 0x74, 0x4c, 0xd8, 0xee, 0xd9, 0xd2, 0x9d, - 0x68, 0x40, 0x46, 0xb7 - }; - - const uint8_t dsag_[128]= - { - 0x0c, 0x1f, 0x4d, 0x27, 0xd4, 0x00, 0x93, 0xb4, 0x29, 0xe9, 0x62, 0xd7, 0x22, 0x38, 0x24, 0xe0, - 0xbb, 0xc4, 0x7e, 0x7c, 0x83, 0x2a, 0x39, 0x23, 0x6f, 0xc6, 0x83, 0xaf, 0x84, 0x88, 0x95, 0x81, - 0x07, 0x5f, 0xf9, 0x08, 0x2e, 0xd3, 0x23, 0x53, 0xd4, 0x37, 0x4d, 0x73, 0x01, 0xcd, 0xa1, 0xd2, - 0x3c, 0x43, 0x1f, 0x46, 0x98, 0x59, 0x9d, 0xda, 0x02, 0x45, 0x18, 0x24, 0xff, 0x36, 0x97, 0x52, - 0x59, 0x36, 0x47, 0xcc, 0x3d, 0xdc, 0x19, 0x7d, 0xe9, 0x85, 0xe4, 0x3d, 0x13, 0x6c, 0xdc, 0xfc, - 0x6b, 0xd5, 0x40, 0x9c, 0xd2, 0xf4, 0x50, 0x82, 0x11, 0x42, 0xa5, 0xe6, 0xf8, 0xeb, 0x1c, 0x3a, - 0xb5, 0xd0, 0x48, 0x4b, 0x81, 0x29, 0xfc, 0xf1, 0x7b, 0xce, 0x4f, 0x7f, 0x33, 0x32, 0x1c, 0x3c, - 0xb3, 0xdb, 0xb1, 0x4a, 0x90, 0x5e, 0x7b, 0x2b, 0x3e, 0x93, 0xbe, 0x47, 0x08, 0xcb, 0xcc, 0x82 - }; - - const CryptoConstants& GetCryptoConstants () - { - static CryptoConstants cryptoConstants = - { - {elgp_, 256}, // elgp - {2}, // elgg - {dsap_, 128}, // dsap - {dsaq_, 20}, // dsaq - {dsag_, 128} // dsag - }; - return cryptoConstants; - } - -} -} - diff --git a/CryptoConst.h b/CryptoConst.h deleted file mode 100644 index ba48a35d..00000000 --- a/CryptoConst.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef CRYPTO_CONST_H__ -#define CRYPTO_CONST_H__ - -#include - -namespace i2p -{ -namespace crypto -{ - struct CryptoConstants - { - // DH/ElGamal - const CryptoPP::Integer elgp; - const CryptoPP::Integer elgg; - - // DSA - const CryptoPP::Integer dsap; - const CryptoPP::Integer dsaq; - const CryptoPP::Integer dsag; - }; - - const CryptoConstants& GetCryptoConstants (); - - // DH/ElGamal - #define elgp GetCryptoConstants ().elgp - #define elgg GetCryptoConstants ().elgg - - // DSA - #define dsap GetCryptoConstants ().dsap - #define dsaq GetCryptoConstants ().dsaq - #define dsag GetCryptoConstants ().dsag - - // RSA - const int rsae = 65537; -} -} - -#endif diff --git a/Datagram.cpp b/Datagram.cpp index 9221824d..2015622c 100644 --- a/Datagram.cpp +++ b/Datagram.cpp @@ -1,7 +1,6 @@ #include #include -#include -#include +#include "Crypto.h" #include "Log.h" #include "TunnelBase.h" #include "RouterContext.h" diff --git a/Destination.cpp b/Destination.cpp index 1534cbf9..f487b9ad 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -1,11 +1,9 @@ #include #include #include -#include - +#include "Crypto.h" #include "Log.h" #include "FS.h" -#include "Crypto.h" #include "Timestamp.h" #include "NetDb.h" #include "Destination.h" diff --git a/Family.cpp b/Family.cpp index 34406faa..a3dc5bd0 100644 --- a/Family.cpp +++ b/Family.cpp @@ -1,9 +1,9 @@ #include -#include -#include +#include "Crypto.h" +#include OPENSSL(evp.h) +#include OPENSSL(ssl.h) #include "FS.h" #include "Log.h" -#include "Crypto.h" #include "Family.h" namespace i2p diff --git a/Garlic.cpp b/Garlic.cpp index e11f8ec8..2188ade7 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -2,8 +2,9 @@ #include "I2PEndian.h" #include #include -#include -#include +#include "Crypto.h" +#include OPENSSL(rand.h) +#include OPENSSL(sha.h) #include "RouterContext.h" #include "I2NPProtocol.h" #include "Tunnel.h" diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 9674fdca..e2451f68 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -1,7 +1,5 @@ #include #include -#include -#include #include "Base.h" #include "Log.h" #include "Crypto.h" diff --git a/I2NPProtocol.h b/I2NPProtocol.h index cf8f4266..113e8eb8 100644 --- a/I2NPProtocol.h +++ b/I2NPProtocol.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include "Crypto.h" #include "I2PEndian.h" #include "Identity.h" #include "RouterInfo.h" diff --git a/I2PControl.cpp b/I2PControl.cpp index 1ef56c2d..ef9b5081 100644 --- a/I2PControl.cpp +++ b/I2PControl.cpp @@ -1,7 +1,8 @@ #include #include -#include -#include +#include "Crypto.h" +#include OPENSSL(x509.h) +#include OPENSSL(pem.h) #include #include #include diff --git a/I2PControl.h b/I2PControl.h index 728c9925..0bd70956 100644 --- a/I2PControl.h +++ b/I2PControl.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include // might include openssl #include namespace i2p diff --git a/Identity.cpp b/Identity.cpp index f221dd04..71ca007f 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -1,8 +1,5 @@ #include #include -#include -#include -#include #include "Crypto.h" #include "I2PEndian.h" #include "Log.h" diff --git a/NTCPSession.cpp b/NTCPSession.cpp index a7832335..ae020f5f 100644 --- a/NTCPSession.cpp +++ b/NTCPSession.cpp @@ -1,13 +1,11 @@ #include #include -#include -#include #include #include "I2PEndian.h" #include "Base.h" +#include "Crypto.h" #include "Log.h" #include "Timestamp.h" -#include "Crypto.h" #include "I2NPProtocol.h" #include "RouterContext.h" #include "Transports.h" diff --git a/NetDb.cpp b/NetDb.cpp index 857381d8..3aeff92f 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -2,10 +2,10 @@ #include #include #include -#include #include #include "I2PEndian.h" #include "Base.h" +#include "Crypto.h" #include "Log.h" #include "Timestamp.h" #include "I2NPProtocol.h" diff --git a/Reseed.cpp b/Reseed.cpp index caac8071..81811a5e 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -3,10 +3,11 @@ #include #include #include -#include -#include -#include -#include +#include // might include openssl +#include "Crypto.h" +#include OPENSSL(bn.h) +#include OPENSSL(ssl.h) +#include OPENSSL(err.h) #include #include "I2PEndian.h" @@ -14,7 +15,6 @@ #include "FS.h" #include "Log.h" #include "Identity.h" -#include "Crypto.h" #include "NetDb.h" #include "util.h" diff --git a/SSUSession.cpp b/SSUSession.cpp index a1bbf4d9..cf56ca15 100644 --- a/SSUSession.cpp +++ b/SSUSession.cpp @@ -1,7 +1,5 @@ #include -#include -#include -#include +#include "Crypto.h" #include "Log.h" #include "Timestamp.h" #include "RouterContext.h" diff --git a/Signature.h b/Signature.h index a0b54468..e3a39339 100644 --- a/Signature.h +++ b/Signature.h @@ -3,14 +3,14 @@ #include #include -#include -#include -#include -#include -#include -#include -#include #include "Crypto.h" +#include OPENSSL(sha.h) +#include OPENSSL(dsa.h) +#include OPENSSL(ec.h) +#include OPENSSL(ecdsa.h) +#include OPENSSL(rsa.h) +#include OPENSSL(rand.h) +#include OPENSSL(evp.h) namespace i2p { diff --git a/Streaming.cpp b/Streaming.cpp index e425ce27..ab0a6df0 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -1,4 +1,4 @@ -#include +#include "Crypto.h" #include "Log.h" #include "RouterInfo.h" #include "RouterContext.h" diff --git a/Transports.cpp b/Transports.cpp index 0fdfce3d..057e2472 100644 --- a/Transports.cpp +++ b/Transports.cpp @@ -1,4 +1,3 @@ -#include #include "Log.h" #include "Crypto.h" #include "RouterContext.h" diff --git a/Tunnel.cpp b/Tunnel.cpp index 5e237d87..bf81dc5e 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include "Crypto.h" #include "RouterContext.h" #include "Log.h" #include "Timestamp.h" diff --git a/TunnelConfig.h b/TunnelConfig.h index c089b13c..0340254e 100644 --- a/TunnelConfig.h +++ b/TunnelConfig.h @@ -5,7 +5,6 @@ #include #include #include -#include #include "Crypto.h" #include "Identity.h" #include "RouterContext.h" diff --git a/TunnelEndpoint.cpp b/TunnelEndpoint.cpp index 842b624f..1bc8a937 100644 --- a/TunnelEndpoint.cpp +++ b/TunnelEndpoint.cpp @@ -1,6 +1,6 @@ #include "I2PEndian.h" #include -#include +#include "Crypto.h" #include "Log.h" #include "NetDb.h" #include "I2NPProtocol.h" diff --git a/TunnelGateway.cpp b/TunnelGateway.cpp index 4f517eb8..3383010b 100644 --- a/TunnelGateway.cpp +++ b/TunnelGateway.cpp @@ -1,6 +1,5 @@ #include -#include -#include +#include "Crypto.h" #include "I2PEndian.h" #include "Log.h" #include "RouterContext.h" diff --git a/TunnelPool.cpp b/TunnelPool.cpp index c74ff475..5e7e8ec4 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -1,5 +1,4 @@ #include -#include #include "I2PEndian.h" #include "Crypto.h" #include "Tunnel.h"