File tree 1 file changed +4
-2
lines changed
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:
252
252
# Detect leading zeroes in the crypto. These are not reflected in the
253
253
# encrypted value (as leading zeroes do not influence the value of an
254
254
# 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' )
256
258
257
259
# If we can't find the cleartext marker, decryption failed.
258
260
cleartext_marker_bad = not compare_digest (cleartext [:2 ], b'\x00 \x02 ' )
@@ -267,7 +269,7 @@ def decrypt(crypto: bytes, priv_key: key.PrivateKey) -> bytes:
267
269
# `\x00\x02` marker that preceeds it).
268
270
sep_idx_bad = sep_idx < 10
269
271
270
- anything_bad = crypto_len_bad | cleartext_marker_bad | sep_idx_bad
272
+ anything_bad = cleartext_marker_bad | sep_idx_bad
271
273
if anything_bad :
272
274
raise DecryptionError ('Decryption failed' )
273
275
You can’t perform that action at this time.
0 commit comments