mirror of
https://github.com/azaion/loader.git
synced 2026-04-22 10:36:32 +00:00
Quality cleanup refactoring
Made-with: Cursor
This commit is contained in:
+2
-7
@@ -35,13 +35,8 @@ cdef class Security:
|
||||
|
||||
decrypted_padded_bytes = decryptor.update(ciphertext_bytes) + decryptor.finalize()
|
||||
|
||||
# Manual PKCS7 unpadding check and removal
|
||||
padding_value = decrypted_padded_bytes[-1] # Get the last byte, which indicates padding length
|
||||
if 1 <= padding_value <= 16: # Valid PKCS7 padding value range for AES-128
|
||||
padding_length = padding_value
|
||||
plaintext_bytes = decrypted_padded_bytes[:-padding_length] # Remove padding bytes
|
||||
else:
|
||||
plaintext_bytes = decrypted_padded_bytes
|
||||
unpadder = padding.PKCS7(128).unpadder()
|
||||
plaintext_bytes = unpadder.update(decrypted_padded_bytes) + unpadder.finalize()
|
||||
|
||||
return bytes(plaintext_bytes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user