Skip to content
Draft
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
15 changes: 5 additions & 10 deletions src/java/com/wolfssl/WolfSSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,10 @@ public WolfSSL() throws WolfSSLException {
getTls13SecretEnum_CLIENT_HANDSHAKE_TRAFFIC_SECRET();
SERVER_HANDSHAKE_TRAFFIC_SECRET =
getTls13SecretEnum_SERVER_HANDSHAKE_TRAFFIC_SECRET();
CLIENT_TRAFFIC_SECRET =
getTls13SecretEnum_CLIENT_TRAFFIC_SECRET();
SERVER_TRAFFIC_SECRET =
getTls13SecretEnum_SERVER_TRAFFIC_SECRET();
EARLY_EXPORTER_SECRET =
getTls13SecretEnum_EARLY_EXPORTER_SECRET();
EXPORTER_SECRET =
getTls13SecretEnum_EXPORTER_SECRET();
CLIENT_TRAFFIC_SECRET = getTls13SecretEnum_CLIENT_TRAFFIC_SECRET();
SERVER_TRAFFIC_SECRET = getTls13SecretEnum_SERVER_TRAFFIC_SECRET();
EARLY_EXPORTER_SECRET = getTls13SecretEnum_EARLY_EXPORTER_SECRET();
EXPORTER_SECRET = getTls13SecretEnum_EXPORTER_SECRET();

this.active = true;

Expand Down Expand Up @@ -783,8 +779,7 @@ public static void loadLibrary() throws UnsatisfiedLinkError {

int fipsLoaded = 0;

String skipLoad =
System.getProperty("wolfssl.skipLibraryLoad");
String skipLoad = System.getProperty("wolfssl.skipLibraryLoad");
if (skipLoad != null && skipLoad.equalsIgnoreCase("true")) {
/* User will load native libraries manually */
libraryLoadSkipped = true;
Expand Down
9 changes: 3 additions & 6 deletions src/java/com/wolfssl/WolfSSLCRL.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ private static Asn1TimeData buildAsn1TimeData(Date date) {
boolean useUtcTime = (year >= ASN1_UTC_YEAR_MIN &&
year <= ASN1_UTC_YEAR_MAX);

String pattern = useUtcTime ? "yyMMddHHmmss'Z'" :
"yyyyMMddHHmmss'Z'";
String pattern = useUtcTime ? "yyMMddHHmmss'Z'" : "yyyyMMddHHmmss'Z'";
int type = useUtcTime ? ASN_UTC_TIME : ASN_GENERALIZED_TIME;

SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US);
Expand Down Expand Up @@ -160,8 +159,7 @@ public WolfSSLCRL() throws WolfSSLException {
this.weOwnCrlPtr = true;

WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, crlPtr,
() -> "creating new WolfSSLCRL");
WolfSSLDebug.INFO, crlPtr, () -> "creating new WolfSSLCRL");

synchronized (stateLock) {
this.active = true;
Expand Down Expand Up @@ -646,8 +644,7 @@ public byte[] getSignature() {

synchronized (crlLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.crlPtr,
() -> "entered getSignature()");
WolfSSLDebug.INFO, this.crlPtr, () -> "entered getSignature()");

return X509_CRL_get_signature(this.crlPtr);
}
Expand Down
6 changes: 2 additions & 4 deletions src/java/com/wolfssl/WolfSSLCertificate.java
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,7 @@ public void setAuthorityKeyIdEx(WolfSSLCertificate issuer)
() -> "entering setAuthorityKeyIdEx(issuerPtr=" +
issuerX509Ptr + ")");

ret = X509_set_authority_key_id_ex(this.x509Ptr,
issuerX509Ptr);
ret = X509_set_authority_key_id_ex(this.x509Ptr, issuerX509Ptr);
}

