[openssl] master update

Matt Caswell matt at openssl.org
Thu Apr 18 11:43:32 UTC 2019


The branch master has been updated
       via  87d9955e8cd2f1a2aa7f3a3e1da6c3c828070da1 (commit)
      from  86a7ac5e76fd3df9a5c3422153ae5a3e4f99b3a8 (commit)


- Log -----------------------------------------------------------------
commit 87d9955e8cd2f1a2aa7f3a3e1da6c3c828070da1
Author: Simo Sorce <simo at redhat.com>
Date:   Wed Apr 17 10:48:49 2019 -0400

    Add SSHKDF in evp_kdf_test
    
    Signed-off-by: Simo Sorce <simo at redhat.com>
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/8774)

-----------------------------------------------------------------------

Summary of changes:
 test/evp_kdf_test.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/test/evp_kdf_test.c b/test/evp_kdf_test.c
index 4215fe3..955daf7 100644
--- a/test/evp_kdf_test.c
+++ b/test/evp_kdf_test.c
@@ -253,6 +253,60 @@ static int test_kdf_ss_kmac(void)
     return ret;
 }
 
+static int test_kdf_sshkdf(void)
+{
+    int ret;
+    EVP_KDF_CTX *kctx;
+    unsigned char out[8];
+    /* Test data from NIST CAVS 14.1 test vectors */
+    const unsigned char key[] = {
+        0x00, 0x00, 0x00, 0x81, 0x00, 0x87, 0x5c, 0x55, 0x1c, 0xef, 0x52, 0x6a,
+        0x4a, 0x8b, 0xe1, 0xa7, 0xdf, 0x27, 0xe9, 0xed, 0x35, 0x4b, 0xac, 0x9a,
+        0xfb, 0x71, 0xf5, 0x3d, 0xba, 0xe9, 0x05, 0x67, 0x9d, 0x14, 0xf9, 0xfa,
+        0xf2, 0x46, 0x9c, 0x53, 0x45, 0x7c, 0xf8, 0x0a, 0x36, 0x6b, 0xe2, 0x78,
+        0x96, 0x5b, 0xa6, 0x25, 0x52, 0x76, 0xca, 0x2d, 0x9f, 0x4a, 0x97, 0xd2,
+        0x71, 0xf7, 0x1e, 0x50, 0xd8, 0xa9, 0xec, 0x46, 0x25, 0x3a, 0x6a, 0x90,
+        0x6a, 0xc2, 0xc5, 0xe4, 0xf4, 0x8b, 0x27, 0xa6, 0x3c, 0xe0, 0x8d, 0x80,
+        0x39, 0x0a, 0x49, 0x2a, 0xa4, 0x3b, 0xad, 0x9d, 0x88, 0x2c, 0xca, 0xc2,
+        0x3d, 0xac, 0x88, 0xbc, 0xad, 0xa4, 0xb4, 0xd4, 0x26, 0xa3, 0x62, 0x08,
+        0x3d, 0xab, 0x65, 0x69, 0xc5, 0x4c, 0x22, 0x4d, 0xd2, 0xd8, 0x76, 0x43,
+        0xaa, 0x22, 0x76, 0x93, 0xe1, 0x41, 0xad, 0x16, 0x30, 0xce, 0x13, 0x14,
+        0x4e
+    };
+    const unsigned char xcghash[] = {
+        0x0e, 0x68, 0x3f, 0xc8, 0xa9, 0xed, 0x7c, 0x2f, 0xf0, 0x2d, 0xef, 0x23,
+        0xb2, 0x74, 0x5e, 0xbc, 0x99, 0xb2, 0x67, 0xda, 0xa8, 0x6a, 0x4a, 0xa7,
+        0x69, 0x72, 0x39, 0x08, 0x82, 0x53, 0xf6, 0x42
+    };
+    const unsigned char sessid[] = {
+        0x0e, 0x68, 0x3f, 0xc8, 0xa9, 0xed, 0x7c, 0x2f, 0xf0, 0x2d, 0xef, 0x23,
+        0xb2, 0x74, 0x5e, 0xbc, 0x99, 0xb2, 0x67, 0xda, 0xa8, 0x6a, 0x4a, 0xa7,
+        0x69, 0x72, 0x39, 0x08, 0x82, 0x53, 0xf6, 0x42
+    };
+    const unsigned char expected[sizeof(out)] = {
+        0x41, 0xff, 0x2e, 0xad, 0x16, 0x83, 0xf1, 0xe6
+    };
+
+    ret = TEST_ptr(kctx = EVP_KDF_CTX_new_id(EVP_KDF_SSHKDF))
+          && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()),
+                         0)
+          && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, key,
+                                      sizeof(key)), 0)
+          && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SSHKDF_XCGHASH,
+                                      xcghash, sizeof(xcghash)), 0)
+          && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SSHKDF_SESSION_ID,
+                                      sessid, sizeof(sessid)), 0)
+          && TEST_int_gt(
+                EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SSHKDF_TYPE,
+                             (int)EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV),
+                0)
+          && TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out)), 0)
+          && TEST_mem_eq(out, sizeof(out), expected, sizeof(expected));
+
+    EVP_KDF_CTX_free(kctx);
+    return ret;
+}
+
 int setup_tests(void)
 {
     ADD_TEST(test_kdf_tls1_prf);
@@ -264,5 +318,6 @@ int setup_tests(void)
     ADD_TEST(test_kdf_ss_hash);
     ADD_TEST(test_kdf_ss_hmac);
     ADD_TEST(test_kdf_ss_kmac);
+    ADD_TEST(test_kdf_sshkdf);
     return 1;
 }


More information about the openssl-commits mailing list