#pragma once #include #include namespace roro { // Plain SHA-256 (FIPS 180-4), streaming. Small and dependency-free, so the same code runs in the // PC tests and on the device. class Sha256 { public: Sha256(); void update(const uint8_t* data, size_t len); void finish(uint8_t out[32]); static void hash(const uint8_t* data, size_t len, uint8_t out[32]) { Sha256 s; s.update(data, len); s.finish(out); } private: void block(const uint8_t* p); uint32_t h_[8]; uint8_t buf_[64]; size_t used_ = 0; uint64_t bits_ = 0; }; } // namespace roro