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 2017/09/05 16:36:50 UTC
svn commit: r1807368 -
/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.cpp
Author: scantor
Date: Tue Sep 5 16:36:50 2017
New Revision: 1807368
URL: http://svn.apache.org/viewvc?rev=1807368&view=rev
Log:
SANTUARIO-418 - Invalid acceptance of unpadded RSA signatures
Modified:
santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.cpp
Modified: santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.cpp?rev=1807368&r1=1807367&r2=1807368&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.cpp Tue Sep 5 16:36:50 2017
@@ -482,7 +482,7 @@ bool OpenSSLCryptoKeyRSA::verifySHA1PKCS
EvpEncodeCtxRAII dctx;
if (!dctx.of()) {
- throw XSECCryptoException(XSECCryptoException::ECError,
+ throw XSECCryptoException(XSECCryptoException::RSAError,
"OpenSSL:RSA - allocation fail during Context Creation");
}
@@ -504,6 +504,16 @@ bool OpenSSLCryptoKeyRSA::verifySHA1PKCS
sigValLen += t;
+ // OpenSSL allows the signature size to be less than the key size.
+ // Java does not and the spec requires that this fail, so we have to
+ // perform this check.
+
+ int keySize = RSA_size(mp_rsaKey);
+ if (keySize != sigValLen) {
+ throw XSECCryptoException(XSECCryptoException::RSAError,
+ "OpenSSL:RSA - Signature size does not match key size");
+ }
+
// Now decrypt
unsigned char * decryptBuf;