Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 3 | * 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 Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 13 | #ifndef NDN_UTIL_CRYPTO_HPP |
| 14 | #define NDN_UTIL_CRYPTO_HPP |
| 15 | |
Alexander Afanasyev | 1950885 | 2014-01-29 01:01:51 -0800 | [diff] [blame] | 16 | #include "../common.hpp" |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 17 | #include "../encoding/buffer.hpp" |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 18 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 19 | namespace ndn { |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 20 | |
| 21 | /** |
Yingdi Yu | 110881d | 2014-03-04 18:27:29 -0800 | [diff] [blame] | 22 | * @brief Compute the sha-256 digest of data. |
| 23 | * |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 24 | * @param data Pointer to the input byte array. |
| 25 | * @param dataLength The length of data. |
Yingdi Yu | 110881d | 2014-03-04 18:27:29 -0800 | [diff] [blame] | 26 | * @param digest A pointer to a buffer of size crypto::SHA256_DIGEST_SIZE to receive the data. |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 27 | */ |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 28 | void ndn_digestSha256(const uint8_t* data, size_t dataLength, uint8_t* digest); |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 29 | |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 30 | namespace crypto { |
| 31 | |
Yingdi Yu | 110881d | 2014-03-04 18:27:29 -0800 | [diff] [blame] | 32 | /// @brief number of octets in a SHA256 digest |
| 33 | static const size_t SHA256_DIGEST_SIZE = 32; |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 34 | |
| 35 | /** |
Yingdi Yu | 110881d | 2014-03-04 18:27:29 -0800 | [diff] [blame] | 36 | * @brief Compute the sha-256 digest of data. |
| 37 | * |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 38 | * @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 | */ |
| 42 | ConstBufferPtr |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 43 | sha256(const uint8_t* data, size_t dataLength); |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 44 | |
| 45 | } // namespace crypto |
| 46 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 47 | } // namespace ndn |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 48 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 49 | #endif // NDN_UTIL_CRYPTO_HPP |