Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[submodule "openssl"]
path = openssl
url = https://github.com/pocoproject/openssl
branch = master

[submodule "gradle"]
path = gradle
url = https://github.com/pocoproject/gradle
3 changes: 0 additions & 3 deletions Crypto/src/CipherKeyImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ CipherKeyImpl::Mode CipherKeyImpl::mode() const

case EVP_CIPH_GCM_MODE:
return MODE_GCM;

case EVP_CIPH_CCM_MODE:
return MODE_CCM;
#endif
}
throw Poco::IllegalStateException("Unexpected value of EVP_CIPHER_mode()");
Expand Down
12 changes: 10 additions & 2 deletions Crypto/src/DigestEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
//


//Changed for port OpenSSL -> BoringSSL
#if defined(OPENSSL_IS_BORINGSSL)
#include "openssl/digest.h"
#endif
#include "Poco/Crypto/DigestEngine.h"
#include "Poco/Exception.h"


namespace Poco {
namespace Crypto {

Expand All @@ -37,7 +40,12 @@ DigestEngine::~DigestEngine()

int DigestEngine::nid() const
{
return EVP_MD_nid(EVP_MD_CTX_md(_pContext));
//Changed for port OpenSSL -> BoringSSL
#if defined(OPENSSL_IS_BORINGSSL)
return EVP_MD_type(EVP_MD_CTX_md(_pContext));
#else
return EVP_MD_nid(EVP_MD_CTX_md(_pContext));
#endif
}

std::size_t DigestEngine::digestLength() const
Expand Down
37 changes: 21 additions & 16 deletions Crypto/src/PKCS12Container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,31 @@ PKCS12Container::~PKCS12Container()

std::string PKCS12Container::extractFriendlyName(X509* pCert)
{
std::string friendlyName;
if(pCert)
{
STACK_OF(PKCS12_SAFEBAG)*pBags = 0;
PKCS12_SAFEBAG*pBag = PKCS12_add_cert(&pBags, pCert);
if(pBag)
{
char* pBuffer = PKCS12_get_friendlyname(pBag);
if(pBuffer)
//Changed for port OpenSSL -> BoringSSL
#if defined(OPENSSL_IS_BORINGSSL)
throw NotImplementedException();
#else
std::string friendlyName;
f(pCert)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt this will compile

{
STACK_OF(PKCS12_SAFEBAG)*pBags = 0;
PKCS12_SAFEBAG*pBag = PKCS12_add_cert(&pBags, pCert);
if(pBag)
{
friendlyName = pBuffer;
OPENSSL_free(pBuffer);
char* pBuffer = PKCS12_get_friendlyname(pBag);
if(pBuffer)
{
friendlyName = pBuffer;
OPENSSL_free(pBuffer);
}
if(pBags) sk_PKCS12_SAFEBAG_pop_free(pBags, PKCS12_SAFEBAG_free);
}
if(pBags) sk_PKCS12_SAFEBAG_pop_free(pBags, PKCS12_SAFEBAG_free);
else throw OpenSSLException("PKCS12Container::extractFriendlyName()");
}
else throw OpenSSLException("PKCS12Container::extractFriendlyName()");
}
else throw NullPointerException("PKCS12Container::extractFriendlyName()");
else throw NullPointerException("PKCS12Container::extractFriendlyName()");

return friendlyName;
return friendlyName;
#endif
}


Expand Down
7 changes: 6 additions & 1 deletion Crypto/src/RSACipherImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ namespace
case RSA_PADDING_PKCS1_OAEP:
return RSA_PKCS1_OAEP_PADDING;
case RSA_PADDING_SSLV23:
return RSA_SSLV23_PADDING;
//Changed for port OpenSSL -> BoringSSL
#if defined(OPENSSL_IS_BORINGSSL)
throw NotImplementedException();
#else
return RSA_SSLV23_PADDING;
#endif
case RSA_PADDING_NONE:
return RSA_NO_PADDING;
default:
Expand Down
44 changes: 31 additions & 13 deletions NetSSL_OpenSSL/src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ void Context::useCertificate(const Poco::Crypto::X509Certificate& certificate)

void Context::addChainCertificate(const Poco::Crypto::X509Certificate& certificate)
{
int errCode = SSL_CTX_add_extra_chain_cert(_pSSLContext, certificate.certificate());
//Changed for port OpenSSL -> BoringSSL
#if defined(OPENSSL_IS_BORINGSSL)
int errCode = SSL_CTX_add_extra_chain_cert(_pSSLContext, const_cast<X509*>(certificate.certificate()));
#else
int errCode = SSL_CTX_add_extra_chain_cert(_pSSLContext, certificate.certificate());
#endif

if (errCode != 1)
{
std::string msg = Utility::getLastError();
Expand Down Expand Up @@ -511,25 +517,37 @@ void Context::initDH(const std::string& dhParamsFile)
std::string msg = Utility::getLastError();
throw SSLContextException("Error creating Diffie-Hellman parameters", msg);
}
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
BIGNUM* p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0);
BIGNUM* g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0);
DH_set0_pqg(dh, p, 0, g);
DH_set_length(dh, 160);
if (!p || !g)
{
DH_free(dh);
throw SSLContextException("Error creating Diffie-Hellman parameters");
}
#else

//Changed for port OpenSSL -> BoringSSL
#if defined(OPENSSL_IS_BORINGSSL)
dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0);
dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to set dh->length here?

dh->length = 160;
if ((!dh->p) || (!dh->g))
{
DH_free(dh);
throw SSLContextException("Error creating Diffie-Hellman parameters");
}
#else
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
BIGNUM* p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0);
BIGNUM* g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0);
DH_set0_pqg(dh, p, 0, g);
DH_set_length(dh, 160);
if (!p || !g)
{
DH_free(dh);
throw SSLContextException("Error creating Diffie-Hellman parameters");
}
#else
dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0);
dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0);
dh->length = 160;
if ((!dh->p) || (!dh->g))
{
DH_free(dh);
throw SSLContextException("Error creating Diffie-Hellman parameters");
}
#endif
#endif
}
SSL_CTX_set_tmp_dh(_pSSLContext, dh);
Expand Down
1 change: 0 additions & 1 deletion openssl
Submodule openssl deleted from 26b167