00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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;
00341 DWORD m_keySpec;
00342
00343 BYTE * mp_modulus;
00344 BYTE * mp_exponent;
00345
00346 unsigned int m_modulusLen;
00347 unsigned int m_exponentLen;
00348
00349
00350
00351 void loadParamsFromKey(void);
00352
00353 };
00354
00355 #endif