Skip to content

Commit

Permalink
Encrypt extension and body XML separately
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG committed Nov 18, 2024
1 parent b15677b commit b361995
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions reolink_aio/baichuan/baichuan.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ async def send(
enc_body_bytes = b""
if mess_len > 0:
if enc_type == EncType.BC:
enc_body_bytes = encrypt_baichuan(extension + body, enc_offset)
enc_body_bytes = encrypt_baichuan(extension, enc_offset) + encrypt_baichuan(body, enc_offset)
elif enc_type == EncType.AES:
enc_body_bytes = self._aes_encrypt(extension + body)
enc_body_bytes = self._aes_encrypt(extension) + self._aes_encrypt(body)
else:
raise InvalidParameterError(f"Baichuan host {self._host}: invalid param enc_type '{enc_type}'")

Expand Down Expand Up @@ -177,6 +177,8 @@ async def send(

def _aes_encrypt(self, body: str) -> bytes:
"""Encrypt a message using AES encryption"""
if not body:
return b""
if self._aes_key is None:
raise InvalidParameterError(f"Baichuan host {self._host}: first login before using AES encryption")

Expand Down

0 comments on commit b361995

Please sign in to comment.