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 450743 2006-09-28 07:51:31Z blautenb $
00025  *
00026  */
00027 
00028 #ifndef WINCAPICRYPTOKEYRSA_INCLUDE
00029 #define WINCAPICRYPTOKEYRSA_INCLUDE
00030 
00031 #include <xsec/enc/XSECCryptoKeyRSA.hpp>
00032 
00033 #if defined (HAVE_WINCAPI)
00034 
00035 #if !defined(_WIN32_WINNT)
00036 #   define _WIN32_WINNT 0x0400
00037 #endif
00038 
00039 #include <wincrypt.h>
00040 
00041 class WinCAPICryptoProvider;
00042 
00053 class DSIG_EXPORT WinCAPICryptoKeyRSA : public XSECCryptoKeyRSA {
00054 
00055 public :
00056 
00059 
00070     WinCAPICryptoKeyRSA(HCRYPTPROV prov);
00071 
00084     WinCAPICryptoKeyRSA(HCRYPTPROV prov, HCRYPTKEY k);
00085 
00097     WinCAPICryptoKeyRSA(HCRYPTPROV prov, DWORD keySpec, bool isPrivate);
00098 
00099     virtual ~WinCAPICryptoKeyRSA();
00100 
00102 
00105 
00113     virtual XSECCryptoKey::KeyType getKeyType();
00114 
00119     virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVWinCAPI;}
00120     
00125     virtual XSECCryptoKey * clone();
00126 
00128 
00134 
00152     virtual void setOAEPparams(unsigned char * params, unsigned int paramsLen);
00153 
00162     virtual unsigned int getOAEPparamsLen(void);
00163 
00173     virtual const unsigned char * getOAEPparams(void);
00174 
00190     virtual bool verifySHA1PKCS1Base64Signature(const unsigned char * hashBuf, 
00191                                  unsigned int hashLen,
00192                                  const char * base64Signature,
00193                                  unsigned int sigLen,
00194                                  hashMethod hm);
00195 
00214     virtual unsigned int signSHA1PKCS1Base64Signature(unsigned char * hashBuf,
00215                                 unsigned int hashLen,
00216                                 char * base64SignatureBuf,
00217                                 unsigned int base64SignatureBufLen,
00218                                 hashMethod hm);
00219 
00235     virtual unsigned int privateDecrypt(const unsigned char * inBuf,
00236                                  unsigned char * plainBuf, 
00237                                  unsigned int inLength,
00238                                  unsigned int maxOutLength,
00239                                  PaddingType padding,
00240                                  hashMethod hm);
00241 
00257     virtual unsigned int publicEncrypt(const unsigned char * inBuf,
00258                                  unsigned char * cipherBuf, 
00259                                  unsigned int inLength,
00260                                  unsigned int maxOutLength,
00261                                  PaddingType padding,
00262                                  hashMethod hm);
00263 
00270     virtual unsigned int getLength(void);
00271 
00273 
00280 
00290     virtual void loadPublicModulusBase64BigNums(const char * b64, unsigned int len);
00291 
00301     virtual void loadPublicExponentBase64BigNums(const char * b64, unsigned int len);
00302 
00304 
00307 
00308 
00319     unsigned int getExponentBase64BigNums(char * b64, unsigned int len);
00320 
00331     unsigned int getModulusBase64BigNums(char * b64, unsigned int len);
00332 
00341     HCRYPTKEY importKey(void);
00342 
00344 
00345 private:
00346 
00347     HCRYPTPROV                  m_p;
00348     HCRYPTKEY                   m_key;          // For a public key
00349     DWORD                       m_keySpec;      // For a private key
00350 
00351     BYTE                        * mp_modulus;
00352     BYTE                        * mp_exponent;
00353 
00354     unsigned int                m_modulusLen;
00355     unsigned int                m_exponentLen;
00356 
00357     // Instruct to import from parameters
00358 
00359     void loadParamsFromKey(void);
00360 
00361 };
00362 
00363 #endif /* HAVE_WINCAPI */
00364 #endif /* WINCAPICRYPTOKEYRSA_INCLUDE */

Generated on Sun Jan 28 19:37:23 2007 for XML-Security-C by  doxygen 1.4.2