libcryptopp/libcryptopp-CVE-2023-50981.patch

15 lines
479 B
Diff
Raw Permalink Normal View History

Index: cryptopp-CRYPTOPP_8_9_0/nbtheory.cpp
===================================================================
--- cryptopp-CRYPTOPP_8_9_0.orig/nbtheory.cpp
+++ cryptopp-CRYPTOPP_8_9_0/nbtheory.cpp
@@ -543,6 +543,9 @@ Integer CRT(const Integer &xp, const Int
Integer ModularSquareRoot(const Integer &a, const Integer &p)
{
+ if (!IsPrime(p))
+ throw InvalidArgument("ModularSquareRoot: p must be a prime");
+
if (p%4 == 3)
return a_exp_b_mod_c(a, (p+1)/4, p);