if (ret != WolfSSL.SSL_SUCCESS) {
Expand Down Expand Up @@ -1238,8 +1237,7 @@ public void addAltNameIP(String ipAddress)
throws IllegalStateException, WolfSSLException {

if (ipAddress == null || ipAddress.isEmpty()) {
throw new WolfSSLException(
"IP address must not be null or empty");
throw new WolfSSLException("IP address must not be null or empty");
}

addAltName(ipAddress, WolfSSL.ASN_IP_TYPE);
Expand Down
9 changes: 3 additions & 6 deletions src/java/com/wolfssl/WolfSSLContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ private int internalIORecvCallback(WolfSSLSession ssl, byte[] buf, int sz)
int ret;

/* call user-registered recv method */
ret = internRecvCb.receiveCallback(ssl, buf, sz,
ssl.getIOReadCtx());
ret = internRecvCb.receiveCallback(ssl, buf, sz, ssl.getIOReadCtx());

return ret;
}
Expand All @@ -166,8 +165,7 @@ private int internalIOSendCallback(WolfSSLSession ssl, byte[] buf, int sz)
int ret;

/* call user-registered recv method */
ret = internSendCb.sendCallback(ssl, buf, sz,
ssl.getIOWriteCtx());
ret = internSendCb.sendCallback(ssl, buf, sz, ssl.getIOWriteCtx());

return ret;
}
Expand Down Expand Up @@ -319,8 +317,7 @@ private int internalRsaDecCallback(WolfSSLSession ssl, ByteBuffer in,
}

