YPC  0.2.0
hash_impl.h
1 #pragma once
2 #include "ypc/common/byte.h"
3 
4 namespace ypc {
5 namespace crypto {
6 namespace internal {
7 
8 template <typename Hash> struct hash_impl {
9  typedef Hash hash_t;
10 
11 public:
12  template <typename BytesType>
13  static uint32_t hash_256(const BytesType &msg, BytesType &sig) {
14  sig = BytesType(32);
15  return hash_t::hash_256(msg.data(), msg.size(), sig.data());
16  }
17 
18  static uint32_t hash_256(const uint8_t *msg, uint32_t msg_size,
19  uint8_t *hash) {
20  return hash_t::hash_256(msg, msg_size, hash);
21  }
22 
23  static uint32_t get_msg_hash_size() { return hash_t::get_msg_hash_size(); }
24  static uint32_t msg_hash(const uint8_t *raw_msg, uint32_t msg_size,
25  uint8_t *hash, uint32_t hash_size) {
26  return hash_t::msg_hash(raw_msg, msg_size, hash, hash_size);
27  }
28  template <typename BytesType>
29  static uint32_t msg_hash(const BytesType &raw_msg, BytesType &hash) {
30  hash = BytesType(hash_t::get_msg_hash_size());
31  return hash_t::msg_hash(raw_msg.data(), raw_msg.size(), hash.data(),
32  hash.size());
33  }
34 };
35 
36 } // namespace internal
37 } // namespace crypto
38 } // namespace ypc
ypc::crypto::internal::hash_impl
Definition: hash_impl.h:8