Skip to content

Commit

Permalink
Include FIPS mode in OpenSSL_version return value (#1689)
Browse files Browse the repository at this point in the history
This backports PR 1419 to the 2022 FIPS branch. Confirmed that modifying
`crypto.c` does not affect the FIPS module.
  • Loading branch information
WillChilds-Klein authored Jul 3, 2024
1 parent d6d496b commit ad4b47b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ env:

jobs:
macOS:
runs-on: macos-11 # latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- name: Build ${{ env.PACKAGE_NAME }}
run: |
./tests/ci/run_posix_tests.sh
macOS-FIPS:
runs-on: macos-11 # latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- name: Build ${{ env.PACKAGE_NAME }} with FIPS mode
run: |
./tests/ci/run_fips_tests.sh
3 changes: 2 additions & 1 deletion crypto/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */

#include <openssl/crypto.h>
#include <openssl/service_indicator.h>

#include <assert.h>

Expand Down Expand Up @@ -118,7 +119,7 @@ const char *SSLeay_version(int which) { return OpenSSL_version(which); }
const char *OpenSSL_version(int which) {
switch (which) {
case OPENSSL_VERSION:
return AWSLC_VERSION_NAME;
return AWSLC_VERSION_STRING;
case OPENSSL_CFLAGS:
return "compiler: n/a";
case OPENSSL_BUILT_ON:
Expand Down
4 changes: 4 additions & 0 deletions crypto/crypto_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <openssl/crypto.h>
#include <openssl/cipher.h>
#include <openssl/mem.h>
#include <openssl/service_indicator.h>

#include <gtest/gtest.h>

Expand All @@ -35,6 +36,9 @@ TEST(CryptoTest, Version) {
(OPENSSL_VERSION_NUMBER >> 12) & 0xff);
EXPECT_EQ(expected,
std::string(OPENSSL_VERSION_TEXT).substr(0, strlen(expected)));
std::string full_expected = AWSLC_VERSION_STRING;
std::string actual = std::string(OpenSSL_version(OPENSSL_VERSION));
EXPECT_EQ(actual, full_expected);
}

TEST(CryptoTest, Strndup) {
Expand Down

0 comments on commit ad4b47b

Please sign in to comment.