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

WinCAPICryptoKeyRSA.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2005 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  * limitations under the License.
00015  */
00016 
00017 /*
00018  * XSEC
00019  *
00020  * WinCAPICryptoKeyRSA := Windows implementation of RSA Keys
00021  *
00022  * Author(s): Berin Lautenbach
00023  *
00024  * $Id: WinCAPICryptoKeyRSA.hpp,v 1.11 2005/06/04 11:30:26 blautenb Exp $
00025  *
00026  */
00027 
00028 #ifndef WINCAPICRYPTOKEYRSA_INCLUDE
00029 #define WINCAPICRYPTOKEYRSA_INCLUDE
00030 
00031 #include <xsec/enc/XSECCryptoKeyRSA.hpp>
00032 
00033 #if !defined(_WIN32_WINNT)
00034 #   define _WIN32_WINNT 0x0400
00035 #endif
00036 
00037 #include <wincrypt.h>
00038 
00039 class WinCAPICryptoProvider;
00040 
00051 class DSIG_EXPORT WinCAPICryptoKeyRSA : public XSECCryptoKeyRSA {
00052 
00053 public :
00054 
00057 
00068     WinCAPICryptoKeyRSA(HCRYPTPROV prov);
00069 
00082     WinCAPICryptoKeyRSA(HCRYPTPROV prov, HCRYPTKEY k);
00083 
00095     WinCAPICryptoKeyRSA(HCRYPTPROV prov, DWORD keySpec, bool isPrivate);
00096 
00097     virtual ~WinCAPICryptoKeyRSA();
00098 
00100 
00103 
00111     virtual XSECCryptoKey::KeyType getKeyType();
00112 
00117     virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVWinCAPI;}
00118     
00123     virtual XSECCryptoKey * clone();
00124 
00126 
00132 
00150     virtual void setOAEPparams(unsigned char * params, unsigned int paramsLen);
00151 
00160     virtual unsigned int getOAEPparamsLen(void);
00161 
00171     virtual const unsigned char * getOAEPparams(void);
00172 
00186     virtual bool verifySHA1PKCS1Base64Signature(const unsigned char * hashBuf, 
00187                                  unsigned int hashLen,
00188                                  const char * base64Signature,
00189                                  unsigned int sigLen);
00190 
00207     virtual unsigned int signSHA1PKCS1Base64Signature(unsigned char * hashBuf,
00208                                 unsigned int hashLen,
00209                                 char * base64SignatureBuf,
00210                                 unsigned int base64SignatureBufLen);
00211 
00227     virtual unsigned int privateDecrypt(const unsigned char * inBuf,
00228                                  unsigned char * plainBuf, 
00229                                  unsigned int inLength,
00230                                  unsigned int maxOutLength,
00231                                  PaddingType padding,
00232                                  hashMethod hm);
00233 
00249     virtual unsigned int publicEncrypt(const unsigned char * inBuf,
00250                                  unsigned char * cipherBuf, 
00251                                  unsigned int inLength,
00252                                  unsigned int maxOutLength,
00253                                  PaddingType padding,
00254                                  hashMethod hm);
00255 
00262     virtual unsigned int getLength(void);
00263 
00265 
00272 
00282     virtual void loadPublicModulusBase64BigNums(const char * b64, unsigned int len);
00283 
00293     virtual void loadPublicExponentBase64BigNums(const char * b64, unsigned int len);
00294 
00296 
00299 
00300 
00311     unsigned int getExponentBase64BigNums(char * b64, unsigned int len);
00312 
00323     unsigned int getModulusBase64BigNums(char * b64, unsigned int len);
00324 
00333     HCRYPTKEY importKey(void);
00334 
00336 
00337 private:
00338 
00339     HCRYPTPROV                  m_p;
00340     HCRYPTKEY                   m_key;          // For a public key
00341     DWORD                       m_keySpec;      // For a private key
00342 
00343     BYTE                        * mp_modulus;
00344     BYTE                        * mp_exponent;
00345 
00346     unsigned int                m_modulusLen;
00347     unsigned int                m_exponentLen;
00348 
00349     // Instruct to import from parameters
00350 
00351     void loadParamsFromKey(void);
00352 
00353 };
00354 
00355 #endif /* WINCAPICRYPTOKEYRSA_INCLUDE */

Generated on Sun Jul 3 17:37:26 2005 for XML-Security-C by  doxygen 1.4.2