blob: 82e769f672083334aff17d5ce7d9f44eab1fede2 [file] [log] [blame]
Jeff Thompson3af7e792013-08-23 14:22:11 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
Jeff Thompson3af7e792013-08-23 14:22:11 -07003 * See COPYING for copyright and distribution information.
4 */
5
Alexander Afanasyevd409d592014-01-28 18:36:38 -08006#ifndef NDN_UTIL_CRYPTO_HPP
7#define NDN_UTIL_CRYPTO_HPP
8
Alexander Afanasyev19508852014-01-29 01:01:51 -08009#include "../common.hpp"
Yingdi Yu21157162014-02-28 13:02:34 -080010#include "../encoding/buffer.hpp"
Jeff Thompson3af7e792013-08-23 14:22:11 -070011
Alexander Afanasyevd409d592014-01-28 18:36:38 -080012namespace ndn {
Jeff Thompson3af7e792013-08-23 14:22:11 -070013
14/**
Yingdi Yu110881d2014-03-04 18:27:29 -080015 * @brief Compute the sha-256 digest of data.
16 *
Jeff Thompson3af7e792013-08-23 14:22:11 -070017 * @param data Pointer to the input byte array.
18 * @param dataLength The length of data.
Yingdi Yu110881d2014-03-04 18:27:29 -080019 * @param digest A pointer to a buffer of size crypto::SHA256_DIGEST_SIZE to receive the data.
Jeff Thompson3af7e792013-08-23 14:22:11 -070020 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070021void ndn_digestSha256(const uint8_t* data, size_t dataLength, uint8_t* digest);
Jeff Thompson3af7e792013-08-23 14:22:11 -070022
Yingdi Yu21157162014-02-28 13:02:34 -080023namespace crypto {
24
Yingdi Yu110881d2014-03-04 18:27:29 -080025/// @brief number of octets in a SHA256 digest
26static const size_t SHA256_DIGEST_SIZE = 32;
Yingdi Yu21157162014-02-28 13:02:34 -080027
28/**
Yingdi Yu110881d2014-03-04 18:27:29 -080029 * @brief Compute the sha-256 digest of data.
30 *
Yingdi Yu21157162014-02-28 13:02:34 -080031 * @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 */
35ConstBufferPtr
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070036sha256(const uint8_t* data, size_t dataLength);
Yingdi Yu21157162014-02-28 13:02:34 -080037
38} // namespace crypto
39
Alexander Afanasyevd409d592014-01-28 18:36:38 -080040} // namespace ndn
Jeff Thompson3af7e792013-08-23 14:22:11 -070041
Alexander Afanasyevd409d592014-01-28 18:36:38 -080042#endif // NDN_UTIL_CRYPTO_HPP