6666 */
6767public class WolfSSLEngine extends SSLEngine {
6868
69- private WolfSSLEngineHelper EngineHelper = null ;
69+ private WolfSSLEngineHelper engineHelper = null ;
7070 private WolfSSLSession ssl = null ;
7171 private com .wolfssl .WolfSSLContext ctx = null ;
7272 private WolfSSLAuthStore authStore = null ;
@@ -164,11 +164,11 @@ protected WolfSSLEngine(com.wolfssl.WolfSSLContext ctx,
164164 null , ex );
165165 throw new WolfSSLException ("Error with init" );
166166 }
167- EngineHelper = new WolfSSLEngineHelper (this .ssl , this .authStore ,
168- this .params );
167+ this . engineHelper = new WolfSSLEngineHelper (this .ssl , this .authStore ,
168+ this .params );
169169
170170 try {
171- EngineHelper .LoadKeyAndCertChain (null , this );
171+ this . engineHelper .LoadKeyAndCertChain (null , this );
172172 } catch (CertificateEncodingException | IOException e ) {
173173 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
174174 "failed to load private key and/or cert chain" );
@@ -200,11 +200,11 @@ protected WolfSSLEngine(com.wolfssl.WolfSSLContext ctx,
200200 null , ex );
201201 throw new WolfSSLException ("Error with init" );
202202 }
203- EngineHelper = new WolfSSLEngineHelper (this .ssl , this .authStore ,
203+ this . engineHelper = new WolfSSLEngineHelper (this .ssl , this .authStore ,
204204 this .params , port , host );
205205
206206 try {
207- EngineHelper .LoadKeyAndCertChain (null , this );
207+ this . engineHelper .LoadKeyAndCertChain (null , this );
208208 } catch (CertificateEncodingException | IOException e ) {
209209 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
210210 "failed to load private key and/or cert chain" );
@@ -355,7 +355,7 @@ private synchronized int ClosingConnection() throws SocketException {
355355 * since underlying get1Session can use I/O with peek. */
356356 if (!this .sessionStored ) {
357357 synchronized (ioLock ) {
358- EngineHelper .saveSession ();
358+ this . engineHelper .saveSession ();
359359 }
360360 }
361361
@@ -444,7 +444,7 @@ private synchronized int SendAppData(ByteBuffer[] in, int ofst, int len)
444444
445445 /* only send up to maximum app data size chunk */
446446 sendSz = Math .min (totalIn ,
447- EngineHelper .getSession ().getApplicationBufferSize ());
447+ this . engineHelper .getSession ().getApplicationBufferSize ());
448448 dataBuf = ByteBuffer .allocate (sendSz );
449449
450450 /* gather byte array of sendSz bytes from input buffers */
@@ -533,7 +533,7 @@ public synchronized SSLEngineResult wrap(ByteBuffer[] in, int ofst, int len,
533533 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
534534 "==== [ entering wrap() ] ===================================" );
535535 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
536- "setUseClientMode: " + EngineHelper .getUseClientMode ());
536+ "setUseClientMode: " + this . engineHelper .getUseClientMode ());
537537 for (i = 0 ; i < len ; i ++) {
538538 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
539539 "ByteBuffer in[" +i +"].remaining(): " + in [i ].remaining ());
@@ -583,7 +583,7 @@ public synchronized SSLEngineResult wrap(ByteBuffer[] in, int ofst, int len,
583583 }
584584
585585 if (needInit ) {
586- EngineHelper .initHandshake (this );
586+ this . engineHelper .initHandshake (this );
587587 needInit = false ;
588588 closed = false ; /* opened a connection */
589589 }
@@ -593,7 +593,8 @@ public synchronized SSLEngineResult wrap(ByteBuffer[] in, int ofst, int len,
593593 }
594594
595595 /* Force out buffer to be large enough to hold max packet size */
596- if (out .remaining () < EngineHelper .getSession ().getPacketBufferSize ()) {
596+ if (out .remaining () <
597+ this .engineHelper .getSession ().getPacketBufferSize ()) {
597598 return new SSLEngineResult (Status .BUFFER_OVERFLOW , hs , 0 , 0 );
598599 }
599600
@@ -610,7 +611,7 @@ public synchronized SSLEngineResult wrap(ByteBuffer[] in, int ofst, int len,
610611 status = SSLEngineResult .Status .CLOSED ;
611612 /* Handshake has finished and SSLEngine is closed, release
612613 * global JNI verify callback pointer */
613- this .EngineHelper .unsetVerifyCallback ();
614+ this .engineHelper .unsetVerifyCallback ();
614615
615616 try {
616617 ClosingConnection ();
@@ -645,7 +646,7 @@ else if (produced == 0) {
645646 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
646647 "==== [ exiting wrap() ] ===================================" );
647648 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
648- "setUseClientMode: " + EngineHelper .getUseClientMode ());
649+ "setUseClientMode: " + this . engineHelper .getUseClientMode ());
649650 for (i = 0 ; i < len ; i ++) {
650651 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
651652 "ByteBuffer in[" +i +"].remaining(): " + in [i ].remaining ());
@@ -896,7 +897,7 @@ public synchronized SSLEngineResult unwrap(ByteBuffer in, ByteBuffer[] out,
896897 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
897898 "==== [ entering unwrap() ] =================================" );
898899 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
899- "setUseClientMode: " + EngineHelper .getUseClientMode ());
900+ "setUseClientMode: " + this . engineHelper .getUseClientMode ());
900901 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
901902 "in.remaining(): " + in .remaining ());
902903 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
@@ -959,7 +960,7 @@ else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP &&
959960 else {
960961
961962 if (needInit ) {
962- EngineHelper .initHandshake (this );
963+ this . engineHelper .initHandshake (this );
963964 needInit = false ;
964965 closed = false ;
965966 }
@@ -971,7 +972,7 @@ else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP &&
971972 status = SSLEngineResult .Status .CLOSED ;
972973 /* Handshake has finished and SSLEngine is closed,
973974 * release, global JNI verify callback pointer */
974- this .EngineHelper .unsetVerifyCallback ();
975+ this .engineHelper .unsetVerifyCallback ();
975976 }
976977 } catch (SocketException e ) {
977978 throw new SSLException (e );
@@ -1027,8 +1028,8 @@ else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP &&
10271028 if (!this .sessionStored ) {
10281029 synchronized (ioLock ) {
10291030 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
1030- "calling EngineHelper .saveSession()" );
1031- int ret2 = EngineHelper .saveSession ();
1031+ "calling engineHelper .saveSession()" );
1032+ int ret2 = this . engineHelper .saveSession ();
10321033 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
10331034 "return from saveSession(), ret = " + ret2 );
10341035 if (ret2 == WolfSSL .SSL_SUCCESS ) {
@@ -1043,7 +1044,7 @@ else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP &&
10431044 status = SSLEngineResult .Status .CLOSED ;
10441045 /* Handshake has finished and SSLEngine is closed,
10451046 * release, global JNI verify callback pointer */
1046- this .EngineHelper .unsetVerifyCallback ();
1047+ this .engineHelper .unsetVerifyCallback ();
10471048 }
10481049
10491050 int err = ssl .getError (ret );
@@ -1083,7 +1084,7 @@ else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP &&
10831084 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
10841085 "==== [ exiting unwrap() ] ==================================" );
10851086 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
1086- "setUseClientMode: " + EngineHelper .getUseClientMode ());
1087+ "setUseClientMode: " + this . engineHelper .getUseClientMode ());
10871088 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
10881089 "in.remaining(): " + in .remaining ());
10891090 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
@@ -1188,10 +1189,10 @@ else if (!this.outBoundOpen && !this.closeNotifySent) {
11881189 "SSL/TLS handshake finished" );
11891190 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
11901191 "SSL/TLS protocol: " +
1191- EngineHelper .getSession ().getProtocol ());
1192+ this . engineHelper .getSession ().getProtocol ());
11921193 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
11931194 "SSL/TLS cipher suite: " +
1194- EngineHelper .getSession ().getCipherSuite ());
1195+ this . engineHelper .getSession ().getCipherSuite ());
11951196 }
11961197 /* give priority of WRAP/UNWRAP to state of our internal
11971198 * I/O data buffers first, then wolfSSL err status */
@@ -1279,49 +1280,49 @@ public synchronized boolean isOutboundDone() {
12791280 public String [] getSupportedCipherSuites () {
12801281 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
12811282 "entered getSupportedCipherSuites()" );
1282- return EngineHelper .getAllCiphers ();
1283+ return this . engineHelper .getAllCiphers ();
12831284 }
12841285
12851286 @ Override
12861287 public String [] getEnabledCipherSuites () {
12871288 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
12881289 "entered getEnabledCipherSuites()" );
1289- return EngineHelper .getCiphers ();
1290+ return this . engineHelper .getCiphers ();
12901291 }
12911292
12921293 @ Override
12931294 public void setEnabledCipherSuites (String [] suites ) {
12941295 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
12951296 "entered setEnabledCipherSuites()" );
1296- EngineHelper .setCiphers (suites );
1297+ this . engineHelper .setCiphers (suites );
12971298 }
12981299
12991300 @ Override
13001301 public String [] getSupportedProtocols () {
13011302 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
13021303 "entered getSupportedProtocols()" );
1303- return EngineHelper .getAllProtocols ();
1304+ return this . engineHelper .getAllProtocols ();
13041305 }
13051306
13061307 @ Override
13071308 public synchronized String [] getEnabledProtocols () {
13081309 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
13091310 "entered getEnabledProtocols()" );
1310- return EngineHelper .getProtocols ();
1311+ return this . engineHelper .getProtocols ();
13111312 }
13121313
13131314 @ Override
13141315 public synchronized void setEnabledProtocols (String [] protocols ) {
13151316 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
13161317 "entered setEnabledProtocols()" );
1317- EngineHelper .setProtocols (protocols );
1318+ this . engineHelper .setProtocols (protocols );
13181319 }
13191320
13201321 @ Override
13211322 public synchronized SSLSession getSession () {
13221323 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
13231324 "entered getSession()" );
1324- return EngineHelper .getSession ();
1325+ return this . engineHelper .getSession ();
13251326 }
13261327
13271328 /**
@@ -1335,7 +1336,7 @@ public synchronized SSLSession getSession() {
13351336 * @throws SSLException if native JNI call fails or underlying
13361337 * WolfSSLSession has been freed
13371338 */
1338- public boolean sessionResumed () throws SSLException {
1339+ public synchronized boolean sessionResumed () throws SSLException {
13391340 if (this .ssl != null ) {
13401341 try {
13411342 int resume = this .ssl .sessionReused ();
@@ -1353,7 +1354,7 @@ public boolean sessionResumed() throws SSLException {
13531354 public synchronized SSLSession getHandshakeSession () {
13541355 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
13551356 "entered getHandshakeSession()" );
1356- return EngineHelper .getSession ();
1357+ return this . engineHelper .getSession ();
13571358 }
13581359
13591360 @ Override
@@ -1379,14 +1380,14 @@ public synchronized void beginHandshake() throws SSLException {
13791380 if (needInit == true ) {
13801381 /* will throw SSLHandshakeException if session creation is
13811382 not allowed */
1382- EngineHelper .initHandshake (this );
1383+ this . engineHelper .initHandshake (this );
13831384 needInit = false ;
13841385 }
13851386
13861387 try {
13871388 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
1388- "calling EngineHelper .doHandshake()" );
1389- int ret = EngineHelper .doHandshake (1 , 0 );
1389+ "calling engineHelper .doHandshake()" );
1390+ int ret = this . engineHelper .doHandshake (1 , 0 );
13901391 SetHandshakeStatus (ret );
13911392
13921393 } catch (SocketTimeoutException e ) {
@@ -1422,63 +1423,63 @@ public synchronized SSLEngineResult.HandshakeStatus getHandshakeStatus() {
14221423 public synchronized void setUseClientMode (boolean mode ) {
14231424 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14241425 "entered setUseClientMode(" + mode + ")" );
1425- EngineHelper .setUseClientMode (mode );
1426+ this . engineHelper .setUseClientMode (mode );
14261427 this .clientModeSet = true ;
14271428 }
14281429
14291430 @ Override
14301431 public synchronized boolean getUseClientMode () {
14311432 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14321433 "entered getUseClientMode()" );
1433- return EngineHelper .getUseClientMode ();
1434+ return this . engineHelper .getUseClientMode ();
14341435 }
14351436
14361437 @ Override
14371438 public synchronized void setNeedClientAuth (boolean need ) {
14381439 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14391440 "entered setNeedClientAuth(" + need + ")" );
1440- EngineHelper .setNeedClientAuth (need );
1441+ this . engineHelper .setNeedClientAuth (need );
14411442 }
14421443
14431444 @ Override
14441445 public synchronized boolean getNeedClientAuth () {
14451446 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14461447 "entered getNeedClientAuth()" );
1447- return EngineHelper .getNeedClientAuth ();
1448+ return this . engineHelper .getNeedClientAuth ();
14481449 }
14491450
14501451 @ Override
14511452 public synchronized void setWantClientAuth (boolean want ) {
14521453 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14531454 "entered setWantClientAuth(" + want + ")" );
1454- EngineHelper .setWantClientAuth (want );
1455+ this . engineHelper .setWantClientAuth (want );
14551456 }
14561457
14571458 @ Override
14581459 public synchronized boolean getWantClientAuth () {
14591460 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14601461 "entered getWantClientAuth()" );
1461- return EngineHelper .getWantClientAuth ();
1462+ return this . engineHelper .getWantClientAuth ();
14621463 }
14631464
14641465 @ Override
14651466 public synchronized void setEnableSessionCreation (boolean flag ) {
14661467 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14671468 "entered setEnableSessionCreation(" + flag + ")" );
1468- EngineHelper .setEnableSessionCreation (flag );
1469+ this . engineHelper .setEnableSessionCreation (flag );
14691470 }
14701471
14711472 @ Override
14721473 public synchronized boolean getEnableSessionCreation () {
14731474 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14741475 "entered getEnableSessionCreation()" );
1475- return EngineHelper .getEnableSessionCreation ();
1476+ return this . engineHelper .getEnableSessionCreation ();
14761477 }
14771478
14781479 public synchronized String getApplicationProtocol () {
14791480 WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
14801481 "entered getApplicationProtocol()" );
1481- return EngineHelper .getAlpnSelectedProtocolString ();
1482+ return this . engineHelper .getAlpnSelectedProtocolString ();
14821483 }
14831484
14841485 /**
@@ -1501,7 +1502,7 @@ public synchronized String getHandshakeApplicationProtocol() {
15011502 "entered getHandshakeApplicationProtocol()" );
15021503
15031504 if (!this .needInit && !this .handshakeFinished ) {
1504- return EngineHelper .getAlpnSelectedProtocolString ();
1505+ return this . engineHelper .getAlpnSelectedProtocolString ();
15051506 }
15061507
15071508 return null ;
@@ -1786,7 +1787,6 @@ protected synchronized void finalize() throws Throwable {
17861787 this .ssl .freeSSL ();
17871788 this .ssl = null ;
17881789 }
1789- this .EngineHelper = null ;
17901790 super .finalize ();
17911791 }
17921792}
0 commit comments