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

OpenSSLCryptoHashHMAC.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-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  * OpenSSLCryptoHashHMAC := OpenSSL Implementation of HMAC
00021  *
00022  * Author(s): Berin Lautenbach
00023  *
00024  * $Id: OpenSSLCryptoHashHMAC.hpp,v 1.9 2005/06/04 11:30:26 blautenb Exp $
00025  *
00026  */
00027 
00028 #ifndef OPENSSLCRYPTOHASHHMAC_INCLUDE
00029 #define OPENSSLCRYPTOHASHHMAC_INCLUDE
00030 
00031 #include <xsec/framework/XSECDefs.hpp>
00032 #include <xsec/enc/XSECCryptoHash.hpp>
00033 #include <xsec/utils/XSECSafeBuffer.hpp>
00034 
00035 // OpenSSL Includes
00036 #if defined (HAVE_OPENSSL)
00037 
00038 #include <openssl/evp.h>
00039 #include <openssl/hmac.h>
00040 
00053 class DSIG_EXPORT OpenSSLCryptoHashHMAC : public XSECCryptoHash {
00054 
00055 public :
00056 
00059 
00069     OpenSSLCryptoHashHMAC(XSECCryptoHash::HashType alg);
00070 
00077     virtual ~OpenSSLCryptoHashHMAC();
00078 
00080 
00083     
00093     virtual void        setKey(XSECCryptoKey * key);
00094 
00099     virtual const XMLCh * getProviderName() {return DSIGConstants::s_unicodeStrPROVOpenSSL;}
00100 
00102 
00104     //{@
00105 
00112     virtual void        reset(void);
00113 
00125     virtual void        hash(unsigned char * data, 
00126                              unsigned int length);
00140     virtual unsigned int finish(unsigned char * hash,
00141                                 unsigned int maxLength);// Finish and get hash
00142 
00144 
00147 
00156     virtual HashType getHashType(void);
00157 
00159 
00160 private:
00161 
00162     // Not implemented constructors
00163     OpenSSLCryptoHashHMAC();
00164 
00165     const EVP_MD        * mp_md;                        // Digest instance
00166     unsigned char       m_mdValue[EVP_MAX_MD_SIZE];     // Final output
00167     unsigned int        m_mdLen;                        // Length of digest
00168     HashType            m_hashType;                     // What type of hash is this?
00169     HMAC_CTX            m_hctx;                         // Context for HMAC
00170     safeBuffer          m_keyBuf;                       // The loaded key
00171     unsigned int        m_keyLen;                       // The loaded key length
00172     bool                m_initialised;
00173 
00174 };
00175 #endif /* HAVE_OPENSSL */
00176 #endif /* OPENSSLCRYPTOHASHHMAC_INCLUDE */

Generated on Sun Jul 3 17:37:26 2005 for XML-Security-C by  doxygen 1.4.2