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

XSECCryptoKeyRSA Class Reference
[Cryptographic Abstraction Layer]

#include <XSECCryptoKeyRSA.hpp>

Inheritance diagram for XSECCryptoKeyRSA:

Inheritance graph
[legend]
Collaboration diagram for XSECCryptoKeyRSA:

Collaboration graph
[legend]
List of all members.

Detailed Description

Interface class for RSA keys.

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


Public Types

enum  PaddingType {
  PAD_NONE = 0,
  PAD_PKCS_1_5 = 1,
  PAD_OAEP_MGFP1 = 2
}
 Padding type. More...

Public Member Functions

Constructors and Destructors
 XSECCryptoKeyRSA ()
virtual ~XSECCryptoKeyRSA ()
Key Interface methods
virtual XSECCryptoKey::KeyType getKeyType ()
 Return the type of this key.
virtual XSECCryptoKeyclone ()=0
 Replicate key.
Mandatory RSA interface methods
These classes are required by the library.

virtual void setOAEPparams (unsigned char *params, unsigned int paramsLen)=0
 Set the OAEPparams string.
virtual unsigned int getOAEPparamsLen (void)=0
 Get OAEPparams Length.
virtual const unsigned char * getOAEPparams (void)=0
 Get the OAEPparams.
virtual bool verifySHA1PKCS1Base64Signature (const unsigned char *hashBuf, unsigned int hashLen, const char *base64Signature, unsigned int sigLen)=0
 Verify a SHA1 PKCS1 encoded signature.
virtual unsigned int signSHA1PKCS1Base64Signature (unsigned char *hashBuf, unsigned int hashLen, char *base64SignatureBuf, unsigned int base64SignatureBufLen)=0
 Create a signature.
virtual unsigned int privateDecrypt (const unsigned char *inBuf, unsigned char *plainBuf, unsigned int inLength, unsigned int maxOutLength, PaddingType padding, hashMethod hm)=0
 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)=0
 Encrypt using a public key.
virtual unsigned int getLength (void)=0
 Obtain the length of an RSA key.
Optional Interface methods
These functions do not necessarily have to be implmented. They are used by XSECKeyInfoResolverDefault to try to create a key from KeyInfo elements without knowing anything else.

If an interface class does not implement these functions, a simple stub that does nothing should be used.

virtual void loadPublicModulusBase64BigNums (const char *b64, unsigned int len)=0
 Load the modulus.
virtual void loadPublicExponentBase64BigNums (const char *b64, unsigned int len)=0
 Load the exponent.


Member Enumeration Documentation

enum XSECCryptoKeyRSA::PaddingType
 

Padding type.

Type of padding to be used for RSA encrypt/decrypt operations

Enumeration values:
PAD_NONE 
PAD_PKCS_1_5  No padding (Illegal for all enc ops)
PAD_OAEP_MGFP1  PKCS 1.5 padding


Constructor & Destructor Documentation

XSECCryptoKeyRSA::XSECCryptoKeyRSA  )  [inline]
 

virtual XSECCryptoKeyRSA::~XSECCryptoKeyRSA  )  [inline, virtual]
 


Member Function Documentation

virtual XSECCryptoKey* XSECCryptoKeyRSA::clone  )  [pure virtual]
 

Replicate key.

Implements XSECCryptoKey.

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual XSECCryptoKey::KeyType XSECCryptoKeyRSA::getKeyType  )  [inline, 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 XSECCryptoKey.

Reimplemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual unsigned int XSECCryptoKeyRSA::getLength void   )  [pure virtual]
 

Obtain the length of an RSA key.

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

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual const unsigned char* XSECCryptoKeyRSA::getOAEPparams void   )  [pure virtual]
 

Get the OAEPparams.

Returns:
a pointer to the (crypto object owned) buffer holding the OAEPparams or NULL if no params are held

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual unsigned int XSECCryptoKeyRSA::getOAEPparamsLen void   )  [pure virtual]
 

Get OAEPparams Length.

Returns:
the number of bytes of the OAEPparams buffer (assuming it has been set)

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual void XSECCryptoKeyRSA::loadPublicExponentBase64BigNums const char *  b64,
unsigned int  len
[pure 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

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual void XSECCryptoKeyRSA::loadPublicModulusBase64BigNums const char *  b64,
unsigned int  len
[pure 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

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual unsigned int XSECCryptoKeyRSA::privateDecrypt const unsigned char *  inBuf,
unsigned char *  plainBuf,
unsigned int  inLength,
unsigned int  maxOutLength,
PaddingType  padding,
hashMethod  hm
[pure 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()

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual unsigned int XSECCryptoKeyRSA::publicEncrypt const unsigned char *  inBuf,
unsigned char *  cipherBuf,
unsigned int  inLength,
unsigned int  maxOutLength,
PaddingType  padding,
hashMethod  hm
[pure 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
hm Hash Method for OAEP encryption (OAEPParams should be set using setOAEPparams()

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual void XSECCryptoKeyRSA::setOAEPparams unsigned char *  params,
unsigned int  paramsLen
[pure 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.

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

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

Create a signature.

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

This call needs to do a PKCS1 encode for a SHA-1 signature.

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

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.

virtual bool XSECCryptoKeyRSA::verifySHA1PKCS1Base64Signature const unsigned char *  hashBuf,
unsigned int  hashLen,
const char *  base64Signature,
unsigned int  sigLen
[pure 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

Implemented in OpenSSLCryptoKeyRSA, and WinCAPICryptoKeyRSA.


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