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

WinCAPICryptoKeyRSA Class Reference
[Windows Crypto API Interface]

#include <WinCAPICryptoKeyRSA.hpp>

Inheritance diagram for WinCAPICryptoKeyRSA:

Inheritance graph
[legend]
Collaboration diagram for WinCAPICryptoKeyRSA:

Collaboration graph
[legend]
List of all members.

Detailed Description

WinCAPI implementation of the interface class for RSA keys.

The library uses classes derived from this to process RSA keys.


Public Member Functions

Constructors and Destructors
 WinCAPICryptoKeyRSA (HCRYPTPROV prov)
 Create an RSA key.
 WinCAPICryptoKeyRSA (HCRYPTPROV prov, HCRYPTKEY k)
 Dedicated WinCAPI constructor for a public RSA key.
 WinCAPICryptoKeyRSA (HCRYPTPROV prov, DWORD keySpec, bool isPrivate)
 Dedicated WinCAPI constructor for a private RSA key.
virtual ~WinCAPICryptoKeyRSA ()
Key Interface methods
virtual XSECCryptoKey::KeyType getKeyType ()
 Return the type of this key.
virtual const XMLCh * getProviderName ()
 Return the WinCAPI identifier string.
virtual XSECCryptoKeyclone ()
 Replicate key.
Mandatory RSA interface methods
These classes are required by the library.

virtual void setOAEPparams (unsigned char *params, unsigned int paramsLen)
 Set the OAEPparams string.
virtual unsigned int getOAEPparamsLen (void)
 Get OAEPparams Length.
virtual const unsigned char * getOAEPparams (void)
 Get the OAEPparams.
virtual bool verifySHA1PKCS1Base64Signature (const unsigned char *hashBuf, unsigned int hashLen, const char *base64Signature, unsigned int sigLen)
 Verify a SHA1 PKCS1 encoded signature.
virtual unsigned int signSHA1PKCS1Base64Signature (unsigned char *hashBuf, unsigned int hashLen, char *base64SignatureBuf, unsigned int base64SignatureBufLen)
 Create a signature.
virtual unsigned int privateDecrypt (const unsigned char *inBuf, unsigned char *plainBuf, unsigned int inLength, unsigned int maxOutLength, PaddingType padding, hashMethod hm)
 Decrypt using private key.
virtual unsigned int publicEncrypt (const unsigned char *inBuf, unsigned char *cipherBuf, unsigned int inLength, unsigned int maxOutLength, PaddingType padding, hashMethod hm)
 Encrypt using a public key.
virtual unsigned int getLength (void)
 Obtain the length of an RSA key.
Optional Interface methods
Have been implemented to allow interoperability testing

virtual void loadPublicModulusBase64BigNums (const char *b64, unsigned int len)
 Load the modulus.
virtual void loadPublicExponentBase64BigNums (const char *b64, unsigned int len)
 Load the exponent.
WinCAPI Specific Functions
unsigned int getExponentBase64BigNums (char *b64, unsigned int len)
 Retrieve the exponent.
unsigned int getModulusBase64BigNums (char *b64, unsigned int len)
 Retrieve the modulus.
HCRYPTKEY importKey (void)
 Import key and return it.


Constructor & Destructor Documentation

WinCAPICryptoKeyRSA::WinCAPICryptoKeyRSA HCRYPTPROV  prov  ) 
 

Create an RSA key.

Constructor used to create an "empty" RSA key, that the library will later set parameters for the public key within.

Parameters:
prov A handle to a PROV_RSA_FULL provider that the library will eventually import the key into

WinCAPICryptoKeyRSA::WinCAPICryptoKeyRSA HCRYPTPROV  prov,
HCRYPTKEY  k
 

Dedicated WinCAPI constructor for a public RSA key.

Create a public RSA key for use in XSEC from an existing HCRYPTKEY

