Skip to content

Commit

Permalink
support ChaCha64 encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Jan 17, 2025
1 parent 11a2f03 commit c3c0450
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions firebirdsql/fbcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,15 +761,15 @@ def _parse_connect_response(self):

if enc_plugin and self.wire_crypt and session_key:
self._op_crypt(enc_plugin)
if enc_plugin == b'Arc4':
self.sock.set_translator(
ARC4.new(session_key), ARC4.new(session_key))
elif enc_plugin == b'ChaCha':
if enc_plugin in (b'ChaCha64', b'ChaCha'):
k = hashlib.sha256(session_key).digest()
self.sock.set_translator(
ChaCha20.new(k, nonce),
ChaCha20.new(k, nonce),
)
elif enc_plugin == b'Arc4':
self.sock.set_translator(
ARC4.new(session_key), ARC4.new(session_key))
else:
raise OperationalError(
'Unknown wirecrypt plugin %s' % (enc_plugin)
Expand Down
8 changes: 4 additions & 4 deletions firebirdsql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ def guess_wire_crypt(b):
elif t == 3:
plugin_nonce.append(v)

# if b'ChaCha64' in available_plugins:
# for s in plugin_nonce:
# if s[:9] == b"ChaCha64\x00":
# return (b'ChaCha64', s[9:])
if b'ChaCha64' in available_plugins:
for s in plugin_nonce:
if s[:9] == b"ChaCha64\x00":
return (b'ChaCha64', s[9:])
if b'ChaCha' in available_plugins:
for s in plugin_nonce:
if s[:7] == b"ChaCha\x00":
Expand Down

0 comments on commit c3c0450

Please sign in to comment.