12#include <boost/scoped_ptr.hpp> 
   14#include <openssl/evp.h> 
   31        return (EVP_sha256());
 
   33        return (EVP_sha224());
 
   35        return (EVP_sha384());
 
   37        return (EVP_sha512());
 
 
   55    : hash_algorithm_(hash_algorithm), md_(0) {
 
   59                      "Unknown hash algorithm: " <<
 
   60                      static_cast<int>(hash_algorithm));
 
   63        md_ = EVP_MD_CTX_new();
 
   66                      "OpenSSL EVP_MD_CTX_new() failed");
 
   69        EVP_DigestInit_ex(md_, algo, NULL);
 
 
   82        return (hash_algorithm_);
 
 
   89        return (EVP_MD_CTX_size(md_));
 
 
   96        EVP_DigestUpdate(md_, 
data, len);
 
 
  104        std::vector<unsigned char> 
digest(size);
 
  105        EVP_DigestFinal_ex(md_, &
digest[0], NULL);
 
  109        result.writeData(&
digest[0], len);
 
 
  115    void final(
void* result, 
size_t len) {
 
  117        std::vector<unsigned char> 
digest(size);
 
  118        EVP_DigestFinal_ex(md_, &
digest[0], NULL);
 
  122        std::memcpy(result, &
digest[0], len);
 
 
  128    std::vector<uint8_t> 
final(
size_t len) {
 
  130        std::vector<unsigned char> 
digest(size);
 
  131        EVP_DigestFinal_ex(md_, &
digest[0], NULL);
 
  135        return (std::vector<uint8_t>(
digest.begin(), 
digest.end()));
 
 
  147    impl_ = 
new HashImpl(hash_algorithm);
 
  156    return (impl_->getHashAlgorithm());
 
  161    return (impl_->getOutputLength());
 
  166    impl_->update(data, len);
 
  170Hash::final(isc::util::OutputBuffer& result, 
size_t len) {
 
  171    impl_->final(result, len);
 
  176    impl_->final(result, len);
 
  181    return impl_->final(len);
 
Botan implementation of Hash.
size_t getOutputLength() const
Returns the output size of the digest.
HashAlgorithm getHashAlgorithm() const
Returns the HashAlgorithm of the object.
void update(const void *data, const size_t len)
Adds data to the digest.
HashImpl(const HashAlgorithm hash_algorithm)
Constructor for specific hash algorithm.
void update(const void *data, const size_t len)
Add data to digest.
size_t getOutputLength() const
Returns the output size of the digest.
HashAlgorithm getHashAlgorithm() const
Returns the HashAlgorithm of the object.
void final(isc::util::OutputBuffer &result, size_t len)
Calculate the final digest.
This exception is raised when a general error that was not specifically caught is thrown by the under...
This exception is thrown when a cryptographic action is requested for an algorithm that is not suppor...
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
const EVP_MD * getHashAlgorithm(isc::cryptolink::HashAlgorithm algorithm)
Decode the HashAlgorithm enum into an EVP_MD pointer (or 0)
HashAlgorithm
Hash algorithm identifiers.
void digest(const void *data, const size_t data_len, const HashAlgorithm hash_algorithm, isc::util::OutputBuffer &result, size_t len)
Create an Hash digest for the given data.
Defines the logger used by the top-level component of kea-lfc.