Skip to content

Commit 8cff198

Browse files
Merge branch 'main' into jdb
2 parents f36b4ae + 7466d79 commit 8cff198

37 files changed

+1106
-177
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.6.0
4+
5+
### Minor
6+
* [PR 433:](https://github.com/corretto/amazon-corretto-crypto-provider/pull/433) Add build option for exposing self-test failure messages
7+
38
## 2.5.0
49

510
### Minor
@@ -13,6 +18,7 @@
1318
* [PR 426:](https://github.com/corretto/amazon-corretto-crypto-provider/pull/426) Add null check to AesCbcSpi
1419
* [PR 427:](https://github.com/corretto/amazon-corretto-crypto-provider/pull/427) Add provider info string
1520
* [PR 432:](https://github.com/corretto/amazon-corretto-crypto-provider/pull/432) Support Ed25519ph, bump AWS-LC to v1.46.0yy
21+
* [PR 434:](https://github.com/corretto/amazon-corretto-crypto-provider/pull/434) Encode ML-DSA priv key as seed, expose MlDsaUtils
1622

1723
## 2.4.1
1824

CMakeLists.txt

+25-4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ set(TEST_DATA_DIR ${PROJECT_SOURCE_DIR}/test-data/ CACHE STRING "Path to directo
4242
set(ORIG_SRCROOT ${PROJECT_SOURCE_DIR} CACHE STRING "Path to root of original package")
4343
set(PROVIDER_VERSION_STRING "" CACHE STRING "X.Y.Z formatted version of the provider")
4444
set(EXPERIMENTAL_FIPS NO CACHE BOOL "Determines if this build is for FIPS mode with extra features from a non-FIPS branch of AWS-LC.")
45+
set(FIPS_SELF_TEST_SKIP_ABORT NO CACHE BOOL "Determines whether ACCP throws exceptions on self-test failure, or AWS-LC aborts. If NO, AWS-LC aborts. If YES, ACCP will provide error messages.")
4546
set(FIPS NO CACHE BOOL "Determine if this build is for FIPS mode")
4647
set(ALWAYS_ALLOW_EXTERNAL_LIB NO CACHE BOOL "Always permit tests to load ACCP shared objects from the library path")
4748
set(AWS_LC_VERSION_STRING "" CACHE STRING "Git version of AWS-LC used in this build")
@@ -51,6 +52,10 @@ if (EXPERIMENTAL_FIPS)
5152
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEXPERIMENTAL_FIPS_BUILD")
5253
endif()
5354

55+
if (FIPS_SELF_TEST_SKIP_ABORT)
56+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIPS_SELF_TEST_SKIP_ABORT")
57+
endif()
58+
5459
if (USE_CLANG_TIDY)
5560
# https://releases.llvm.org/9.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/list.html
5661
# https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics
@@ -161,10 +166,12 @@ add_custom_command(
161166
# detected by CMake.
162167
if (${CMAKE_VERSION} VERSION_LESS "3.12.0")
163168
file(GLOB_RECURSE ACCP_SRC "src/com/amazon/corretto/crypto/provider/*.java")
169+
file(GLOB_RECURSE ACCP_UTILS_SRC "src/com/amazon/corretto/crypto/utils/*.java")
164170
else()
165171
file(GLOB_RECURSE ACCP_SRC CONFIGURE_DEPENDS "src/com/amazon/corretto/crypto/provider/*.java")
172+
file(GLOB_RECURSE ACCP_UTILS_SRC CONFIGURE_DEPENDS "src/com/amazon/corretto/crypto/utils/*.java")
166173
endif()
167-
set(ACCP_SRC ${ACCP_SRC} ${GENERATED_JAVA_SRC})
174+
set(ACCP_SRC ${ACCP_SRC} ${ACCP_UTILS_SRC} ${GENERATED_JAVA_SRC})
168175

169176
set(BASE_JAVA_COMPILE_FLAGS ${CMAKE_JAVA_COMPILE_FLAGS} -h "${JNI_HEADER_DIR}" -Werror -Xlint)
170177

@@ -292,6 +299,7 @@ set(C_SRC
292299
csrc/util.cpp
293300
csrc/util_class.cpp
294301
csrc/fips_kat_self_test.cpp
302+
csrc/fips_status.cpp
295303
${JNI_HEADER_DIR}/generated-headers.h)
296304

297305
if(FIPS)
@@ -502,7 +510,7 @@ if(NOT ENABLE_NATIVE_TEST_HOOKS)
502510
CHECK_LINKER_FLAG_SUPPORT(USE_VERSION_SCRIPT "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/final-link.version")
503511

504512
# This does the same thing as the version script, but works on Darwin platforms
505-
CHECK_LINKER_FLAG_SUPPORT(USE_EXPORTED_SYMBOL "-Wl,-exported_symbol '-Wl,_Java_*' -Wl,-exported_symbol '-Wl,_JNI_*'")
513+
CHECK_LINKER_FLAG_SUPPORT(USE_EXPORTED_SYMBOL "-Wl,-exported_symbol '-Wl,_Java_*' '-Wl,_AWS_LC_fips_failure_callback' -Wl,-exported_symbol '-Wl,_JNI_*'")
506514
endif()
507515

508516
# Attempt to drop unused sections; the idea here is to exclude unreferenced
@@ -679,6 +687,7 @@ add_custom_target(check-junit
679687
--select-package=com.amazon.corretto.crypto.provider.test
680688
--exclude-package=com.amazon.corretto.crypto.provider.test.integration
681689
--exclude-classname=com.amazon.corretto.crypto.provider.test.SecurityManagerTest
690+
--exclude-classname=com.amazon.corretto.crypto.provider.test.FipsStatusTest
682691

683692
DEPENDS accp-jar tests-jar)
684693

@@ -700,6 +709,15 @@ add_custom_target(check-junit-SecurityManager
700709

701710
DEPENDS accp-jar tests-jar)
702711

712+
add_custom_target(check-junit-FipsStatus
713+
COMMAND ${TEST_JAVA_EXECUTABLE}
714+
${TEST_RUNNER_ARGUMENTS}
715+
--select-class=com.amazon.corretto.crypto.provider.test.AesTest # Force loading ciphers
716+
--select-class=com.amazon.corretto.crypto.provider.test.SHA1Test # Force loading digests
717+
--select-class=com.amazon.corretto.crypto.provider.test.FipsStatusTest
718+
719+
DEPENDS accp-jar tests-jar)
720+
703721
add_custom_target(check-with-jni-flag
704722
COMMAND ${TEST_JAVA_EXECUTABLE}
705723
-Xcheck:jni
@@ -747,6 +765,7 @@ add_custom_target(check-junit-extra-checks
747765
${TEST_RUNNER_ARGUMENTS}
748766
--select-package=com.amazon.corretto.crypto.provider.test
749767
--exclude-package=com.amazon.corretto.crypto.provider.test.integration
768+
--exclude-classname=com.amazon.corretto.crypto.provider.test.FipsStatusTest
750769
--exclude-classname=com.amazon.corretto.crypto.provider.test.SecurityManagerTest
751770

752771
DEPENDS accp-jar tests-jar)
@@ -843,7 +862,8 @@ add_custom_target(check-junit-edKeyFactory
843862

844863
DEPENDS accp-jar tests-jar)
845864

846-
set(check_targets check-recursive-init
865+
set(check_targets
866+
check-recursive-init
847867
check-install-via-properties
848868
check-install-via-properties-with-debug
849869
check-junit
@@ -852,7 +872,8 @@ set(check_targets check-recursive-init
852872
check-junit-AesLazy
853873
check-junit-AesEager
854874
check-junit-DifferentTempDir
855-
check-junit-edKeyFactory)
875+
check-junit-edKeyFactory
876+
check-junit-FipsStatus)
856877

857878
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
858879
set(check_targets ${check_targets} check-with-jni-flag)

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ ACCP did not track a FIPS branch/release version of AWS-LC until ACCP v2.3.0. Be
133133
| 2.3.3 | 1.17.0 | 2.0.2 |
134134
| 2.4.0 | 1.30.1 | 2.0.13 |
135135
| 2.4.1 | 1.30.1 | 2.0.13 |
136-
| 2.5.0 | 1.46.0 | 3.0.0 |
136+
| 2.5.0 | 1.47.0 | 3.0.0 |
137+
| 2.6.0 | 1.48.2 | 3.0.0 |
137138

138139
Notable differences between ACCP and ACCP-FIPS:
139140
* ACCP uses [the latest release of AWS-LC](https://github.com/aws/aws-lc/releases), whereas, ACCP-FIPS uses [the fips-2022-11-02 branch of AWS-LC](https://github.com/aws/aws-lc/tree/fips-2022-11-02).

aws-lc

build.gradle

+42-17
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ plugins {
88
id 'maven-publish'
99
id 'signing'
1010
id "com.diffplug.spotless" version "6.18.0"
11-
id "com.google.osdetector" version "1.7.0"
11+
id "com.google.osdetector" version "1.7.3"
1212
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
1313
}
1414

1515
group = 'software.amazon.cryptools'
1616
version = '2.5.0'
17-
ext.awsLcMainTag = 'v1.46.0'
17+
ext.awsLcMainTag = 'v1.48.2'
1818
ext.awsLcFipsTag = 'AWS-LC-FIPS-3.0.0'
1919
ext.isExperimentalFips = Boolean.getBoolean('EXPERIMENTAL_FIPS')
2020
ext.isFips = ext.isExperimentalFips || Boolean.getBoolean('FIPS')
@@ -32,6 +32,16 @@ if (System.properties["AWSLC_GITVERSION"]) {
3232
}
3333

3434
ext.isLegacyBuild = Boolean.getBoolean('LEGACY_BUILD')
35+
ext.allowFipsTestBreak = Boolean.getBoolean('ALLOW_FIPS_TEST_BREAK')
36+
ext.isFipsSelfTestFailureSkipAbort = Boolean.getBoolean('FIPS_SELF_TEST_SKIP_ABORT')
37+
38+
if (allowFipsTestBreak && !isFips) {
39+
throw new GradleException("ALLOW_FIPS_TEST_BREAK can only be set if FIPS is also set to true")
40+
}
41+
42+
if (isFipsSelfTestFailureSkipAbort && !isFips) {
43+
throw new GradleException("FIPS_SELF_TEST_SKIP_ABORT can only be set if FIPS is also set to true")
44+
}
3545

3646
ext.lcovIgnore = System.properties['LCOV_IGNORE']
3747
if (ext.lcovIgnore == null) {
@@ -78,6 +88,7 @@ spotless {
7888
target 'csrc/*'
7989
licenseHeaderFile 'build-tools/license-headers/LicenseHeader.h'
8090
clangFormat(clangFormatVersion)
91+
toggleOffOn()
8192
}
8293
}
8394
}
@@ -90,13 +101,11 @@ spotless {
90101
*/
91102
def getClangFormatVersion() {
92103
def version_command = 'clang-format --version'
93-
def shell_output = new ByteArrayOutputStream()
94-
exec {
104+
def version_exec = providers.exec {
95105
commandLine "bash", "-c", version_command
96-
standardOutput = shell_output
97-
ignoreExitValue true
106+
ignoreExitValue = true
98107
}
99-
def shell_output_string = shell_output.toString().trim()
108+
def shell_output_string = version_exec.standardOutput.asText.get().trim()
100109
def matcher = shell_output_string =~ /version ([\w\.-]+)/
101110
if (matcher.find()) {
102111
return matcher.group(1)
@@ -114,13 +123,11 @@ if (System.properties["AWSLC_SRC_DIR"]) {
114123

115124
// Execute cmake3 command to see if it exists. Mainly to support AL2.
116125
def detect_cmake3 = {
117-
def exec_cmake3 = exec {
126+
def cmake3_exec = providers.exec {
118127
executable "bash" args "-l", "-c", 'command -v cmake3'
119-
ignoreExitValue true
120-
standardOutput = new ByteArrayOutputStream()
121-
errorOutput = standardOutput
128+
ignoreExitValue = true
122129
}
123-
if(exec_cmake3.getExitValue() == 0) {
130+
if (cmake3_exec.result.get().exitValue == 0) {
124131
return "cmake3"
125132
}
126133
return "cmake"
@@ -249,12 +256,27 @@ task buildAwsLc {
249256
args '-DCMAKE_BUILD_TYPE=RelWithDebInfo'
250257
args "-DCMAKE_INSTALL_PREFIX=${sharedObjectOutDir}"
251258
args "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
252-
259+
def cmakeCFlags = ""
253260

254261
if (isFips) {
262+
println "Building AWS-LC in FIPS mode"
255263
args '-DFIPS=1'
256264
}
257265

266+
if (allowFipsTestBreak) {
267+
println "Building AWS-LC with hooks to break FIPS tests"
268+
cmakeCFlags += '-DBORINGSSL_FIPS_BREAK_TESTS '
269+
}
270+
271+
if (isFipsSelfTestFailureSkipAbort) {
272+
println "Building AWS-LC to enable CPU jitter sampling when seeding its DRBG"
273+
args '-DENABLE_FIPS_ENTROPY_CPU_JITTER=ON'
274+
println "Building AWS-LC to call callback instead of aborting on self-test failure"
275+
cmakeCFlags += '-DAWSLC_FIPS_FAILURE_CALLBACK '
276+
}
277+
278+
args "-DCMAKE_C_FLAGS='${cmakeCFlags}'"
279+
258280
args '.'
259281
}
260282
}
@@ -341,6 +363,11 @@ task executeCmake(type: Exec) {
341363
if (isExperimentalFips) {
342364
args '-DEXPERIMENTAL_FIPS=ON'
343365
}
366+
367+
if (isFipsSelfTestFailureSkipAbort) {
368+
args '-DFIPS_SELF_TEST_SKIP_ABORT=ON'
369+
}
370+
344371
if (prebuiltJar != null) {
345372
args '-DSIGNED_JAR=' + prebuiltJar
346373
println "Using SIGNED_JAR=${prebuiltJar}"
@@ -478,8 +505,8 @@ task unit_tests(type: Copy) {
478505
test.dependsOn unit_tests
479506

480507
task singleTest(type: Exec) {
481-
group 'Verification'
482-
description 'Pass in the test class using -DSINGLE_TEST=${fully_qualified_test_class}'
508+
group = 'Verification'
509+
description = 'Pass in the test class using -DSINGLE_TEST=${fully_qualified_test_class}'
483510
dependsOn executeCmake
484511
workingDir "${buildDir}/cmake"
485512
// Our cmake doesn't properly react java source changes, but it will rebuild them if the jars are missing
@@ -552,11 +579,9 @@ task coverage_cmake(type: Exec) {
552579
if (isExperimentalFips) {
553580
args '-DEXPERIMENTAL_FIPS=ON'
554581
}
555-
556582
if (System.properties['JAVA_HOME'] != null) {
557583
args '-DJAVA_HOME=' + System.properties['JAVA_HOME']
558584
}
559-
560585
if (System.properties['SINGLE_TEST'] != null) {
561586
args '-DSINGLE_TEST=' + System.properties['SINGLE_TEST']
562587

csrc/auto_free.h

+5
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class OPENSSL_buffer_auto {
117117
{
118118
}
119119

120+
explicit OPENSSL_buffer_auto(size_t buf_size)
121+
: buf((unsigned char*)OPENSSL_malloc(buf_size))
122+
{
123+
}
124+
120125
virtual ~OPENSSL_buffer_auto() { OPENSSL_free(buf); }
121126

122127
operator unsigned char*() { return buf; }

csrc/ed_gen.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
using namespace AmazonCorrettoCryptoProvider;
99

10-
void generateEdKey(EVP_PKEY_auto& key)
10+
static void generateEdKey(EVP_PKEY_auto& key)
1111
{
1212
EVP_PKEY_CTX_auto ctx = EVP_PKEY_CTX_auto::from(EVP_PKEY_CTX_new_id(EVP_PKEY_ED25519, nullptr));
1313
CHECK_OPENSSL(ctx.isInitialized());
1414
CHECK_OPENSSL(EVP_PKEY_keygen_init(ctx) == 1);
15-
CHECK_OPENSSL(EVP_PKEY_keygen(ctx, key.getAddressOfPtr()));
15+
CHECK_OPENSSL(EVP_PKEY_keygen(ctx, key.getAddressOfPtr()) == 1);
1616
}
1717

1818
JNIEXPORT jlong JNICALL Java_com_amazon_corretto_crypto_provider_EdGen_generateEvpEdKey(JNIEnv* pEnv, jclass)

0 commit comments

Comments
 (0)