{
EVP_MD_CTX_cleanup(&mdctx);
initialized = false;
+ finalized = false;
}
}
return _dp->name;
}
+ bool Digest::reset()
+ {
+ if (!_dp->initialized)
+ return false;
+ if(!_dp->finalized)
+ {
+ (void)EVP_DigestFinal_ex(&_dp->mdctx, _dp->md_value, &_dp->md_len);
+ _dp->finalized = true;
+ }
+ if(!EVP_DigestInit_ex(&_dp->mdctx, _dp->md, NULL))
+ return false;
+ _dp->finalized = false;
+ return true;
+ }
+
std::string Digest::digest()
{
if(!_dp->maybeInit())
return std::string(mdtxt);
}
+ std::vector<unsigned char> Digest::digestVector()
+ {
+ std::vector<unsigned char> r;
+ if(!_dp->maybeInit())
+ return r;
+
+ if(!_dp->finalized)
+ {
+ if(!EVP_DigestFinal_ex(&_dp->mdctx, _dp->md_value, &_dp->md_len))
+ return r;
+ _dp->finalized = true;
+ }
+ r.reserve(_dp->md_len);
+ for(unsigned i = 0; i < _dp->md_len; ++i)
+ r.push_back(_dp->md_value[i]);
+ return r;
+ }
+
bool Digest::update(const char* bytes, size_t len)
{
if(!bytes)
#include <string>
#include <iosfwd>
+#include <vector>
#include <zypp/Callback.h>
#include <zypp/Pathname.h>
* */
std::string digest();
+ /** \brief get vector of unsigned char representation of the digest
+ *
+ * this function will finalize the digest computation. calls to update
+ * after this function will start from scratch
+ *
+ * @return vector representation of the digest
+ * */
+ std::vector<unsigned char> digestVector();
+
+ /** \brief reset internal digest state
+ *
+ * this function is equivalent to calling create() with an unchanged name,
+ * but it may be implemented in a more efficient way.
+ */
+ bool reset();
+
/** \brief compute digest of a stream. convenience function
*
* calls create, update and digest in one function. The data for the