You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2003/04/07 14:27:14 UTC
cvs commit: xml-security/c/src/utils XSECPlatformUtils.cpp XSECPlatformUtils.hpp XSECSafeBuffer.cpp XSECSafeBuffer.hpp
blautenb 2003/04/07 05:27:14
Modified: c/Projects/VC6.0/xsec/xsec_lib xsec_lib.dsp
c/src/dsig DSIGConstants.cpp DSIGConstants.hpp
DSIGSignature.cpp
c/src/enc XSECCryptoException.cpp XSECCryptoException.hpp
XSECCryptoHash.hpp XSECCryptoKey.hpp
XSECCryptoProvider.hpp
c/src/enc/OpenSSL OpenSSLCryptoHashHMAC.hpp
OpenSSLCryptoKeyDSA.hpp OpenSSLCryptoKeyHMAC.hpp
OpenSSLCryptoKeyRSA.hpp
c/src/tools/checksig checksig.cpp
c/src/tools/templatesign templatesign.cpp
c/src/utils XSECPlatformUtils.cpp XSECPlatformUtils.hpp
XSECSafeBuffer.cpp XSECSafeBuffer.hpp
Log:
Initial checkin of alpha support for Windows Crypto API as crypto provider for signatures
Revision Changes Path
1.7 +65 -1 xml-security/c/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp
Index: xsec_lib.dsp
===================================================================
RCS file: /home/cvs/xml-security/c/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- xsec_lib.dsp 30 Mar 2003 06:57:12 -0000 1.6
+++ xsec_lib.dsp 7 Apr 2003 12:27:12 -0000 1.7
@@ -81,7 +81,7 @@
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 xerces-c_2D.lib Xalan-C_1D.lib libeay32.lib /nologo /version:0.2 /dll /debug /machine:I386 /out:"../../../../Build/Win32/VC6/Debug/xsec_lib_01D.dll" /pdbtype:sept
+# ADD LINK32 xerces-c_2D.lib Xalan-C_1D.lib libeay32.lib crypt32.lib /nologo /version:0.2 /dll /debug /machine:I386 /out:"../../../../Build/Win32/VC6/Debug/xsec_lib_01D.dll" /pdbtype:sept
!ELSEIF "$(CFG)" == "xsec_lib - Win32 Debug No Xalan"
@@ -378,6 +378,70 @@
# Begin Source File
SOURCE=..\..\..\..\src\enc\OpenSSL\OpenSSLCryptoX509.hpp
+# End Source File
+# End Group
+# Begin Group "XSCrypt"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\XSCrypt\XSCryptCryptoBase64.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\XSCrypt\XSCryptCryptoBase64.hpp
+# End Source File
+# End Group
+# Begin Group "WinCAPI"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoHash.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoHash.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoHashHMAC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoHashHMAC.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoKeyDSA.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoKeyDSA.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoKeyHMAC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoKeyHMAC.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoProvider.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoProvider.hpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoX509.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\enc\WinCAPI\WinCAPICryptoX509.hpp
# End Source File
# End Group
# Begin Source File
1.4 +11 -1 xml-security/c/src/dsig/DSIGConstants.cpp
Index: DSIGConstants.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGConstants.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DSIGConstants.cpp 30 Mar 2003 06:57:12 -0000 1.3
+++ DSIGConstants.cpp 7 Apr 2003 12:27:13 -0000 1.4
@@ -96,6 +96,8 @@
static XMLCh * s_unicodeStrURIHMAC_SHA1;
static XMLCh * s_unicodeStrURIXMLNS;
static XMLCh * s_unicodeStrURIMANIFEST;
+static XMLCh * s_unicodeStrPROVOpenSSL;
+static XMLCh * s_unicodeStrPROVWinCAPI;
// --------------------------------------------------------------------------------
@@ -125,6 +127,9 @@
const XMLCh * const & DSIGConstants::s_unicodeStrURIXMLNS = ::s_unicodeStrURIXMLNS;
const XMLCh * const & DSIGConstants::s_unicodeStrURIMANIFEST = ::s_unicodeStrURIMANIFEST;
+const XMLCh * const & DSIGConstants::s_unicodeStrPROVOpenSSL = ::s_unicodeStrPROVOpenSSL;
+const XMLCh * const & DSIGConstants::s_unicodeStrPROVWinCAPI = ::s_unicodeStrPROVWinCAPI;
+
// --------------------------------------------------------------------------------
// Constant Strings Class
// --------------------------------------------------------------------------------
@@ -156,6 +161,8 @@
::s_unicodeStrURIHMAC_SHA1 = XMLString::transcode(URI_ID_HMAC_SHA1);
::s_unicodeStrURIXMLNS = XMLString::transcode(URI_ID_XMLNS);
::s_unicodeStrURIMANIFEST = XMLString::transcode(URI_ID_MANIFEST);
+ ::s_unicodeStrPROVOpenSSL = XMLString::transcode(PROV_OPENSSL);
+ ::s_unicodeStrPROVWinCAPI = XMLString::transcode(PROV_WINCAPI);
}
@@ -185,5 +192,8 @@
delete[] ::s_unicodeStrURIHMAC_SHA1;
delete[] ::s_unicodeStrURIXMLNS;
delete[] ::s_unicodeStrURIMANIFEST;
+
+ delete[] ::s_unicodeStrPROVOpenSSL;
+ delete[] ::s_unicodeStrPROVWinCAPI;
}
1.5 +10 -1 xml-security/c/src/dsig/DSIGConstants.hpp
Index: DSIGConstants.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGConstants.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DSIGConstants.hpp 30 Mar 2003 06:57:12 -0000 1.4
+++ DSIGConstants.hpp 7 Apr 2003 12:27:13 -0000 1.5
@@ -119,6 +119,11 @@
#define URI_ID_XMLNS "http://www.w3.org/2000/xmlns/"
#define URI_ID_MANIFEST "http://www.w3.org/2000/09/xmldsig#Manifest"
+// Internal Crypto Providers
+
+#define PROV_OPENSSL "OpenSSL Provider"
+#define PROV_WINCAPI "WinCAPI Provider"
+
// Enumerated Types
@@ -300,6 +305,10 @@
static const XMLCh * const & s_unicodeStrURIHMAC_SHA1;
static const XMLCh * const & s_unicodeStrURIXMLNS;
static const XMLCh * const & s_unicodeStrURIMANIFEST;
+
+ // Internal Crypto Providers
+ static const XMLCh * const & s_unicodeStrPROVOpenSSL;
+ static const XMLCh * const & s_unicodeStrPROVWinCAPI;
DSIGConstants();
1.9 +2 -1 xml-security/c/src/dsig/DSIGSignature.cpp
Index: DSIGSignature.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGSignature.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DSIGSignature.cpp 8 Mar 2003 08:45:16 -0000 1.8
+++ DSIGSignature.cpp 7 Apr 2003 12:27:13 -0000 1.9
@@ -234,6 +234,7 @@
b64->encodeInit();
outputLen = b64->encode((unsigned char *) raw, rawLen, b64Str, 1024);
outputLen += b64->encodeFinish(&b64Str[outputLen], 1024 - outputLen);
+ b64Str[outputLen] = '\0';
// Copy out
1.3 +1 -0 xml-security/c/src/enc/XSECCryptoException.cpp
Index: XSECCryptoException.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/XSECCryptoException.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSECCryptoException.cpp 9 Feb 2003 11:13:49 -0000 1.2
+++ XSECCryptoException.cpp 7 Apr 2003 12:27:13 -0000 1.3
@@ -78,6 +78,7 @@
extern const char * XSECCryptoExceptionStrings[] = {
"No Error",
+ "General error occurred somewhere in cryptographic routines",
"Error Creating SHA1 MD",
"Error in Base64",
"Memory allocation error",
1.4 +9 -8 xml-security/c/src/enc/XSECCryptoException.hpp
Index: XSECCryptoException.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/XSECCryptoException.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSECCryptoException.hpp 23 Feb 2003 08:41:13 -0000 1.3
+++ XSECCryptoException.hpp 7 Apr 2003 12:27:13 -0000 1.4
@@ -121,13 +121,14 @@
enum XSECCryptoExceptionType {
None = 0,
- MDError = 1, // Error in Message Digest
- Base64Error = 2, // Error in a Base64 operation
- MemoryError = 3, // Memory allocation error
- X509Error = 4, // X509 problem
- DSAError = 5, // DSA Error
- RSAError = 6, // RSA Error
- UnknownError = 7 // Must be last!
+ GeneralError = 1,
+ MDError = 2, // Error in Message Digest
+ Base64Error = 3, // Error in a Base64 operation
+ MemoryError = 4, // Memory allocation error
+ X509Error = 5, // X509 problem
+ DSAError = 6, // DSA Error
+ RSAError = 7, // RSA Error
+ UnknownError = 8 // Must be last!
};
1.6 +3 -0 xml-security/c/src/enc/XSECCryptoHash.hpp
Index: XSECCryptoHash.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/XSECCryptoHash.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSECCryptoHash.hpp 30 Mar 2003 06:57:12 -0000 1.5
+++ XSECCryptoHash.hpp 7 Apr 2003 12:27:13 -0000 1.6
@@ -76,6 +76,9 @@
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/enc/XSECCryptoKey.hpp>
+#define XSEC_MAX_HASH_SIZE 256 /* Max size of any expected hash algorithms (oversized) */
+#define XSEC_MAX_HASH_BLOCK_SIZE 64 /* Max size of blocks used - MD5 and SHA1 are both 64 bytes*/
+
/**
* @ingroup crypto
* @{
1.5 +8 -1 xml-security/c/src/enc/XSECCryptoKey.hpp
Index: XSECCryptoKey.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/XSECCryptoKey.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSECCryptoKey.hpp 2 Mar 2003 08:21:01 -0000 1.4
+++ XSECCryptoKey.hpp 7 Apr 2003 12:27:13 -0000 1.5
@@ -76,6 +76,7 @@
#define XSECCRYPTOKEY_INCLUDE
#include <xsec/framework/XSECDefs.hpp>
+#include <xsec/dsig/DSIGConstants.hpp>
/**
* \ingroup crypto
@@ -142,6 +143,12 @@
*/
virtual KeyType getKeyType() {return KEY_NONE;}
+
+ /**
+ * \brief Returns a string that identifies the crypto owner of this library.
+ */
+
+ virtual const XMLCh * getProviderName() = 0;
/**
* \brief Clone the key
1.4 +6 -0 xml-security/c/src/enc/XSECCryptoProvider.hpp
Index: XSECCryptoProvider.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/XSECCryptoProvider.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSECCryptoProvider.hpp 30 Mar 2003 06:57:12 -0000 1.3
+++ XSECCryptoProvider.hpp 7 Apr 2003 12:27:13 -0000 1.4
@@ -138,6 +138,12 @@
#define CRYPTO_MAX_HASH_SIZE 128
/**
+ *\brief OID For DSA
+ */
+
+#define CRYPTO_OID_DSA "1.2.840.10040.4.1"
+
+/**
*\brief The base class that all *CryptoProviders need to implement.
*
* The instatiations of this class are used by the core library to
1.3 +2 -3 xml-security/c/src/enc/OpenSSL/OpenSSLCryptoHashHMAC.hpp
Index: OpenSSLCryptoHashHMAC.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/OpenSSL/OpenSSLCryptoHashHMAC.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OpenSSLCryptoHashHMAC.hpp 9 Feb 2003 11:13:49 -0000 1.2
+++ OpenSSLCryptoHashHMAC.hpp 7 Apr 2003 12:27:13 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -94,6 +92,7 @@
// Key activities
virtual void setKey(XSECCryptoKey * key);
+ virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVOpenSSL;}
// Hashing Activities
virtual void reset(void); // Reset the hash
1.3 +3 -3 xml-security/c/src/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp
Index: OpenSSLCryptoKeyDSA.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OpenSSLCryptoKeyDSA.hpp 9 Feb 2003 11:13:49 -0000 1.2
+++ OpenSSLCryptoKeyDSA.hpp 7 Apr 2003 12:27:13 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -89,6 +87,8 @@
// Generic key functions
virtual XSECCryptoKey::KeyType getKeyType();
+ virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVOpenSSL;}
+
virtual XSECCryptoKey * clone();
// DSA Specific Functions
1.3 +2 -3 xml-security/c/src/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp
Index: OpenSSLCryptoKeyHMAC.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OpenSSLCryptoKeyHMAC.hpp 9 Feb 2003 11:13:49 -0000 1.2
+++ OpenSSLCryptoKeyHMAC.hpp 7 Apr 2003 12:27:13 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -88,6 +86,7 @@
// Generic key functions
virtual XSECCryptoKey::KeyType getKeyType() {return KEY_HMAC;}
+ virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVOpenSSL;}
// HMAC Key functions
1.3 +2 -3 xml-security/c/src/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp
Index: OpenSSLCryptoKeyRSA.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OpenSSLCryptoKeyRSA.hpp 9 Feb 2003 11:13:50 -0000 1.2
+++ OpenSSLCryptoKeyRSA.hpp 7 Apr 2003 12:27:13 -0000 1.3
@@ -64,9 +64,7 @@
*
* Author(s): Berin Lautenbach
*
- * $ID$
- *
- * $LOG$
+ * $Id$
*
*/
@@ -89,6 +87,7 @@
// Generic key functions
virtual XSECCryptoKey::KeyType getKeyType();
+ virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVOpenSSL;}
virtual XSECCryptoKey * clone();
// RSA Specific Functions
1.13 +34 -1 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- checksig.cpp 23 Mar 2003 09:58:16 -0000 1.12
+++ checksig.cpp 7 Apr 2003 12:27:13 -0000 1.13
@@ -84,6 +84,7 @@
#if defined(_WIN32)
#include <xsec/utils/winutils/XSECURIResolverGenericWin32.hpp>
+#include <xsec/enc/WinCAPI/WinCAPICryptoProvider.hpp>
#else
#include <xsec/utils/unixutils/XSECURIResolverGenericUnix.hpp>
#endif
@@ -167,6 +168,10 @@
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)
+ cerr << " --wincapi/-w\n";
+ cerr << " Use the Windows CAPI crypto Provider\n\n";
+#endif
cerr << " Exits with codes :\n";
cerr << " 0 = Signature OK\n";
cerr << " 1 = Signature Bad\n";
@@ -180,6 +185,9 @@
char * hmacKeyStr = NULL;
OpenSSLCryptoKeyHMAC * hmacKey;
bool useXSECURIResolver = false;
+#if defined(_WIN32)
+ HCRYPTPROV win32CSP = 0; // Crypto Provider
+#endif
bool skipRefs = false;
@@ -206,6 +214,26 @@
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;
+ return 2;
+ }
+
+ // Use default DSS provider
+ cp = new WinCAPICryptoProvider(win32CSP);
+ XSECPlatformUtils::SetCryptoProvider(cp);
+ paramCount++;
+
+ }
+#endif
else {
printUsage();
return 2;
@@ -412,6 +440,11 @@
retResult = 1;
}
+#if defined (_WIN32)
+ if (win32CSP != 0) {
+ CryptReleaseContext(win32CSP, 0);
+ }
+#endif
prov.releaseSignature(sig);
// Janitor will clean up the parser
return retResult;
1.5 +117 -10 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- templatesign.cpp 22 Feb 2003 08:47:24 -0000 1.4
+++ templatesign.cpp 7 Apr 2003 12:27:13 -0000 1.5
@@ -83,6 +83,20 @@
#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(_WIN32)
+# include <xsec/enc/WinCAPI/WinCAPICryptoProvider.hpp>
+# include <xsec/enc/WinCAPI/WinCAPICryptoKeyDSA.hpp>
+#endif
+
#include <memory.h>
#include <string.h>
#include <iostream>
@@ -113,14 +127,6 @@
#endif
-// OpenSSL
-
-#include <openssl/bio.h>
-#include <openssl/dsa.h>
-#include <openssl/err.h>
-#include <openssl/evp.h>
-#include <openssl/pem.h>
-
// Uplift entire program into Xerces namespace
XERCES_CPP_NAMESPACE_USE
@@ -555,6 +561,9 @@
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)
+ cerr << " NOTE: Not usable if --wincapi previously set\n";
+#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";
@@ -564,6 +573,14 @@
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)
+ cerr << " --windss/-wd\n";
+ cerr << " Use the default user AT_SIGNATURE key from default\n";
+ cerr << " Windows DSS CSP\n";
+ cerr << " --windsskeyinfo/-wdi\n";
+ cerr << " Clear KeyInfo elements and insert DSS parameters from windows key\n";
+#endif
+
}
@@ -575,6 +592,11 @@
int certCount = 0;
int paramCount;
bool clearKeyInfo = false;
+#if defined(_WIN32)
+ HCRYPTPROV win32CSP = 0; // Crypto Provider
+ bool winDssKeyInfo = false;
+ WinCAPICryptoKeyDSA * winKey = NULL;
+#endif
// Initialise the XML system
@@ -619,7 +641,7 @@
if (stricmp(argv[paramCount], "--dsakey") == 0 || stricmp(argv[paramCount], "-d") == 0 ||
stricmp(argv[paramCount], "--rsakey") == 0 || stricmp(argv[paramCount], "-r") == 0) {
- // DSA or RSA Key
+ // DSA or RSA OpenSSL Key
if (paramCount + 3 >= argc) {
@@ -760,6 +782,44 @@
paramCount += 1;
}
+
+#if defined (_WIN32)
+ 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,
+ NULL,
+ NULL,
+ PROV_DSS,
+ 0)) {
+ cerr << "Error acquiring DSS Crypto Service Provider" << endl;
+ return 2;
+ }
+ cp = new WinCAPICryptoProvider(win32CSP);
+ XSECPlatformUtils::SetCryptoProvider(cp);
+
+ // Now get the key
+ HCRYPTKEY k;
+ BOOL fResult = CryptGetUserKey(
+ win32CSP,
+ AT_SIGNATURE,
+ &k);
+
+ if (!fResult || k == 0) {
+ cerr << "Error obtaining default user AT_SIGNATURE key from windows DSS provider\n";
+ exit(1);
+ };
+ winKey = new WinCAPICryptoKeyDSA(cp, k, true);
+ key = winKey;
+ paramCount++;
+ }
+ else if (stricmp(argv[paramCount], "--windsskeyinfo") == 0 || stricmp(argv[paramCount], "-wdi") == 0) {
+ winDssKeyInfo = true;
+ paramCount++;
+ }
+
+#endif
+
else {
printUsage();
@@ -849,6 +909,34 @@
// Add any KeyInfo elements
+#if defined(_WIN32)
+
+ if (winDssKeyInfo == true && winKey != NULL) {
+ char pBuf[1024];
+ char qBuf[1024];
+ char gBuf[1024];
+ char yBuf[1024];
+
+ unsigned int i;
+ i = winKey->getPBase64BigNums((char *) pBuf, 1024);
+ pBuf[i] = '\0';
+ i = winKey->getQBase64BigNums((char *) qBuf, 1024);
+ qBuf[i] = '\0';
+ i = winKey->getGBase64BigNums((char *) gBuf, 1024);
+ gBuf[i] = '\0';
+ i = winKey->getYBase64BigNums((char *) yBuf, 1024);
+ yBuf[i] = '\0';
+
+ sig->clearKeyInfo();
+ sig->appendDSAKeyValue(
+ MAKE_UNICODE_STRING(pBuf),
+ MAKE_UNICODE_STRING(qBuf),
+ MAKE_UNICODE_STRING(gBuf),
+ MAKE_UNICODE_STRING(yBuf));
+ }
+
+#endif
+
if (certCount > 0) {
// Have some certificates - see if there is already an X509 list
@@ -914,6 +1002,25 @@
cout << doc;
+ delete [] gEncodingName;
+ delete [] (void *) encNameStr;
+ delete formatTarget;
+
+#if defined (_WIN32)
+ if (win32CSP != 0)
+ CryptReleaseContext(win32CSP,0);
+#endif
+
prov.releaseSignature(sig);
+ delete parser;
+
+ XSECPlatformUtils::Terminate();
+#ifndef XSEC_NO_XALAN
+ XalanTransformer::terminate();
+ XPathEvaluator::terminate();
+#endif
+ XMLPlatformUtils::Terminate();
+
+
return 0;
}
1.5 +11 -1 xml-security/c/src/utils/XSECPlatformUtils.cpp
Index: XSECPlatformUtils.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECPlatformUtils.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XSECPlatformUtils.cpp 22 Feb 2003 08:47:26 -0000 1.4
+++ XSECPlatformUtils.cpp 7 Apr 2003 12:27:13 -0000 1.5
@@ -101,6 +101,16 @@
};
+void XSECPlatformUtils::SetCryptoProvider(XSECCryptoProvider * p) {
+
+ if (g_cryptoProvider != NULL)
+ delete g_cryptoProvider;
+
+ g_cryptoProvider = p;
+
+}
+
+
void XSECPlatformUtils::Terminate(void) {
if (--initCount > 0)
1.6 +18 -1 xml-security/c/src/utils/XSECPlatformUtils.hpp
Index: XSECPlatformUtils.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECPlatformUtils.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSECPlatformUtils.hpp 2 Mar 2003 08:21:02 -0000 1.5
+++ XSECPlatformUtils.hpp 7 Apr 2003 12:27:13 -0000 1.6
@@ -131,6 +131,23 @@
static void Initialise(XSECCryptoProvider * p = NULL);
/**
+ * \brief Set a new crypto provider
+ *
+ * Set the crypto provider to the value passed in. Any current provider
+ * is deleted.
+ *
+ * @note This is not thread-safe. It should be called prior to any real
+ * usage of the library.
+ *
+ * @param p A pointer to a XSECCryptoProvider object that the library
+ * should use for cryptographic functions.
+ * @note Ownership of the provider is passed to the library, which will
+ * delete it at Termination.
+ */
+
+ static void SetCryptoProvider(XSECCryptoProvider * p);
+
+ /**
* \brief Terminate
*
* Should be called prior to any program exist to allow the library
1.4 +12 -2 xml-security/c/src/utils/XSECSafeBuffer.cpp
Index: XSECSafeBuffer.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECSafeBuffer.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSECSafeBuffer.cpp 18 Feb 2003 11:28:12 -0000 1.3
+++ XSECSafeBuffer.cpp 7 Apr 2003 12:27:13 -0000 1.4
@@ -265,7 +265,7 @@
}
-void safeBuffer::sbMemcpyIn(void * inBuf, int n) {
+void safeBuffer::sbMemcpyIn(const void * inBuf, int n) {
checkAndExpand(n);
memcpy(buffer, inBuf, n);
@@ -309,6 +309,16 @@
memcpy(outBuf, buffer, n);
}
+
+void safeBuffer::sbMemshift(int toOffset, int fromOffset, int len) {
+
+ // Move data in the buffer around
+ checkAndExpand((toOffset > fromOffset ? toOffset : fromOffset) + len);
+
+ memmove(&buffer[toOffset], &buffer[fromOffset], len);
+
+}
+
// Comparisons
1.6 +3 -2 xml-security/c/src/utils/XSECSafeBuffer.hpp
Index: XSECSafeBuffer.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/XSECSafeBuffer.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSECSafeBuffer.hpp 2 Mar 2003 08:21:02 -0000 1.5
+++ XSECSafeBuffer.hpp 7 Apr 2003 12:27:13 -0000 1.6
@@ -132,10 +132,11 @@
void sbStrncatIn(char * inStr, int n);
void sbStrinsIn(const char * inStr, unsigned int offset);
- void sbMemcpyIn(void * inBuf, int n);
+ void sbMemcpyIn(const void * inBuf, int n);
void sbMemcpyIn(int offset, const void * inBuf, int n);
void sbMemcpyOut(void * outBuf, int n) const;
+ void sbMemshift(int toOffset, int fromOffset, int len);
// Comparison functions