Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 1 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 Regents of the University of California. |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 6 | #ifndef NDN_UTIL_CRYPTO_HPP |
| 7 | #define NDN_UTIL_CRYPTO_HPP |
| 8 | |
Alexander Afanasyev | 1950885 | 2014-01-29 01:01:51 -0800 | [diff] [blame] | 9 | #include "../common.hpp" |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 10 | #include "../encoding/buffer.hpp" |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 11 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 12 | namespace ndn { |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 13 | |
| 14 | /** |
Yingdi Yu | 110881d | 2014-03-04 18:27:29 -0800 | [diff] [blame^] | 15 | * @brief Compute the sha-256 digest of data. |
| 16 | * |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 17 | * @param data Pointer to the input byte array. |
| 18 | * @param dataLength The length of data. |
Yingdi Yu | 110881d | 2014-03-04 18:27:29 -0800 | [diff] [blame^] | 19 | * @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] | 20 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 21 | 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] | 22 | |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 23 | namespace crypto { |
| 24 | |
Yingdi Yu | 110881d | 2014-03-04 18:27:29 -0800 | [diff] [blame^] | 25 | /// @brief number of octets in a SHA256 digest |
| 26 | static const size_t SHA256_DIGEST_SIZE = 32; |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 27 | |
| 28 | /** |
Yingdi Yu | 110881d | 2014-03-04 18:27:29 -0800 | [diff] [blame^] | 29 | * @brief Compute the sha-256 digest of data. |
| 30 | * |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 31 | * @param data Pointer to the input byte array. |
| 32 | * @param dataLength The length of data. |
| 33 | * @return A pointer to a buffer of SHA256_DIGEST. |
| 34 | */ |
| 35 | ConstBufferPtr |
| 36 | sha256(const uint8_t *data, size_t dataLength); |
| 37 | |
| 38 | } // namespace crypto |
| 39 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 40 | } // namespace ndn |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 41 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 42 | #endif // NDN_UTIL_CRYPTO_HPP |