ams: support building unit test programs on windows/linux/macos

This commit is contained in:
Michael Scire
2022-03-06 12:08:20 -08:00
committed by SciresM
parent 9a38be201a
commit 64a97576d0
756 changed files with 33359 additions and 9372 deletions

View File

@@ -29,25 +29,30 @@ namespace ams::crypto::impl {
static constexpr size_t HashSize = 0x14;
static constexpr size_t BlockSize = 0x40;
private:
struct State {
u32 intermediate_hash[HashSize / sizeof(u32)];
u8 buffer[BlockSize];
u64 bits_consumed;
size_t num_buffered;
bool finalized;
enum State {
State_None,
State_Initialized,
State_Done,
};
private:
u32 m_intermediate_hash[HashSize / sizeof(u32)];
u8 m_buffer[BlockSize];
size_t m_buffered_bytes;
u64 m_bits_consumed;
State m_state;
public:
Sha1Impl() { m_state.finalized = false; }
Sha1Impl() : m_state(State_None) { /* ... */ }
~Sha1Impl() {
static_assert(std::is_trivially_destructible<State>::value);
ClearMemory(std::addressof(m_state), sizeof(m_state));
ClearMemory(this, sizeof(*this));
}
void Initialize();
void Update(const void *data, size_t size);
void GetHash(void *dst, size_t size);
private:
void ProcessBlock(const void *data);
void ProcessBlocks(const u8 *data, size_t block_count);
void ProcessLastBlock();
};
/* static_assert(HashFunction<Sha1Impl>); */