Skip to content

Commit

Permalink
Import ARC4 from 'decrepit' module
Browse files Browse the repository at this point in the history
...where it well and truly belongs, for the record.

This quashes a deprecation warning and solves a future incompatibility with cryptography 48.x.x
  • Loading branch information
MatthiasValvekens committed Oct 20, 2024
1 parent 5bbc2ea commit 0db5648
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyhanko/pdf_utils/crypt/_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import secrets
import struct

from cryptography.hazmat.decrepit.ciphers.algorithms import ARC4
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

Expand Down Expand Up @@ -30,7 +31,7 @@ def aes_cbc_encrypt(key, data, iv, use_padding=True):


def rc4_encrypt(key, data):
cipher = Cipher(algorithms.ARC4(key), mode=None)
cipher = Cipher(ARC4(key), mode=None)
encryptor = cipher.encryptor()
# NOTE: Suppress LGTM warning here, we have to do what the spec says
return encryptor.update(data) + encryptor.finalize() # lgtm

0 comments on commit 0db5648

Please sign in to comment.