File libcryptopp-CVE-2023-50981.patch of Package libcryptopp.32012
Index: cryptopp-CRYPTOPP_8_6_0/nbtheory.cpp
===================================================================
--- cryptopp-CRYPTOPP_8_6_0.orig/nbtheory.cpp
+++ cryptopp-CRYPTOPP_8_6_0/nbtheory.cpp
@@ -571,6 +571,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);