Skip to content

Commit

Permalink
Merge pull request #45 from janispritzkau/fix-rsa-decrypt-error
Browse files Browse the repository at this point in the history
Fix decrypt error with pkcs1 padding
  • Loading branch information
invisal authored Nov 14, 2022
2 parents 0544b74 + 450aebc commit fd9af92
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rsa/rsa_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export function rsadp(key: RSAKey, c: bigint): bigint {
if (m1 >= m2) {
h = (key.qi * (m1 - m2)) % key.p;
} else {
h = (key.qi * (m1 - m2 + key.p * (key.p / key.q))) % key.p;
h = ((key.qi * (m1 - m2 + key.p * (key.p / key.q))) % key.p + key.p) %
key.p;
}

return (m2 + h * key.q) % (key.q * key.p);
Expand Down

0 comments on commit fd9af92

Please sign in to comment.