Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X509toolcomparison #1714

Merged
merged 39 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ec75969
added comparison tests
ecdeye Jul 18, 2024
6e6e243
added comparison tests
ecdeye Jul 18, 2024
eae6530
updated yml
ecdeye Jul 18, 2024
96eb4a6
updated yml
ecdeye Jul 18, 2024
556be2d
updated x509 comparison test
ecdeye Jul 18, 2024
2f9600a
updated yml
ecdeye Jul 18, 2024
37967e7
updated yml
ecdeye Jul 18, 2024
46c3080
updated yml
ecdeye Jul 18, 2024
518a3d8
updated yml
ecdeye Jul 18, 2024
eb1fb1d
updated yml
ecdeye Jul 18, 2024
3def331
updated script
ecdeye Jul 18, 2024
3f40498
updated script
ecdeye Jul 18, 2024
dc49382
updated script
ecdeye Jul 18, 2024
b1cd114
updated script
ecdeye Jul 18, 2024
ffd8117
updated script
ecdeye Jul 18, 2024
32a6ab9
updated script
ecdeye Jul 18, 2024
5f4cd1a
x509 test updates msvc issue
ecdeye Jul 19, 2024
7c0aa37
x509 test updates msvc issue
ecdeye Jul 19, 2024
ce2f43e
x509 test updates removefile issue
ecdeye Jul 19, 2024
adeb529
x509 test updates removefile issue
ecdeye Jul 19, 2024
8c9bcb7
x509 test updates
ecdeye Jul 19, 2024
3ef96e1
x509 test updates
ecdeye Jul 19, 2024
2c1a9c2
x509 test updates
ecdeye Jul 19, 2024
5ecedc5
updated script
ecdeye Jul 19, 2024
cac0fdc
Merge branch 'main' into x509toolcomparison
ecdeye Jul 19, 2024
8dcda1a
Update tool-openssl/x509_test.cc
ecdeye Jul 20, 2024
a389df0
Update tool-openssl/x509_test.cc
ecdeye Jul 20, 2024
f5cfb17
Update tool-openssl/x509_test.cc
ecdeye Jul 20, 2024
ec83567
Update tool-openssl/x509_test.cc
ecdeye Jul 20, 2024
259e94d
updated script and tests
ecdeye Jul 22, 2024
f86ab98
updated common and comparison scripts
ecdeye Jul 22, 2024
e8540c8
Merge branch 'main' into x509toolcomparison
ecdeye Jul 22, 2024
02fb873
updated benchmark script
ecdeye Jul 22, 2024
e4e283d
Update tool-openssl/x509.cc
ecdeye Jul 23, 2024
b0479b1
updated test variables
ecdeye Jul 23, 2024
f0ac497
x509 bio
ecdeye Jul 23, 2024
7dfa396
updated bash script
ecdeye Jul 23, 2024
4eed235
updated x509 tests
ecdeye Jul 23, 2024
110eb35
Merge branch 'main' into x509toolcomparison
ecdeye Jul 24, 2024
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
27 changes: 27 additions & 0 deletions .github/workflows/opensslcomparison.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: OpenSSL CLI Comparison Tests
on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]

jobs:
openssl_comparison_tests:
if: github.repository_owner == 'aws'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install OS Dependencies
run: |
sudo apt-get update
sudo apt-get -y --no-install-recommends install \
cmake gcc ninja-build golang make autoconf pkg-config openssl

- name: Make the script executable
run: chmod +x ./tests/ci/run_openssl_comparison_tests.sh

- name: Build AWS-LC & OpenSSL and Run Comparison Tests
run: |
./tests/ci/run_openssl_comparison_tests.sh
13 changes: 13 additions & 0 deletions tests/ci/common_posix_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ function sde_getenforce_check {
fi
}

function build_openssl {
branch=$1
echo "building OpenSSL ${branch}"
git clone --depth 1 --branch "${branch}" "${openssl_url}" "${scratch_folder}/openssl-${branch}"
pushd "${scratch_folder}/openssl-${branch}"
mkdir -p "${install_dir}/openssl-${branch}"
./config --prefix="${install_dir}/openssl-${branch}" --openssldir="${install_dir}/openssl-${branch}" -d
make "-j${NUM_CPU_THREADS}" > /dev/null
make install_sw
popd
rm -rf "${scratch_folder}/openssl-${branch}"
}

print_executable_information "cmake" "--version" "CMake version"
print_executable_information "cmake3" "--version" "CMake version (cmake3 executable)"
print_executable_information "go" "version" "Go version"
Expand Down
13 changes: 0 additions & 13 deletions tests/ci/run_benchmark_build_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,6 @@ function build_aws_lc_branch {
rm -rf "${scratch_folder}/aws-lc-${branch}"
}