Parameters:
prov The handle to the provider that was used to create the key
k The key to use
Note:
k is owned by the library. When the wrapper WinCAPICryptoKeyRSA is deleted, k will be destroyed using CryptDestroyKey()

WinCAPICryptoKeyRSA::WinCAPICryptoKeyRSA HCRYPTPROV  prov,
DWORD  keySpec,
bool  isPrivate
 

Dedicated WinCAPI constructor for a private RSA key.

Create a public RSA key for use in XSEC from an keySpec

Parameters:
prov The handle to the provider that was used to create the key
keySpec The key to use (AT_SIGNATURE or AT_KEYEXCHANGE
isPrivate Should be true. May be used later for public keys created this way

virtual WinCAPICryptoKeyRSA::~WinCAPICryptoKeyRSA  )  [virtual]
 


Member Function Documentation

virtual XSECCryptoKey* WinCAPICryptoKeyRSA::clone  )  [virtual]
 

Replicate key.

Implements XSECCryptoKeyRSA.

unsigned int WinCAPICryptoKeyRSA::getExponentBase64BigNums char *  b64,
unsigned int  len
 

Retrieve the exponent.

Retrieves the exponent in ds:CryptoBinary encoded format

Parameters:
b64 Buffer to place encoded exponent into
len Maximum number of bytes to place in buffer
Returns:
The number of bytes placed in the buffer

virtual XSECCryptoKey::KeyType WinCAPICryptoKeyRSA::getKeyType  )  [virtual]
 

Return the type of this key.

For RSA keys, this allows people to determine whether this is a public key, private key or a key pair

Reimplemented from XSECCryptoKeyRSA.

virtual unsigned int WinCAPICryptoKeyRSA::getLength void   )  [virtual]
 

Obtain the length of an RSA key.

Returns:
The length of the rsa key (in bytes)

Implements XSECCryptoKeyRSA.

unsigned int WinCAPICryptoKeyRSA::getModulusBase64BigNums char *  b64,
unsigned int  len
 

Retrieve the modulus.

Retrieves the modulus in ds:CryptoBinary encoded format

Parameters:
b64 Buffer to place the encoded modulus into
len Maximum number of bytes to place in buffer
Returns:
The number of bytes placed in the buffer

virtual const unsigned char* WinCAPICryptoKeyRSA::getOAEPparams void   )  [virtual]
 

Get the OAEPparams.

Returns:
a pointer to the (crypto object owned) buffer holding the OAEPparams or NULL if no params are held
Note:
The Microsoft Crypto RSA_AES and RSA_FULL providers do not support the ability to set OAEP parameters, so this will always return NULL

Implements XSECCryptoKeyRSA.

virtual unsigned int WinCAPICryptoKeyRSA::getOAEPparamsLen void   )  [virtual]
 

Get OAEPparams Length.

Returns:
the number of bytes of the OAEPparams buffer (assuming it has been set)
Note:
The Microsoft Crypto RSA_AES and RSA_FULL providers do not support the ability to set OAEP parameters, so this will always return 0

Implements XSECCryptoKeyRSA.

virtual const XMLCh* WinCAPICryptoKeyRSA::getProviderName  )  [inline, virtual]
 

Return the WinCAPI identifier string.

Implements XSECCryptoKey.

HCRYPTKEY WinCAPICryptoKeyRSA::importKey void   ) 
 

Import key and return it.

Retrieves the RSA key as HCRYPTKEY

Returns:
The key

virtual void WinCAPICryptoKeyRSA::loadPublicExponentBase64BigNums const char *  b64,
unsigned int  len
[virtual]
 

Load the exponent.

Load the exponent from a Base64 encoded string

param b64 A buffer containing the encoded string param len The length of the data in the buffer

Implements XSECCryptoKeyRSA.

virtual void WinCAPICryptoKeyRSA::loadPublicModulusBase64BigNums const char *  b64,
unsigned int  len
[virtual]
 

Load the modulus.

Load the modulus from a Base64 encoded string

param b64 A buffer containing the encoded string param len The length of the data in the buffer

