Skip to content

Commit d24d307

Browse files
committed
Merge branch 'nos3#637' into dev
2 parents b9a9c7d + a8df98a commit d24d307

File tree

80 files changed

+5893
-8434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5893
-8434
lines changed
File renamed without changes.

.github/workflows/build.yml

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -47,66 +47,60 @@ jobs:
4747
export CFLAGS="-fprofile-arcs -ftest-coverage -fcondition-coverage -g"
4848
bash ${GITHUB_WORKSPACE}/support/scripts/build_internal.sh
4949
50+
5051
# - name: Code-Coverage
5152
# working-directory: ${{github.workspace}}
5253
# run: make gcov
5354

5455
- name: Upload
55-
uses: codecov/codecov-action@v4
56-
env:
57-
CODECOV_TOKEN: 71699f25-12a3-44a4-8a83-be777b9e577a
56+
uses: codecov/codecov-action@v5
5857
with:
58+
token: ${{ secrets.CODECOV_TOKEN }}
5959
files: 'coverage/*.c.gcov'
6060
verbose: true
6161

6262
#
6363
# KMC Build
6464
#
65-
# kmc_build:
66-
# # Container Setup
67-
# runs-on: ubuntu-latest
68-
# steps:
69-
# - uses: actions/checkout@v4
70-
# - name: Update
71-
# run: sudo apt-get update
72-
# - name: Install Dependencies
73-
# run: sudo apt-get install -y lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3
74-
# - name: Install Python Libraries
75-
# run: sudo pip install pycryptodome
76-
# - name: Install Libgcrypt
77-
# run: >
78-
# curl
79-
# -LS https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.50.tar.bz2
80-
# -o /tmp/libgpg-error-1.50.tar.bz2
81-
# && tar -xjf /tmp/libgpg-error-1.50.tar.bz2 -C /tmp/
82-
# && cd /tmp/libgpg-error-1.50
83-
# && sudo ./configure
84-
# && sudo make install
85-
# && curl
86-
# -LS https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.11.0.tar.bz2
87-
# -o /tmp/libgcrypt-1.11.0.tar.bz2
88-
# && tar -xjf /tmp/libgcrypt-1.11.0.tar.bz2 -C /tmp/
89-
# && cd /tmp/libgcrypt-1.11.0
90-
# && sudo ./configure
91-
# && sudo make install
92-
# && sudo ldconfig
93-
# # End Container Setup
94-
95-
# - name: KMC Build Script
96-
# working-directory: ${{github.workspace}}
97-
# run: bash ${GITHUB_WORKSPACE}/support/scripts/build_kmc.sh
98-
99-
# - name: Code-Coverage
100-
# working-directory: ${{github.workspace}}
101-
# run: make gcov
102-
103-
# - name: Upload
104-
# uses: codecov/codecov-action@v4
105-
# env:
106-
# CODECOV_TOKEN: 71699f25-12a3-44a4-8a83-be777b9e577a
107-
# with:
108-
# files: 'coverage/*.c.gcov'
109-
# verbose: true
65+
kmc_build:
66+
# Container Setup
67+
runs-on: ubuntu-latest
68+
container:
69+
image: ivvitc/cryptolib:20250108
70+
steps:
71+
- uses: actions/checkout@v4
72+
with:
73+
repository: NASA-AMMOS/DCS
74+
path: DCS
75+
submodules: recursive
76+
- name: setup python
77+
uses: actions/setup-python@v5
78+
with:
79+
python-version: '3.11'
80+
- name: Set current branch
81+
run: echo "BRANCH_NAME=$(echo ${{ github.head_ref || github.ref_name }})" >> $GITHUB_ENV
82+
- name: Update
83+
run: apt-get update
84+
- name: Install Dependencies
85+
run: apt-get install -y libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3 openjdk-17-jdk openjdk-17-jre cmake swig maven podman default-jdk
86+
- name: Install Python Libraries
87+
run: |
88+
pip3 install --break-system-packages pycryptodome cffi invoke
89+
- name: update Cryptolib
90+
run: |
91+
cd DCS/ammos-cryptolib
92+
rm -rf CryptoLib
93+
git clone --single-branch --branch $BRANCH_NAME https://github.com/nasa/CryptoLib.git
94+
- name: add required jars
95+
run: |
96+
cd DCS/ammos-cryptolib/kmc_sdls/kmc_sdls_java/kmc_sdls_java_test
97+
curl -LS https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar -o ./junit-4.13.2.jar
98+
curl -LS https://repo1.maven.org/maven2/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar -o ./hamcrest-2.2.jar
99+
- name: build DCS
100+
run: |
101+
cd ./DCS
102+
export JAVA_HOME=/lib/jvm/java-17-openjdk-amd64
103+
./kmc-resources/scripts/build.sh
110104
111105
#
112106
# Wolf Build
@@ -155,9 +149,8 @@ jobs:
155149

