blob: 15ccf9d5b5bc954e778ae13ea134b6e356bc8097 [file] [log] [blame]
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompson3af7e792013-08-23 14:22:11 -07002/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
Jeff Thompson3af7e792013-08-23 14:22:11 -070011 */
12
Alexander Afanasyevd409d592014-01-28 18:36:38 -080013#ifndef NDN_UTIL_CRYPTO_HPP
14#define NDN_UTIL_CRYPTO_HPP
15
Alexander Afanasyev19508852014-01-29 01:01:51 -080016#include "../common.hpp"
Yingdi Yu21157162014-02-28 13:02:34 -080017#include "../encoding/buffer.hpp"
Jeff Thompson3af7e792013-08-23 14:22:11 -070018
Alexander Afanasyevd409d592014-01-28 18:36:38 -080019namespace ndn {
Jeff Thompson3af7e792013-08-23 14:22:11 -070020
21/**
Yingdi Yu110881d2014-03-04 18:27:29 -080022 * @brief Compute the sha-256 digest of data.
23 *
Jeff Thompson3af7e792013-08-23 14:22:11 -070024 * @param data Pointer to the input byte array.
25 * @param dataLength The length of data.
Yingdi Yu110881d2014-03-04 18:27:29 -080026 * @param digest A pointer to a buffer of size crypto::SHA256_DIGEST_SIZE to receive the data.
Jeff Thompson3af7e792013-08-23 14:22:11 -070027 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070028void ndn_digestSha256(const uint8_t* data, size_t dataLength, uint8_t* digest);
Jeff Thompson3af7e792013-08-23 14:22:11 -070029
Yingdi Yu21157162014-02-28 13:02:34 -080030namespace crypto {
31
Yingdi Yu110881d2014-03-04 18:27:29 -080032/// @brief number of octets in a SHA256 digest
33static const size_t SHA256_DIGEST_SIZE = 32;
Yingdi Yu21157162014-02-28 13:02:34 -080034
35/**
Yingdi Yu110881d2014-03-04 18:27:29 -080036 * @brief Compute the sha-256 digest of data.
37 *
Yingdi Yu21157162014-02-28 13:02:34 -080038 * @param data Pointer to the input byte array.
39 * @param dataLength The length of data.
40 * @return A pointer to a buffer of SHA256_DIGEST.
41 */
42ConstBufferPtr
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070043sha256(const uint8_t* data, size_t dataLength);
Yingdi Yu21157162014-02-28 13:02:34 -080044
45} // namespace crypto
46
Alexander Afanasyevd409d592014-01-28 18:36:38 -080047} // namespace ndn
Jeff Thompson3af7e792013-08-23 14:22:11 -070048
Alexander Afanasyevd409d592014-01-28 18:36:38 -080049#endif // NDN_UTIL_CRYPTO_HPP