Skip to content

Commit

Permalink
style(pre-commit): auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 17, 2024
1 parent 5a62808 commit 1ff9a19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion discord/types/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
from .snowflake import Snowflake

SupportedModes = Literal[
"xsalsa20_poly1305_lite", "xsalsa20_poly1305_suffix", "xsalsa20_poly1305", "aead_xchacha20_poly1305_rtpsize"
"xsalsa20_poly1305_lite",
"xsalsa20_poly1305_suffix",
"xsalsa20_poly1305",
"aead_xchacha20_poly1305_rtpsize",
]


Expand Down
14 changes: 10 additions & 4 deletions discord/voice_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,14 @@ def _encrypt_aead_xchacha20_poly1305_rtpsize(self, header: bytes, data) -> bytes
box = nacl.secret.Aead(bytes(self.secret_key))
nonce = bytearray(24)

nonce[:4] = struct.pack('>I', self._lite_nonce)
self.checked_add('_lite_nonce', 1, 4294967295)
nonce[:4] = struct.pack(">I", self._lite_nonce)
self.checked_add("_lite_nonce", 1, 4294967295)

return header + box.encrypt(bytes(data), bytes(header), bytes(nonce)).ciphertext + nonce[:4]
return (
header
+ box.encrypt(bytes(data), bytes(header), bytes(nonce)).ciphertext
+ nonce[:4]
)

def _decrypt_xsalsa20_poly1305(self, header, data):
# Deprecated, remove in 2.7
Expand Down Expand Up @@ -635,7 +639,9 @@ def _decrypt_aead_xchacha20_poly1305_rtpsize(self, header, data):
nonce[:4] = data[-4:]
data = data[:-4]

return self.strip_header_ext(box.decrypt(bytes(data), bytes(header), bytes(nonce)))
return self.strip_header_ext(
box.decrypt(bytes(data), bytes(header), bytes(nonce))
)

@staticmethod
def strip_header_ext(data):
Expand Down

0 comments on commit 1ff9a19

Please sign in to comment.