156150
- name: Upload
157151
uses: codecov/codecov-action@v4
158-
env:
159-
CODECOV_TOKEN: 71699f25-12a3-44a4-8a83-be777b9e577a
160152
with:
153+
token: ${{ secrets.CODECOV_TOKEN }}
161154
files: 'coverage/*.c.gcov'
162155
verbose: true
163156

@@ -174,7 +167,7 @@ jobs:
174167
- name: Update
175168
run: yum update -y
176169
- name: Install Dependencies
177-
run: yum install -y --enablerepo=devel python3-pip python3-devel epel-release libcurl-devel git cmake gcc java-11-openjdk-devel openssl wget bzip2 ldconfig mariadb-devel mariadb-common mariadb-connector-c mariadb-connector-c-config mariadb-errmsg mariadb-gssapi-server
170+
run: yum install -y --enablerepo=devel python3-pip python3-devel epel-release libcurl-devel git cmake gcc java-11-openjdk-devel openssl wget bzip2 ldconfig mariadb-devel mariadb-common mariadb-connector-c mariadb-connector-c-config mariadb-errmsg mariadb-gssapi-server libasan
178171
# Might want to trim this down, but these dependencies should work for KMC
179172
- name: install lcov
180173
run: yum install -y --enablerepo=epel lcov
@@ -209,9 +202,8 @@ jobs:
209202

210203
- name: Upload
211204
uses: codecov/codecov-action@v4
212-
env:
213-
CODECOV_TOKEN: 71699f25-12a3-44a4-8a83-be777b9e577a
214205
with:
206+
token: ${{ secrets.CODECOV_TOKEN }}
215207
files: 'coverage/*.c.gcov'
216208
verbose: true
217209

@@ -243,8 +235,7 @@ jobs:
243235

244236
- name: Upload
245237
uses: codecov/codecov-action@v4
246-
env:
247-
CODECOV_TOKEN: 71699f25-12a3-44a4-8a83-be777b9e577a
248238
with:
239+
token: ${{ secrets.CODECOV_TOKEN }}
249240
files: 'coverage/*.c.gcov'
250241
verbose: true

.github/workflows/codeql.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
name: Analyze Build_Internal
2323
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
2424
container:
25-
image: ivvitc/cryptolib:20250102
25+
image: ivvitc/cryptolib:20250108
2626
permissions:
2727
# required for all workflows
2828
security-events: write
@@ -74,7 +74,7 @@ jobs:
7474
name: Analyze Build_Minimal
7575
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
7676
container:
77-
image: ivvitc/cryptolib:20250102
77+
image: ivvitc/cryptolib:20250108
7878
permissions:
7979
# required for all workflows
8080
security-events: write
@@ -126,7 +126,7 @@ jobs:
126126
name: Analyze Build_Wolf
127127
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
128128
container:
129-
image: ivvitc/cryptolib:20250102
129+
image: ivvitc/cryptolib:20250108
130130
permissions:
131131
# required for all workflows
132132
security-events: write
@@ -204,7 +204,7 @@ jobs:
204204
name: Analyze Build_RHEL
205205
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
206206
container:
207-
image: ivvitc/cryptolib:20250102
207+
image: ivvitc/cryptolib:20250108
208208
permissions:
209209
# required for all workflows
210210
security-events: write
@@ -256,7 +256,7 @@ jobs:
256256
name: Analyze Build_EP
257257
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
258258
container:
259-
image: ivvitc/cryptolib:20250102
259+
image: ivvitc/cryptolib:20250108
260260
permissions:
261261
# required for all workflows
262262
security-events: write

.github/workflows/cpp-linter.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@ name: cpp-linter
22

33
on:
44
pull_request:
5-
branches: [ main, dev ]
65

