Skip to content

Commit

Permalink
Github issue #359
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhosv committed Feb 6, 2024
1 parent 0fdb5f7 commit 3df220a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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
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

0 comments on commit 3df220a

Please sign in to comment.