Skip to content

Commit

Permalink
add assert length check to decrypt_int_fast
Browse files Browse the repository at this point in the history
pass modulus to decrypt_int_fast
  • Loading branch information
myheroyuki committed Jan 23, 2025
1 parent baabcc7 commit fb024d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rsa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def decrypt_int_fast(
rs: typing.List[int],
ds: typing.List[int],
ts: typing.List[int],
n: int,
) -> int:
"""Decrypts a cypher text more quickly using the Chinese Remainder Theorem."""

Expand All @@ -76,6 +77,8 @@ def decrypt_int_fast(
assert_int(d, "d")
for t in ts:
assert_int(t, "t")

assert_length(cyphertext, n)

p, q, rs = rs[0], rs[1], rs[2:]
exp1, exp2, ds = ds[0], ds[1], ds[2:]
Expand Down
1 change: 1 addition & 0 deletions rsa/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ def blinded_decrypt(self, encrypted: int) -> int:
[self.p, self.q] + self.rs,
[self.exp1, self.exp2] + self.ds,
[self.coef] + self.ts,
self.n,
)
return self.unblind(decrypted, blindfac_inverse)

Expand Down

0 comments on commit fb024d6

Please sign in to comment.