Implements XSECCryptoKeyRSA.

virtual unsigned int WinCAPICryptoKeyRSA::privateDecrypt const unsigned char *  inBuf,
unsigned char *  plainBuf,
unsigned int  inLength,
unsigned int  maxOutLength,
PaddingType  padding,
hashMethod  hm
[virtual]
 

Decrypt using private key.

The library will call this function to decrypt a piece of cipher text using the private component of this key.

Parameters:
inBuf cipher text to decrypt
plainBuf output buffer for decrypted bytes
inLength bytes of cipher text to decrypt
maxOutLength size of outputBuffer
padding Type of padding (PKCS 1.5 or OAEP)
hm Hash Method for OAEP encryption (OAEPParams should be set using setOAEPparams()

Implements XSECCryptoKeyRSA.

virtual unsigned int WinCAPICryptoKeyRSA::publicEncrypt const unsigned char *  inBuf,
unsigned char *  cipherBuf,
unsigned int  inLength,
unsigned int  maxOutLength,
PaddingType  padding,
hashMethod  hm
[virtual]
 

Encrypt using a public key.

The library will call this function to encrypt a plain text buffer using the public component of this key.

Parameters:
inBuf plain text to decrypt
cipherBuf output buffer for decrypted bytes
inLength bytes of plain text to encrypt
maxOutLength size of outputBuffer
padding Type of padding (PKCS 1.5 or OAEP)
hm Hash Method for OAEP encryption (OAEPParams should be set using setOAEPparams()

Implements XSECCryptoKeyRSA.

virtual void WinCAPICryptoKeyRSA::setOAEPparams unsigned char *  params,
unsigned int  paramsLen
[virtual]
 

Set the OAEPparams string.

By default, the library expects crypto implementations to perform OAEP padding with no params. This call allows the library (or user) to set a params value prior to an encrypt/decrypt operation.

Parameters:
params buffer containing the params data. Pass in NULL to clear any old paramters.
paramsLen number of bytes in buffer to use. Pass in 0 to clear any old parameters.
Note:
The Microsoft Crypto RSA_AES and RSA_FULL providers do not support the ability to set OAEP parameters, so this will throw an XSECCryptoException::UnsupportedError, unless the passed in paramters are NULL and 0 (to clear).

Implements XSECCryptoKeyRSA.

virtual unsigned int WinCAPICryptoKeyRSA::signSHA1PKCS1Base64Signature unsigned char *  hashBuf,
unsigned int  hashLen,
char *  base64SignatureBuf,
unsigned int  base64SignatureBufLen
[virtual]
 

Create a signature.

The library will call this function to create a signature from a pre-calculated digest. The output signature will be Base64 encoded such that it can be placed directly into the XML document

Parameters:
hashBuf Buffer containing the pre-calculated (binary) digest
hashLen Number of bytes of hash in the hashBuf
base64SignatureBuf Buffer to place the base64 encoded result in.
base64SignatureBufLen Implementations need to ensure they do not write more bytes than this into the buffer

Implements XSECCryptoKeyRSA.

virtual bool WinCAPICryptoKeyRSA::verifySHA1PKCS1Base64Signature const unsigned char *  hashBuf,
unsigned int  hashLen,
const char *  base64Signature,
unsigned int  sigLen
[virtual]
 

Verify a SHA1 PKCS1 encoded signature.

The library will call this function to validate an RSA signature The standard by default uses SHA1 in a PKCS1 encoding.

Parameters:
hashBuf Buffer containing the pre-calculated (binary) digest
hashLen Length of the data in the digest buffer
base64Signature Buffer containing the Base64 encoded signature
sigLen Length of the data in the signature buffer
Returns:
true if the signature was valid, false otherwise

Implements XSECCryptoKeyRSA.


The documentation for this class was generated from the following file:
Generated on Sun Jul 3 17:43:43 2005 for XML-Security-C by  doxygen 1.4.2