Coverage Report

Created: 2021-08-28 18:14

D:\git\skunkworks\herald-for-cpp\herald\src\payload\simple\f.cpp
Line
Count
Source (jump to first uncovered line)
1
//  Copyright 2021 Herald Project Contributors
2
//  SPDX-License-Identifier: Apache-2.0
3
//
4
5
#include "herald/payload/simple/f.h"
6
#include "herald/datatype/data.h"
7
#include "herald/datatype/sha256.h"
8
9
namespace herald {
10
namespace payload {
11
namespace simple {
12
13
using namespace herald::datatype;
14
15
namespace F {
16
17
[[maybe_unused]]
18
0
Data h(const Data& data) noexcept {
19
0
  SHA256 sha;
20
0
  return sha.digest(data);
21
0
}
22
23
[[maybe_unused]]
24
0
Data t(const Data& data) noexcept {
25
0
  return t(data,data.size() / 2);
26
0
}
27
28
[[maybe_unused]]
29
0
Data t(const Data& data, int n) noexcept {
30
0
  return data.subdata(0,n);
31
0
}
32
33
[[maybe_unused]]
34
0
Data xorData(const Data& left, const Data& right) noexcept {
35
0
  Data result;
36
0
  // note: we're ensuring we don't have an out of bound index (has effect of XOR with 0 as we set value above)
37
0
  for (std::size_t i = 0;i < right.size() && i < left.size();i++) {
38
0
    result.append(std::byte(((int)left.at(i)) ^ ((int)right.at(i))));
39
0
  }
40
0
  if (right.size() < left.size()) {
41
0
    for (std::size_t i = left.size();i < left.size();i++) {
42
0
      result.append(left.at(i));
43
0
    }
44
0
  }
45
0
  return result;
46
0
}
47
48
} // end namespace f
49
50
}
51
}
52
}