summaryrefslogtreecommitdiff
path: root/rsa
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2020-11-15 16:18:18 +0100
committerSybren A. Stüvel <sybren@stuvel.eu>2020-11-15 16:18:18 +0100
commitf254895b02f0cb106f9ccee6d8dc6af1a27f0bd1 (patch)
treed1e6997076de361d258c322ff73b15c50d9e5984 /rsa
parent240b0d8910299f970921391ea9737cb64ec09208 (diff)
downloadrsa-git-f254895b02f0cb106f9ccee6d8dc6af1a27f0bd1.tar.gz
Use `bytes.find()` instead of `bytes.index()`
Use `bytes.find()` instead of `bytes.index()`, as the former doesn't raise an exception when the to-be-found byte doesn't exist.
Diffstat (limited to 'rsa')
-rw-r--r--rsa/pkcs1.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/rsa/pkcs1.py b/rsa/pkcs1.py
index 8a85b1c..d0149a1 100644
--- a/rsa/pkcs1.py
+++ b/rsa/pkcs1.py
@@ -258,10 +258,8 @@ def decrypt(crypto: bytes, priv_key: key.PrivateKey) -> bytes:
cleartext_marker_bad = not compare_digest(cleartext[:2], b'\x00\x02')
# Find the 00 separator between the padding and the message
- try:
- sep_idx = cleartext.index(b'\x00', 2)
- except ValueError:
- sep_idx = -1
+ sep_idx = cleartext.find(b'\x00', 2)
+
# sep_idx indicates the position of the `\x00` separator that separates the
# padding from the actual message. The padding should be at least 8 bytes
# long (see https://tools.ietf.org/html/rfc8017#section-7.2.2 step 3), which