Kea  1.9.9-git
crypto_hash.cc
Go to the documentation of this file.
1 // Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #include <config.h>
8 
9 #include <cryptolink.h>
10 #include <cryptolink/crypto_hash.h>
11 
12 #include <boost/scoped_ptr.hpp>
13 
14 #include <cstring>
15 
16 namespace isc {
17 namespace cryptolink {
18 
19 void
20 digest(const void* data, const size_t data_len,
21  const HashAlgorithm hash_algorithm,
22  isc::util::OutputBuffer& result, size_t len)
23 {
24  boost::scoped_ptr<Hash> hash(
25  CryptoLink::getCryptoLink().createHash(hash_algorithm));
26  hash->update(data, data_len);
27  if (len == 0) {
28  len = hash->getOutputLength();
29  }
30  hash->final(result, len);
31 }
32 
33 void
34 deleteHash(Hash* hash) {
35  delete hash;
36 }
37 
38 } // namespace cryptolink
39 } // namespace isc
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
Defines the logger used by the top-level component of kea-dhcp-ddns.