blautenb 2003/04/11 05:25:49
Modified: c/src/tools/checksig checksig.cpp
c/src/tools/templatesign templatesign.cpp
c/src/tools/txfmout txfmout.cpp
c/src/tools/xtest xtest.cpp
Log:
Tools updated to compile with WinCAPI and without OpenSSL available
Revision Changes Path
1.14 +159 -27 xml-security/c/src/tools/checksig/checksig.cpp
Index: checksig.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/tools/checksig/checksig.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- checksig.cpp 7 Apr 2003 12:27:13 -0000 1.13
+++ checksig.cpp 11 Apr 2003 12:25:49 -0000 1.14
@@ -60,7 +60,7 @@
/*
* XSEC
*
- * checkSig := tool to check a signature embedded in an XML file
+ * checkSig := (Very ugly) tool to check a signature embedded in an XML file
*
* Author(s): Berin Lautenbach
*
@@ -77,16 +77,14 @@
#include <xsec/framework/XSECException.hpp>
#include <xsec/enc/XSECCryptoException.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
-#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
#include <xsec/enc/XSECKeyInfoResolverDefault.hpp>
// ugly :<
#if defined(_WIN32)
-#include <xsec/utils/winutils/XSECURIResolverGenericWin32.hpp>
-#include <xsec/enc/WinCAPI/WinCAPICryptoProvider.hpp>
+# include <xsec/utils/winutils/XSECURIResolverGenericWin32.hpp>
#else
-#include <xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp>
+# include <xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp>
#endif
// General
@@ -142,9 +140,20 @@
#endif
+#if defined (HAVE_OPENSSL)
// OpenSSL
-#include <openssl/err.h>
+# include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
+# include <openssl/err.h>
+
+#endif
+
+#if defined (HAVE_WINCAPI)
+
+# include <xsec/enc/WinCAPI/WinCAPICryptoProvider.hpp>
+# include <xsec/enc/WinCAPI/WinCAPICryptoKeyHMAC.hpp>
+
+#endif
#ifdef XSEC_NO_XALAN
@@ -168,9 +177,14 @@
cerr << " Set an hmac key using the <string>\n\n";
cerr << " --xsecresolver/-x\n";
cerr << " Use the xml-security test XMLDSig URI resolver\n\n";
-#if defined(_WIN32)
+#if defined(HAVE_WINCAPI)
+# if defined (HAVE_OPENSSL)
cerr << " --wincapi/-w\n";
cerr << " Use the Windows CAPI crypto Provider\n\n";
+# endif
+ cerr << " --winhmackey/-wh <string>\n";
+ cerr << " Use the Windows CAPI crypto provider and hash the
<string>\n";
+ cerr << " into a Windows key using SHA-1\n\n";
#endif
cerr << " Exits with codes :\n";
cerr << " 0 = Signature OK\n";
@@ -183,10 +197,11 @@
char * filename = NULL;
char * hmacKeyStr = NULL;
- OpenSSLCryptoKeyHMAC * hmacKey;
+ XSECCryptoKey * key = NULL;
bool useXSECURIResolver = false;
#if defined(_WIN32)
- HCRYPTPROV win32CSP = 0; //
Crypto Provider
+ HCRYPTPROV win32DSSCSP = 0;
// Crypto Providers
+ HCRYPTPROV win32RSACSP = 0;
#endif
bool skipRefs = false;
@@ -214,24 +229,92 @@
useXSECURIResolver = true;
paramCount++;
}
-#if defined (_WIN32)
- else if (stricmp(argv[paramCount], "--wincapi") == 0 ||
stricmp(argv[paramCount], "-w") == 0) {
- WinCAPICryptoProvider * cp;
- // Obtain default PROV_DSS
- if (!CryptAcquireContext(&win32CSP,
- NULL,
- NULL,
- PROV_DSS,
- 0)) {
- cerr << "Error acquiring DSS Crypto
Service Provider" << endl;
+#if defined (HAVE_WINCAPI)
+ else if (stricmp(argv[paramCount], "--wincapi") == 0 ||
stricmp(argv[paramCount], "-w") == 0 ||
+ stricmp(argv[paramCount], "--winhmackey") == 0 ||
stricmp(argv[paramCount], "-wh") == 0) {
+
+ if (win32DSSCSP == 0) {
+ WinCAPICryptoProvider * cp;
+ // Obtain default PROV_DSS
+ if (!CryptAcquireContext(&win32DSSCSP,
+ NULL,
+ NULL,
+ PROV_DSS,
+ 0)) {
+ cerr << "Error acquiring DSS
Crypto Service Provider" << endl;
+ return 2;
+ }
+
+ if (!CryptAcquireContext(&win32RSACSP,
+ NULL,
+ NULL,
+ PROV_RSA_FULL,
+ 0)) {
+ cerr << "Error acquiring RSA
Crypto Service Provider" << endl;
+ return 2;
+ }
+
+ // Use default DSS provider
+ cp = new WinCAPICryptoProvider(win32DSSCSP,
win32RSACSP);
+ XSECPlatformUtils::SetCryptoProvider(cp);
+ }
+
+ if (stricmp(argv[paramCount], "--winhmackey") == 0 ||
stricmp(argv[paramCount], "-wh") == 0) {
+
+ // Create a SHA-1 based key based on the
<string> parameter
+
+ paramCount++;
+
+ HCRYPTKEY k;
+ HCRYPTHASH h;
+ BOOL fResult = CryptCreateHash(
+ win32RSACSP,
+ CALG_SHA,
+ 0,
+ 0,
+ &h);
+
+ if (fResult == 0) {
+ cerr << "Error creating hash to create
windows hmac key from password" << endl;
+ return 2;
+ }
+ fResult = CryptHashData(
+ h,
+ (unsigned char *) argv[paramCount],
+ strlen(argv[paramCount]),
+ 0);
+
+ if (fResult == 0) {
+ cerr << "Error hashing password to
create windows hmac key" << endl;
+ return 2;
+ }
+
+ // Now create a key
+ fResult = CryptDeriveKey(
+ win32RSACSP,
+ CALG_RC2,
+ h,
+ CRYPT_EXPORTABLE,
+ &k);
+
+ if (fResult == 0) {
+ cerr << "Error deriving key from hash
value" << endl;
return 2;
+ }
+
+ // Wrap in a WinCAPI object
+ WinCAPICryptoKeyHMAC * hk;
+ hk = new WinCAPICryptoKeyHMAC();
+ hk->setWinKey(k);
+
+ key = hk;
+
+ CryptDestroyHash(h);
+
}
- // Use default DSS provider
- cp = new WinCAPICryptoProvider(win32CSP);
- XSECPlatformUtils::SetCryptoProvider(cp);
paramCount++;
-
+
}
#endif
else {
@@ -240,6 +323,37 @@
}
}
+#if defined (HAVE_WINCAPI) && !defined(HAVE_OPENSSL)
+
+ if (win32DSSCSP == 0) {
+ WinCAPICryptoProvider * cp;
+ // Obtain default PROV_DSS
+ if (!CryptAcquireContext(&win32DSSCSP,
+ NULL,
+ NULL,
+ PROV_DSS,
+ 0)) {
+ cerr << "Error acquiring DSS Crypto Service
Provider" << endl;
+ return 2;
+ }
+
+ if (!CryptAcquireContext(&win32RSACSP,
+ NULL,
+ NULL,
+ PROV_RSA_FULL,
+ 0)) {
+ cerr << "Error acquiring RSA Crypto Service
Provider" << endl;
+ return 2;
+ }
+
+ // Use default DSS provider
+ cp = new WinCAPICryptoProvider(win32DSSCSP, win32RSACSP);
+ XSECPlatformUtils::SetCryptoProvider(cp);
+
+ }
+
+#endif
+
if (paramCount >= argc) {
printUsage();
return 2;
@@ -382,11 +496,24 @@
// Load a key if necessary
if (hmacKeyStr != NULL) {
+#if defined (HAVE_OPENSSL)
+ OpenSSLCryptoKeyHMAC * hmacKey;
hmacKey = new OpenSSLCryptoKeyHMAC();
+#else
+# if defined (HAVE_WINCAPI)
+ WinCAPICryptoKeyHMAC * hmacKey;
+ hmacKey = new WinCAPICryptoKeyHMAC();
+# endif
+#endif
hmacKey->setKey((unsigned char *) hmacKeyStr,
strlen(hmacKeyStr));
sig->setSigningKey(hmacKey);
}
+ else if (key != NULL) {
+
+ sig->setSigningKey(key);
+
+ }
sig->load();
if (skipRefs)
@@ -408,12 +535,14 @@
<< e.getMsg() << endl;
errorsOccured = true;
+#if defined (HAVE_OPENSSL)
ERR_load_crypto_strings();
BIO * bio_err;
if ((bio_err=BIO_new(BIO_s_file())) != NULL)
BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
ERR_print_errors(bio_err);
+#endif
return 2;
}
@@ -440,9 +569,12 @@
retResult = 1;
}
-#if defined (_WIN32)
- if (win32CSP != 0) {
- CryptReleaseContext(win32CSP, 0);
+#if defined (HAVE_WINCAPI)
+ if (win32DSSCSP != 0) {
+ CryptReleaseContext(win32DSSCSP, 0);
+ }
+ if (win32RSACSP != 0) {
+ CryptReleaseContext(win32RSACSP, 0);
}
#endif
prov.releaseSignature(sig);
1.6 +211 -41 xml-security/c/src/tools/templatesign/templatesign.cpp
Index: templatesign.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/tools/templatesign/templatesign.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- templatesign.cpp 7 Apr 2003 12:27:13 -0000 1.5
+++ templatesign.cpp 11 Apr 2003 12:25:49 -0000 1.6
@@ -78,23 +78,25 @@
#include <xsec/dsig/DSIGKeyInfoX509.hpp>
#include <xsec/framework/XSECException.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
-#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
-#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
-#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
-#include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
-
-// OpenSSL
-
-#include <openssl/bio.h>
-#include <openssl/dsa.h>
-#include <openssl/err.h>
-#include <openssl/evp.h>
-#include <openssl/pem.h>
+#if defined (HAVE_OPENSSL)
+# include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
+# include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
+# include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
+# include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
+
+# include <openssl/bio.h>
+# include <openssl/dsa.h>
+# include <openssl/err.h>
+# include <openssl/evp.h>
+# include <openssl/pem.h>
+#endif
-#if defined(_WIN32)
+#if defined(HAVE_WINCAPI)
# include <xsec/enc/WinCAPI/WinCAPICryptoProvider.hpp>
# include <xsec/enc/WinCAPI/WinCAPICryptoKeyDSA.hpp>
+# include <xsec/enc/WinCAPI/WinCAPICryptoKeyRSA.hpp>
+# include <xsec/enc/WinCAPI/WinCAPICryptoKeyHMAC.hpp>
#endif
#include <memory.h>
@@ -557,28 +559,38 @@
void printUsage(void) {
cerr << "\nUsage: templatesign <key options> <file to sign>\n\n";
+#if defined (HAVE_OPENSSL)
cerr << " Where <key options> are one of :\n\n";
cerr << " --dsakey/-d <dsa private key file> <password>\n";
cerr << " <dsa private key file> contains a PEM
encoded private key\n";
cerr << " <password> is the password used to
decrypt the key file\n";
-#if defined (_WIN32)
+# if defined (HAVE_WINCAPI)
cerr << " NOTE: Not usable if --wincapi previously
set\n";
-#endif
+# endif
cerr << " --rsakey/-r <rsa private key file> <password>\n";
cerr << " <rsa privatekey file> contains a PEM
encoded private key\n";
cerr << " <password> is the password used to
decrypt the key file\n";
+ cerr << " --x509cert/-x <filename>\n";
+ cerr << " <filename> contains a PEM certificate to
be added as a KeyInfo\n";
+#endif
cerr << " --hmackey/-h <string>\n";
cerr << " <string> is the hmac key to set\n";
cerr << " --clearkeys/-c\n";
cerr << " Clears out any current KeyInfo elements
in the file\n";
- cerr << " --x509cert/-x <filename>\n";
- cerr << " <filename> contains a PEM certificate to
be added as a KeyInfo\n";
-#if defined(_WIN32)
+#if defined(HAVE_WINCAPI)
cerr << " --windss/-wd\n";
cerr << " Use the default user AT_SIGNATURE key
from default\n";
cerr << " Windows DSS CSP\n";
+ cerr << " --winrsa/-wr\n";
+ cerr << " Use the default user AT_SIGNATURE key
from default\n";
+ cerr << " Windows RSA CSP\n";
+ cerr << " --winhmac/-wh <string>\n";
+ cerr << " Create a windows HMAC key using <string>
as the password.\n";
+ cerr << " Uses a SHA-1 hash of the password to
derive a key\n";
cerr << " --windsskeyinfo/-wdi\n";
cerr << " Clear KeyInfo elements and insert DSS
parameters from windows key\n";
+ cerr << " --winrsakeyinfo/-wri\n";
+ cerr << " Clear KeyInfo elements and insert RSA
parameters from windows key\n";
#endif
@@ -588,14 +600,19 @@
XSECCryptoKey * key = NULL;
DSIGKeyInfoX509 * keyInfoX509 = NULL;
+#if defined (HAVE_OPENSSL)
OpenSSLCryptoX509 * certs[128];
+#endif
int certCount = 0;
int paramCount;
bool clearKeyInfo = false;
-#if defined(_WIN32)
- HCRYPTPROV win32CSP = 0;
// Crypto Provider
+#if defined(HAVE_WINCAPI)
+ HCRYPTPROV win32DSSCSP = 0;
// Crypto Provider
+ HCRYPTPROV win32RSACSP = 0;
// Crypto Provider
bool winDssKeyInfo = false;
- WinCAPICryptoKeyDSA * winKey = NULL;
+ bool winRsaKeyInfo = false;
+ WinCAPICryptoKeyDSA * winKeyDSA = NULL;
+ WinCAPICryptoKeyRSA * winKeyRSA = NULL;
#endif
// Initialise the XML system
@@ -619,6 +636,8 @@
}
+#if defined (HAVE_OPENSSL)
+
// Initialise OpenSSL
ERR_load_crypto_strings();
BIO * bio_err;
@@ -626,6 +645,8 @@
if ((bio_err=BIO_new(BIO_s_file())) != NULL)
BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
+#endif
+
if (argc < 2) {
printUsage();
@@ -638,6 +659,8 @@
// Run through all parameters
+#if defined (HAVE_OPENSSL)
+
if (stricmp(argv[paramCount], "--dsakey") == 0 ||
stricmp(argv[paramCount], "-d") == 0 ||
stricmp(argv[paramCount], "--rsakey") == 0 ||
stricmp(argv[paramCount], "-r") == 0) {
@@ -766,10 +789,18 @@
paramCount += 2;
} /* argv[1] = "--x509cert" */
+
+ else
+#endif
+ if (stricmp(argv[paramCount], "--hmackey") == 0 ||
stricmp(argv[paramCount], "-h") == 0) {
- else if (stricmp(argv[paramCount], "--hmackey") == 0 ||
stricmp(argv[paramCount], "-h") == 0) {
-
+#if defined (HAVE_OPENSSL)
OpenSSLCryptoKeyHMAC * hmacKey = new
OpenSSLCryptoKeyHMAC();
+#else
+# if defined (HAVE_WINCAPI)
+ WinCAPICryptoKeyHMAC * hmacKey = new
WinCAPICryptoKeyHMAC();
+# endif
+#endif
hmacKey->setKey((unsigned char *) argv[paramCount + 1],
strlen(argv[paramCount + 1]));
key = hmacKey;
paramCount += 2;
@@ -783,11 +814,11 @@
}
-#if defined (_WIN32)
+#if defined (HAVE_WINCAPI)
else if (stricmp(argv[paramCount], "--windss") == 0 ||
stricmp(argv[paramCount], "-wd") == 0) {
WinCAPICryptoProvider * cp;
// Obtain default PROV_DSS, with default user key
container
- if (!CryptAcquireContext(&win32CSP,
+ if (!CryptAcquireContext(&win32DSSCSP,
NULL,
NULL,
PROV_DSS,
@@ -795,13 +826,14 @@
cerr << "Error acquiring DSS Crypto
Service Provider" << endl;
return 2;
}
- cp = new WinCAPICryptoProvider(win32CSP);
+ // We know RSA provider is not required
+ cp = new WinCAPICryptoProvider(win32DSSCSP, 0);
XSECPlatformUtils::SetCryptoProvider(cp);
// Now get the key
HCRYPTKEY k;
BOOL fResult = CryptGetUserKey(
- win32CSP,
+ win32DSSCSP,
AT_SIGNATURE,
&k);
@@ -809,15 +841,135 @@
cerr << "Error obtaining default user
AT_SIGNATURE key from windows DSS provider\n";
exit(1);
};
- winKey = new WinCAPICryptoKeyDSA(cp, k, true);
- key = winKey;
+ winKeyDSA = new WinCAPICryptoKeyDSA(cp, k, true);
+ key = winKeyDSA;
paramCount++;
}
+
+ else if (stricmp(argv[paramCount], "--winrsa") == 0 ||
stricmp(argv[paramCount], "-wr") == 0) {
+ WinCAPICryptoProvider * cp;
+ // Obtain default PROV_DSS and PROV_RSA_FULL, with
default user key containers
+ if (!CryptAcquireContext(&win32DSSCSP,
+ NULL,
+ NULL,
+ PROV_DSS,
+ 0)) {
+ cerr << "Error acquiring DSS Crypto
Service Provider" << endl;
+ return 2;
+ }
+
+ if (!CryptAcquireContext(&win32RSACSP,
+ NULL,
+ NULL,
+ PROV_RSA_FULL,
+ 0)) {
+ cerr << "Error acquiring RSA Crypto
Service Provider" << endl;
+ return 2;
+ }
+
+ cp = new WinCAPICryptoProvider(win32DSSCSP,
win32RSACSP);
+ XSECPlatformUtils::SetCryptoProvider(cp);
+
+ // Now get the key
+ HCRYPTKEY k;
+ BOOL fResult = CryptGetUserKey(
+ win32RSACSP,
+ AT_SIGNATURE,
+ &k);
+
+ if (!fResult || k == 0) {
+ cerr << "Error obtaining default user
AT_SIGNATURE key from windows RSA provider\n";
+ exit(1);
+ };
+
+ winKeyRSA = new WinCAPICryptoKeyRSA(cp, k, true);
+ key = winKeyRSA;
+ paramCount++;
+ }
+
+ else if (stricmp(argv[paramCount], "--winhmac") == 0 ||
stricmp(argv[paramCount], "-wh") == 0) {
+
+ WinCAPICryptoProvider * cp;
+ // Obtain default PROV_DSS, with default user key
container
+ if (!CryptAcquireContext(&win32DSSCSP,
+ NULL,
+ NULL,
+ PROV_DSS,
+ 0)) {
+ cerr << "Error acquiring DSS Crypto
Service Provider" << endl;
+ return 2;
+ }
+ if (!CryptAcquireContext(&win32RSACSP,
+ NULL,
+ NULL,
+ PROV_RSA_FULL,
+ 0)) {
+ cerr << "Error acquiring RSA Crypto
Service Provider" << endl;
+ return 2;
+ }
+ cp = new WinCAPICryptoProvider(win32DSSCSP,
win32RSACSP);
+ XSECPlatformUtils::SetCryptoProvider(cp);
+
+ paramCount++;
+ HCRYPTKEY k;
+ HCRYPTHASH h;
+ BOOL fResult = CryptCreateHash(
+ win32RSACSP,
+ CALG_SHA,
+ 0,
+ 0,
+ &h);
+
+ if (fResult == 0) {
+ cerr << "Error creating hash to create windows
hmac key from password" << endl;
+ return 2;
+ }
+ fResult = CryptHashData(
+ h,
+ (unsigned char *) argv[paramCount],
+ strlen(argv[paramCount]),
+ 0);
+
+ if (fResult == 0) {
+ cerr << "Error hashing password to create
windows hmac key" << endl;
+ return 2;
+ }
+
+ // Now create a key
+ fResult = CryptDeriveKey(
+ win32RSACSP,
+ CALG_RC2,
+ h,
+ CRYPT_EXPORTABLE,
+ &k);
+
+ if (fResult == 0) {
+ cerr << "Error deriving key from hash value" <<
endl;
+ return 2;
+ }
+
+ // Wrap in a WinCAPI object
+ WinCAPICryptoKeyHMAC * hk;
+ hk = new WinCAPICryptoKeyHMAC();
+ hk->setWinKey(k);
+
+ key = hk;
+
+ CryptDestroyHash(h);
+ paramCount++;
+
+ }
+
else if (stricmp(argv[paramCount], "--windsskeyinfo") == 0 ||
stricmp(argv[paramCount], "-wdi") == 0) {
winDssKeyInfo = true;
paramCount++;
}
+ else if (stricmp(argv[paramCount], "--winrsakeyinfo") == 0 ||
stricmp(argv[paramCount], "-wri") == 0) {
+ winRsaKeyInfo = true;
+ paramCount++;
+ }
+
#endif
else {
@@ -897,8 +1049,6 @@
XSECProvider prov;
DSIGSignature * sig = prov.newSignatureFromDOM(theDOM, sigNode);
- int i;
-
try {
sig->load();
if (clearKeyInfo == true)
@@ -909,22 +1059,22 @@
// Add any KeyInfo elements
-#if defined(_WIN32)
+#if defined(HAVE_WINCAPI)
- if (winDssKeyInfo == true && winKey != NULL) {
+ if (winDssKeyInfo == true && winKeyDSA != NULL) {
char pBuf[1024];
char qBuf[1024];
char gBuf[1024];
char yBuf[1024];
unsigned int i;
- i = winKey->getPBase64BigNums((char *) pBuf, 1024);
+ i = winKeyDSA->getPBase64BigNums((char *) pBuf, 1024);
pBuf[i] = '\0';
- i = winKey->getQBase64BigNums((char *) qBuf, 1024);
+ i = winKeyDSA->getQBase64BigNums((char *) qBuf, 1024);
qBuf[i] = '\0';
- i = winKey->getGBase64BigNums((char *) gBuf, 1024);
+ i = winKeyDSA->getGBase64BigNums((char *) gBuf, 1024);
gBuf[i] = '\0';
- i = winKey->getYBase64BigNums((char *) yBuf, 1024);
+ i = winKeyDSA->getYBase64BigNums((char *) yBuf, 1024);
yBuf[i] = '\0';
sig->clearKeyInfo();
@@ -935,10 +1085,27 @@
MAKE_UNICODE_STRING(yBuf));
}
-#endif
+ if (winRsaKeyInfo == true && winKeyRSA != NULL) {
+ char eBuf[1024];
+ char mBuf[1024];
+
+ unsigned int i;
+ i = winKeyRSA->getExponentBase64BigNums((char *) eBuf,
1024);
+ eBuf[i] = '\0';
+ i = winKeyRSA->getModulusBase64BigNums((char *) mBuf,
1024);
+ mBuf[i] = '\0';
+
+ sig->clearKeyInfo();
+ sig->appendRSAKeyValue(
+ MAKE_UNICODE_STRING(mBuf),
+ MAKE_UNICODE_STRING(eBuf));
+ }
+#endif
+#if defined (HAVE_OPENSSL)
if (certCount > 0) {
+ int i;
// Have some certificates - see if there is already an
X509 list
DSIGKeyInfoList * kiList = sig->getKeyInfoList();
int kiSize = kiList->getSize();
@@ -965,6 +1132,7 @@
}
} /* certCount > 0 */
+#endif
}
catch (XSECException &e) {
@@ -1007,8 +1175,10 @@
delete formatTarget;
#if defined (_WIN32)
- if (win32CSP != 0)
- CryptReleaseContext(win32CSP,0);
+ if (win32DSSCSP != 0)
+ CryptReleaseContext(win32DSSCSP,0);
+ if (win32RSACSP != 0)
+ CryptReleaseContext(win32RSACSP,0);
#endif
prov.releaseSignature(sig);
1.8 +1 -2 xml-security/c/src/tools/txfmout/txfmout.cpp
Index: txfmout.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/tools/txfmout/txfmout.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- txfmout.cpp 23 Mar 2003 09:58:16 -0000 1.7
+++ txfmout.cpp 11 Apr 2003 12:25:49 -0000 1.8
@@ -79,7 +79,6 @@
#include <xsec/framework/XSECException.hpp>
#include <xsec/enc/XSECCryptoException.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
-#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
#include <xsec/utils/XSECBinTXFMInputStream.hpp>
#if defined(_WIN32)
1.5 +22 -2 xml-security/c/src/tools/xtest/xtest.cpp
Index: xtest.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/tools/xtest/xtest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- xtest.cpp 1 Mar 2003 06:27:29 -0000 1.4
+++ xtest.cpp 11 Apr 2003 12:25:49 -0000 1.5
@@ -112,11 +112,17 @@
#include <xsec/dsig/DSIGSignature.hpp>
#include <xsec/utils/XSECNameSpaceExpander.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
-#include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
#include <xsec/enc/XSECCryptoException.hpp>
#include <xsec/dsig/DSIGKeyInfoX509.hpp>
#include <xsec/dsig/DSIGKeyInfoName.hpp>
+#if defined (HAVE_OPENSSL)
+# include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
+#endif
+#if defined (HAVE_WINCAPI)
+# include <xsec/enc/WinCAPI/WinCAPICryptoKeyHMAC.hpp>
+#endif
+
using std::ostream;
using std::cout;
using std::cerr;
@@ -760,7 +766,15 @@
sig->appendKeyName(MAKE_UNICODE_STRING("The secret key is
\"secret\""));
+#if defined (HAVE_OPENSSL)
OpenSSLCryptoKeyHMAC * hmacKey = new OpenSSLCryptoKeyHMAC();
+ cerr << "Using OpenSSL as the cryptography provider" << endl;
+#else
+# if defined (HAVE_WINCAPI)
+ WinCAPICryptoKeyHMAC * hmacKey = new WinCAPICryptoKeyHMAC();
+ cerr << "Using Windows Crypto API as the cryptography provider"
<< endl;
+# endif
+#endif
hmacKey->setKey((unsigned char *) "secret", strlen("secret"));
sig->setSigningKey(hmacKey);
sig->sign();
@@ -810,7 +824,13 @@
}
cerr << "Setting incorrect key in Signature object" << endl;
+#if defined (HAVE_OPENSSL)
hmacKey = new OpenSSLCryptoKeyHMAC();
+#else
+# if defined (HAVE_WINCAPI)
+ hmacKey = new WinCAPICryptoKeyHMAC();
+# endif
+#endif
hmacKey->setKey((unsigned char *) "badsecret",
strlen("badsecret"));
sig->setSigningKey(hmacKey);