Use SHA1 and MD5 from Crypto++ instead of our own implementations#238
Open
danim7 wants to merge 1 commit into
Open
Use SHA1 and MD5 from Crypto++ instead of our own implementations#238danim7 wants to merge 1 commit into
danim7 wants to merge 1 commit into
Conversation
|
Great job @danim7, thanks. Will mark it for 3.1.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening as a draft to be ready after 3.0.1 release
Closes #181
What
Migrate MD5 and SHA1 hash algorithms from our own implementation to Crypto++'s.
We were already linking that library for MD4 and RSA, but the other crypto algorithms were directly implemented on aMule's source code.
The main goals of this migration are:
The RC4 algorithm migration to Crypto++'s version is out of scope. According to @Stoatwblr analysis here #194 (comment) , RC4 implementation in aMule is slightly broken vs Crypto++, and migrating to Crypto++'s version would actually inccur in a performance penalty because of the workarounds needed to make it work. We keep the existing implementation.
Also, credit to eMuleAI: SHA1 and MD5 migrations to Crypto++ are largely based on their code (SHA.* MD5Sum.*) here: https://github.com/eMuleAI/eMuleAI/tree/master/srchybrid
Tests
Performance
Performance comparison for SHA1 hash operations follows.
Since MD5 is only used to hash a few bytes (EC password, key agreement for RC4 encryption), the performance impact is assumed to be negligible.
Methodology
Before each test, remove ~/.aMule folder
Launch amule(d) to create the ~/.aMule folder, and close it.
Create three files in ~/.aMule/Incoming as follows and restart amule(d)
fallocate -l 300mb test-300mb
fallocate -l 2gb test-2gb
fallocate -l 5gb test-5gb
Measure start time from log line: SharedFileList.cpp(410): Found 0 known shared files, 3 unknown
Measure end time from known2_64.met modification time after all 3 files are hashed, since Release builds don't show any log line on hash completion.
Results:
amule on a CPU with SHA instructions:
amuled on a CPU without SHA instructions (RPi 400):