mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Adds partially support to t:sha1 transformation
This commit is contained in:
@@ -65,7 +65,7 @@ void SHA1::update(std::istream *is) {
|
||||
}
|
||||
|
||||
|
||||
std::string SHA1::final() {
|
||||
std::string SHA1::final_bin(bool toReset = true) {
|
||||
/* Total number of hashed bits */
|
||||
uint64_t total_bits = (transforms*BLOCK_BYTES + buffer.size()) * 8;
|
||||
|
||||
@@ -91,6 +91,22 @@ std::string SHA1::final() {
|
||||
block[BLOCK_INTS - 2] = (total_bits >> 32);
|
||||
transform(block);
|
||||
|
||||
if (toReset) {
|
||||
/* Reset for next run */
|
||||
reset();
|
||||
}
|
||||
|
||||
std::string bin;
|
||||
bin.append((const char*) digest, BLOCK_INTS);
|
||||
|
||||
return bin;
|
||||
}
|
||||
|
||||
|
||||
std::string SHA1::final() {
|
||||
|
||||
final_bin(false);
|
||||
|
||||
/* Hex std::string */
|
||||
std::ostringstream result;
|
||||
for (unsigned int i = 0; i < DIGEST_INTS; i++) {
|
||||
|
@@ -47,6 +47,10 @@ class SHA1 {
|
||||
void update(std::string *s);
|
||||
void update(std::istream *is);
|
||||
std::string final();
|
||||
std::string final_bin() {
|
||||
return final_bin(true);
|
||||
}
|
||||
std::string final_bin(bool reset);
|
||||
|
||||
private:
|
||||
/* number of 32bit integers per SHA1 digest */
|
||||
|
Reference in New Issue
Block a user