File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -252,7 +252,9 @@ def decrypt(crypto: bytes, priv_key: key.PrivateKey) -> bytes:
252252 # Detect leading zeroes in the crypto. These are not reflected in the
253253 # encrypted value (as leading zeroes do not influence the value of an
254254 # integer). This fixes CVE-2020-13757.
255- crypto_len_bad = len (crypto ) > blocksize
255+ if len (crypto ) > blocksize :
256+ # This is operating on public information, so doesn't need to be constant-time.
257+ raise DecryptionError ('Decryption failed' )
256258
257259 # If we can't find the cleartext marker, decryption failed.
258260 cleartext_marker_bad = not compare_digest (cleartext [:2 ], b'\x00 \x02 ' )
@@ -267,7 +269,7 @@ def decrypt(crypto: bytes, priv_key: key.PrivateKey) -> bytes:
267269 # `\x00\x02` marker that preceeds it).
268270 sep_idx_bad = sep_idx < 10
269271
270- anything_bad = crypto_len_bad | cleartext_marker_bad | sep_idx_bad
272+ anything_bad = cleartext_marker_bad | sep_idx_bad
271273 if anything_bad :
272274 raise DecryptionError ('Decryption failed' )
273275
You can’t perform that action at this time.
0 commit comments