-/* Header for class com_wolfssl_wolfcrypt_EccKey */
-
-#ifndef _Included_com_wolfssl_wolfcrypt_EccKey
-#define _Included_com_wolfssl_wolfcrypt_EccKey
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: com_wolfssl_wolfcrypt_EccKey
- * Method: EccPublicKeyToDer
- * Signature: (J)[B
- */
-JNIEXPORT jbyteArray JNICALL Java_com_wolfssl_wolfcrypt_EccKey_EccPublicKeyToDer
- (JNIEnv *, jobject, jlong);
-
-/*
- * Class: com_wolfssl_wolfcrypt_EccKey
- * Method: EccPrivateKeyToDer
- * Signature: (J)[B
- */
-JNIEXPORT jbyteArray JNICALL Java_com_wolfssl_wolfcrypt_EccKey_EccPrivateKeyToDer
- (JNIEnv *, jobject, jlong);
-
-/*
- * Class: com_wolfssl_wolfcrypt_EccKey
- * Method: EccPrivateKeyToPKCS8
- * Signature: (J)[B
- */
-JNIEXPORT jbyteArray JNICALL Java_com_wolfssl_wolfcrypt_EccKey_EccPrivateKeyToPKCS8
- (JNIEnv *, jobject, jlong);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/platform/android_aosp/wolfssljni/Android.mk b/platform/android_aosp/wolfssljni/Android.mk
index 803020be..4b33e748 100644
--- a/platform/android_aosp/wolfssljni/Android.mk
+++ b/platform/android_aosp/wolfssljni/Android.mk
@@ -32,9 +32,9 @@ include $(CLEAR_VARS)
LOCAL_CFLAGS += $(native_cflags)
LOCAL_CFLAGS:= -DHAVE_FFDHE_2048 -DWOLFSSL_TLS13 -DHAVE_TLS_EXTENSIONS -DHAVE_SUPPORTED_CURVES -DTFM_TIMING_RESISTANT -DECC_TIMING_RESISTANT -DWC_RSA_BLINDING -DHAVE_AESGCM -DWOLFSSL_SHA512 -DWOLFSSL_SHA384 -DHAVE_HKDF -DNO_DSA -DHAVE_ECC -DTFM_ECC256 -DECC_SHAMIR -DWC_RSA_PSS -DWOLFSSL_BASE64_ENCODE -DNO_RC4 -DWOLFSSL_SHA224 -DWOLFSSL_SHA3 -DHAVE_POLY1305 -DHAVE_ONE_TIME_AUTH -DHAVE_CHACHA -DHAVE_HASHDRBG -DHAVE_TLS_EXTENSIONS -DHAVE_SUPPORTED_CURVES -DHAVE_EXTENDED_MASTER -DHAVE_SNI -DHAVE_ALPN -DWOLFSSL_JNI -DWOLFSSL_DTLS -DOPENSSL_EXTRA -DOPENSSL_ALL -DHAVE_EX_DATA -DHAVE_CRL -DHAVE_OCSP -DHAVE_CRL_MONITOR -DPERSIST_SESSION_CACHE -DPERSIST_CERT_CACHE -DATOMIC_USER -DHAVE_PK_CALLBACKS -DWOLFSSL_CERT_EXT -DWOLFSSL_CERT_GEN -DHAVE_ENCRYPT_THEN_MAC -DNO_MD4 -DWOLFSSL_ENCRYPTED_KEYS -DUSE_FAST_MATH -DNO_DES3 -DKEEP_PEER_CERT -DSESSION_CERTS -DHAVE_SESSION_TICKET -DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 -Os -fomit-frame-pointer
LOCAL_SRC_FILES := \
- native/com_wolfssl_wolfcrypt_ECC.c \
- native/com_wolfssl_wolfcrypt_EccKey.c \
- native/com_wolfssl_wolfcrypt_RSA.c \
+ native/com_wolfssl_WolfCryptECC.c \
+ native/com_wolfssl_WolfCryptEccKey.c \
+ native/com_wolfssl_WolfCryptRSA.c \
native/com_wolfssl_WolfSSL.c \
native/com_wolfssl_WolfSSLCertificate.c \
native/com_wolfssl_WolfSSLCertManager.c \
diff --git a/scripts/infer.sh b/scripts/infer.sh
index c7f3c3d6..97bc30d2 100755
--- a/scripts/infer.sh
+++ b/scripts/infer.sh
@@ -63,11 +63,12 @@ infer --fail-on-issue run -- javac \
src/java/com/wolfssl/WolfSSLSession.java \
src/java/com/wolfssl/WolfSSLTls13SecretCallback.java \
src/java/com/wolfssl/WolfSSLVerifyCallback.java \
+ src/java/com/wolfssl/WolfSSLVerifyDecryptCallback.java \
src/java/com/wolfssl/WolfSSLX509Name.java \
src/java/com/wolfssl/WolfSSLX509StoreCtx.java \
- src/java/com/wolfssl/wolfcrypt/ECC.java \
- src/java/com/wolfssl/wolfcrypt/EccKey.java \
- src/java/com/wolfssl/wolfcrypt/RSA.java \
+ src/java/com/wolfssl/WolfCryptECC.java \
+ src/java/com/wolfssl/WolfCryptEccKey.java \
+ src/java/com/wolfssl/WolfCryptRSA.java \
src/java/com/wolfssl/provider/jsse/WolfSSLAuthStore.java \
src/java/com/wolfssl/provider/jsse/WolfSSLContext.java \
src/java/com/wolfssl/provider/jsse/WolfSSLCustomUser.java \
diff --git a/src/java/com/wolfssl/wolfcrypt/ECC.java b/src/java/com/wolfssl/WolfCryptECC.java
similarity index 87%
rename from src/java/com/wolfssl/wolfcrypt/ECC.java
rename to src/java/com/wolfssl/WolfCryptECC.java
index fde31d83..aef2d8da 100644
--- a/src/java/com/wolfssl/wolfcrypt/ECC.java
+++ b/src/java/com/wolfssl/WolfCryptECC.java
@@ -1,4 +1,4 @@
-/* ECC.java
+/* WolfCryptECC.java
*
* Copyright (C) 2006-2025 wolfSSL Inc.
*
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
-package com.wolfssl.wolfcrypt;
+package com.wolfssl;
import java.nio.ByteBuffer;
@@ -29,12 +29,17 @@
* written to be used with this package's example ECC public key callbacks.
* Usage can be found in examples/Client.java and examples/Server.java.
*
+ * This class was previously named 'ECC' and was renamed to 'WolfCryptECC'
+ * to avoid naming conflicts with the 'ECC' class in the wolfCrypt JNI/JCE
+ * package. Apart from the name change, the class behavior and use
+ * remains the same.
+ *
* @author wolfSSL
*/
-public class ECC {
+public class WolfCryptECC {
- /** Default ECC constructor */
- public ECC() { }
+ /** Default WolfCryptECC constructor */
+ public WolfCryptECC() { }
/**
* ECC verify. Wraps native wc_ecc_verify_hash() to verify ECDSA
diff --git a/src/java/com/wolfssl/wolfcrypt/EccKey.java b/src/java/com/wolfssl/WolfCryptEccKey.java
similarity index 87%
rename from src/java/com/wolfssl/wolfcrypt/EccKey.java
rename to src/java/com/wolfssl/WolfCryptEccKey.java
index 0f4e082d..07d124c2 100644
--- a/src/java/com/wolfssl/wolfcrypt/EccKey.java
+++ b/src/java/com/wolfssl/WolfCryptEccKey.java
@@ -1,4 +1,4 @@
-/* EccKey.java
+/* WolfCryptEccKey.java
*
* Copyright (C) 2006-2025 wolfSSL Inc.
*
@@ -19,16 +19,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
-package com.wolfssl.wolfcrypt;
+package com.wolfssl;
import com.wolfssl.WolfSSLException;
/**
* Wraps a native ecc_key structure pointer.
*
+ * This class was previously named 'EccKey' and was renamed to 'WolfCryptEccKey'
+ * to avoid naming conflicts with the wolfCrypt JNI/JCE package name space.
+ * Apart from the name change, the class behavior and use remains the same.
+ *
* @author wolfSSL
*/
-public class EccKey {
+public class WolfCryptEccKey {
/* internal ecc_key structure pointer */
private long eccKeyPtr;
@@ -37,13 +41,13 @@ public class EccKey {
private boolean active = false;
/**
- * Create new EccKey object, wrapping native ecc_key with pointer
+ * Create new WolfCryptEccKey object, wrapping native ecc_key with pointer
* keyPtr.
*
* @param keyPtr pointer to native ecc_key structure
* @throws com.wolfssl.WolfSSLException if key object creation failed
*/
- public EccKey(long keyPtr) throws WolfSSLException {
+ public WolfCryptEccKey(long keyPtr) throws WolfSSLException {
if (keyPtr == 0) {
throw new WolfSSLException("NULL ecc_key pointer not allowed");
} else {
@@ -119,5 +123,5 @@ protected void finalize() throws Throwable
super.finalize();
}
-} /* end EccKey */
+} /* end WolfCryptEccKey */
diff --git a/src/java/com/wolfssl/wolfcrypt/RSA.java b/src/java/com/wolfssl/WolfCryptRSA.java
similarity index 90%
rename from src/java/com/wolfssl/wolfcrypt/RSA.java
rename to src/java/com/wolfssl/WolfCryptRSA.java
index 0c9753b4..98c55a92 100644
--- a/src/java/com/wolfssl/wolfcrypt/RSA.java
+++ b/src/java/com/wolfssl/WolfCryptRSA.java
@@ -1,4 +1,4 @@
-/* RSA.java
+/* WolfCryptRSA.java
*
* Copyright (C) 2006-2025 wolfSSL Inc.
*
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
-package com.wolfssl.wolfcrypt;
+package com.wolfssl;
import java.nio.ByteBuffer;
@@ -29,12 +29,17 @@
* written to be used with this package's example RSA public key callbacks.
* Usage can be found in examples/Client.java and examples/Server.java.
*
+ * This class was previously named 'RSA' and was renamed to 'WolfCryptRSA'
+ * to avoid naming conflicts with the 'RSA' class in the wolfCrypt JNI/JCE
+ * package. Apart from the name change, the class behavior and use
+ * remains the same.
+ *
* @author wolfSSL
*/
-public class RSA {
+public class WolfCryptRSA {
- /** Default RSA constructor */
- public RSA() { }
+ /** Default WolfCryptRSA constructor */
+ public WolfCryptRSA() { }
/**
* RSA sign, wraps native wolfCrypt operation.
diff --git a/src/java/com/wolfssl/WolfSSL.java b/src/java/com/wolfssl/WolfSSL.java
index c0c8380e..98adadab 100644
--- a/src/java/com/wolfssl/WolfSSL.java
+++ b/src/java/com/wolfssl/WolfSSL.java
@@ -394,17 +394,19 @@ public enum TLS_VERSION {
/** TLS 1.3 secret callback function failure */
public static final int TLS13_SECRET_CB_E = -438;
- /* hmac codes, from wolfssl/wolfcrypt/hmac.h */
+ /* HMAC codes, from wolfssl/wolfcrypt/hmac.h. These values
+ * are set via JNI calls in static class block since they can change
+ * depending on if wolfSSL is a FIPS or non-FIPS build. */
/** Md5 HMAC type */
- public static final int MD5 = 0;
+ public static int MD5;
/** SHA-1 HMAC type */
- public static final int SHA = 1;
+ public static int SHA;
/** SHA2-256 HMAC type */
- public static final int SHA256 = 2;
+ public static int SHA256;
/** SHA2-512 HMAC type */
- public static final int SHA512 = 4;
+ public static int SHA512;
/** SHA2-384 HMAC type */
- public static final int SHA384 = 5;
+ public static int SHA384;
/* key types */
/** DSA key type */
@@ -579,7 +581,7 @@ public WolfSSL() throws WolfSSLException {
+ ret);
}
- /* initialize enum values */
+ /* initialize cipher enum values */
wolfssl_aes = getBulkCipherAlgorithmEnumAES();
wolfssl_cipher_null = getBulkCipherAlgorithmEnumNULL();
wolfssl_rc4 = getBulkCipherAlgorithmEnumRC4();
@@ -590,6 +592,13 @@ public WolfSSL() throws WolfSSLException {
wolfssl_aes_gcm = getBulkCipherAlgorithmEnumAESGCM();
wolfssl_aes_ccm = getBulkCipherAlgorithmEnumAESCCM();
+ /* initialize cipher enum values */
+ MD5 = getHmacEnumMD5();
+ SHA = getHmacEnumSHA1();
+ SHA256 = getHmacEnumSHA256();
+ SHA384 = getHmacEnumSHA384();
+ SHA512 = getHmacEnumSHA512();
+
/* initialize TLS 1.3 secret callback ID enums */
CLIENT_EARLY_TRAFFIC_SECRET =
getTls13SecretEnum_CLIENT_EARLY_TRAFFIC_SECRET();
@@ -631,6 +640,12 @@ public WolfSSL() throws WolfSSLException {
static native int getBulkCipherAlgorithmEnumCHACHA();
static native int getBulkCipherAlgorithmEnumCAMELLIA();
+ static native int getHmacEnumMD5();
+ static native int getHmacEnumSHA1();
+ static native int getHmacEnumSHA256();
+ static native int getHmacEnumSHA384();
+ static native int getHmacEnumSHA512();
+
static native int getTls13SecretEnum_CLIENT_EARLY_TRAFFIC_SECRET();
static native int getTls13SecretEnum_CLIENT_HANDSHAKE_TRAFFIC_SECRET();
static native int getTls13SecretEnum_SERVER_HANDSHAKE_TRAFFIC_SECRET();
@@ -931,7 +946,7 @@ protected static byte[] fileToBytes(File file)
/**
* Tests if native wolfSSL has been compiled with HAVE_SECRET_CALLBACK
- * default. If defined, will compile in APIs to support SSL/TLS secret
+ * If defined, will compile in APIs to support SSL/TLS secret
* callback support.
*
* @return true if enabled, otherwise false if HAVE_SECRET_CALLBACK
@@ -939,6 +954,14 @@ protected static byte[] fileToBytes(File file)
*/
public static native boolean secretCallbackEnabled();
+ /**
+ * Tests if native wolfSSL has been compiled with HAVE_ENCRYPT_THEN_MAC.
+ *
+ * @return true if enabled, otherwise false if HAVE_ENCRYPT_THEN_MAC
+ * has not been defined.
+ */
+ public static native boolean encryptThenMacEnabled();
+
/* ---------------- native SSL/TLS version functions ---------------- */
/**
diff --git a/src/java/com/wolfssl/WolfSSLContext.java b/src/java/com/wolfssl/WolfSSLContext.java
index 24f8e44f..f2906ed1 100644
--- a/src/java/com/wolfssl/WolfSSLContext.java
+++ b/src/java/com/wolfssl/WolfSSLContext.java
@@ -23,7 +23,7 @@
import java.util.Arrays;
import java.nio.ByteBuffer;
-import com.wolfssl.wolfcrypt.EccKey;
+import com.wolfssl.WolfCryptEccKey;
import com.wolfssl.WolfSSLDebug;
import com.wolfssl.WolfSSLException;
import com.wolfssl.WolfSSLJNIException;
@@ -48,9 +48,10 @@ public class WolfSSLContext {
/* user-registered DTLS cookie generation callback */
private WolfSSLGenCookieCallback internCookieCb = null;
- /* user-registered MAC/encrypt and decrypt/verify callbacks */
+ /* user-registered MAC/encrypt, dec/verify, verify/dec callbacks */
private WolfSSLMacEncryptCallback internMacEncryptCb = null;
private WolfSSLDecryptVerifyCallback internDecryptVerifyCb = null;
+ private WolfSSLVerifyDecryptCallback internVerifyDecryptCb = null;
/* user-registered ECC sign/verify callbacks */
private WolfSSLEccSignCallback internEccSignCb = null;
@@ -147,6 +148,11 @@ synchronized WolfSSLDecryptVerifyCallback getInternDecryptVerifyCb() {
return internDecryptVerifyCb;
}
+ /* used by JNI native verify/decrypt Cb */
+ synchronized WolfSSLVerifyDecryptCallback getInternVerifyDecryptCb() {
+ return internVerifyDecryptCb;
+ }
+
/* this will be registered with native wolfSSL library */
private int internalIORecvCallback(WolfSSLSession ssl, byte[] buf, int sz)
{
@@ -210,6 +216,20 @@ private int internalDecryptVerifyCallback(WolfSSLSession ssl,
return ret;
}
+ private int internalVerifyDecryptCallback(WolfSSLSession ssl,
+ ByteBuffer decOut, byte[] decIn, long decSz, int content,
+ int macVerify, long[] padSz)
+ {
+ int ret;
+
+ /* call user-registered verify/decrypt method */
+ ret = internVerifyDecryptCb.verifyDecryptCallback(ssl, decOut,
+ decIn, decSz, content, macVerify, padSz,
+ ssl.getVerifyDecryptCtx());
+
+ return ret;
+ }
+
private int internalEccSignCallback(WolfSSLSession ssl, ByteBuffer in,
long inSz, ByteBuffer out, long[] outSz, ByteBuffer keyDer,
long keySz)
@@ -237,7 +257,7 @@ private int internalEccVerifyCallback(WolfSSLSession ssl, ByteBuffer sig,
}
private int internalEccSharedSecretCallback(WolfSSLSession ssl,
- EccKey otherKey, ByteBuffer pubKeyDer, long[] pubKeyDerSz,
+ WolfCryptEccKey otherKey, ByteBuffer pubKeyDer, long[] pubKeyDerSz,
ByteBuffer out, long[] outSz, int side)
{
int ret;
@@ -385,6 +405,7 @@ private native int useCertificateChainBufferFormat(long ctx, byte[] in,
private native int setOCSPOverrideUrl(long ctx, String url);
private native void setMacEncryptCb(long ctx);
private native void setDecryptVerifyCb(long ctx);
+ private native void setVerifyDecryptCb(long ctx);
private native void setEccSignCb(long ctx);
private native void setEccVerifyCb(long ctx);
private native void setEccSharedSecretCb(long ctx);
@@ -1583,6 +1604,7 @@ WolfSSLDebug.INFO, getContextPtr(),
* @throws IllegalStateException WolfSSLContext has been freed
* @throws WolfSSLJNIException Internal JNI error
* @see #setDecryptVerifyCb(WolfSSLDecryptVerifyCallback)
+ * @see #setVerifyDecryptCb(WolfSSLVerifyDecryptCallback)
*/
public synchronized void setMacEncryptCb(WolfSSLMacEncryptCallback callback)
throws IllegalStateException, WolfSSLJNIException {
@@ -1626,6 +1648,7 @@ WolfSSLDebug.INFO, getContextPtr(),
* @throws IllegalStateException WolfSSLContext has been freed
* @throws WolfSSLJNIException Internal JNI error
* @see #setMacEncryptCb(WolfSSLMacEncryptCallback)
+ * @see #setVerifyDecryptCb(WolfSSLVerifyDecryptCallback)
*/
public synchronized void setDecryptVerifyCb(
WolfSSLDecryptVerifyCallback callback)
@@ -1646,6 +1669,51 @@ WolfSSLDebug.INFO, getContextPtr(),
}
}
+ /**
+ * Allows caller to set the Atomic Record Processing Verify/Decrypt
+ * Callback.
+ * The callback should return 0 for success, or a negative value for
+ * an error. The ssl and ctx pointers are available
+ * for the users convenience. decOut is the output buffer
+ * where the result of the decryption should be stored. decIn
+ * is the encrypted input buffer and decInSz notes the size of the
+ * buffer. context and macVerify are needed for
+ * setTlsHmacInner() and can be passed along as-is. padSz is
+ * an output variable, where the first element in the array should be set
+ * with the total value of the padding. That is, the mac size plus any
+ * padding and pad bytes. An example callback can be found in
+ * examples/MyVerifyDecryptCallback.java.
+ *
+ * @param callback object to be registered as the verify/decrypt
+ * callback for the WolfSSL context. The signature of
+ * this object and corresponding method must match that
+ * as shown in
+ * WolfSSLVerifyDecryptCallback.java, inside
+ * verifyDecryptCallback().
+ * @throws IllegalStateException WolfSSLContext has been freed
+ * @throws WolfSSLJNIException Internal JNI error
+ * @see #setMacEncryptCb(WolfSSLMacEncryptCallback)
+ * @see #setDecryptVerifyCb(WolfSSLDecryptVerifyCallback)
+ */
+ public synchronized void setVerifyDecryptCb(
+ WolfSSLVerifyDecryptCallback callback)
+ throws IllegalStateException, WolfSSLJNIException {
+
+ confirmObjectIsActive();
+
+ synchronized (ctxLock) {
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
+ WolfSSLDebug.INFO, getContextPtr(),
+ "entered setVerifyDecryptCb(" + callback + ")");
+
+ /* set verify/decrypt callback */
+ internVerifyDecryptCb = callback;
+
+ /* register internal callback with native library */
+ setVerifyDecryptCb(getContextPtr());
+ }
+ }
+
/**
* Allows caller to set the Public Key Callback for ECC Signing.
* The callback should return 0 for success or a negative value for an
diff --git a/src/java/com/wolfssl/WolfSSLEccSharedSecretCallback.java b/src/java/com/wolfssl/WolfSSLEccSharedSecretCallback.java
index b69aa067..4cbfebe6 100644
--- a/src/java/com/wolfssl/WolfSSLEccSharedSecretCallback.java
+++ b/src/java/com/wolfssl/WolfSSLEccSharedSecretCallback.java
@@ -22,7 +22,7 @@
package com.wolfssl;
import java.nio.ByteBuffer;
-import com.wolfssl.wolfcrypt.EccKey;
+import com.wolfssl.WolfCryptEccKey;
/**
* wolfSSL ECC Shared Secret Callback Interface.
@@ -62,8 +62,8 @@ public interface WolfSSLEccSharedSecretCallback {
* @return 0 upon success,
* otherwise a negative value on error.
*/
- public int eccSharedSecretCallback(WolfSSLSession ssl, EccKey otherKey,
- ByteBuffer pubKeyDer, long[] pubKeyDerSz, ByteBuffer out,
- long[] outSz, int side, Object ctx);
+ public int eccSharedSecretCallback(WolfSSLSession ssl,
+ WolfCryptEccKey otherKey, ByteBuffer pubKeyDer, long[] pubKeyDerSz,
+ ByteBuffer out, long[] outSz, int side, Object ctx);
}
diff --git a/src/java/com/wolfssl/WolfSSLSession.java b/src/java/com/wolfssl/WolfSSLSession.java
index da2f8db1..987a29c8 100644
--- a/src/java/com/wolfssl/WolfSSLSession.java
+++ b/src/java/com/wolfssl/WolfSSLSession.java
@@ -52,6 +52,7 @@ public class WolfSSLSession {
private Object genCookieCtx;
private Object macEncryptCtx;
private Object decryptVerifyCtx;
+ private Object verifyDecryptCtx;
private Object eccSignCtx;
private Object eccVerifyCtx;
private Object eccSharedSecretCtx;
@@ -199,6 +200,10 @@ synchronized Object getDecryptVerifyCtx() {
return this.decryptVerifyCtx;
}
+ synchronized Object getVerifyDecryptCtx() {
+ return this.verifyDecryptCtx;
+ }
+
synchronized Object getEccSignCtx() {
return this.eccSignCtx;
}
@@ -3579,6 +3584,30 @@ public void setDecryptVerifyCtx(Object ctx)
}
}
+ /**
+ * Allows caller to set the Atomic User Record Processing Verify/Decrypt
+ * Callback Context.
+ *
+ * @param ctx context object to be registered with the SSL session's
+ * verify/decrypt method.
+ * @throws IllegalStateException WolfSSLContext has been freed
+ * @throws WolfSSLJNIException Internal JNI error
+ * @see WolfSSLContext#setVerifyDecryptCb(WolfSSLVerifyDecryptCallback)
+ */
+ public void setVerifyDecryptCtx(Object ctx)
+ throws IllegalStateException, WolfSSLJNIException {
+
+ confirmObjectIsActive();
+
+ synchronized (sslLock) {
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
+ WolfSSLDebug.INFO, this.sslPtr,
+ "entered setVerifyDecryptCtx(" + ctx + ")");
+
+ verifyDecryptCtx = ctx;
+ }
+ }
+
/**
* Allows caller to set the Public Key ECC Signing Callback Context.
*
diff --git a/src/java/com/wolfssl/WolfSSLVerifyDecryptCallback.java b/src/java/com/wolfssl/WolfSSLVerifyDecryptCallback.java
new file mode 100644
index 00000000..87015c42
--- /dev/null
+++ b/src/java/com/wolfssl/WolfSSLVerifyDecryptCallback.java
@@ -0,0 +1,67 @@
+/* WolfSSLVerifyDecryptCallback.java
+ *
+ * Copyright (C) 2006-2025 wolfSSL Inc.
+ *
+ * This file is part of wolfSSL.
+ *
+ * wolfSSL is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * wolfSSL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
+ */
+
+package com.wolfssl;
+
+import java.nio.ByteBuffer;
+
+/**
+ * wolfSSL Verify/Decrypt callback interface.
+ * This interface specifies how applicaitons should implement the verify/decrypt
+ * callback class to be used by wolfSSL when using atomic record layer callbacks.
+ * Note that this is different than the decrypt/verify callback. For that, see
+ * WolfSSLDecryptVerifyCallback.
+ *
+ * After implementing this interface, it should be passed as a parameter
+ * to the {@link WolfSSLContext#setVerifyDecryptCb(WolfSSLVerifyDecryptCallback)
+ * WolfSSLContext.setVerifyDecryptCb()} method to be registered with the
+ * native wolfSSL library.
+ *
+ * @author wolfSSL
+ */
+public interface WolfSSLVerifyDecryptCallback {
+
+ /**
+ * Atomic record layer verify/decrypt callback method.
+ * This method acts as the verify/decrypt callback to be used with
+ * the wolfSSL atomic record layer processing.
+ *
+ * @param ssl the current SSL session object from which the
+ * callback was initiated.
+ * @param decOut output buffer where the result of the decryption
+ * should be stored.
+ * @param decIn the encrypted input buffer
+ * @param decSz the size of the input buffer, decIn
+ * @param content used with setTlsHmacInner(), the type of message
+ * @param macVerify used with setTlsHmacInner(), specifies whether this
+ * is a verification of a peer message.
+ * @param padSz output variable that should be set with the total
+ * value of the padding. When setting this, the first
+ * element of the the array should be used.
+ * @param ctx user-registered decrypt/verify context
+ * @return 0 upon success,
+ * otherwise a negative value on failure.
+ */
+ public int verifyDecryptCallback(WolfSSLSession ssl, ByteBuffer decOut,
+ byte[] decIn, long decSz, int content, int macVerify, long[] padSz,
+ Object ctx);
+}
+
diff --git a/src/test/com/wolfssl/test/WolfCryptECCTest.java b/src/test/com/wolfssl/test/WolfCryptECCTest.java
index 77a613ca..129b0d4d 100644
--- a/src/test/com/wolfssl/test/WolfCryptECCTest.java
+++ b/src/test/com/wolfssl/test/WolfCryptECCTest.java
@@ -27,25 +27,25 @@
import static org.junit.Assert.*;
import com.wolfssl.WolfSSLException;
-import com.wolfssl.wolfcrypt.ECC;
+import com.wolfssl.WolfCryptECC;
public class WolfCryptECCTest {
- ECC ecc;
+ WolfCryptECC ecc;
@Test
public void testECC() throws WolfSSLException {
- System.out.println("ECC Class");
+ System.out.println("WolfCryptECC Class");
test_ECC_new();
}
public void test_ECC_new() {
- System.out.print("\tECC()");
- ecc = new ECC();
- System.out.println("\t\t\t\t... passed");
+ System.out.print("\tWolfCryptECC()");
+ ecc = new WolfCryptECC();
+ System.out.println("\t\t\t... passed");
}
}
diff --git a/src/test/com/wolfssl/test/WolfCryptRSATest.java b/src/test/com/wolfssl/test/WolfCryptRSATest.java
index b4141420..4321f9d8 100644
--- a/src/test/com/wolfssl/test/WolfCryptRSATest.java
+++ b/src/test/com/wolfssl/test/WolfCryptRSATest.java
@@ -27,25 +27,25 @@
import static org.junit.Assert.*;
import com.wolfssl.WolfSSLException;
-import com.wolfssl.wolfcrypt.RSA;
+import com.wolfssl.WolfCryptRSA;
public class WolfCryptRSATest {
- RSA rsa;
+ WolfCryptRSA rsa;
@Test
public void testRSA() throws WolfSSLException {
- System.out.println("RSA Class");
+ System.out.println("WolfCryptRSA Class");
test_RSA_new();
}
public void test_RSA_new() {
- System.out.print("\tRSA()");
- rsa = new RSA();
- System.out.println("\t\t\t\t... passed");
+ System.out.print("\tWolfCryptRSA()");
+ rsa = new WolfCryptRSA();
+ System.out.println("\t\t\t... passed");
}
}