esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sha256-cryptosuite.hpp
Go to the documentation of this file.
1 #ifndef ESP8266NDN_PORT_SHA256_CRYPTOSUITE_HPP
2 #define ESP8266NDN_PORT_SHA256_CRYPTOSUITE_HPP
3 
4 #include "../vendor/cryptosuite-sha256.h"
5 #include <algorithm>
6 
7 namespace esp8266ndn {
8 namespace ndnph_port {
9 
11 class Sha256 {
12 public:
13  Sha256() {
14  m_sha.init();
15  }
16 
17  void update(const uint8_t* chunk, size_t size) {
18  m_sha.write(chunk, size);
19  }
20 
21  bool final(uint8_t* digest) {
22  std::copy_n(m_sha.result(), 32, digest);
23  return true;
24  }
25 
26 private:
27  ::Sha256 m_sha;
28 };
29 
31 class HmacSha256 {
32 public:
33  explicit HmacSha256(const uint8_t* key, size_t keyLen) {
34  m_sha.initHmac(key, keyLen);
35  }
36 
37  void update(const uint8_t* chunk, size_t size) {
38  m_sha.write(chunk, size);
39  }
40 
41  bool final(uint8_t* result) {
42  std::copy_n(m_sha.resultHmac(), HASH_LENGTH, result);
43  m_sha.reset();
44  return true;
45  }
46 
47 private:
48  ::Sha256 m_sha;
49 };
50 
51 } // namespace ndnph_port
52 } // namespace esp8266ndn
53 
54 namespace ndnph {
55 namespace port {
58 } // namespace port
59 } // namespace ndnph
60 
61 #undef HASH_LENGTH
62 #undef BLOCK_LENGTH
63 
64 #endif // ESP8266NDN_PORT_SHA256_CRYPTOSUITE_HPP
void update(const uint8_t *chunk, size_t size)
Definition: sha256-cryptosuite.hpp:37
HmacSha256(const uint8_t *key, size_t keyLen)
Definition: sha256-cryptosuite.hpp:33
SHA256 algorithm, implemented with BearSSL.
Definition: sha256-bearssl.hpp:11
Sha256()
Definition: sha256-cryptosuite.hpp:13
void update(const uint8_t *chunk, size_t size)
Definition: sha256-cryptosuite.hpp:17
Definition: autoconfig.hpp:24
esp8266ndn::ndnph_port::HmacSha256 HmacSha256
Definition: sha256-bearssl.hpp:59
esp8266ndn::ndnph_port::Sha256 Sha256
Definition: sha256-bearssl.hpp:58
Definition: fs.hpp:33