76
jobs:
8-
cpp-linter:
9-
permissions:
10-
pull-requests: write
11-
contents: write
12-
actions: write
7+
linter:
138
runs-on: ubuntu-latest
149
steps:
15-
- uses: actions/checkout@v4
16-
- uses: cpp-linter/cpp-linter-action@v2
17-
id: linter
10+
- name: Checkout Repository
11+
uses: actions/checkout@v4
12+
13+
- name: Install clang-format
14+
run: sudo apt-get update && sudo apt-get install -y clang-format
15+
16+
- name: Run Linter
17+
uses: DoozyX/clang-format-lint-action@v0.15
18+
with:
19+
source: '.'
20+
extensions: 'c,h'
21+
clangFormatVersion: 14
22+
style: file
23+
inplace: true
24+
25+
- name: Auto-Commit Formatting Changes
26+
uses: stefanzweifel/git-auto-commit-action@v5
1827
with:
19-
style: 'file'
20-
files-changed-only: false
21-
verbosity: 'info'
22-
step-summary: 'true'
23-
no-lgtm: 'false'
24-
passive-reviews: 'true'
25-
ignore: 'test/include/utest.h'
28+
commit_message: 'style: auto-format via clang-format'
29+
30+

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ __pycache__
1212
*.dat
1313
*.so
1414
build/
15+
build-*/
1516
venv
1617
vgcore*
1718
core.*
@@ -32,4 +33,10 @@ test/CMakeFiles/*
3233
Testing/Temporary/*
3334
docs/wiki/_build
3435
docs/wiki/_templates
35-
36+
support/fuzz/corpus/
37+
support/fuzz/output/
38+
support/scripts/src/*
39+
support/scripts/test/*
40+
support/scripts/bin/*
41+
support/scripts/CMakeFiles/*
42+
output/*

CMakeLists.txt

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
cmake_minimum_required(VERSION 3.14.0)
1919
project(crypto C)
2020

21+
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
22+
2123
#
2224
# CUSTOM PATH Definiton
2325
#
@@ -35,36 +37,59 @@ set(CRYPTO_CUSTOM_PATH_DEFAULT "../../crypto/custom")
3537
# For flags with the same prefix, one or more may be enabled
3638
#
3739
option(CODECOV "Code Coverage" OFF)
38-
option(CRYPTO_LIBGCRYPT "Cryptography Module - Libgcrypt" ON)
40+
option(CRYPTO_LIBGCRYPT "Cryptography Module - Libgcrypt" OFF)
3941
option(CRYPTO_KMC "Cryptography Module - KMC" OFF)
4042
option(CRYPTO_WOLFSSL "Cryptography Module - WolfSSL" OFF)
4143
option(CRYPTO_CUSTOM "Cryptography Module - CUSTOM" OFF)
4244
option(CRYPTO_CUSTOM_PATH "Cryptography Module - CUSTOM PATH" OFF)
4345
option(DEBUG "Debug" OFF)
46+
option(ENABLE_FUZZING "Enable fuzz testing" OFF)
4447
option(KEY_CUSTOM "Key Module - Custom" OFF)
4548
option(KEY_CUSTOM_PATH "Custom Key Path" OFF)
46-
option(KEY_INTERNAL "Key Module - Internal" ON)
49+
option(KEY_INTERNAL "Key Module - Internal" OFF)
4750
option(KEY_KMC "Key Module - KMC" OFF)
4851
option(MC_CUSTOM "Monitoring and Control - Custom" OFF)
4952
option(MC_CUSTOM_PATH "Custom Monitoring and Control path" OFF)
5053
option(MC_DISABLED "Monitoring and Control - Disabled" OFF)
51-
option(MC_INTERNAL "Monitoring and Control - Internal" ON)
54+
option(MC_INTERNAL "Monitoring and Control - Internal" OFF)
5255
option(SA_CUSTOM "Security Association - Custom" OFF)
5356
option(SA_CUSTOM_PATH "Custom Security Association Path" OFF)
54-
option(SA_INTERNAL "Security Association - Internal" ON)
57+
option(SA_INTERNAL "Security Association - Internal" OFF)
5558
option(SA_MARIADB "Security Association - MariaDB" OFF)
5659
option(SUPPORT "Support" OFF)
5760
option(SYSTEM_INSTALL "SystemInstall" OFF)
5861
option(TEST "Test" OFF)
59-
# option(TEST_ENC "Tests - Encryption" OFF)
6062
option(SA_FILE "Save Security Association to File" OFF)
6163
option(KEY_VALIDATION "Validate existance of key duplication" OFF)
62-
6364
OPTION(KMC_MDB_RH "KMC-MDB-RedHat-Integration-Testing" OFF) #Disabled by default, enable with: -DKMC_MDB_RH=ON
6465
OPTION(KMC_MDB_DB "KMC-MDB-Debian-Integration-Testing" OFF) #Disabled by default, enable with: -DKMC_MDB_DB=ON
65-
OPTION(KMC_CFFI_EXCLUDE "KMC-Exclude-Problematic-CFFI-Code" OFF) #Disabled by default, enable with: -DKMC_CFFI_EXCLUDE=ON
66-
6766
OPTION(CRYPTO_EPROC "Enables the building and use of Extended Procedures" OFF) #Disabled by default, enable with -DCRYPTO_EPROC=ON
67+
OPTION(STANDALONE_TCP "Enables TCP support for standalone" OFF)
68+
69+
OPTION(MAC_SIZE "The size of the max MAC buffer in bytes")
70+
OPTION(IV_SIZE "The size of the max IV buffer in bytes")
71+
Option(NUM_SA "The max number of SAs that will be used")
72+
Option(NUM_KEYS "The max number of keys that will be used")
73+
74+
#
75+
# Max Size Defines
76+
#
77+
if(NUM_SA)
78+
add_compile_definitions(NUM_SA=${NUM_SA})
79+
message(STATUS "NUM_SA set to: ${NUM_SA}")
80+
endif()
81+
if(MAC_SIZE)
82+
add_compile_definitions(MAC_SIZE=${MAC_SIZE})
83+
message(STATUS "MAC_SIZE set to: ${MAC_SIZE}")
84+
endif()
85+
if(IV_SIZE)
86+
add_compile_definitions(IV_SIZE=${IV_SIZE})
87+
message(STATUS "IV_SIZE set to: ${IV_SIZE}")
88+
endif()
89+
if(NUM_KEYS)
90+
add_compile_definitions(NUM_KEYS=${NUM_KEYS})
91+
message(STATUS "NUM_KEYS set to: ${NUM_KEYS}")
92+
endif()
6893

6994
#
7095
# Custom Module Paths
@@ -131,18 +156,15 @@ endif()
131156

132157
IF(KMC_MDB_RH)
133158
ADD_DEFINITIONS(-DKMC_MDB_RH)
134-
ADD_DEFINITIONS(-DKMC_CFFI_EXCLUDE)
135159
ENDIF(KMC_MDB_RH)
136160

137161
IF(KMC_MDB_DB)
138162
ADD_DEFINITIONS(-DKMC_MDB_DB)
139-
ADD_DEFINITIONS(-DKMC_CFFI_EXCLUDE)
140163
ENDIF(KMC_MDB_DB)
141164

142165
IF(CRYPTO_EPROC)
143166
ADD_DEFINITIONS(-DCRYPTO_EPROC)
144167
message(WARNING "Cryptolib Extended Procedures NOT complete. NOT Fully tested. Use at own risk!")
145-
146168
ENDIF(CRYPTO_EPROC)
147169

148170
if(SYSTEM_INSTALL)
@@ -170,7 +192,13 @@ endif()
170192
#
171193
# Project Specifics
172194
#
173-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -O0")
195+
if(ENABLE_FUZZING)
196+
# More permissive flags for fuzzing (afl compiler fails with -Werror for self-assign warnings)
197+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-self-assign -g -O0")
198+
else()
199+
# Stricter flags for normal builds (treat warnings as errors)
200+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -O0")
201+
endif()
174202

175203
include_directories(include)
176204
add_subdirectory(src)
@@ -182,3 +210,7 @@ endif()
182210
if(TEST)
183211
add_subdirectory(test)
184212
endif()
213+
214+
if(ENABLE_FUZZING)
215+
add_subdirectory(./support/fuzz)
216+
endif()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Build](https://github.com/nasa/CryptoLib/actions/workflows/build.yml/badge.svg)
22
[![CodeCov](https://codecov.io/gh/nasa/CryptoLib/branch/main/graph/badge.svg?token=KCOMCQO0ZU)](https://codecov.io/gh/nasa/CryptoLib)
3-
[![CodeQL Advanced](https://github.com/nasa/CryptoLib/actions/workflows/codeql.yml/badge.svg?branch=dev)](https://github.com/nasa/CryptoLib/actions/workflows/codeql.yml)
3+
[![CodeQL Advanced](https://github.com/nasa/CryptoLib/actions/workflows/codeql.yml/badge.svg)](https://github.com/nasa/CryptoLib/actions/workflows/codeql.yml)
44

55
![CryptoLib logo Final All orange](https://github.com/user-attachments/assets/fc02870b-e2d2-4577-83c2-78985d5fbdd6)
66

0 commit comments

Comments
 (0)