aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/sha1.cxx7
-rw-r--r--libbutl/sha1.mxx7
-rw-r--r--libbutl/sha256.cxx7
-rw-r--r--libbutl/sha256.mxx7
4 files changed, 20 insertions, 8 deletions
diff --git a/libbutl/sha1.cxx b/libbutl/sha1.cxx
index 3c1cbdc..d17119f 100644
--- a/libbutl/sha1.cxx
+++ b/libbutl/sha1.cxx
@@ -71,11 +71,12 @@ using namespace std;
namespace butl
{
- sha1::
- sha1 ()
- : done_ (false), empty_ (true)
+ void sha1::
+ reset ()
{
SHA1_Init (reinterpret_cast<SHA1_CTX*> (buf_));
+ done_ = false;
+ empty_ = true;
}
void sha1::
diff --git a/libbutl/sha1.mxx b/libbutl/sha1.mxx
index f69ae5a..ea87367 100644
--- a/libbutl/sha1.mxx
+++ b/libbutl/sha1.mxx
@@ -40,7 +40,7 @@ LIBBUTL_MODEXPORT namespace butl
class LIBBUTL_SYMEXPORT sha1
{
public:
- sha1 ();
+ sha1 () {reset ();}
// Append binary data.
//
@@ -79,6 +79,11 @@ LIBBUTL_MODEXPORT namespace butl
bool
empty () const {return empty_;}
+ // Reset to the default-constructed state.
+ //
+ void
+ reset ();
+
// Extract result.
//
// It can be obtained as either a 20-byte binary digest or as a 40-
diff --git a/libbutl/sha256.cxx b/libbutl/sha256.cxx
index 31730a2..65cd18c 100644
--- a/libbutl/sha256.cxx
+++ b/libbutl/sha256.cxx
@@ -65,11 +65,12 @@ using namespace std;
namespace butl
{
- sha256::
- sha256 ()
- : done_ (false), empty_ (true)
+ void sha256::
+ reset ()
{
SHA256_Init (reinterpret_cast<SHA256_CTX*> (buf_));
+ done_ = false;
+ empty_ = true;
}
void sha256::
diff --git a/libbutl/sha256.mxx b/libbutl/sha256.mxx
index 2bb58b3..6d53ead 100644
--- a/libbutl/sha256.mxx
+++ b/libbutl/sha256.mxx
@@ -41,7 +41,7 @@ LIBBUTL_MODEXPORT namespace butl
class LIBBUTL_SYMEXPORT sha256
{
public:
- sha256 ();
+ sha256 () {reset ();}
// Append binary data.
//
@@ -113,6 +113,11 @@ LIBBUTL_MODEXPORT namespace butl
bool
empty () const {return empty_;}
+ // Reset to the default-constructed state.
+ //
+ void
+ reset ();
+
// Extract result.
//
// It can be obtained as either a 32-byte binary digest or as a 64-