blob: e406006df9a26d46c8ab4c27317c95b9051b1c2b [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompson3af7e792013-08-23 14:22:11 -07002/**
Alexander Afanasyev2fa59392016-07-29 17:24:23 -07003 * Copyright (c) 2013-2016 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Jeff Thompson3af7e792013-08-23 14:22:11 -070020 */
21
Alexander Afanasyevd409d592014-01-28 18:36:38 -080022#ifndef NDN_UTIL_CRYPTO_HPP
23#define NDN_UTIL_CRYPTO_HPP
24
Alexander Afanasyev19508852014-01-29 01:01:51 -080025#include "../common.hpp"
Yingdi Yu21157162014-02-28 13:02:34 -080026#include "../encoding/buffer.hpp"
Jeff Thompson3af7e792013-08-23 14:22:11 -070027
Alexander Afanasyevd409d592014-01-28 18:36:38 -080028namespace ndn {
Yingdi Yu21157162014-02-28 13:02:34 -080029namespace crypto {
30
Yingdi Yu110881d2014-03-04 18:27:29 -080031/// @brief number of octets in a SHA256 digest
32static const size_t SHA256_DIGEST_SIZE = 32;
Yingdi Yu21157162014-02-28 13:02:34 -080033
34/**
Yingdi Yu110881d2014-03-04 18:27:29 -080035 * @brief Compute the sha-256 digest of data.
36 *
Yingdi Yu21157162014-02-28 13:02:34 -080037 * @param data Pointer to the input byte array.
38 * @param dataLength The length of data.
39 * @return A pointer to a buffer of SHA256_DIGEST.
40 */
41ConstBufferPtr
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070042computeSha256Digest(const uint8_t* data, size_t dataLength);
43
44/**
45 * @brief Compute the sha-256 digest of data.
46 *
47 * @deprecated Use computeSha256Digest function instead
48 */
49inline ConstBufferPtr
50sha256(const uint8_t* data, size_t dataLength)
51{
52 return computeSha256Digest(data, dataLength);
53}
Yingdi Yu21157162014-02-28 13:02:34 -080054
55} // namespace crypto
56
Alexander Afanasyevd409d592014-01-28 18:36:38 -080057} // namespace ndn
Jeff Thompson3af7e792013-08-23 14:22:11 -070058
Alexander Afanasyevd409d592014-01-28 18:36:38 -080059#endif // NDN_UTIL_CRYPTO_HPP