This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git


The following commit(s) were added to refs/heads/master by this push:
     new c6322c0  Revert 46c7441 - fix initialisation circularity
c6322c0 is described below

commit c6322c0659ea6f283cd5f24cc55eaeb34ff4bc62
Author: Sebb <[email protected]>
AuthorDate: Wed Jun 29 13:17:02 2022 +0100

    Revert 46c7441 - fix initialisation circularity
    
    Ensure we use the same class name for the property
---
 .../org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java    |  5 ++++-
 .../org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java    |  9 ++++++---
 .../java/org/apache/commons/crypto/jna/OpenSslNativeJna.java  | 11 ++++-------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java 
b/src/main/java/org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java
index 7cfef2f..2823d6e 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSsl10XNativeJna.java
@@ -36,7 +36,10 @@ class OpenSsl10XNativeJna {
         boolean ok = false;
         Throwable thrown = null;
         try {
-            Native.register(OpenSslNativeJna.CRYPTO_LIBRARY);
+            final String libName = System.getProperty(Crypto.CONF_PREFIX + 
OpenSslNativeJna.class.getSimpleName(),
+                    "crypto");
+            OpenSslJna.debug("Native.register('%s')%n", libName);
+            Native.register(libName);
             ok = true;
         } catch (final Exception | UnsatisfiedLinkError e) {
             thrown = e;
diff --git 
a/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java 
b/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java
index 19c1e09..a68a7e3 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java
@@ -36,7 +36,10 @@ class OpenSsl11XNativeJna {
         boolean ok = false;
         Throwable thrown = null;
         try {
-            Native.register(OpenSslNativeJna.CRYPTO_LIBRARY);
+            final String libName = System.getProperty(Crypto.CONF_PREFIX + 
OpenSslNativeJna.class.getSimpleName(),
+                    "crypto");
+            OpenSslJna.debug("Native.register('%s')%n", libName);
+            Native.register(libName);
             ok = true;
         } catch (final Exception | UnsatisfiedLinkError e) {
             thrown = e;
@@ -67,7 +70,7 @@ class OpenSsl11XNativeJna {
     /**
      * Generates a human-readable string representing the error code e.
      *
-     * @see <a 
href="https://www.openssl.org/docs/man1.1.1/man3/ERR_error_string.html";>ERR_error_string</a>
+     * @see <a 
href="https://www.openssl.org/docs/man1.1.0/man3/ERR_error_string.html";>ERR_error_string</a>
      *
      * @param err
      *            the error code
@@ -143,7 +146,7 @@ class OpenSsl11XNativeJna {
      * @return 1 for success and 0 for failure.
      */
     public static native int EVP_CipherInit_ex(PointerByReference ctx, 
PointerByReference cipher,
-            PointerByReference impl, byte[] key, byte[] iv, int enc);
+            PointerByReference impl, byte key[], byte iv[], int enc);
 
     /**
      * Continues a multiple-part encryption/decryption operation.
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java 
b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java
index 78c44c7..035f2f9 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java
@@ -42,16 +42,13 @@ class OpenSslNativeJna {
     public static final long VERSION_1_0_X = 0x10000000;
     public static final long VERSION_1_1_X = 0x10100000;
 
-    // Pass the library alreaded to OpenSsl10XNativeJna and 
OpenSsl11XNativeJna 
-    static final NativeLibrary CRYPTO_LIBRARY;
     static {
-        final String library_name = System.getProperty(Crypto.CONF_PREFIX + 
OpenSslNativeJna.class.getSimpleName(), "crypto");
-        OpenSslJna.debug("NativeLibrary.getInstance('%s')%n", library_name);
-        CRYPTO_LIBRARY = NativeLibrary.getInstance(library_name);
-        OpenSslJna.debug("%s%n", CRYPTO_LIBRARY.toString()); // show what was 
loaded
+        final String libraryName = System.getProperty(Crypto.CONF_PREFIX + 
OpenSslNativeJna.class.getSimpleName(), "crypto");
+        OpenSslJna.debug("NativeLibrary.getInstance('%s')%n", libraryName);
+        final NativeLibrary crypto = NativeLibrary.getInstance(libraryName);
         Function version = null;
         try {
-            version = CRYPTO_LIBRARY.getFunction("SSLeay");
+            version = crypto.getFunction("SSLeay");
         } catch (final UnsatisfiedLinkError e) {
             // Swallow the Error.
         }

Reply via email to