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 * NSSCryptoProvider := Base class to handle NSS 00021 * 00022 * Author(s): Milan Tomic 00023 * 00024 */ 00025 00026 #ifndef NSSCRYPTOPROVIDER_INCLUDE 00027 #define NSSCRYPTOPROVIDER_INCLUDE 00028 00029 #include <xsec/framework/XSECDefs.hpp> 00030 #include <xsec/enc/XSECCryptoProvider.hpp> 00031 00032 #if defined (HAVE_NSS) 00033 00034 #include "nss/pk11func.h" 00035 #include "nss/nss.h" 00036 00043 /*\@{*/ 00044 00045 class DSIG_EXPORT NSSCryptoProvider : public XSECCryptoProvider { 00046 00047 00048 public : 00049 00062 NSSCryptoProvider(const char * dbDir); 00063 00070 NSSCryptoProvider(); 00071 00072 virtual ~NSSCryptoProvider(); 00073 00075 00078 00089 virtual XSECCryptoHash * hashSHA1(); 00090 00101 virtual XSECCryptoHash * hashSHA(int length = 160); 00102 00114 virtual XSECCryptoHash * hashHMACSHA1(); 00115 00127 virtual XSECCryptoHash * hashHMACSHA(int length = 160); 00128 00139 virtual XSECCryptoHash * hashMD5(); 00140 00157 virtual XSECCryptoHash * hashHMACMD5(); 00158 00169 virtual XSECCryptoKeyHMAC * keyHMAC(void); 00170 00178 virtual bool algorithmSupported(XSECCryptoHash::HashType alg); 00179 00181 00184 00198 virtual XSECCryptoBase64 * base64(); 00199 00201 00204 00214 virtual XSECCryptoKeyDSA * keyDSA(); 00215 00225 virtual XSECCryptoKeyRSA * keyRSA(); 00226 00237 virtual XSECCryptoX509 * X509(); 00238 00246 virtual bool algorithmSupported(XSECCryptoSymmetricKey::SymmetricKeyType alg); 00247 00258 virtual XSECCryptoSymmetricKey * keySymmetric(XSECCryptoSymmetricKey::SymmetricKeyType alg); 00259 00272 virtual unsigned int getRandom(unsigned char * buffer, unsigned int numOctets); 00273 00284 static SECItem * b642SI(const char * b64, unsigned int b64Len); 00285 00298 static unsigned char * SI2b64(SECItem * n, unsigned int &retLen); 00299 00301 00304 00309 virtual const XMLCh * getProviderName(); 00310 00312 00313 00314 private: 00315 00316 void Init(const char * dbDir); 00317 static int m_initialised; 00318 00319 }; 00320 00321 /*\@}*/ 00322 00323 #endif /* HAVE_NSS */ 00324 #endif /* NSSCRYPTOPROVIDER_INCLUDE */ 00325