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

Github issue #359 #361

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,15 @@ add_custom_target(check-junit-AesGcmEager

DEPENDS accp-jar tests-jar)

add_custom_target(check-junit-DifferentTempDir
Copy link
Contributor

@geedo0 geedo0 Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not convinced that this is a high signal test. There's no assertion anywhere that a different tmpdir was actually used. Just that these two tests (also, just 1 is sufficient) succeeded when this property was set. I'm inclined to drop this test target.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll drop it in the next patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the PR already has the two approvals, I'll drop this in another PR.

COMMAND ${TEST_JAVA_EXECUTABLE}
-Dcom.amazon.corretto.crypto.provider.tmpdir=${CMAKE_BINARY_DIR}/tmpdir
${TEST_RUNNER_ARGUMENTS}
--select-class=com.amazon.corretto.crypto.provider.test.AesTest
--select-class=com.amazon.corretto.crypto.provider.test.AesGcmKatTest

DEPENDS accp-jar tests-jar)

add_custom_target(check-junit-extra-checks
COMMAND ${TEST_JAVA_EXECUTABLE}
-Dcom.amazon.corretto.crypto.provider.extrachecks=ALL
Expand Down Expand Up @@ -768,7 +777,8 @@ add_custom_target(check
check-junit-SecurityManager
check-external-lib
check-junit-AesGcmLazy
check-junit-AesGcmEager)
check-junit-AesGcmEager
check-junit-DifferentTempDir)

if(ENABLE_NATIVE_TEST_HOOKS)
add_custom_target(check-keyutils
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ Thus, these should all be set on the JVM command line using `-D`.
encryption/decryption operations would not require allocation and release of `EVP_CIPHER_CTX`
structure. A common use case would be having long-running threads that each would get its
own instance of `Cipher` class.
* `com.amazon.corretto.crypto.provider.tmpdir`
Allows one to set the temporary directory used by ACCP when loading native libraries.
If this system property is not defined, the system property `java.io.tmpdir` is used.

# License
This library is licensed under the Apache 2.0 license although portions of this
Expand Down
5 changes: 4 additions & 1 deletion src/com/amazon/corretto/crypto/provider/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ final class Loader {
private static final String TEMP_DIR_PREFIX = "amazonCorrettoCryptoProviderNativeLibraries.";
private static final String JNI_LIBRARY_NAME = "amazonCorrettoCryptoProvider";
private static final String PROPERTY_VERSION_STR = "versionStr";

private static final String PROPERTY_TMP_DIR = "tmpdir";
private static final String[] JAR_RESOURCES = {JNI_LIBRARY_NAME};
private static final Pattern TEST_FILENAME_PATTERN =
Pattern.compile("[-a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)*");
Expand Down Expand Up @@ -431,7 +433,8 @@ private static byte[] bootstrapRng(int numBytes) throws IOException {
* SecureRandom, which results in a circular dependency.
*/
private static synchronized Path createPrivateTmpDir(final String prefix) throws IOException {
final Path systemTempDir = Paths.get(System.getProperty("java.io.tmpdir"));
final Path systemTempDir =
Paths.get(getProperty(PROPERTY_TMP_DIR, System.getProperty("java.io.tmpdir")));

final int RETRY_LIMIT = 10;
int attempt = 0;
Expand Down
Loading