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

WinCAPICryptoKeyRSA.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  * WinCAPICryptoKeyRSA := Windows implementation of RSA Keys
00021  *
00022  * Author(s): Berin Lautenbach
00023  *
00024  * $Id: WinCAPICryptoKeyRSA.hpp,v 1.8 2004/02/08 10:23:33 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 
00052 class DSIG_EXPORT WinCAPICryptoKeyRSA : public XSECCryptoKeyRSA {
00053 
00054 public :
00055 
00058 
00069     WinCAPICryptoKeyRSA(HCRYPTPROV prov);
00070 
00083     WinCAPICryptoKeyRSA(HCRYPTPROV prov, HCRYPTKEY k);
00084 
00096     WinCAPICryptoKeyRSA(HCRYPTPROV prov, DWORD keySpec, bool isPrivate);
00097 
00098     virtual ~WinCAPICryptoKeyRSA();
00099 
00101 
00104 
00112     virtual XSECCryptoKey::KeyType getKeyType();
00113 
00118     virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVWinCAPI;}
00119     
00124     virtual XSECCryptoKey * clone();
00125 
00127 
00133 
00151     virtual void setOAEPparams(unsigned char * params, unsigned int paramsLen);
00152 
00161     virtual unsigned int getOAEPparamsLen(void);
00162 
00172     virtual const unsigned char * getOAEPparams(void);
00173 
00187     virtual bool verifySHA1PKCS1Base64Signature(const unsigned char * hashBuf, 
00188                                  unsigned int hashLen,
00189                                  const char * base64Signature,
00190                                  unsigned int sigLen);
00191 
00208     virtual unsigned int signSHA1PKCS1Base64Signature(unsigned char * hashBuf,
00209                                 unsigned int hashLen,
00210                                 char * base64SignatureBuf,
00211                                 unsigned int base64SignatureBufLen);
00212 
00228     virtual unsigned int privateDecrypt(const unsigned char * inBuf,
00229                                  unsigned char * plainBuf, 
00230                                  unsigned int inLength,
00231                                  unsigned int maxOutLength,
00232                                  PaddingType padding,
00233                                  hashMethod hm);
00234 
00250     virtual unsigned int publicEncrypt(const unsigned char * inBuf,
00251                                  unsigned char * cipherBuf, 
00252                                  unsigned int inLength,
00253                                  unsigned int maxOutLength,
00254                                  PaddingType padding,
00255                                  hashMethod hm);
00256 
00263     virtual unsigned int getLength(void);
00264 
00266 
00273 
00283     virtual void loadPublicModulusBase64BigNums(const char * b64, unsigned int len);
00284 
00294     virtual void loadPublicExponentBase64BigNums(const char * b64, unsigned int len);
00295 
00297 
00300 
00301 
00312     unsigned int getExponentBase64BigNums(char * b64, unsigned int len);
00313 
00324     unsigned int getModulusBase64BigNums(char * b64, unsigned int len);
00325 
00327 
00328 private:
00329 
00330     HCRYPTPROV                  m_p;
00331     HCRYPTKEY                   m_key;          // For a public key
00332     DWORD                       m_keySpec;      // For a private key
00333 
00334     BYTE                        * mp_modulus;
00335     BYTE                        * mp_exponent;
00336 
00337     unsigned int                m_modulusLen;
00338     unsigned int                m_exponentLen;
00339 
00340     // Instruct to import from parameters
00341 
00342     void importKey(void);
00343     void loadParamsFromKey(void);
00344 
00345 };
00346 
00347 #endif /* WINCAPICRYPTOKEYRSA_INCLUDE */

Generated on Sun Mar 14 20:20:36 2004 for XML-Security-C by doxygen 1.3.2