refactor: clang-format
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-01-10 04:25:03 +01:00
parent 391e2973e8
commit 4b216a6f6e
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
16 changed files with 182 additions and 145 deletions

View File

@ -17,7 +17,7 @@ Accumulator::Accumulator() noexcept {
}
Accumulator::~Accumulator() noexcept {};
} //namespace accumulator
} //namespace fortuna
} // namespace accumulator
} // namespace fortuna
#endif//FORTUNA_ACCUMULATOR_CPP
#endif // FORTUNA_ACCUMULATOR_CPP

View File

@ -13,7 +13,7 @@ auto DoTask::die_pls() -> void {
}
auto DoTask::thread_pls(const std::chrono::seconds& interval,
std::function<void()> callback) -> void {
std::function<void()> callback) -> void {
if (th.joinable()) {
die_pls();
@ -33,6 +33,6 @@ DoTask::~DoTask() noexcept {
}
}
} //namespace fortuna
} // namespace fortuna
#endif//FORTUNA_DO_TASK_CPP
#endif // FORTUNA_DO_TASK_CPP

View File

@ -12,16 +12,17 @@ class DoTask {
private:
std::timed_mutex do_sleep;
std::thread th;
public:
DoTask() noexcept = default;
~DoTask() noexcept;
auto thread_pls(const std::chrono::seconds& interval,
std::function<void()> callback) -> void;
std::function<void()> callback) -> void;
auto die_pls() -> void;
}; // class DoTask
} // namespace fortuna
#endif//FORTUNA_DO_TASK_H
#endif // FORTUNA_DO_TASK_H

View File

@ -8,6 +8,9 @@ namespace fortuna {
namespace accumulator {
class EntropySrc {
private:
std::unique_ptr<EventAdderImpl> impl;
public:
virtual void schedule(accumulator::EventScheduler scheduler) = 0;
virtual void event(accumulator::EventAdderImpl adder) = 0;
@ -19,6 +22,6 @@ public:
~EntropySrc() noexcept;
};
} //namespace accumulator
} //namespace fortuna
#endif//FORTUNA_ENTROPY_SRC_H
} // namespace accumulator
} // namespace fortuna
#endif // FORTUNA_ENTROPY_SRC_H

View File

@ -11,6 +11,6 @@ public:
virtual void add(std::vector<char> e) = 0;
};
} //namespace accumulator
} //namespace fortuna
#endif//FORTUNA_EVENT_ADDER_H
} // namespace accumulator
} // namespace fortuna
#endif // FORTUNA_EVENT_ADDER_H

View File

@ -15,7 +15,8 @@ private:
static accumulator::Pool pools[p_size];
public:
EventAdderImpl(const unsigned int source_id, const accumulator::Pool pools[32]) {
EventAdderImpl(const unsigned int source_id,
const accumulator::Pool pools[32]) {
this->source_id = source_id;
for (unsigned int i = 0; i < this->p_size; i++) {
this->pools[i] = pools[i];
@ -27,9 +28,8 @@ public:
this->pool = (this->pool + 1) % p_size;
pools[this->pool].add_entropy(source_id, event);
}
};
} //namespace accumulator
} //namespace fortuna
#endif//FORTUNA_EVENT_ADDER_IMPL_H
} // namespace accumulator
} // namespace fortuna
#endif // FORTUNA_EVENT_ADDER_IMPL_H

View File

@ -15,8 +15,8 @@ public:
~EventScheduler() noexcept;
};
} //namespace accumulator
} //namespace fortuna
} // namespace accumulator
} // namespace fortuna
#endif//FORTUNA_EVENT_SCHEDULER_H
#endif // FORTUNA_EVENT_SCHEDULER_H

View File

