[cpp-xmltooling] branch main updated: CPPXT-154 - Log which encryption key was used when decrypting
Scott Cantor
cantor.2 at osu.edu
Mon Oct 24 15:33:49 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository cpp-xmltooling.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-xmltooling.git;a=commit;h=6bcd348eefe5cc90b2d2f4b3f48c0981c979ae28
The following commit(s) were added to refs/heads/main by this push:
new 6bcd348 CPPXT-154 - Log which encryption key was used when decrypting
6bcd348 is described below
commit 6bcd348eefe5cc90b2d2f4b3f48c0981c979ae28
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Oct 24 11:33:23 2022 -0400
CPPXT-154 - Log which encryption key was used when decrypting
https://shibboleth.atlassian.net/browse/CPPXT-154
---
xmltooling/encryption/impl/Decrypter.cpp | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/xmltooling/encryption/impl/Decrypter.cpp b/xmltooling/encryption/impl/Decrypter.cpp
index 8d4a302..99514a4 100644
--- a/xmltooling/encryption/impl/Decrypter.cpp
+++ b/xmltooling/encryption/impl/Decrypter.cpp
@@ -33,6 +33,8 @@
#include "security/CredentialCriteria.h"
#include "security/CredentialResolver.h"
+#include <xmltooling/security/SecurityHelper.h>
+
#include <xsec/enc/XSECCryptoException.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/framework/XSECAlgorithmMapper.hpp>
@@ -151,7 +153,13 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
key = (*cred)->getPrivateKey();
if (!key)
continue;
- return decryptData(encryptedData, key);
+ DOMDocumentFragment* retval = decryptData(encryptedData, key);
+ if ((*cred)->getPublicKey()) {
+ std::string message = "encrypted with public key with SHA-1 fingerprint: " +
+ SecurityHelper::getDEREncoding(*((*cred)->getPublicKey()), "SHA1");
+ logging::Category::getInstance(XMLTOOLING_LOGCAT ".Decrypter").debug(message.c_str());
+ }
+ return retval;
}
catch(const DecryptionException& ex) {
logging::Category::getInstance(XMLTOOLING_LOGCAT ".Decrypter").warn(ex.what());
@@ -354,6 +362,12 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
int keySize = m_cipher->decryptKey(encryptedKey.getDOM(), buffer, 1024);
if (keySize<=0)
throw DecryptionException("Unable to decrypt key.");
+
+ if ((*cred)->getPublicKey()) {
+ std::string message = "encrypted with pubkey sha1:" +
+ SecurityHelper::getDEREncoding(*((*cred)->getPublicKey()), "SHA1");
+ logging::Category::getInstance(XMLTOOLING_LOGCAT ".Decrypter").debug(message.c_str());
+ }
// Try to wrap the key.
return handler->createKeyForURI(algorithm, buffer, keySize);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list