Blame SOURCES/0091-FIPS-RSA-encapsulate.patch

3da501
diff -up openssl-3.0.1/providers/implementations/kem/rsa_kem.c.encap openssl-3.0.1/providers/implementations/kem/rsa_kem.c
3da501
--- openssl-3.0.1/providers/implementations/kem/rsa_kem.c.encap	2022-11-22 12:27:30.994530801 +0100
3da501
+++ openssl-3.0.1/providers/implementations/kem/rsa_kem.c	2022-11-22 12:32:15.916875495 +0100
3da501
@@ -264,6 +264,14 @@ static int rsasve_generate(PROV_RSA_CTX
3da501
             *secretlen = nlen;
3da501
         return 1;
3da501
     }
3da501
+
3da501
+#ifdef FIPS_MODULE
3da501
+    if (nlen < OPENSSL_RSA_FIPS_MIN_MODULUS_BITS/8) {
3da501
+        ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SIZE_TOO_SMALL);
3da501
+        return 0;
3da501
+    }
3da501
+#endif
3da501
+
3da501
     /*
3da501
      * Step (2): Generate a random byte string z of nlen bytes where
3da501
      *            1 < z < n - 1
3da501
@@ -307,6 +315,13 @@ static int rsasve_recover(PROV_RSA_CTX *
3da501
         return 1;
3da501
     }
3da501
 
3da501
+#ifdef FIPS_MODULE
3da501
+    if (nlen < OPENSSL_RSA_FIPS_MIN_MODULUS_BITS/8) {
3da501
+        ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SIZE_TOO_SMALL);
3da501
+        return 0;
3da501
+    }
3da501
+#endif
3da501
+
3da501
     /* Step (2): check the input ciphertext 'inlen' matches the nlen */
3da501
     if (inlen != nlen) {
3da501
         ERR_raise(ERR_LIB_PROV, PROV_R_BAD_LENGTH);