crypto: add Sha256Context

This commit is contained in:
Michael Scire
2020-03-11 03:26:55 -07:00
parent 45f8343659
commit 70367e3e7c
3 changed files with 59 additions and 0 deletions

View File

@@ -22,6 +22,11 @@
namespace ams::crypto {
struct Sha256Context {
u32 intermediate_hash[impl::Sha256Impl::HashSize / sizeof(u32)];
u64 bits_consumed;
};
class Sha256Generator {
private:
using Impl = impl::Sha256Impl;
@@ -54,6 +59,22 @@ namespace ams::crypto {
void GetHash(void *dst, size_t size) {
this->impl.GetHash(dst, size);
}
void InitializeWithContext(const Sha256Context *context) {
this->impl.InitializeWithContext(context);
}
size_t GetContext(Sha256Context *context) const {
return this->impl.GetContext(context);
}
size_t GetBufferedDataSize() const {
return this->impl.GetBufferedDataSize();
}
void GetBufferedData(void *dst, size_t dst_size) const {
return this->impl.GetBufferedData(dst, dst_size);
}
};
void GenerateSha256Hash(void *dst, size_t dst_size, const void *src, size_t src_size);