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

Switch to using ChaCha20Poly1305Reusable for encryption #3

Merged
merged 4 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Switch to using ChaCha20Poly1305Reusable for encryption
The ChaCha20Poly1305 that comes with cryptography recreates the
ctx every time encrypt is called.  Since we call encrypt in
 a loop, we can avoid this overhead by using ChaCha20Poly1305Reusable
instead as we are doing everything in the same thread and not concerned
about thread safety
  • Loading branch information
bdraco committed Jun 18, 2022
commit 4f3b6a2a5cec179bfce303a86af2df7bd7956104
2 changes: 1 addition & 1 deletion pyhap/hap_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from chacha20poly1305_reuseable import ChaCha20Poly1305Reusable as ChaCha20Poly1305
from cryptography.hazmat.primitives.kdf.hkdf import HKDF

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion pyhap/hap_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from cryptography.exceptions import InvalidSignature, InvalidTag
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ed25519, x25519
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from chacha20poly1305_reuseable import ChaCha20Poly1305Reusable as ChaCha20Poly1305

from pyhap import tlv
from pyhap.const import (
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
README = f.read()


REQUIRES = ["cryptography", "zeroconf>=0.36.2", "h11"]
REQUIRES = ["cryptography", "chacha20poly1305-reuseable", "zeroconf>=0.36.2", "h11"]


setup(
Expand Down