File openssl-kdf-tls-selftest.patch of Package openssl-1_1

diff --git a/crypto/fips/fips_kdf_selftest.c b/crypto/fips/fips_kdf_selftest.c
index 81d2459..762077f 100644
--- a/crypto/fips/fips_kdf_selftest.c
+++ b/crypto/fips/fips_kdf_selftest.c
@@ -61,4 +61,44 @@ err:
     return ret;
 }
 
+int FIPS_selftest_tls(void)
+{
+    int ret = 0;
+    EVP_KDF_CTX *kctx;
+    unsigned char out[16];
+
+    if ((kctx = EVP_KDF_CTX_new_id(EVP_KDF_TLS1_PRF)) == NULL)
+        goto err;
+
+    if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0)
+        goto err;
+
+    if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_TLS_SECRET,
+                     "secret", (size_t)6) <= 0)
+        goto err;
+
+    if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_ADD_TLS_SEED, "seed", (size_t)4) <= 0)
+        goto err;
+
+    if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0)
+        goto err;
+
+    {
+        const unsigned char expected[sizeof(out)] = {
+            0x8e, 0x4d, 0x93, 0x25, 0x30, 0xd7, 0x65, 0xa0,
+            0xaa, 0xe9, 0x74, 0xc3, 0x04, 0x73, 0x5e, 0xcc
+        };
+        if (memcmp(out, expected, sizeof(expected))) {
+            goto err;
+        }
+    }
+    ret = 1;
+
+err:
+    if (!ret)
+        FIPSerr(FIPS_F_FIPS_SELFTEST_TLS, FIPS_R_SELFTEST_FAILED);
+    EVP_KDF_CTX_free(kctx);
+    return ret;
+}
+
 #endif
diff --git a/crypto/fips/fips_post.c b/crypto/fips/fips_post.c
index 5fbb78f..fd01ca2 100644
--- a/crypto/fips/fips_post.c
+++ b/crypto/fips/fips_post.c
@@ -106,6 +106,9 @@ int FIPS_selftest(void)
         rv = 0;
     if (!FIPS_selftest_pbkdf2())
         rv = 0;
+    if (!FIPS_selftest_tls())
+        rv = 0;
+
     return rv;
 }
 
diff --git a/include/crypto/fips.h b/include/crypto/fips.h
index 1dab00e..d44cd73 100644
--- a/include/crypto/fips.h
+++ b/include/crypto/fips.h
@@ -77,6 +77,7 @@ int FIPS_selftest_hmac(void);
 int FIPS_selftest_drbg(void);
 int FIPS_selftest_cmac(void);
 int FIPS_selftest_pbkdf2(void);
+int FIPS_selftest_tls(void);
 
 int fips_in_post(void);
 
diff --git a/include/openssl/fips.h b/include/openssl/fips.h
index 9cfb511..6cb8318 100644
--- a/include/openssl/fips.h
+++ b/include/openssl/fips.h
@@ -125,6 +125,7 @@ extern "C" {
 # define FIPS_F_FIPS_SELFTEST_ECDSA                       133
 # define FIPS_F_FIPS_SELFTEST_HMAC                        113
 # define FIPS_F_FIPS_SELFTEST_PBKDF2                      152
+# define FIPS_F_FIPS_SELFTEST_TLS                         153
 # define FIPS_F_FIPS_SELFTEST_SHA1                        115
 # define FIPS_F_FIPS_SELFTEST_SHA2                        105
 # define FIPS_F_OSSL_ECDSA_SIGN_SIG                       143
openSUSE Build Service is sponsored by