blob: dc0a754baf1bcb0f4971fb8103c75631d05780e1 [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 Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 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 {
Jeff Thompson3af7e792013-08-23 14:22:11 -070029
30/**
Yingdi Yu110881d2014-03-04 18:27:29 -080031 * @brief Compute the sha-256 digest of data.
32 *
Jeff Thompson3af7e792013-08-23 14:22:11 -070033 * @param data Pointer to the input byte array.
34 * @param dataLength The length of data.
Yingdi Yu110881d2014-03-04 18:27:29 -080035 * @param digest A pointer to a buffer of size crypto::SHA256_DIGEST_SIZE to receive the data.
Jeff Thompson3af7e792013-08-23 14:22:11 -070036 */
Alexander Afanasyev197e5652014-06-13 16:56:31 -070037void
38ndn_digestSha256(const uint8_t* data, size_t dataLength, uint8_t* digest);
Jeff Thompson3af7e792013-08-23 14:22:11 -070039
Yingdi Yu21157162014-02-28 13:02:34 -080040namespace crypto {
41
Yingdi Yu110881d2014-03-04 18:27:29 -080042/// @brief number of octets in a SHA256 digest
43static const size_t SHA256_DIGEST_SIZE = 32;
Yingdi Yu21157162014-02-28 13:02:34 -080044
45/**
Yingdi Yu110881d2014-03-04 18:27:29 -080046 * @brief Compute the sha-256 digest of data.
47 *
Yingdi Yu21157162014-02-28 13:02:34 -080048 * @param data Pointer to the input byte array.
49 * @param dataLength The length of data.
50 * @return A pointer to a buffer of SHA256_DIGEST.
51 */
52ConstBufferPtr
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070053sha256(const uint8_t* data, size_t dataLength);
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