diff options
author | Narayan Kamath <narayan@google.com> | 2014-12-02 18:58:22 +0000 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-12-03 10:08:30 +0000 |
commit | 2e47cbcfd5aad2a525af42cbc93a919b96e2c62a (patch) | |
tree | 0e0c6a957b996a6955c81387928adc83cd4f5587 /luni | |
parent | 4e05c844ea6c6359345b66120182d4d86fc9e22b (diff) | |
download | libcore-2e47cbcfd5aad2a525af42cbc93a919b96e2c62a.zip libcore-2e47cbcfd5aad2a525af42cbc93a919b96e2c62a.tar.gz libcore-2e47cbcfd5aad2a525af42cbc93a919b96e2c62a.tar.bz2 |
Add tests for issue 18554122.
We assert that UNDERFLOW is returned on empty inputs both
during and after a handshake.
bug: 18554122
(cherry picked from commit 03365a863c7316325ff12bf88aa19dc33e34f19f)
Change-Id: I41d7fbdbd0363aea84904b14a1e99116cebff0f5
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java index 5239977..fd24944 100644 --- a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java +++ b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java @@ -86,6 +86,32 @@ public class SSLEngineTest extends TestCase { test_SSLEngine_getSupportedCipherSuites_connect(testKeyStore, false); test_SSLEngine_getSupportedCipherSuites_connect(testKeyStore, true); } + + // http://b/18554122 + public void test_SSLEngine_underflowsOnEmptyBuffersDuringHandshake() throws Exception { + final SSLEngine sslEngine = SSLContext.getDefault().createSSLEngine(); + sslEngine.setUseClientMode(false); + ByteBuffer input = ByteBuffer.allocate(1024); + input.flip(); + ByteBuffer output = ByteBuffer.allocate(1024); + sslEngine.beginHandshake(); + assertEquals(SSLEngineResult.HandshakeStatus.NEED_UNWRAP, sslEngine.getHandshakeStatus()); + SSLEngineResult result = sslEngine.unwrap(input, output); + assertEquals(SSLEngineResult.Status.BUFFER_UNDERFLOW, result.getStatus()); + assertEquals(SSLEngineResult.HandshakeStatus.NEED_UNWRAP, result.getHandshakeStatus()); + } + + // http://b/18554122 + public void test_SSLEngine_underflowsOnEmptyBuffersAfterHandshake() throws Exception { + // Note that create performs the handshake. + final TestSSLEnginePair engines = TestSSLEnginePair.create(null /* hooks */); + ByteBuffer input = ByteBuffer.allocate(1024); + input.flip(); + ByteBuffer output = ByteBuffer.allocate(1024); + assertEquals(SSLEngineResult.Status.BUFFER_UNDERFLOW, + engines.client.unwrap(input, output).getStatus()); + } + private void test_SSLEngine_getSupportedCipherSuites_connect(TestKeyStore testKeyStore, boolean secureRenegotiation) throws Exception { |