Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

WinCAPICryptoProvider.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * imitations under the License.
00015  */
00016 
00017 /*
00018  * XSEC
00019  *
00020  * WinCAPICryptoProvider := Base class to handle Windows Crypto API
00021  *
00022  * Author(s): Berin Lautenbach
00023  *
00024  * $Id: WinCAPICryptoProvider.hpp,v 1.13 2004/03/07 03:20:51 blautenb Exp $
00025  *
00026  */
00027 
00028 #ifndef WINCAPICRYPTOPROVIDER_INCLUDE
00029 #define WINCAPICRYPTOPROVIDER_INCLUDE
00030 
00031 #include <xsec/framework/XSECDefs.hpp>
00032 #include <xsec/enc/XSECCryptoProvider.hpp>
00033 
00034 #if defined (_WIN32_WINNT)
00035 #   undef _WIN32_WINNT
00036 #endif
00037 #define _WIN32_WINNT 0x0400
00038 #include <wincrypt.h>
00039 
00040 
00041 // For older versions of wincrypt.h
00042 
00043 #if !defined (PROV_RSA_AES)
00044 #   define PROV_RSA_AES             24
00045 #   define ALG_SID_AES_128          14
00046 #   define ALG_SID_AES_192          15
00047 #   define ALG_SID_AES_256          16
00048 #   define ALG_SID_AES              17
00049 #   define CALG_AES_128             (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_128)
00050 #   define CALG_AES_192             (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_192)
00051 #   define CALG_AES_256             (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_256)
00052 #endif
00053 
00054 #define WINCAPI_BLOBHEADERLEN   0x08
00055 #define WINCAPI_DSSPUBKEYLEN    0x08
00056 #define WINCAPI_DSSSEEDLEN      0x18
00057 #define WINCAPI_RSAPUBKEYLEN    0x0C
00058 
00082  /*\@{*/
00083 
00084 class DSIG_EXPORT WinCAPICryptoProvider : public XSECCryptoProvider {
00085 
00086 
00087 public :
00088 
00103     WinCAPICryptoProvider(LPCSTR provDSSName = NULL, LPCSTR provRSAName = NULL);
00104 
00105     virtual ~WinCAPICryptoProvider();
00106 
00108 
00111 
00122     virtual XSECCryptoHash          * hashSHA1();
00123 
00135     virtual XSECCryptoHash          * hashHMACSHA1();
00136 
00147     virtual XSECCryptoHash          * hashMD5();
00148 
00165     virtual XSECCryptoHash          * hashHMACMD5();
00166 
00168 
00171 
00186     virtual XSECCryptoBase64        * base64();
00187 
00189 
00192 
00202     virtual XSECCryptoKeyDSA        * keyDSA();
00203 
00213     virtual XSECCryptoKeyRSA        * keyRSA();
00214 
00225     virtual XSECCryptoX509          * X509();
00226 
00228 
00231 
00236     HCRYPTPROV getProviderDSS(void) {return m_provDSS;}
00237 
00242     HCRYPTPROV getProviderRSA(void) {return m_provRSA;}
00243 
00248     HCRYPTPROV getApacheKeyStore(void) {return m_provApacheKeyStore;}
00249 
00262     static BYTE * b642WinBN(const char * b64, unsigned int b64Len, unsigned int &retLen);
00263 
00276     static unsigned char * WinBN2b64(BYTE * n, DWORD nLen, unsigned int &retLen);
00277 
00285     virtual bool algorithmSupported(XSECCryptoSymmetricKey::SymmetricKeyType alg);
00286 
00297     virtual XSECCryptoSymmetricKey  * keySymmetric(XSECCryptoSymmetricKey::SymmetricKeyType alg);
00298 
00311     virtual unsigned int getRandom(unsigned char * buffer, unsigned int numOctets);
00312 
00313 
00315 
00318 
00323     virtual const XMLCh * getProviderName();
00324 
00326 
00327 
00328 private:
00329 
00330     HCRYPTPROV      m_provDSS;
00331     HCRYPTPROV      m_provRSA;
00332     HCRYPTPROV      m_provApacheKeyStore;
00333     LPCSTR          m_provDSSName;
00334     LPCSTR          m_provRSAName;
00335     bool            m_haveAES;
00336     DWORD           m_provRSAType;
00337 
00338 };
00339 
00340 /*\@}*/
00341 
00342 
00343 #endif /* WINCAPICRYPTOPROVIDER_INCLUDE */
00344 

Generated on Sun Mar 14 21:35:31 2004 for XML-Security-C by doxygen 1.3.2