@ -20,7 +20,8 @@ auto now{std::chrono::steady_clock::now()};
Fortuna::Fortuna() {
try {
initialize_prng();
} catch(CryptoPP::Exception& e) {
}
catch (CryptoPP::Exception& e) {
fmt::print(stderr, "{}\n", e.what());
}
th_gen = std::thread(generator_service, &R.Gen);
@ -35,12 +36,9 @@ Fortuna::~Fortuna() noexcept {
auto Fortuna::random_data(unsigned int n_bytes) -> void {
const auto start{std::chrono::system_clock::now()};
fmt::print("random_data starting - {}\n", start);
auto elapsed {
std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch() -
now.time_since_epoch()
)
};
auto elapsed{std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch() -
now.time_since_epoch())};
fmt::print("last_reseed: {} ago\n", elapsed);
now = std::chrono::steady_clock::now();
std::string s;
@ -48,13 +46,15 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
// {generator,accumulator,fortuna} service threads -> in member functions
const int pools_to_use{ffsll(static_cast<int>(get_reseed_ctr()))};
if (R.pools[0].get_s_length() >= min_pool_size && elapsed > R.Gen.reseed_interval) {
if (R.pools[0].get_s_length() >= min_pool_size &&
elapsed > R.Gen.reseed_interval) {
for (int i = 0; i < static_cast<int>(pools_to_use); ++i) {
if (R.reseed_ctr % static_cast<int>(pow(2,i)) == 0) {
if (R.reseed_ctr % static_cast<int>(pow(2, i)) == 0) {
try {
s.append(fortuna::Util::do_sha(R.pools[i].get_s()));
R.pools[i].clear_pool();
} catch(std::exception& e) {
}
catch (std::exception& e) {
fmt::print("{}\n", e.what());
}
}
@ -68,18 +68,19 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
if (R.reseed_ctr == 0) {
fmt::print("reseed ctr is 0, PRNG not seeded!\n");
throw std::runtime_error("illegal state, PRNG not seeded");
} else {
}
else {
std::string n{R.Gen.generate_random_data(n_bytes)};
fmt::print("got you {} proper bytes from generate_random_data -> {}\n",
n_bytes, n);
n_bytes, n);
n.clear();
}
const auto end{std::chrono::system_clock::now()};
std::chrono::duration<float> diff = end-start;
std::chrono::duration<float> diff = end - start;
fmt::print("random_data done - {}\n", end);
fmt::print("getting random data took {:.{}f}s\n", diff.count(), 12);
} //random_data
} // random_data
auto Fortuna::generator_service(fortuna::generator::Generator* Gen) -> void {
fmt::print("[i] fortuna: starting generator service\n");
@ -87,14 +88,13 @@ auto Fortuna::generator_service(fortuna::generator::Generator* Gen) -> void {
uint sleep_time{1000}; // in ms
std::chrono::system_clock::time_point time_point;
while(true) {
while (true) {
fmt::print("sleeping [{}]\n", i);
++i;
time_point = fortuna::Util::current_time();
fmt::print("[*] g: @{}\n", time_point);
std::this_thread::sleep_until(
time_point + std::chrono::milliseconds(sleep_time)
);
std::this_thread::sleep_until(time_point +
std::chrono::milliseconds(sleep_time));
}
}
@ -106,24 +106,26 @@ auto Fortuna::seed_file_manager_service() -> void {
auto right_now{fortuna::Util::current_time()};
SeedFileManager sfm(this->accumulator);
while(true) {
while (true) {
right_now = fortuna::Util::current_time();
fmt::print("[*] sfm: checkup time @{}\n", right_now);
if (! sfm.is_job_running()) {
if (!sfm.is_job_running()) {
fmt::print("[*] sfm: job not running, starting\n");
try {
sfm.do_stuff();
} catch (std::exception& e) {
}
catch (std::exception& e) {
fmt::print(stderr, "[!] sfm: exception caught: {}\n", e.what());
}
} else {
}
else {
fmt::print("[*] sfm: job running\n");
}
std::this_thread::sleep_until(right_now +
std::chrono::seconds(checkup_interval));
std::chrono::seconds(checkup_interval));
}
}
} // namespace fortuna
#endif//FORTUNA_FORTUNA_CPP
#endif // FORTUNA_FORTUNA_CPP

View File

@ -1,8 +1,8 @@
#ifndef FORTUNA_FORTUNA_H
#define FORTUNA_FORTUNA_H
#include "generator.h"
#include "accumulator.h"
#include "generator.h"
#include <fmt/core.h>
@ -52,7 +52,8 @@ public:
incr_reseed_ctr();
fmt::print("first reseed\n");
R.Gen.reseed("fortuna");
} catch(std::exception& e) {
}
catch (std::exception& e) {
fmt::print("{}\n", e.what());
}
fmt::print("PRNG initialized\n");
@ -64,9 +65,10 @@ public:
// PRNG state
class R_state {
friend fortuna::Fortuna;
friend fortuna::Fortuna;
public:
R_state(){}
R_state() {}
~R_state() = default;
protected:
@ -76,7 +78,8 @@ public:
}
auto initialize_pools() -> void {
for (unsigned int i = accumulator::Accumulator::init_pool_num; i < num_of_pools; ++i) {
for (unsigned int i = accumulator::Accumulator::init_pool_num;
i < num_of_pools; ++i) {
pools[i].initialize_pool(i);
}
}
@ -96,4 +99,4 @@ public:
} // namespace fortuna
#endif//FORTUNA_FORTUNA_H
#endif // FORTUNA_FORTUNA_H

View File

@ -4,14 +4,14 @@
#include "generator.h"
#include "util.h"
#include <cryptopp/hex.h>
#include <cryptopp/filters.h>
#include <cryptopp/serpent.h>
#include <cryptopp/ccm.h>
#include <cryptopp/filters.h>
#include <cryptopp/hex.h>
#include <cryptopp/serpent.h>
#include <fmt/core.h>
#include <cmath>
#include <cassert>
#include <cmath>
#include <mutex>
#include <stdexcept>
@ -21,7 +21,8 @@ namespace generator {
Generator::Generator() /*noexcept*/ {
try {
initialize_generator();
} catch(CryptoPP::Exception& e) {
}
catch (CryptoPP::Exception& e) {
fmt::print(stderr, "{}\n", e.what());
exit(1);
}
@ -29,12 +30,13 @@ Generator::Generator() /*noexcept*/ {
Generator::~Generator() noexcept {};
void Generator::initialize_generator(){
void Generator::initialize_generator() {
try {
std::memset(G.k, 0x00, G.k.size());
G.ctr = 0;
fmt::print("Generator initialized\n");
} catch(CryptoPP::Exception& e) {
}
catch (CryptoPP::Exception& e) {
fmt::print(stderr, "{}\n", e.what());
exit(1);
}
@ -48,7 +50,8 @@ auto Generator::time_to_reseed() const -> bool {
// TODO(me): implement this
if (true) {
return true;
} else {
}
else {
return false;
}
}
@ -57,14 +60,15 @@ auto Generator::reseed(const std::string& s) -> void {
std::unique_lock<std::mutex> ul(reseed_mtx);
// ref: https://www.cryptopp.com/wiki/SecBlock
std::string da_key(reinterpret_cast<const char*>(&G.k[0]),
G.k.SizeInBytes() * 8); // we need the size in bits
G.k.SizeInBytes() * 8); // we need the size in bits
try {
std::string a{fortuna::Util::do_sha(da_key + s)};
std::memmove(G.k, a.c_str(), G.k_length);
++G.ctr;
fmt::print("[i] generator: reseeded\n");
} catch(std::exception& e) {
}
catch (std::exception& e) {
fmt::print("{}", e.what());
}
}
@ -90,7 +94,7 @@ auto Generator::do_crypto() -> std::string {
try {
CryptoPP::CTR_Mode<CryptoPP::Serpent>::Encryption e;
e.SetKeyWithIV(G.k,G.k.size(),ctr);
e.SetKeyWithIV(G.k, G.k.size(), ctr);
ul.unlock();
// The StreamTransformationFilter adds padding as required. ECB and
@ -98,29 +102,30 @@ auto Generator::do_crypto() -> std::string {
// mode not.
// the "true" param - pump all of the data immediately to its
// attached transformation
CryptoPP::StringSource str_src1(plain,true,
new CryptoPP::StreamTransformationFilter(e,
new CryptoPP::StringSink(cipher)
) // StreamTransformationFilter
CryptoPP::StringSource str_src1(
plain, true,
new CryptoPP::StreamTransformationFilter(
e,
new CryptoPP::StringSink(cipher)) // StreamTransformationFilter
); // StringSource
}
catch(CryptoPP::Exception& e) {
catch (CryptoPP::Exception& e) {
fmt::print(stderr, "{}\n", e.what());
exit(1);
}
// Pretty print cipher text
CryptoPP::StringSource str_src2(cipher,true,
CryptoPP::StringSource str_src2(
cipher, true,
new CryptoPP::HexEncoder(
new CryptoPP::StringSink(encoded_c)
) // HexEncoder
new CryptoPP::StringSink(encoded_c)) // HexEncoder
); // StringSource
return encoded_c;
}
auto Generator::generate_blocks(unsigned int k_blocks) -> std::string {
assert ((G.ctr!=0) && "Counter is not 0, generator has been seeded");
assert((G.ctr != 0) && "Counter is not 0, generator has been seeded");
std::string r{""};
for (uint i = 0; i < k_blocks; ++i) {
r += do_crypto();
@ -150,17 +155,18 @@ auto Generator::generate_random_data(uint n) -> std::string {
try {
/* do magic to compute r
* r rst-n-bytes(GenerateBlocks(G, ceil(n/16) )) */
* r rst-n-bytes(GenerateBlocks(G, ceil(n/16) )) */
// n is number of bytes, i.e. pass n*8 to get number of bits
unsigned int how_many(static_cast<unsigned int>(ceil((n*8)/16)));
unsigned int how_many(static_cast<unsigned int>(ceil((n * 8) / 16)));
// fmt::print("how_many: {}\n", how_many); // debugging
std::string rr{generate_blocks(how_many)};
fmt::print("rr (output from generate_blocks): {}\n", rr);
// since we're truncating hex, we need to get twice more characters
r = rr.substr(0,n*0x02ul);
r = rr.substr(0, n * 0x02ul);
rr.clear();
} catch(std::exception& e) {
}
catch (std::exception& e) {
fmt::print("{}", e.what());
}
@ -172,22 +178,22 @@ auto Generator::generate_random_data(uint n) -> std::string {
// FIXME: +1 for the actual null-termination, not exactly sure if needed
dst.resize(G.k_length + 1);
CryptoPP::StringSource str_s(
nu_G_k,true,new CryptoPP::HexDecoder(new CryptoPP::StringSink(dst))
);
nu_G_k, true,
new CryptoPP::HexDecoder(new CryptoPP::StringSink(dst)));
nu_G_k.clear();
/* clear out the old key and set a new one */
std::memset(G.k, 0x00, G.k_length);
std::memmove(G.k, dst.c_str(), G.k_length);
} catch(std::exception& e) {
}
catch (std::exception& e) {
fmt::print("{}", e.what());
}
return r;
}
} // namespace generator
} // namespace fortuna
#endif

View File

@ -40,10 +40,10 @@ private:
// 32*8
static constexpr const std::size_t k_length{32};
CryptoPP::FixedSizeSecBlock<CryptoPP::byte, k_length> k;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
unsigned __int128 ctr;
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
};
G_state G;
@ -58,6 +58,6 @@ protected:
}; // class generator
} //namespace generator
} //namespace fortuna
#endif//FORTUNA_GENERATOR_H
} // namespace generator
} // namespace fortuna
#endif // FORTUNA_GENERATOR_H

26
pool.h
View File

@ -27,24 +27,28 @@ public:
}
// add entropy contained in a random event of 1 to 32 bytes
auto add_entropy(const uint source, const std::vector<char> &event) -> int {
auto add_entropy(const uint source, const std::vector<char>& event) -> int {
std::string event_str;
const size_t event_size{event.size()};
try {
if (source > 255) {
throw std::invalid_argument("source number outside of interval <0,255>\n");
throw std::invalid_argument(
"source number outside of interval <0,255>\n");
}
if (event_size < 1 || event_size > 32) {
throw std::invalid_argument("the length of the event needs to be from the interval <1,32>\n");
throw std::invalid_argument("the length of the event needs to "
"be from the interval <1,32>\n");
}
} catch(const std::exception& e) {
}
catch (const std::exception& e) {
fmt::print("{}", e.what());
}
try {
event_str = std::string(event.begin(), event.end());
} catch(const std::exception& e) {
}
catch (const std::exception& e) {
fmt::print("{}", e.what());
}
@ -53,7 +57,8 @@ public:
size += event_size;
append_s(digest);
digest.clear();
} catch(const std::exception& e) {
}
catch (const std::exception& e) {
fmt::print("{}", e.what());
}
@ -77,7 +82,8 @@ protected:
auto append_s(const std::string& entropy_s) -> void {
try {
(this->s).append(std::string(entropy_s));
} catch(const std::exception& e) {
}
catch (const std::exception& e) {
fmt::print("{}", e.what());
}
}
@ -89,7 +95,7 @@ private:
}; // class Pool
} //namespace accumulator
} //namespace fortuna
} // namespace accumulator
} // namespace fortuna
#endif//FORTUNA_POOL_H
#endif // FORTUNA_POOL_H

