You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by sc...@apache.org on 2016/12/16 22:37:18 UTC
svn commit: r1774675 - in /santuario/xml-security-cpp/trunk:
Projects/VC10.0/xsec/xsec_lib/ Projects/VC14.0/xsec/xsec_lib/
Projects/VC6.0/xsec/xsec_lib/ Projects/VC7.0/xsec/xsec_lib/
Projects/VC8.0/xsec/xsec_lib/ Projects/VC9.0/xsec/xsec_lib/ xsec/ xse...
Author: scantor
Date: Fri Dec 16 22:37:18 2016
New Revision: 1774675
URL: http://svn.apache.org/viewvc?rev=1774675&view=rev
Log:
OpenSSL 1.1 compatibility - Make DSA opaque
Added:
santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.cpp (with props)
santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.hpp (with props)
Modified:
santuario/xml-security-cpp/trunk/Projects/VC10.0/xsec/xsec_lib/xsec_lib.vcxproj
santuario/xml-security-cpp/trunk/Projects/VC14.0/xsec/xsec_lib/xsec_lib.vcxproj
santuario/xml-security-cpp/trunk/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp
santuario/xml-security-cpp/trunk/Projects/VC7.0/xsec/xsec_lib/xsec_lib.vcproj
santuario/xml-security-cpp/trunk/Projects/VC8.0/xsec/xsec_lib/xsec_lib.vcproj
santuario/xml-security-cpp/trunk/Projects/VC9.0/xsec/xsec_lib/xsec_lib.vcproj
santuario/xml-security-cpp/trunk/xsec/Makefile.am
santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp
santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp
Modified: santuario/xml-security-cpp/trunk/Projects/VC10.0/xsec/xsec_lib/xsec_lib.vcxproj
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/Projects/VC10.0/xsec/xsec_lib/xsec_lib.vcxproj?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/Projects/VC10.0/xsec/xsec_lib/xsec_lib.vcxproj (original)
+++ santuario/xml-security-cpp/trunk/Projects/VC10.0/xsec/xsec_lib/xsec_lib.vcxproj Fri Dec 16 22:37:18 2016
@@ -464,6 +464,7 @@
<ClCompile Include="..\..\..\..\xsec\dsig\DSIGXPathFilterExpr.cpp" />
<ClCompile Include="..\..\..\..\xsec\dsig\DSIGXPathHere.cpp" />
<ClCompile Include="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoKeyEC.cpp" />
+ <ClCompile Include="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.cpp" />
<ClCompile Include="..\..\..\..\xsec\enc\XSECCryptoBase64.cpp" />
<ClCompile Include="..\..\..\..\xsec\enc\XSECCryptoException.cpp" />
<ClCompile Include="..\..\..\..\xsec\enc\XSECCryptoProvider.cpp" />
@@ -612,6 +613,7 @@
<ClInclude Include="..\..\..\..\xsec\dsig\DSIGXPathFilterExpr.hpp" />
<ClInclude Include="..\..\..\..\xsec\dsig\DSIGXPathHere.hpp" />
<ClInclude Include="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoKeyEC.hpp" />
+ <ClInclude Include="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.hpp" />
<ClInclude Include="..\..\..\..\xsec\enc\XSECCryptoKeyEC.hpp" />
<ClInclude Include="..\..\..\..\xsec\framework\resource.h" />
<ClInclude Include="..\..\..\..\xsec\enc\XSECCryptoBase64.hpp" />
Modified: santuario/xml-security-cpp/trunk/Projects/VC14.0/xsec/xsec_lib/xsec_lib.vcxproj
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/Projects/VC14.0/xsec/xsec_lib/xsec_lib.vcxproj?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/Projects/VC14.0/xsec/xsec_lib/xsec_lib.vcxproj (original)
+++ santuario/xml-security-cpp/trunk/Projects/VC14.0/xsec/xsec_lib/xsec_lib.vcxproj Fri Dec 16 22:37:18 2016
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug No Xalan|Win32">
@@ -489,6 +489,7 @@
<ClCompile Include="..\..\..\..\xsec\dsig\DSIGXPathFilterExpr.cpp" />
<ClCompile Include="..\..\..\..\xsec\dsig\DSIGXPathHere.cpp" />
<ClCompile Include="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoKeyEC.cpp" />
+ <ClCompile Include="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.cpp" />
<ClCompile Include="..\..\..\..\xsec\enc\XSECCryptoBase64.cpp" />
<ClCompile Include="..\..\..\..\xsec\enc\XSECCryptoException.cpp" />
<ClCompile Include="..\..\..\..\xsec\enc\XSECCryptoProvider.cpp" />
@@ -637,6 +638,7 @@
<ClInclude Include="..\..\..\..\xsec\dsig\DSIGXPathFilterExpr.hpp" />
<ClInclude Include="..\..\..\..\xsec\dsig\DSIGXPathHere.hpp" />
<ClInclude Include="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoKeyEC.hpp" />
+ <ClInclude Include="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.hpp" />
<ClInclude Include="..\..\..\..\xsec\enc\XSECCryptoKeyEC.hpp" />
<ClInclude Include="..\..\..\..\xsec\framework\resource.h" />
<ClInclude Include="..\..\..\..\xsec\enc\XSECCryptoBase64.hpp" />
Modified: santuario/xml-security-cpp/trunk/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp (original)
+++ santuario/xml-security-cpp/trunk/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp Fri Dec 16 22:37:18 2016
@@ -401,6 +401,22 @@ SOURCE=..\..\..\..\xsec\enc\openssl\Open
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\xsec\enc\openssl\OpenSSLCryptoBase64.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\xsec\enc\openssl\OpenSSLCryptoBase64.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\xsec\enc\openssl\OpenSSSupport.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\xsec\enc\openssl\OpenSSLSupport.hpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\xsec\enc\openssl\OpenSSLCryptoHash.cpp
# End Source File
# Begin Source File
Modified: santuario/xml-security-cpp/trunk/Projects/VC7.0/xsec/xsec_lib/xsec_lib.vcproj
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/Projects/VC7.0/xsec/xsec_lib/xsec_lib.vcproj?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/Projects/VC7.0/xsec/xsec_lib/xsec_lib.vcproj (original)
+++ santuario/xml-security-cpp/trunk/Projects/VC7.0/xsec/xsec_lib/xsec_lib.vcproj Fri Dec 16 22:37:18 2016
@@ -470,6 +470,14 @@
RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoBase64.hpp">
</File>
<File
+ RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.hpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoHash.cpp">
</File>
<File
Modified: santuario/xml-security-cpp/trunk/Projects/VC8.0/xsec/xsec_lib/xsec_lib.vcproj
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/Projects/VC8.0/xsec/xsec_lib/xsec_lib.vcproj?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/Projects/VC8.0/xsec/xsec_lib/xsec_lib.vcproj (original)
+++ santuario/xml-security-cpp/trunk/Projects/VC8.0/xsec/xsec_lib/xsec_lib.vcproj Fri Dec 16 22:37:18 2016
@@ -1046,6 +1046,14 @@
>
</File>
<File
+ RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.hpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoBase64.hpp"
>
</File>
Modified: santuario/xml-security-cpp/trunk/Projects/VC9.0/xsec/xsec_lib/xsec_lib.vcproj
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/Projects/VC9.0/xsec/xsec_lib/xsec_lib.vcproj?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/Projects/VC9.0/xsec/xsec_lib/xsec_lib.vcproj (original)
+++ santuario/xml-security-cpp/trunk/Projects/VC9.0/xsec/xsec_lib/xsec_lib.vcproj Fri Dec 16 22:37:18 2016
@@ -1061,6 +1061,10 @@
>
</File>
<File
+ RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLSupport.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoKeyDSA.hpp"
>
</File>
@@ -1080,6 +1084,10 @@
RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoKeyRSA.hpp"
>
</File>
+ <File
+ RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoSupport.hpp"
+ >
+ </File>
<File
RelativePath="..\..\..\..\xsec\enc\OpenSSL\OpenSSLCryptoKeyEC.cpp"
>
Modified: santuario/xml-security-cpp/trunk/xsec/Makefile.am
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/Makefile.am?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/Makefile.am (original)
+++ santuario/xml-security-cpp/trunk/xsec/Makefile.am Fri Dec 16 22:37:18 2016
@@ -170,7 +170,8 @@ opensslinclude_HEADERS = \
enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp \
enc/OpenSSL/OpenSSLCryptoKeyEC.hpp \
enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp \
- enc/OpenSSL/OpenSSLCryptoHash.hpp
+ enc/OpenSSL/OpenSSLCryptoHash.hpp \
+ enc/OpenSSL/OpenSSLSupport.hpp
nssinclude_HEADERS = \
enc/NSS/NSSCryptoX509.hpp \
@@ -575,8 +576,9 @@ openssl_sources = \
enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp \
enc/OpenSSL/OpenSSLCryptoKeyEC.cpp \
enc/OpenSSL/OpenSSLCryptoSymmetricKey.cpp \
- enc/OpenSSL/OpenSSLCryptoKeyHMAC.cpp
-
+ enc/OpenSSL/OpenSSLCryptoKeyHMAC.cpp \
+ enc/OpenSSL/OpenSSLSupport.cpp
+
nss_sources = \
enc/NSS/NSSCryptoX509.cpp \
enc/NSS/NSSCryptoHashHMAC.cpp \
Modified: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp Fri Dec 16 22:37:18 2016
@@ -30,6 +30,7 @@
#include <xsec/framework/XSECDefs.hpp>
#if defined (XSEC_HAVE_OPENSSL)
+#include <xsec/enc/OpenSSL/OpenSSLSupport.hpp>
#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
#include <xsec/enc/OpenSSL/OpenSSLCryptoBase64.hpp>
#include <xsec/enc/XSECCryptoException.hpp>
@@ -42,7 +43,8 @@ XSEC_USING_XERCES(ArrayJanitor);
#include <openssl/dsa.h>
-OpenSSLCryptoKeyDSA::OpenSSLCryptoKeyDSA() : mp_dsaKey(NULL) {
+
+OpenSSLCryptoKeyDSA::OpenSSLCryptoKeyDSA() : mp_dsaKey(NULL), mp_accumP(NULL), mp_accumQ(NULL), mp_accumG(NULL) {
};
OpenSSLCryptoKeyDSA::~OpenSSLCryptoKeyDSA() {
@@ -54,6 +56,14 @@ OpenSSLCryptoKeyDSA::~OpenSSLCryptoKeyDS
if (mp_dsaKey)
DSA_free(mp_dsaKey);
+ if (mp_accumG)
+ BN_free(mp_accumG);
+
+ if (mp_accumP)
+ BN_free(mp_accumP);
+
+ if (mp_accumQ)
+ BN_free(mp_accumQ);
};
// Generic key functions
@@ -64,53 +74,126 @@ XSECCryptoKey::KeyType OpenSSLCryptoKeyD
if (mp_dsaKey == NULL)
return KEY_NONE;
- if (mp_dsaKey->priv_key != NULL && mp_dsaKey->pub_key != NULL)
+ if (DSA_get0_privkey(mp_dsaKey) != NULL && DSA_get0_pubkey(mp_dsaKey) != NULL)
return KEY_DSA_PAIR;
- if (mp_dsaKey->priv_key != NULL)
+ if (DSA_get0_privkey(mp_dsaKey) != NULL)
return KEY_DSA_PRIVATE;
- if (mp_dsaKey->pub_key != NULL)
+ if (DSA_get0_pubkey(mp_dsaKey) != NULL)
return KEY_DSA_PUBLIC;
return KEY_NONE;
}
-void OpenSSLCryptoKeyDSA::loadPBase64BigNums(const char * b64, unsigned int len) {
+void OpenSSLCryptoKeyDSA::loadPBase64BigNums(const char * b64, unsigned int len) {
+
+ setPBase(OpenSSLCryptoBase64::b642BN((char *) b64, len));
+
+}
+
+void OpenSSLCryptoKeyDSA::setPBase(BIGNUM * p) {
if (mp_dsaKey == NULL)
mp_dsaKey = DSA_new();
- mp_dsaKey->p = OpenSSLCryptoBase64::b642BN((char *) b64, len);
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+
+ // Do it immediately
+ mp_dsaKey->p = p;
+
+#else
+ // Save it for later
+ if (mp_accumP == NULL)
+ BN_free(mp_accumP);
+
+ mp_accumP = p;
+
+ commitPQG();
+
+#endif
}
void OpenSSLCryptoKeyDSA::loadQBase64BigNums(const char * b64, unsigned int len) {
+ setQBase(OpenSSLCryptoBase64::b642BN((char *) b64, len));
+
+}
+
+void OpenSSLCryptoKeyDSA::setQBase(BIGNUM * q) {
+
if (mp_dsaKey == NULL)
mp_dsaKey = DSA_new();
- mp_dsaKey->q = OpenSSLCryptoBase64::b642BN((char *) b64, len);
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+
+ mp_dsaKey->q = q;
+
+#else
+ if (mp_accumQ == NULL)
+ BN_free(mp_accumQ);
+
+ mp_accumQ = q;
+ commitPQG();
+
+#endif
}
+
void OpenSSLCryptoKeyDSA::loadGBase64BigNums(const char * b64, unsigned int len) {
+ setGBase(OpenSSLCryptoBase64::b642BN((char *) b64, len));
+
+}
+
+void OpenSSLCryptoKeyDSA::setGBase(BIGNUM * g) {
+
if (mp_dsaKey == NULL)
mp_dsaKey = DSA_new();
- mp_dsaKey->g = OpenSSLCryptoBase64::b642BN((char *) b64, len);
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+
+ mp_dsaKey->g = g;
+
+#else
+ if (mp_accumG == NULL)
+ BN_free(mp_accumG);
+
+ mp_accumG = g;
+ commitPQG();
+
+#endif
}
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+void OpenSSLCryptoKeyDSA::commitPQG() {
+
+
+ if (mp_accumP != NULL && mp_accumQ != NULL && mp_accumG != NULL) {
+
+ DSA_set0_pqg(mp_dsaKey, mp_accumP, mp_accumQ, mp_accumG);
+ mp_accumP = NULL;
+ mp_accumQ = NULL;
+ mp_accumG = NULL;
+
+ }
+}
+#endif
+
void OpenSSLCryptoKeyDSA::loadYBase64BigNums(const char * b64, unsigned int len) {
if (mp_dsaKey == NULL)
mp_dsaKey = DSA_new();
- mp_dsaKey->pub_key = OpenSSLCryptoBase64::b642BN((char *) b64, len);
+ BIGNUM *newPub = OpenSSLCryptoBase64::b642BN((char *) b64, len);
+ const BIGNUM *oldPriv;
+ DSA_get0_key(mp_dsaKey, NULL, &oldPriv);
+ DSA_set0_key(mp_dsaKey, newPub, (oldPriv?BN_dup(oldPriv):NULL));
}
void OpenSSLCryptoKeyDSA::loadJBase64BigNums(const char * b64, unsigned int len) {
@@ -124,27 +207,35 @@ void OpenSSLCryptoKeyDSA::loadJBase64Big
// "Hidden" OpenSSL functions
-OpenSSLCryptoKeyDSA::OpenSSLCryptoKeyDSA(EVP_PKEY *k) {
+OpenSSLCryptoKeyDSA::OpenSSLCryptoKeyDSA(EVP_PKEY *k) : mp_accumP(NULL), mp_accumQ(NULL), mp_accumG(NULL) {
// Create a new key to be loaded as we go
mp_dsaKey = DSA_new();
- if (k == NULL || k->type != EVP_PKEY_DSA)
+ if (k == NULL || EVP_PKEY_id(k) != EVP_PKEY_DSA)
return; // Nothing to do with us
+ const BIGNUM *otherP = NULL, *otherQ = NULL, *otherG = NULL;
+ DSA_get0_pqg(EVP_PKEY_get0_DSA(k), &otherP, &otherQ, &otherG);
+
+ if (otherP != NULL && otherQ != NULL && otherG != NULL) {
+ DSA_set0_pqg(EVP_PKEY_get0_DSA(k), BN_dup(otherP), BN_dup(otherQ), BN_dup(otherG));
+ }
+
+ const BIGNUM *otherPriv = NULL, *otherPub = NULL;
+ DSA_get0_key(EVP_PKEY_get0_DSA(k), &otherPub, &otherPriv);
- if (k->pkey.dsa->p)
- mp_dsaKey->p = BN_dup(k->pkey.dsa->p);
- if (k->pkey.dsa->q)
- mp_dsaKey->q = BN_dup(k->pkey.dsa->q);
- if (k->pkey.dsa->g)
- mp_dsaKey->g = BN_dup(k->pkey.dsa->g);
- if (k->pkey.dsa->pub_key)
- mp_dsaKey->pub_key = BN_dup(k->pkey.dsa->pub_key);
- if (k->pkey.dsa->priv_key)
- mp_dsaKey->priv_key = BN_dup(k->pkey.dsa->priv_key);
+ if (otherPub != NULL) {
+ BIGNUM *newPriv = NULL;
+
+ if (otherPriv != NULL)
+ newPriv = BN_dup(otherPriv);
+
+ DSA_set0_key(EVP_PKEY_get0_DSA(k), BN_dup(otherPub), newPriv);
+
+ }
}
// --------------------------------------------------------------------------------
@@ -335,23 +426,27 @@ XSECCryptoKey * OpenSSLCryptoKeyDSA::clo
XSECnew(ret, OpenSSLCryptoKeyDSA);
- ret->m_keyType = m_keyType;
ret->mp_dsaKey = DSA_new();
// Duplicate parameters
- if (mp_dsaKey->p)
- ret->mp_dsaKey->p = BN_dup(mp_dsaKey->p);
- if (mp_dsaKey->q)
- ret->mp_dsaKey->q = BN_dup(mp_dsaKey->q);
- if (mp_dsaKey->g)
- ret->mp_dsaKey->g = BN_dup(mp_dsaKey->g);
- if (mp_dsaKey->pub_key)
- ret->mp_dsaKey->pub_key = BN_dup(mp_dsaKey->pub_key);
- if (mp_dsaKey->priv_key)
- ret->mp_dsaKey->priv_key = BN_dup(mp_dsaKey->priv_key);
- return ret;
+ const BIGNUM *p=NULL, *q=NULL, *g=NULL;
+ DSA_get0_pqg(mp_dsaKey, &p, &q, &g);
+
+ if (p && q && g) // DSA_set0_pqg only works if all three params are non zero
+ DSA_set0_pqg(ret->mp_dsaKey, BN_dup(p), BN_dup(q), BN_dup(g));
+ const BIGNUM *oldPub= NULL, *oldPriv=NULL;
+ DSA_get0_key(mp_dsaKey, &oldPub, &oldPriv);
+
+ if (oldPub) {
+
+ // DSA_setKey requires non-null Public
+
+ DSA_set0_key(ret->mp_dsaKey, BN_dup(oldPub), (oldPriv?BN_dup(oldPriv):NULL));
+
+ }
+ return ret;
}
#endif /* XSEC_HAVE_OPENSSL */
Modified: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp?rev=1774675&r1=1774674&r2=1774675&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp Fri Dec 16 22:37:18 2016
@@ -219,10 +219,25 @@ public :
private:
-
- XSECCryptoKey::KeyType m_keyType;
DSA * mp_dsaKey;
-
+
+ /**
+ * \brief storage for accumulating p/q/r
+ *
+ * In OpenSSL 1.1 the DSA structure is opaque and there is only
+ * a setter for p + q + g and they all must be non NULL.
+ *
+ * We have setters for each one individually, so we have to store them and
+ * then when they are all set we can call OpenSSL's setter.
+ */
+ BIGNUM *mp_accumP, *mp_accumQ, *mp_accumG;
+
+ void setPBase(BIGNUM *pBase);
+ void setQBase(BIGNUM *pBase);
+ void setGBase(BIGNUM *pBase);
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+ void commitPQG();
+#endif
};
#endif /* XSEC_HAVE_OPENSSL */
Added: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.cpp?rev=1774675&view=auto
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.cpp (added)
+++ santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.cpp Fri Dec 16 22:37:18 2016
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <xsec/framework/XSECDefs.hpp>
+#if defined (XSEC_HAVE_OPENSSL)
+#include <openssl/evp.h>
+#include <openssl/dsa.h>
+#include <xsec/enc/OpenSSL/OpenSSLSupport.hpp>
+
+const BIGNUM *DSA_get0_pubkey(const DSA *dsa)
+{
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+ return dsa->pub_key;
+#else
+ const BIGNUM *result;
+ DSA_get0_key(dsa, &result, NULL);
+ return result;
+#endif
+}
+
+const BIGNUM *DSA_get0_privkey(const DSA *dsa)
+{
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+ return dsa->priv_key;
+#else
+ const BIGNUM *result;
+ DSA_get0_key(dsa, NULL, &result);
+ return result;
+#endif
+}
+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+
+void DSA_get0_key(const DSA *d,
+ const BIGNUM **pub_key, const BIGNUM **priv_key)
+{
+ if (pub_key != NULL)
+ *pub_key = d->pub_key;
+ if (priv_key != NULL)
+ *priv_key = d->priv_key;
+}
+
+int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key)
+{
+ /* If the field pub_key in d is NULL, the corresponding input
+ * parameters MUST be non-NULL. The priv_key field may
+ * be left NULL.
+ */
+ if (d->pub_key == NULL && pub_key == NULL)
+ return 0;
+
+ if (pub_key != NULL) {
+ BN_free(d->pub_key);
+ d->pub_key = pub_key;
+ }
+ if (priv_key != NULL) {
+ BN_free(d->priv_key);
+ d->priv_key = priv_key;
+ }
+
+ return 1;
+}
+
+void DSA_get0_pqg(const DSA *d,
+ const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
+{
+ if (p != NULL)
+ *p = d->p;
+ if (q != NULL)
+ *q = d->q;
+ if (g != NULL)
+ *g = d->g;
+}
+
+int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g)
+{
+ /* If the fields p, q and g in d are NULL, the corresponding input
+ * parameters MUST be non-NULL.
+ */
+ if ((d->p == NULL && p == NULL)
+ || (d->q == NULL && q == NULL)
+ || (d->g == NULL && g == NULL))
+ return 0;
+
+ if (p != NULL) {
+ BN_free(d->p);
+ d->p = p;
+ }
+ if (q != NULL) {
+ BN_free(d->q);
+ d->q = q;
+ }
+ if (g != NULL) {
+ BN_free(d->g);
+ d->g = g;
+ }
+
+ return 1;
+}
+
+DSA *EVP_PKEY_get0_DSA(EVP_PKEY *pkey)
+{
+ if (pkey->type != EVP_PKEY_DSA) {
+ return NULL;
+ }
+ return pkey->pkey.dsa;
+}
+
+#endif
+
+#endif
\ No newline at end of file
Propchange: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.hpp?rev=1774675&view=auto
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.hpp (added)
+++ santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.hpp Fri Dec 16 22:37:18 2016
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#if defined (XSEC_HAVE_OPENSSL)
+#include <openssl/evp.h>
+#include <openssl/dsa.h>
+
+// Our own helper functions
+const BIGNUM *DSA_get0_pubkey(const DSA *dsa);
+const BIGNUM *DSA_get0_privkey(const DSA *dsa);
+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+// From OpenSSL 1.1
+void DSA_get0_key(const DSA *d,
+ const BIGNUM **pub_key, const BIGNUM **priv_key);
+int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key);
+void DSA_get0_pqg(const DSA *d,
+ const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
+int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g);
+
+DSA *EVP_PKEY_get0_DSA(EVP_PKEY *pkey);
+
+#endif
+
+
+#endif
\ No newline at end of file
Propchange: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLSupport.hpp
------------------------------------------------------------------------------
svn:mime-type = text/plain