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

NSSCryptoKeyRSA.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 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  * NSSCryptoKeyRSA := NSS implementation of RSA Keys
00021  *
00022  * Author(s): Milan Tomic
00023  *
00024  */
00025 
00026 #ifndef NSSCRYPTOKEYRSA_INCLUDE
00027 #define NSSCRYPTOKEYRSA_INCLUDE
00028 
00029 #include <xsec/enc/XSECCryptoKeyRSA.hpp>
00030 
00031 #if defined (HAVE_NSS)
00032 
00033 #include "nss/pk11func.h"
00034 #include "nss/keyhi.h"
00035 #include "nss/nss.h"
00036 
00037 class NSSCryptoProvider;
00038 
00050 class DSIG_EXPORT NSSCryptoKeyRSA : public XSECCryptoKeyRSA {
00051 
00052 public :
00053 
00056 
00064     NSSCryptoKeyRSA(SECKEYPublicKey * pubkey = NULL, SECKEYPrivateKey * privkey = NULL);
00065 
00066     virtual ~NSSCryptoKeyRSA();
00067 
00069 
00072 
00080     virtual XSECCryptoKey::KeyType getKeyType();
00081 
00086     virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVNSS;}
00087     
00092     virtual XSECCryptoKey * clone();
00093 
00095 
00101 
00118     virtual void setOAEPparams(unsigned char * params, unsigned int paramsLen);
00119 
00128     virtual unsigned int getOAEPparamsLen(void);
00129 
00139     virtual const unsigned char * getOAEPparams(void);
00140 
00156     virtual bool verifySHA1PKCS1Base64Signature(const unsigned char * hashBuf, 
00157                                  unsigned int hashLen,
00158                                  const char * base64Signature,
00159                                  unsigned int sigLen,
00160                                  hashMethod hm);
00161 
00179     virtual unsigned int signSHA1PKCS1Base64Signature(unsigned char * hashBuf,
00180                                 unsigned int hashLen,
00181                                 char * base64SignatureBuf,
00182                                 unsigned int base64SignatureBufLen,
00183                                 hashMethod hm);
00184 
00200     virtual unsigned int privateDecrypt(const unsigned char * inBuf,
00201                                  unsigned char * plainBuf, 
00202                                  unsigned int inLength,
00203                                  unsigned int maxOutLength,
00204                                  PaddingType padding,
00205                                  hashMethod hm);
00206 
00222     virtual unsigned int publicEncrypt(const unsigned char * inBuf,
00223                                  unsigned char * cipherBuf, 
00224                                  unsigned int inLength,
00225                                  unsigned int maxOutLength,
00226                                  PaddingType padding,
00227                                  hashMethod hm);
00228 
00235     virtual unsigned int getLength(void);
00236 
00238 
00245 
00255     virtual void loadPublicModulusBase64BigNums(const char * b64, unsigned int len);
00256 
00266     virtual void loadPublicExponentBase64BigNums(const char * b64, unsigned int len);
00267 
00269 
00272 
00273 
00284     unsigned int getExponentBase64BigNums(char * b64, unsigned int len);
00285 
00296     unsigned int getModulusBase64BigNums(char * b64, unsigned int len);
00297 
00299 
00300 private:
00301 
00302   SECKEYPublicKey  *    mp_pubkey;
00303     SECKEYPrivateKey *  mp_privkey;
00304 
00305   SECItem * mp_modulus;
00306   SECItem * mp_exponent;
00307 
00308     // Instruct to import from parameters
00309 
00310     void importKey(void);
00311     void loadParamsFromKey(void);
00312 
00313 };
00314 
00315 #endif /* HAVE_NSS */
00316 #endif /* NSSCRYPTOKEYRSA_INCLUDE */

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