View File

@ -12,10 +12,13 @@
namespace fortuna {
SeedFileManager::SeedFileManager(const fortuna::accumulator::Accumulator& accumulator) noexcept {
SeedFileManager::SeedFileManager(
const fortuna::accumulator::Accumulator& accumulator) noexcept {
this->accumulator = accumulator;
}
SeedFileManager::~SeedFileManager() noexcept {set_job_running(false);};
SeedFileManager::~SeedFileManager() noexcept {
set_job_running(false);
}
auto SeedFileManager::is_job_running() -> bool {
return running;
@ -27,7 +30,7 @@ auto SeedFileManager::set_job_running(bool running) -> void {
auto SeedFileManager::do_stuff() -> void {
update_seed_file();
do_task.thread_pls(config.write_interval, [this]{write_seed_file();});
do_task.thread_pls(config.write_interval, [this] { write_seed_file(); });
running = true;
}
@ -43,35 +46,44 @@ auto SeedFileManager::update_seed_file() -> void {
throw std::runtime_error("error opening seed file");
}
f_stream.read(reinterpret_cast<char*>(buff.BytePtr()), config.seed_f_length);
if (static_cast<std::size_t>(f_stream.gcount()) != config.seed_f_length) {
f_stream.read(reinterpret_cast<char*>(buff.BytePtr()),
config.seed_f_length);
if (static_cast<std::size_t>(f_stream.gcount()) !=
config.seed_f_length) {
std::string msg{"error reading seed from file"};
fmt::print("{} {}, length: {}\n", msg, config.seed_f_path, config.seed_f_length);
fmt::print("{} {}, length: {}\n", msg, config.seed_f_path,
config.seed_f_length);
throw std::runtime_error(msg);
}
}
try {
std::string str_buff(reinterpret_cast<const char*>(&buff[0]),
buff.SizeInBytes() * 8); // we need the size in bits
buff.SizeInBytes() *
8); // we need the size in bits
accumulator.call_reseed(str_buff);
write_seed_file();
} catch(std::exception& e) {
}
catch (std::exception& e) {
fmt::print("{}", e.what());
}
}
auto SeedFileManager::write_seed_file() -> void {
const std::size_t seed_file_length_blocks = fortuna::Util::b2b(config.seed_f_length);
CryptoPP::SecByteBlock buff{seed_file_length_blocks * fortuna::Util::gen_block_size};
const std::size_t seed_file_length_blocks =
fortuna::Util::b2b(config.seed_f_length);
CryptoPP::SecByteBlock buff{seed_file_length_blocks *
fortuna::Util::gen_block_size};
std::string da_buff{accumulator.get_random_data(seed_file_length_blocks)};
fmt::print("[*] sfm: writing seed file\n");
std::ofstream f_stream{config.seed_f_path, std::ios::binary|std::ios::trunc};
f_stream.write(reinterpret_cast<const char*>(buff.BytePtr()), config.seed_f_length);
std::ofstream f_stream{config.seed_f_path,
std::ios::binary | std::ios::trunc};
f_stream.write(reinterpret_cast<const char*>(buff.BytePtr()),
config.seed_f_length);
}
} // namespace fortuna
#endif//FORTUNA_SEED_FILE_MANAGER_CPP
#endif // FORTUNA_SEED_FILE_MANAGER_CPP

View File

@ -11,8 +11,7 @@ namespace fortuna {
class SeedFileManager {
public:
struct conf
{
struct conf {
// std::chrono::minutes write_interval{10};
// 10 minutes (as the standard recommends) is a lot, go with 120s
std::chrono::seconds write_interval{120};
@ -25,7 +24,8 @@ public:
auto is_job_running() -> bool;
auto do_stuff() -> void;
SeedFileManager(const fortuna::accumulator::Accumulator& accumulator) noexcept;
SeedFileManager(
const fortuna::accumulator::Accumulator& accumulator) noexcept;
~SeedFileManager() noexcept;
protected:

View File

@ -19,19 +19,22 @@ public:
auto event(accumulator::EventAdder adder) -> void {
std::ifstream file;
file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try {
std::ifstream urandom("/dev/urandom", std::ios::in|std::ios::binary);
std::ifstream urandom("/dev/urandom",
std::ios::in | std::ios::binary);
// check if stream is open
if(urandom) {
if (urandom) {
urandom.read(reinterpret_cast<char*>(&bytes), bytes.length());
urandom.close();
} else {
}
else {
// open failed
fmt::print(stderr, "Failed to open /dev/urandom\n");
}
} catch(std::ifstream::failure& e) {
}
catch (std::ifstream::failure& e) {
fmt::print("io exception caugth: {}\n", e.what());
}
}
@ -42,7 +45,7 @@ private:
static std::vector<char> bytes[max_event_length];
};
} //namespace accumulator
} //namespace fortuna
#endif//FORTUNA_URANDOM_ENTROPY_SRC_H
} // namespace accumulator
} // namespace fortuna
#endif // FORTUNA_URANDOM_ENTROPY_SRC_H

51
util.h
View File

@ -1,50 +1,51 @@
#ifndef FORTUNA_UTIL_H
#define FORTUNA_UTIL_H
#include <chrono>
#include <cryptopp/filters.h>
#include <cryptopp/hex.h>
#include <cryptopp/sha3.h>
#include <chrono>
#include <cstddef>
namespace fortuna {
class Util final {
public:
static constexpr const std::size_t gen_block_size{32}; // 256 bits
static constexpr const std::size_t gen_block_size{32}; // 256 bits
static auto do_sha(const std::string& str_to_hash) -> const std::string {
// do sha256
std::string digest;
static auto do_sha(const std::string& str_to_hash) -> const std::string {
// do sha256
std::string digest;
// no reason not to go for Keccak
CryptoPP::SHA3_256 sha3_256;
// no reason not to go for Keccak
CryptoPP::SHA3_256 sha3_256;
CryptoPP::StringSource str_src(str_to_hash, true,
new CryptoPP::HashFilter (
sha3_256, new CryptoPP::HexEncoder(
new CryptoPP::StringSink(digest), false))
);
CryptoPP::StringSource str_src(
str_to_hash, true,
new CryptoPP::HashFilter(
sha3_256, new CryptoPP::HexEncoder(
new CryptoPP::StringSink(digest), false)));
return digest;
}
return digest;
}
static auto current_time() -> std::chrono::time_point<std::chrono::system_clock,
static auto current_time() -> std::chrono::time_point<
std::chrono::system_clock,
std::chrono::duration<long, std::ratio<1, 1000000000>>> {
return std::chrono::system_clock::now();
}
return std::chrono::system_clock::now();
}
// returns number of blocks for a given number of bytes
static constexpr std::size_t b2b(std::size_t bytes) noexcept {
// returns number of blocks
return bytes == 0 ? 0 : ((bytes - 1) / gen_block_size) + 1;
}
// returns number of blocks for a given number of bytes
static constexpr std::size_t b2b(std::size_t bytes) noexcept {
// returns number of blocks
return bytes == 0 ? 0 : ((bytes - 1) / gen_block_size) + 1;
}
Util() = delete;
~Util() noexcept;
Util() = delete;
~Util() noexcept;
}; // class Util
} // namespace fortuna
#endif//FORTUNA_UTIL_H
#endif // FORTUNA_UTIL_H