Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHA256 hash based on OpenSSL #304

Merged
merged 9 commits into from
Jun 19, 2024
Merged

SHA256 hash based on OpenSSL #304

merged 9 commits into from
Jun 19, 2024

Conversation

Anilm3
Copy link
Collaborator

@Anilm3 Anilm3 commented Jun 7, 2024

This PR introduces a class to compute the sha256 digest, the code is based on the openssl implementation. At first, the objective is to use this hash for request fingerprinting purposes, however it could be used for other purposes:

  • As a processor generator, in order to produce a hash of part of the request, in a similar fashion to a fingerprint although more targeted.
  • As a transformer, to match obfuscated data.

@codecov-commenter
Copy link

codecov-commenter commented Jun 7, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 9 lines in your changes missing coverage. Please review.

Project coverage is 83.66%. Comparing base (0bcb84c) to head (153eab1).

Files Patch % Lines
src/sha256.cpp 93.87% 5 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #304      +/-   ##
==========================================
+ Coverage   83.39%   83.66%   +0.27%     
==========================================
  Files         135      137       +2     
  Lines        5854     6007     +153     
  Branches     2808     2829      +21     
==========================================
+ Hits         4882     5026     +144     
- Misses        361      366       +5     
- Partials      611      615       +4     
Flag Coverage Δ
waf_test 83.66% <94.11%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pr-commenter
Copy link

pr-commenter bot commented Jun 7, 2024

Benchmarks

Benchmark execution time: 2024-06-17 19:31:06

Comparing candidate commit fae4113 in PR branch anilm3/openssl-sha256 with baseline commit a425414 in branch master.

Found 2 performance improvements and 0 performance regressions! Performance is the same for 17 metrics, 0 unstable metrics.

scenario:signed_equals_matcher.random

  • 🟩 execution_time [-38.937µs; -38.059µs] or [-3.206%; -3.133%]

scenario:unsigned_equals_matcher.random

  • 🟩 execution_time [-41.321µs; -37.832µs] or [-3.399%; -3.112%]

@Anilm3 Anilm3 marked this pull request as ready for review June 10, 2024 08:29
@Anilm3 Anilm3 requested a review from a team as a code owner June 10, 2024 08:29
@Anilm3
Copy link
Collaborator Author

Anilm3 commented Jun 10, 2024

Benchmarked three different variants:

Benchmark                           Time             CPU   Iterations
---------------------------------------------------------------------
BM_SHA256V1HashDigest/64          362 ns          362 ns      1943479
BM_SHA256V1HashDigest/128         528 ns          528 ns      1323954
BM_SHA256V1HashDigest/256         839 ns          839 ns       817359
BM_SHA256V1HashDigest/512        1468 ns         1468 ns       475595
BM_SHA256V1HashDigest/1024       2763 ns         2762 ns       255095
BM_SHA256V2HashDigest/64          390 ns          390 ns      1785310
BM_SHA256V2HashDigest/128         560 ns          560 ns      1184360
BM_SHA256V2HashDigest/256         905 ns          905 ns       760367
BM_SHA256V2HashDigest/512        1588 ns         1588 ns       439426
BM_SHA256V2HashDigest/1024       2953 ns         2953 ns       233425
BM_SHA256V3HashDigest/64          590 ns          590 ns      1127086
BM_SHA256V3HashDigest/128         876 ns          876 ns       764616
BM_SHA256V3HashDigest/256        1468 ns         1468 ns       491038
BM_SHA256V3HashDigest/512        2508 ns         2508 ns       280887
BM_SHA256V3HashDigest/1024       4671 ns         4671 ns       150827

Copy link
Contributor

@cataphract cataphract left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine. As mentioned, it would interesting to see a version using instructions dedicated to it (SHA256H/SHA256H2/SHA256SU0/SHA256SU1 for aarch64) and SHA256MSG1/SHA256MSG2/SHA256RNDS2 for amd64.

@Anilm3 Anilm3 merged commit 6c23797 into master Jun 19, 2024
44 checks passed
@Anilm3 Anilm3 deleted the anilm3/openssl-sha256 branch June 19, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants