-
Notifications
You must be signed in to change notification settings - Fork 135
Hmac sha implementation #2557
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
Open
prikhap
wants to merge
8
commits into
aws:inject-hash-cpp-experiment
Choose a base branch
from
prikhap:hmac_sha_implementation
base: inject-hash-cpp-experiment
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hmac sha implementation #2557
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
81d4a69
Add LIEF as submodule for inject_hash implementation
prikhap faf8ab3
Add CI workflow and tests for C++ inject_hash
prikhap 17650df
Add CI workflow and test script for C++ inject_hash
prikhap 46652e7
Add CI workflow and test script for C++ inject_hash
prikhap a11e97a
Disable LIEF-related warnings in inject_hash_cpp build
prikhap a29cda3
Implement inject_hash using fips_hashing library
prikhap 8801a70
Integration of HMAC and SHA functionalities from the crypto submodule.
prikhap 3c4bf28
Update test-cpp-inject-hash.yml
prikhap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Test C++ inject_hash Implementation | ||
|
||
on: | ||
push: | ||
branches: [ hmac_sha_implementation ] | ||
pull_request: | ||
branches: [ inject-hash-cpp-experiment ] | ||
|
||
jobs: | ||
test-cpp-inject-hash: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
# Don't cancel all jobs if one fails | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.20' | ||
|
||
- name: Install Dependencies (Ubuntu) | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y ninja-build cmake perl golang | ||
|
||
- name: Install Dependencies (macOS) | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew install ninja cmake perl go | ||
|
||
- name: Build and Test | ||
run: | | ||
chmod +x tests/ci/run_inject_hash_cpp.sh | ||
./tests/ci/run_inject_hash_cpp.sh | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "third_party/lief"] | ||
path = third_party/lief | ||
url = https://github.com/lief-project/LIEF.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
if(FIPS) | ||
add_definitions(-DOPENSSL_NO_ASM=1) | ||
remove_definitions(-DBORINGSSL_FIPS -DFIPS_ENTROPY_SOURCE_JITTER_CPU -DFIPS_ENTROPY_SOURCE_PASSIVE) | ||
|
||
add_library( | ||
fips_hashing | ||
|
||
STATIC | ||
|
||
fips_hashing.c | ||
|
||
../mem.c | ||
../thread_none.c | ||
../thread_pthread.c | ||
|
||
../err/err.c | ||
$<TARGET_OBJECTS:generated_err_data> | ||
../decrepit/ripemd/ripemd.c | ||
) | ||
|
||
SET_TARGET_PROPERTIES(fips_hashing PROPERTIES LINKER_LANGUAGE C) | ||
target_include_directories(fips_hashing PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>) | ||
endif() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "../fipsmodule/delocate.h" | ||
|
||
|
||
#include "../fipsmodule/digest/digest.c" | ||
#include "../fipsmodule/digest/digests.c" | ||
#include "../fipsmodule/hmac/hmac.c" | ||
#include "../fipsmodule/md4/md4.c" | ||
#include "../fipsmodule/md5/md5.c" | ||
#include "../fipsmodule/sha/keccak1600.c" | ||
#include "../fipsmodule/sha/sha1.c" | ||
#include "../fipsmodule/sha/sha256.c" | ||
#include "../fipsmodule/sha/sha3.c" | ||
#include "../fipsmodule/sha/sha512.c" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
set -exo pipefail | ||
|
||
# Get directory containing this script | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
cd "${DIR}/../.." | ||
|
||
# Print environment info | ||
echo "Environment:" | ||
go version | ||
cmake --version | ||
ninja --version | ||
|
||
# Build AWS-LC with C++ inject_hash | ||
mkdir -p build | ||
cd build | ||
|
||
# Configure | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
cmake -GNinja \ | ||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | ||
-DFIPS=1 \ | ||
-DFIPS_SHARED=1 \ | ||
-DBUILD_SHARED_LIBS=1 \ | ||
-DUSE_CPP_INJECT_HASH=ON \ | ||
-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \ | ||
.. | ||
else | ||
cmake -GNinja \ | ||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | ||
-DFIPS=1 \ | ||
-DFIPS_SHARED=1 \ | ||
-DBUILD_SHARED_LIBS=1 \ | ||
-DUSE_CPP_INJECT_HASH=ON \ | ||
.. | ||
fi | ||
|
||
# First try to build just inject_hash_cpp | ||
echo "Building inject_hash_cpp..." | ||
ninja inject_hash_cpp | ||
|
||
# Test 1: Check if executable runs | ||
echo "Test 1: Basic execution" | ||
if ./util/fipstools/inject_hash_cpp/inject_hash_cpp; then | ||
echo "Should have failed without arguments" | ||
else | ||
echo "Correctly failed without arguments" | ||
fi | ||
|
||
# Test 2: Check -in-object parameter | ||
echo "Test 2: Testing with test file" | ||
touch test.bin | ||
if ./util/fipstools/inject_hash_cpp/inject_hash_cpp -in-object test.bin; then | ||
echo "Successfully processed test file" | ||
else | ||
echo "Failed to process test file" | ||
fi | ||
|
||
echo "=== Tests Complete ===" | ||
# Build everything | ||
echo "Building full project..." | ||
ninja | ||
|
||
# Test actual FIPS injection | ||
echo "Testing FIPS injection..." | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
./util/fipstools/inject_hash_cpp/inject_hash_cpp -o ./crypto/libcrypto.dylib -in-object ./crypto/libcrypto.dylib -apple | ||
else | ||
./util/fipstools/inject_hash_cpp/inject_hash_cpp -o ./crypto/libcrypto.so -in-object ./crypto/libcrypto.so | ||
fi | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
if(USE_CPP_INJECT_HASH) | ||
add_executable(inject_hash_cpp | ||
inject_hash.cpp | ||
) | ||
|
||
target_include_directories(inject_hash_cpp PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
${CMAKE_SOURCE_DIR}/include | ||
) | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") | ||
target_compile_options(inject_hash_cpp PRIVATE | ||
-Wno-overloaded-virtual | ||
-Wno-unused-parameter | ||
) | ||
endif() | ||
|
||
target_link_libraries(inject_hash_cpp PRIVATE | ||
LIEF::LIEF | ||
fips_hashing | ||
) | ||
|
||
set_target_properties(inject_hash_cpp PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON | ||
) | ||
endif() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'out' [clang-diagnostic-error]