function build_openssl {
branch=$1
echo "building OpenSSL ${branch}"
git clone --depth 1 --branch "${branch}" "${openssl_url}" "${scratch_folder}/openssl-${branch}"
pushd "${scratch_folder}/openssl-${branch}"
mkdir -p "${install_dir}/openssl-${branch}"
./config --prefix="${install_dir}/openssl-${branch}" --openssldir="${install_dir}/openssl-${branch}" -d
make "-j${NUM_CPU_THREADS}" > /dev/null
make install_sw
popd
rm -rf "${scratch_folder}/openssl-${branch}"
}

function build_boringssl {
git clone --depth 1 https://github.com/google/boringssl.git "${scratch_folder}/boringssl"
pushd "${scratch_folder}/boringssl"
Expand Down
45 changes: 45 additions & 0 deletions tests/ci/run_openssl_comparison_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

source tests/ci/common_posix_setup.sh

scratch_folder=${SYS_ROOT}/"openssl-scratch"
install_dir="${scratch_folder}/libcrypto_install_dir"
openssl_url='https://github.com/openssl/openssl.git'
openssl_1_1_1_branch='OpenSSL_1_1_1-stable'
openssl_1_0_2_branch='OpenSSL_1_0_2-stable'
openssl_3_1_branch='openssl-3.1'
openssl_3_2_branch='openssl-3.2'
openssl_master_branch='master'

mkdir -p "${scratch_folder}"
rm -rf "${scratch_folder:?}"/*

build_openssl $openssl_1_0_2_branch
build_openssl $openssl_1_1_1_branch
build_openssl $openssl_3_1_branch
build_openssl $openssl_3_2_branch
build_openssl $openssl_master_branch

run_build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_STANDARD=11 -DENABLE_DILITHIUM=ON

# OpenSSL 3.1.0 on switches from lib folder to lib64 folder
declare -A openssl_branches=(
["$openssl_1_0_2_branch"]="lib"
["$openssl_1_1_1_branch"]="lib"
["$openssl_3_1_branch"]="lib64"
["$openssl_3_2_branch"]="lib64"
["$openssl_master_branch"]="lib64"
)

# Run X509 Comparison Tests against all OpenSSL branches
export AWSLC_TOOL_PATH="${BUILD_ROOT}/tool-openssl/openssl"
for branch in "${!openssl_branches[@]}"; do
export OPENSSL_TOOL_PATH="${install_dir}/openssl-${branch}/bin/openssl"
echo "Running X509ComparisonTests against OpenSSL ${branch}"
LD_LIBRARY_PATH="${install_dir}/openssl-${branch}/${openssl_branches[$branch]}" "${BUILD_ROOT}/tool-openssl/tool_openssl_test" --gtest_filter=X509ComparisonTest.*
ecdeye marked this conversation as resolved.
Show resolved Hide resolved
done

31 changes: 20 additions & 11 deletions tool-openssl/x509.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
#include <cstdio>
#include <ctime>
#include "internal.h"
#include <ctime>

static const argument_t kArguments[] = {
{ "-help", kBooleanArgument, "Display option summary" },
Expand Down Expand Up @@ -99,10 +98,6 @@ bool X509Tool(const args_list_t &args) {
}

// Check for mutually exclusive options
if (noout && (!out_path.empty() || modulus || dates || parsed_args.count("-checkend"))) {
fprintf(stderr, "Error: '-noout' option cannot be used with '-out', '-modulus', '-dates', and '-checkend' options\n");
return false;
}
if (req && (dates || parsed_args.count("-checkend"))){
fprintf(stderr, "Error: '-req' option cannot be used with '-dates' and '-checkend' options\n");
return false;
Expand Down Expand Up @@ -192,7 +187,7 @@ bool X509Tool(const args_list_t &args) {
}

// Write the signed certificate to output file
if (!noout && !out_path.empty()) {
if (!out_path.empty()) {
if (!WriteSignedCertificate(x509.get(), out_path)) {
return false;
}
Expand Down Expand Up @@ -240,9 +235,16 @@ bool X509Tool(const args_list_t &args) {
fprintf(stderr, "Error: unable to load modulus\n");
return false;
}
printf("Modulus=");
BN_print_fp(stdout, n);
printf("\n");
char *hex_modulus = BN_bn2hex(n);
if (!hex_modulus) {
fprintf(stderr, "Error: unable to convert modulus to hex\n");
return false;
}
for (char *p = hex_modulus; *p; ++p) {
*p = toupper(*p);
}
printf("Modulus=%s\n", hex_modulus);
OPENSSL_free(hex_modulus);
} else {
fprintf(stderr, "Error: public key is not an RSA key\n");
return false;
Expand Down Expand Up @@ -271,11 +273,18 @@ bool X509Tool(const args_list_t &args) {
}
}

if (!noout && !out_path.empty()) {
if (!out_path.empty()) {
if (!WriteSignedCertificate(x509.get(), out_path)) {
return false;
}
}

if (!noout && !in_path.empty() && !checkend && parsed_args.count("-out")==0) {
bssl::UniquePtr<BIO> bio_out(BIO_new_fp(stdout, BIO_NOCLOSE));
if (!PEM_write_bio_X509(bio_out.get(), x509.get())) {
return false;
}
}
}
return true;
}
Loading
Loading