diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f47b01338..4c7a09c8b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -100,6 +100,7 @@
Bump commons-parent from 56 to 64 #225.
Bump com.sun.xml.bind:jaxb-impl from 2.3.7 to 2.3.8.
+ Implement OpenSSL_version_num for JNA
Cipher and Random Factory classes don't include JNA
Add support for Linux-riscv64 #264
Allow override of SSL library name for Windows
diff --git a/src/main/java/org/apache/commons/crypto/jna/LibreSsl20XNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/LibreSsl20XNativeJna.java
index 5deb4c867..d0a3ef164 100644
--- a/src/main/java/org/apache/commons/crypto/jna/LibreSsl20XNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/LibreSsl20XNativeJna.java
@@ -286,7 +286,6 @@ public static native int EVP_CipherUpdate(PointerByReference ctx, ByteBuffer bou
public static native PointerByReference RAND_SSLeay();
/**
- * TODO (does not appear to be used yet)
* @return OPENSSL_VERSION_NUMBER which is a numeric release version identifier
*/
public static native NativeLong SSLeay();
@@ -429,6 +428,11 @@ public String _OpenSSL_version(final int i) {
return SSLeay_version(i);
}
+ @Override
+ public long _OpenSSL_version_num() {
+ return SSLeay().longValue();
+ }
+
@Override
public int _RAND_bytes(final ByteBuffer buf, final int length) {
return RAND_bytes(buf, length) ;
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 e70971f52..6a6ef980d 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java
@@ -239,6 +239,11 @@ public static native int EVP_CipherUpdate(PointerByReference ctx, ByteBuffer bou
*/
public static native String OpenSSL_version(int type);
+ /**
+ * @return OPENSSL_VERSION_NUMBER which is a numeric release version identifier
+ */
+ public static native NativeLong OpenSSL_version_num();
+
/**
* Generates random data
*
@@ -385,6 +390,11 @@ public String _OpenSSL_version(final int i) {
return OpenSSL_version(i);
}
+ @Override
+ public long _OpenSSL_version_num() {
+ return OpenSSL_version_num().longValue();
+ }
+
@Override
public int _RAND_bytes(final ByteBuffer buf, final int length) {
return RAND_bytes(buf, length) ;
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSsl30XNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSsl30XNativeJna.java
index 5db9d4f4b..85aa17b3a 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSsl30XNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSsl30XNativeJna.java
@@ -241,6 +241,11 @@ public static native int EVP_CipherUpdate(PointerByReference ctx, ByteBuffer bou
*/
public static native String OpenSSL_version(int type);
+ /**
+ * @return OPENSSL_VERSION_NUMBER which is a numeric release version identifier
+ */
+ public static native NativeLong OpenSSL_version_num();
+
/**
* Generates random data
*
@@ -387,6 +392,11 @@ public String _OpenSSL_version(final int i) {
return OpenSSL_version(i);
}
+ @Override
+ public long _OpenSSL_version_num() {
+ return OpenSSL_version_num().longValue();
+ }
+
@Override
public int _RAND_bytes(final ByteBuffer buf, final int length) {
return RAND_bytes(buf, length) ;
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslInterfaceNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslInterfaceNativeJna.java
index a9c895fc5..caf190b8f 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslInterfaceNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslInterfaceNativeJna.java
@@ -89,6 +89,8 @@ int _EVP_CipherUpdate(final PointerByReference context, final ByteBuffer outBuff
String _OpenSSL_version(final int i);
+ long _OpenSSL_version_num();
+
int _RAND_bytes(final ByteBuffer buf, final int length);
PointerByReference _RAND_get_rand_method();
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java
index bccfe8275..ed8b5f2be 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java
@@ -106,25 +106,15 @@ public static void main(final String[] args) throws Throwable {
System.err.flush(); // helpful for stack traces to not mix in other output.
throw initialisationError; // propagate to make error obvious
}
+ info("OpenSSL library loaded OK, version: 0x%s", Long.toHexString(OpenSslNativeJna.OpenSSL_version_num()));
for (int i = 0; i <= Utils.OPENSSL_VERSION_MAX_INDEX; i++) {
- String data = OpenSSLVersion(i);
+ String data = OpenSslNativeJna.OpenSSLVersion(i);
if (!"not available".equals(data)) {
info("OpenSSLVersion(%d): %s", i, data);
}
}
}
- /**
- * Retrieves version/build information about OpenSSL library.
- *
- * @param type type can be OPENSSL_VERSION, OPENSSL_CFLAGS, OPENSSL_BUILT_ON...
- * @return A pointer to a constant string describing the version of the
- * OpenSSL library or giving information about the library build.
- */
- static String OpenSSLVersion(final int type) {
- return OpenSslNativeJna.OpenSSLVersion(type);
- }
-
/**
* Constructs a new instance.
*
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 fb8fdacf5..3d78aebd4 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java
@@ -200,6 +200,10 @@ public static String OpenSSLVersion(final int i) {
return JnaImplementation._OpenSSL_version(i);
}
+ public static long OpenSSL_version_num() {
+ return JnaImplementation._OpenSSL_version_num();
+ }
+
public static int RAND_bytes(final ByteBuffer buf, final int length) {
return JnaImplementation._RAND_bytes(buf, length);
}