mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-27 17:37:39 +01:00
Reduce ChaCha20CipherReuseable overhead (#489)
This commit is contained in:
parent
7196ca6ee8
commit
401ff3b61a
@ -5,7 +5,7 @@ from abc import abstractmethod
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from struct import Struct
|
from struct import Struct
|
||||||
from typing import TYPE_CHECKING, Any, Callable, Optional, Union, cast
|
from typing import TYPE_CHECKING, Any, Callable, Optional, Type, Union, cast
|
||||||
|
|
||||||
from chacha20poly1305_reuseable import ChaCha20Poly1305Reusable
|
from chacha20poly1305_reuseable import ChaCha20Poly1305Reusable
|
||||||
from cryptography.exceptions import InvalidTag
|
from cryptography.exceptions import InvalidTag
|
||||||
@ -42,12 +42,11 @@ WRITE_EXCEPTIONS = (RuntimeError, ConnectionResetError, OSError)
|
|||||||
class ChaCha20CipherReuseable(ChaCha20Cipher): # type: ignore[misc]
|
class ChaCha20CipherReuseable(ChaCha20Cipher): # type: ignore[misc]
|
||||||
"""ChaCha20 cipher that can be reused."""
|
"""ChaCha20 cipher that can be reused."""
|
||||||
|
|
||||||
@property
|
format_nonce = PACK_NONCE
|
||||||
def klass(self): # type: ignore[no-untyped-def]
|
|
||||||
return ChaCha20Poly1305Reusable
|
|
||||||
|
|
||||||
def format_nonce(self, n: int) -> bytes:
|
@property
|
||||||
return PACK_NONCE(n)
|
def klass(self) -> Type[ChaCha20Poly1305Reusable]:
|
||||||
|
return ChaCha20Poly1305Reusable
|
||||||
|
|
||||||
|
|
||||||
class ESPHomeNoiseBackend(DefaultNoiseBackend): # type: ignore[misc]
|
class ESPHomeNoiseBackend(DefaultNoiseBackend): # type: ignore[misc]
|
||||||
|
Loading…
Reference in New Issue
Block a user