本文整理匯總了Java中javax.net.ssl.SSLEngineResult.sequenceNumber方法的典型用法代碼示例。如果您正苦於以下問題:Java SSLEngineResult.sequenceNumber方法的具體用法?Java SSLEngineResult.sequenceNumber怎麽用?Java SSLEngineResult.sequenceNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.net.ssl.SSLEngineResult
的用法示例。
在下文中一共展示了SSLEngineResult.sequenceNumber方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testOneCipher
import javax.net.ssl.SSLEngineResult; //導入方法依賴的package包/類
@Override
protected void testOneCipher(String cipher) throws SSLException {
SSLContext context = getContext();
int maxPacketSize = getMaxPacketSize();
boolean useSNI = !TEST_MODE.equals("norm");
SSLEngine clientEngine = getClientSSLEngine(context, useSNI);
SSLEngine serverEngine = getServerSSLEngine(context, useSNI);
clientEngine.setEnabledCipherSuites(new String[]{cipher});
serverEngine.setEnabledCipherSuites(new String[]{cipher});
serverEngine.setNeedClientAuth(!cipher.contains("anon"));
long initialEpoch = 0;
long secondEpoch = 0;
long thirdEpoch = 0;
SSLEngineResult r;
doHandshake(clientEngine, serverEngine, maxPacketSize,
HandshakeMode.INITIAL_HANDSHAKE);
sendApplicationData(clientEngine, serverEngine);
r = sendApplicationData(serverEngine, clientEngine);
if (TESTED_SECURITY_PROTOCOL.contains("DTLS")) {
initialEpoch = r.sequenceNumber() >> 48;
}
doHandshake(clientEngine, serverEngine, maxPacketSize,
HandshakeMode.REHANDSHAKE_BEGIN_CLIENT);
sendApplicationData(clientEngine, serverEngine);
r = sendApplicationData(serverEngine, clientEngine);
AssertionError epochError = new AssertionError("Epoch number"
+ " did not grow after re-handshake! "
+ " Was " + initialEpoch + ", now " + secondEpoch + ".");
if (TESTED_SECURITY_PROTOCOL.contains("DTLS")) {
secondEpoch = r.sequenceNumber() >> 48;
if (Long.compareUnsigned(secondEpoch, initialEpoch) <= 0) {
throw epochError;
}
}
doHandshake(clientEngine, serverEngine, maxPacketSize,
HandshakeMode.REHANDSHAKE_BEGIN_SERVER);
sendApplicationData(clientEngine, serverEngine);
r = sendApplicationData(serverEngine, clientEngine);
if (TESTED_SECURITY_PROTOCOL.contains("DTLS")) {
thirdEpoch = r.sequenceNumber() >> 48;
if (Long.compareUnsigned(thirdEpoch, secondEpoch) <= 0) {
throw epochError;
}
}
closeEngines(clientEngine, serverEngine);
}
示例2: testOneCipher
import javax.net.ssl.SSLEngineResult; //導入方法依賴的package包/類
@Override
protected void testOneCipher(String cipher) throws SSLException {
SSLContext context = getContext();
int maxPacketSize = getMaxPacketSize();
SSLEngine clientEngine = context.createSSLEngine();
clientEngine.setUseClientMode(true);
SSLEngine serverEngine = context.createSSLEngine();
serverEngine.setUseClientMode(false);
clientEngine.setEnabledCipherSuites(new String[]{cipher});
serverEngine.setEnabledCipherSuites(
Ciphers.ENABLED_NON_KRB_NOT_ANON_CIPHERS.ciphers);
String randomCipher;
serverEngine.setNeedClientAuth(true);
long initialEpoch = 0;
long secondEpoch = 0;
SSLEngineResult r;
doHandshake(clientEngine, serverEngine, maxPacketSize,
HandshakeMode.INITIAL_HANDSHAKE);
sendApplicationData(clientEngine, serverEngine);
r = sendApplicationData(serverEngine, clientEngine);
if (TESTED_SECURITY_PROTOCOL.contains("DTLS")) {
initialEpoch = r.sequenceNumber() >> 48;
}
final Random RNG = RandomFactory.getRandom();
randomCipher = Ciphers.ENABLED_NON_KRB_NOT_ANON_CIPHERS.ciphers[RNG
.nextInt(Ciphers.ENABLED_NON_KRB_NOT_ANON_CIPHERS.ciphers.length)];
clientEngine.setEnabledCipherSuites(new String[]{randomCipher});
doHandshake(clientEngine, serverEngine, maxPacketSize,
HandshakeMode.REHANDSHAKE_BEGIN_CLIENT);
sendApplicationData(clientEngine, serverEngine);
r = sendApplicationData(serverEngine, clientEngine);
if (TESTED_SECURITY_PROTOCOL.contains("DTLS")) {
secondEpoch = r.sequenceNumber() >> 48;
AssertionError epochError = new AssertionError("Epoch number"
+ " did not grow after re-handshake! "
+ " Was " + initialEpoch + ", now " + secondEpoch + ".");
if (Long.compareUnsigned(secondEpoch, initialEpoch) <= 0) {
throw epochError;
}
}
closeEngines(clientEngine, serverEngine);
}