@@ -86,6 +86,14 @@ private void appendDisplayText(String s)
8686 /* Enable wolfJSSE debug messages */
8787 System .setProperty ("wolfjsse.debug" , "true" );
8888
89+ /* Select The devId which will be registered and used on every other invocation */
90+ /* Unique devId's are compiled into wolfssljni */
91+ //int devId = 0x56490420; /* VaultIC 420 */
92+ int devId = WolfSSL .INVALID_DEVID ; /* No hardware offload */
93+
94+ /* Select if the cipher suites and protocols will be limited */
95+ boolean limitCipherProtocol = false ;
96+
8997 long [] ts = new long [10 ];
9098
9199 ts [0 ] = System .currentTimeMillis ();
@@ -95,9 +103,8 @@ private void appendDisplayText(String s)
95103
96104 ts [1 ] = System .currentTimeMillis ();
97105 connectCount ++;
98- /* Unique devId's are compiled into wolfssljni */
99- int devId = 0x56490420 ;
100- if ((connectCount % 2 ) == 0 ) {
106+
107+ if (((connectCount % 2 ) == 0 ) && (devId != WolfSSL .INVALID_DEVID )) {
101108 appendDisplayText ("B. Using hardware offload\n " );
102109 wolfProv .registerDevId (devId );
103110 wolfProv .setDevId (devId );
@@ -117,11 +124,13 @@ private void appendDisplayText(String s)
117124 SSLSocketFactory sf = ctx .getSocketFactory ();
118125 SSLSocket sock = (SSLSocket ) sf .createSocket (host , port );
119126
120- /* Limit cipherSuites and protocol */
121- String [] cipherSuites = new String [] {"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" };
122- sock .setEnabledCipherSuites (cipherSuites );
123- String [] protocols = new String []{"TLSv1.2" };
124- sock .setEnabledProtocols (protocols );
127+ if (limitCipherProtocol ) {
128+ /* Limit cipherSuites and protocol */
129+ String [] cipherSuites = new String []{"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" };
130+ sock .setEnabledCipherSuites (cipherSuites );
131+ String [] protocols = new String []{"TLSv1.2" };
132+ sock .setEnabledProtocols (protocols );
133+ }
125134
126135 ts [3 ] = System .currentTimeMillis ();
127136 appendDisplayText ("D. Starting Handshake\n " );
@@ -153,7 +162,7 @@ private void appendDisplayText(String s)
153162 sock .close ();
154163
155164 ts [7 ] = System .currentTimeMillis ();
156- if ((connectCount % 2 ) == 0 ) {
165+ if ((( connectCount % 2 ) == 0 ) && ( devId != WolfSSL . INVALID_DEVID ) ) {
157166 appendDisplayText ("H. Disabling hardware offload\n " );
158167 wolfProv .setDevId (WolfSSL .INVALID_DEVID );
159168 wolfProv .unRegisterDevId (devId );
@@ -175,9 +184,9 @@ private void appendDisplayText(String s)
175184 " C:" + (ts [3 ] - ts [2 ]) +
176185 " D:" + (ts [4 ] - ts [3 ]) +
177186 " E:" + (ts [5 ] - ts [4 ]) +
178- ", " + getCmd .length () * 1000 / (ts [5 ] - ts [4 ]) + "Bps" +
187+ ", " + getCmd .length () * 1000 / (ts [5 ] - ts [4 ] + 1 ) + "Bps" +
179188 " F:" + (ts [6 ] - ts [5 ]) +
180- ", " + totalRead * 1000 / (ts [6 ] - ts [5 ]) + "Bps" +
189+ ", " + totalRead * 1000 / (ts [6 ] - ts [5 ] + 1 ) + "Bps" +
181190 " G:" + (ts [7 ] - ts [6 ]) +
182191 " H:" + (ts [8 ] - ts [7 ]) +
183192 " I:" + (ts [9 ] - ts [8 ]) +
0 commit comments