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 2012/06/24 20:43:48 UTC

svn commit: r1353308 - /santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoSymmetricKey.cpp

Author: scantor
Date: Sun Jun 24 18:43:47 2012
New Revision: 1353308

URL: http://svn.apache.org/viewvc?rev=1353308&view=rev
Log:
Fix non-GCM support in encryptFinish routine.

Modified:
    santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoSymmetricKey.cpp

Modified: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoSymmetricKey.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoSymmetricKey.cpp?rev=1353308&r1=1353307&r2=1353308&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoSymmetricKey.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoSymmetricKey.cpp Sun Jun 24 18:43:47 2012
@@ -960,9 +960,19 @@ unsigned int OpenSSLCryptoSymmetricKey::
 		    throw XSECCryptoException(XSECCryptoException::SymmetricError,
 			    "OpenSSLSymmetricKey::encryptFinish - **WARNING** - no room in ciphertext buffer for authentication tag"); 
         }
-
-        EVP_CIPHER_CTX_ctrl(&m_ctx, EVP_CTRL_GCM_GET_TAG, taglen, cipherBuf + outl);
-        outl += taglen;
+        if (m_keyMode == MODE_GCM) {
+#ifdef XSEC_OPENSSL_HAVE_GCM
+            EVP_CIPHER_CTX_ctrl(&m_ctx, EVP_CTRL_GCM_GET_TAG, taglen, cipherBuf + outl);
+            outl += taglen;
+#else
+		    throw XSECCryptoException(XSECCryptoException::SymmetricError,
+			    "OpenSSLSymmetricKey::encryptFinish - AES-GCM not supported in this version of OpenSSL"); 
+#endif
+        }
+        else {
+		    throw XSECCryptoException(XSECCryptoException::SymmetricError,
+			    "OpenSSLSymmetricKey::encryptFinish - cipher mode does not support authentication tag"); 
+        }
     }
 
 	return outl;