diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-05 08:30:00 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-05 08:30:00 +0200 |
commit | 88adf3f7f2e9c6f1ea3c722ead41a5579b3292bf (patch) | |
tree | 8329c7f984ea18c6cb35cc1b5ec77f1b39d8656f /libbutl/sha256.cxx | |
parent | f6675a4626267c08e53bbc20bd3dd41ac8744605 (diff) |
Add sha{1,256}::empty()
Diffstat (limited to 'libbutl/sha256.cxx')
-rw-r--r-- | libbutl/sha256.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libbutl/sha256.cxx b/libbutl/sha256.cxx index 6dbe2a0..31730a2 100644 --- a/libbutl/sha256.cxx +++ b/libbutl/sha256.cxx @@ -67,7 +67,7 @@ namespace butl { sha256:: sha256 () - : done_ (false) + : done_ (false), empty_ (true) { SHA256_Init (reinterpret_cast<SHA256_CTX*> (buf_)); } @@ -75,7 +75,13 @@ namespace butl void sha256:: append (const void* b, size_t n) { - SHA256_Update (reinterpret_cast<SHA256_CTX*> (buf_), b, n); + if (n != 0) + { + SHA256_Update (reinterpret_cast<SHA256_CTX*> (buf_), b, n); + + if (empty_) + empty_ = false; + } } void sha256:: |