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

Improving performance #15

Merged
merged 1 commit into from
Dec 4, 2019
Merged

Improving performance #15

merged 1 commit into from
Dec 4, 2019

Conversation

silverdaz
Copy link
Collaborator

We replaced openssl chacha20 encryption/decryption with the ones from libsodium (via the pynacl bindings)

The test was:
Starting from a 1G file, named testfile with random data, we encrypt and decrypt n times, using intermediate staging files. We make sure that last file is the same as the original file (with diff).

The test script is:

#!/usr/bin/env bash
set -e

LIMIT=${1:-10}

unlink testfile.v1.1 &>/dev/null || true
ln -s testfile testfile.1

for (( i=1; i<=$LIMIT; i++ ))
do
    echo -n "o"
    crypt4gh encrypt --sk from.sec --recipient_pk to.pub < testfile.$i  > testfile.c4gh.$i
    echo -n "."
    crypt4gh decrypt --sk to.sec < testfile.c4gh.$i > testfile.$((i+1))
    unlink testfile.$i
    unlink testfile.c4gh.$i
done

echo "|"
diff testfile testfile.$i
unlink testfile.$i

and we time the execution, with 50 loops.

time with openssl with libsodium
real 5m57.990s 4m24.042s
user 3m53.821s 2m39.777s
sys 1m42.902s 1m35.706s

So it seems to bring an improvement of roughly 35%. Not bad.

We keep the cryptography dependency, because we use it to parse the ssh keys.

@silverdaz silverdaz self-assigned this Dec 4, 2019
@silverdaz silverdaz merged commit c277cc8 into master Dec 4, 2019
@silverdaz silverdaz deleted the performance branch December 10, 2019 07: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.

1 participant