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 | /** |
| 15 | * Compute the sha-256 digest of data. |
| 16 | * @param data Pointer to the input byte array. |
| 17 | * @param dataLength The length of data. |
| 18 | * @param digest A pointer to a buffer of size SHA256_DIGEST_LENGTH to receive the data. |
| 19 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 20 | 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] | 21 | |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 22 | namespace crypto { |
| 23 | |
| 24 | static size_t SHA256_DIGEST_LENGTH = 32; |
| 25 | |
| 26 | /** |
| 27 | * Compute the sha-256 digest of data. |
| 28 | * @param data Pointer to the input byte array. |
| 29 | * @param dataLength The length of data. |
| 30 | * @return A pointer to a buffer of SHA256_DIGEST. |
| 31 | */ |
| 32 | ConstBufferPtr |
| 33 | sha256(const uint8_t *data, size_t dataLength); |
| 34 | |
| 35 | } // namespace crypto |
| 36 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 37 | } // namespace ndn |
Jeff Thompson | 3af7e79 | 2013-08-23 14:22:11 -0700 | [diff] [blame] | 38 | |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 39 | #endif // NDN_UTIL_CRYPTO_HPP |