private long internalPskClientCallback(WolfSSLSession ssl, String hint,
StringBuffer identity, long idMaxLen, byte[] key,
long keyMaxLen)
StringBuffer identity, long idMaxLen, byte[] key, long keyMaxLen)
{
long ret;

Expand Down
3 changes: 1 addition & 2 deletions src/java/com/wolfssl/WolfSSLDebug.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public class WolfSSLDebug {
* com.wolfssl.jni - JNI layer logging
* com.wolfssl.jsse - JSSE layer logging
*/
private static final Logger jniLogger =
Logger.getLogger("com.wolfssl.jni");
private static final Logger jniLogger = Logger.getLogger("com.wolfssl.jni");
private static final Logger jsseLogger =
Logger.getLogger("com.wolfssl.jsse");

Expand Down
3 changes: 1 addition & 2 deletions src/java/com/wolfssl/WolfSSLIOSendCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public interface WolfSSLIOSendCallback {
* codes, see the default EmbedSend() function in
* wolfssl_package/src/io.c
*/
public int sendCallback(WolfSSLSession ssl, byte[] buf, int sz,
Object ctx);
public int sendCallback(WolfSSLSession ssl, byte[] buf, int sz, Object ctx);
}

3 changes: 1 addition & 2 deletions src/java/com/wolfssl/WolfSSLPskClientCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public interface WolfSSLPskClientCallback {
* @return length of key in octets or 0 for error
*/
public long pskClientCallback(WolfSSLSession ssl, String hint,
StringBuffer identity, long idMaxLen, byte[] key,
long keyMaxLen);
StringBuffer identity, long idMaxLen, byte[] key, long keyMaxLen);
}

33 changes: 11 additions & 22 deletions src/java/com/wolfssl/WolfSSLSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,7 @@ private int internalIOSSLSendCallback(WolfSSLSession ssl,
}

private long internalPskClientCallback(WolfSSLSession ssl, String hint,
StringBuffer identity, long idMaxLen, byte[] key,
long keyMaxLen)
StringBuffer identity, long idMaxLen, byte[] key, long keyMaxLen)
{
/* call user-registered PSK client callback method */
return internPskClientCb.pskClientCallback(ssl, hint, identity,
Expand Down Expand Up @@ -638,8 +637,7 @@ private native int useCertificateBuffer(long ssl, byte[] in, long sz,
int format);
private native int usePrivateKeyBuffer(long ssl, byte[] in, long sz,
int format);
private native int useCertificateChainBuffer(long ssl, byte[] in,
long sz);
private native int useCertificateChainBuffer(long ssl, byte[] in, long sz);
private native int useCertificateChainBufferFormat(
long ssl, byte[] in, long sz, int format);
private native int setGroupMessages(long ssl);
Expand Down Expand Up @@ -1798,8 +1796,7 @@ public void freeSSL()
}

WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered freeSSL()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered freeSSL()");

/* free native resources */
freeSSL(this.sslPtr);
Expand Down Expand Up @@ -4007,8 +4004,7 @@ public byte[] getMacSecret(int verify)

synchronized (sslLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered getMacSecret()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered getMacSecret()");

return getMacSecret(this.sslPtr, verify);
}
Expand Down Expand Up @@ -4129,8 +4125,7 @@ public int getKeySize() throws IllegalStateException {

synchronized (sslLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered getKeySize()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered getKeySize()");

return getKeySize(this.sslPtr);
}
Expand Down Expand Up @@ -4282,8 +4277,7 @@ public int getHmacSize() throws IllegalStateException {

synchronized (sslLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered getHmacSize()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered getHmacSize()");

return getHmacSize(this.sslPtr);
}
Expand Down Expand Up @@ -4949,8 +4943,7 @@ public long getOptions()

synchronized (sslLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered getOptions()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered getOptions()");

return getOptions(this.sslPtr);
}
Expand Down Expand Up @@ -5777,8 +5770,7 @@ public void keepArrays()

synchronized (sslLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered keepArrays()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered keepArrays()");

keepArrays(this.sslPtr);
}
Expand Down Expand Up @@ -5854,8 +5846,7 @@ public synchronized byte[] sessionToDer()
confirmObjectIsActive();
synchronized (sslLock) {
WolfSSLDebug.log(WolfSSLSession.class, WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered sessionToDer()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered sessionToDer()");
long sessPtr = this.getSession();
return sessionToDerNative(sessPtr);
}
Expand Down Expand Up @@ -5957,8 +5948,7 @@ public int rehandshake() throws IllegalStateException {

synchronized (sslLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered rehandshake()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered rehandshake()");

return rehandshake(this.sslPtr);
}
Expand All @@ -5976,8 +5966,7 @@ public int getShutdown() throws IllegalStateException {

synchronized (sslLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.sslPtr,
() -> "entered getShutdown()");
WolfSSLDebug.INFO, this.sslPtr, () -> "entered getShutdown()");

ret = getShutdown(this.sslPtr);

Expand Down
6 changes: 2 additions & 4 deletions src/java/com/wolfssl/WolfSSLX509Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ public synchronized String getSurname() {
confirmObjectIsActive();

WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.x509NamePtr,
() -> "entered getSurname()");
WolfSSLDebug.INFO, this.x509NamePtr, () -> "entered getSurname()");

return this.surname;
}
Expand Down Expand Up @@ -577,8 +576,7 @@ public synchronized String getUserId() {
confirmObjectIsActive();

WolfSSLDebug.log(getClass(), WolfSSLDebug.Component.JNI,
WolfSSLDebug.INFO, this.x509NamePtr,
() -> "entered getUserId()");
WolfSSLDebug.INFO, this.x509NamePtr, () -> "entered getUserId()");

return this.userId;
}
Expand Down
9 changes: 3 additions & 6 deletions src/java/com/wolfssl/provider/jsse/WolfSSLAuthStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ else if (!sessionCipherSuiteAvailable(
ses.setValid(true); /* new sessions marked as valid */

ses.isFromTable = false;
ses.setPseudoSessionId(
Integer.toString(ssl.hashCode()).getBytes());
ses.setPseudoSessionId(Integer.toString(ssl.hashCode()).getBytes());
}
else {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
Expand Down Expand Up @@ -544,8 +543,7 @@ private void printSessionStoreStatus() {
}

synchronized (storeLock) {
Collection<WolfSSLImplementSSLSession> values =
store.values();
Collection<WolfSSLImplementSSLSession> values = store.values();

WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
() -> "SessionStore Status : (" + this +
Expand Down Expand Up @@ -758,8 +756,7 @@ protected void updateTimeouts(int in, int side) {
diff = (now - current.creation.getTime()) / 1000;

if (diff < 0) {
/* session is from the future ... */ //@TODO

/* session is from the future ... @TODO */
}

if (in > 0 && diff > in) {
Expand Down
9 changes: 3 additions & 6 deletions src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,7 @@ else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP &&
if (this.ssl.dtls() == 1) {
int pending = this.ssl.pending();
if (pending > 0) {
status =
SSLEngineResult.Status.
status = SSLEngineResult.Status.
BUFFER_OVERFLOW;
}
}
Expand All @@ -1344,8 +1343,7 @@ else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP &&
* time. */
synchronized (ioLock) {
if (this.handshakeFinished &&
(ssl.getError(0) == 0) &&
!this.sessionStored) {
(ssl.getError(0) == 0) && !this.sessionStored) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
() -> "calling engineHelper.saveSession()");
int ret2 = this.engineHelper.saveSession();
Expand Down Expand Up @@ -2259,8 +2257,7 @@ protected synchronized int internalSendCb(ByteBuffer in, int sz) {
}
byte[] newBuf = new byte[newSz];
System.arraycopy(this.internalIOSendBuf, 0,
newBuf, 0,
this.internalIOSendBufOffset);
newBuf, 0, this.internalIOSendBufOffset);
this.internalIOSendBuf = newBuf;
this.internalIOSendBufSz = newSz;
}
Expand Down
18 changes: 6 additions & 12 deletions src/java/com/wolfssl/provider/jsse/WolfSSLEngineHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ private void getSystemAndSecurityProperties() {
checkBooleanProperty("jsse.enableSNIExtension", true);
this.jdkTlsTrustNameService =
checkBooleanProperty("jdk.tls.trustNameService", false);
this.wolfjsseAutoSni =
checkBooleanProperty("wolfjsse.autoSNI", false);
this.wolfjsseAutoSni = checkBooleanProperty("wolfjsse.autoSNI", false);
}

/**
Expand Down Expand Up @@ -1125,10 +1124,8 @@ private void setLocalSigAlgorithms() {
* user in "wolfjsse.enabledSigAlgorithms" Security property */
sigAlgos = WolfSSLUtil.getSignatureAlgorithms();
}
sigSchemes =
WolfSSLUtil.getSignatureSchemes(this.clientMode);
cleanSigList =
WolfSSLUtil.formatSigSchemes(sigAlgos, sigSchemes);
sigSchemes = WolfSSLUtil.getSignatureSchemes(this.clientMode);
cleanSigList = WolfSSLUtil.formatSigSchemes(sigAlgos, sigSchemes);

if (cleanSigList != null) {
ret = this.ssl.setSignatureAlgorithms(cleanSigList);
Expand Down Expand Up @@ -1252,8 +1249,7 @@ private void setLocalParams(SSLSocket socket, SSLEngine engine)

this.setLocalCiphers(
WolfSSLUtil.sanitizeSuites(this.params.getCipherSuites()));
this.setLocalProtocol(
WolfSSLUtil.sanitizeProtocols(
this.setLocalProtocol(WolfSSLUtil.sanitizeProtocols(
this.params.getProtocols(), WolfSSL.TLS_VERSION.INVALID));
this.setLocalAuth(socket, engine);
this.setLocalServerNames();
Expand Down Expand Up @@ -1350,8 +1346,7 @@ private void initHandshakeInternal(SSLSocket socket, SSLEngine engine)
this.session.setSessionContext(authStore.getServerContext());
this.session.setSide(WolfSSL.WOLFSSL_SERVER_END);
/* Track client auth state for getPeerCertificates() */
boolean clientAuthRequested =
this.params.getNeedClientAuth() ||
boolean clientAuthRequested = this.params.getNeedClientAuth() ||
this.params.getWantClientAuth();
this.session.setClientAuthRequested(clientAuthRequested);
}
Expand Down Expand Up @@ -1510,8 +1505,7 @@ else if (peerAddr != null) {
this.session.updateStoredSessionValues();

if (!this.clientMode && !matchSNI()) {
throw new SSLHandshakeException(
"Unrecognized Server Name");
throw new SSLHandshakeException("Unrecognized Server Name");
}

return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,7 @@ public synchronized Certificate[] getPeerCertificates()
x509 = this.ssl.getPeerCertificate();
} catch (IllegalStateException | WolfSSLJNIException ex) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
() -> "Error getting peer certificate: "
+ ex.getMessage());
() -> "Error getting peer certificate: " + ex.getMessage());
x509 = 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ public int verifyCallback(int preverify_ok, long x509StorePtr) {
try {
/* Get WolfSSLCertificate[] from x509StorePtr, certs from
* store.getCerts() should be listed in order of peer to root */
WolfSSLX509StoreCtx store =
new WolfSSLX509StoreCtx(x509StorePtr);
WolfSSLX509StoreCtx store = new WolfSSLX509StoreCtx(x509StorePtr);
certs = store.getCerts();

} catch (WolfSSLException e) {
Expand Down
Loading
Loading