Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/main/cpp/exchange.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2020 Comcast Cable Communications Management, LLC
* Copyright 2020-2026 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -393,12 +393,12 @@ static Sec_Result hkdf(SEC_BYTE* key, SEC_SIZE key_len, SEC_BYTE* out, const SEC
return SEC_RESULT_FAILURE;
}

#if OPENSSL_VERSION_NUMBER >= 0x30000000
if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, reinterpret_cast<const unsigned char*>(use_salt ? "salt" : nullptr),
// OpenSSL 3.x OSSL_PARAM_construct_octet_string() rejects NULL data pointer
// even when length is 0, causing EVP_PKEY_CTX_set1_hkdf_salt() to fail.
// Pass "" instead of nullptr to satisfy the non-NULL check.
if (EVP_PKEY_CTX_set1_hkdf_salt(pctx,
reinterpret_cast<const unsigned char*>(use_salt ? "salt" : ""),
use_salt ? 4 : 0) <= 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this tested on OpenSSL < 0x30000000? Is that compile define no longer needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so, RDK platform only tested 1.0 to 3.0.15 and all passed, however using 3.0.18 it will be failed here. you see I did a bunch test from 1.0 to latest 3.6.1 to make sure the change does not break any openssl version.

#else
if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, use_salt ? "salt" : nullptr, use_salt ? 4 : 0) <= 0) {
#endif
EVP_PKEY_CTX_free(pctx);
return SEC_RESULT_FAILURE;
}
Expand Down
Loading