mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
LibCrypto: Ensure RSA decryption with CRT works for all inputs
Ensure becomes `m1` greater than `m2` even when smaller by more than one `p`. Since the next operations on `m1` are modulus `p` we can add it as many times as it's needed.
This commit is contained in:
parent
1c9f0601e9
commit
8620a2af47
Notes:
github-actions[bot]
2024-12-19 17:44:17 +00:00
Author: https://github.com/devgianlu Commit: https://github.com/LadybirdBrowser/ladybird/commit/8620a2af473 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2969
1 changed files with 1 additions and 3 deletions
|
@ -141,11 +141,9 @@ void RSA::decrypt(ReadonlyBytes in, Bytes& out)
|
|||
} else {
|
||||
auto m1 = NumberTheory::ModularPower(in_integer, m_private_key.exponent1(), m_private_key.prime1());
|
||||
auto m2 = NumberTheory::ModularPower(in_integer, m_private_key.exponent2(), m_private_key.prime2());
|
||||
if (m1 < m2)
|
||||
while (m1 < m2)
|
||||
m1 = m1.plus(m_private_key.prime1());
|
||||
|
||||
VERIFY(m1 >= m2);
|
||||
|
||||
auto h = NumberTheory::Mod(m1.minus(m2).multiplied_by(m_private_key.coefficient()), m_private_key.prime1());
|
||||
m = m2.plus(h.multiplied_by(m_private_key.prime2()));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue