23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package sun.security.ssl; |
26 package sun.security.ssl; |
27 |
27 |
28 import java.io.*; |
28 import java.io.IOException; |
29 import java.nio.*; |
29 import java.nio.ByteBuffer; |
30 import java.security.GeneralSecurityException; |
30 import java.security.GeneralSecurityException; |
31 import java.util.ArrayList; |
31 import java.util.ArrayList; |
32 import javax.crypto.BadPaddingException; |
32 import javax.crypto.BadPaddingException; |
33 import javax.net.ssl.*; |
33 import javax.net.ssl.SSLException; |
|
34 import javax.net.ssl.SSLHandshakeException; |
|
35 import javax.net.ssl.SSLProtocolException; |
34 import sun.security.ssl.SSLCipher.SSLReadCipher; |
36 import sun.security.ssl.SSLCipher.SSLReadCipher; |
35 |
37 |
36 /** |
38 /** |
37 * {@code InputRecord} implementation for {@code SSLEngine}. |
39 * {@code InputRecord} implementation for {@code SSLEngine}. |
38 */ |
40 */ |
39 final class SSLEngineInputRecord extends InputRecord implements SSLRecord { |
41 final class SSLEngineInputRecord extends InputRecord implements SSLRecord { |
40 // used by handshake hash computation for handshake fragment |
|
41 private byte prevType = -1; |
|
42 private int hsMsgOff = 0; |
|
43 private int hsMsgLen = 0; |
|
44 |
|
45 private boolean formatVerified = false; // SSLv2 ruled out? |
42 private boolean formatVerified = false; // SSLv2 ruled out? |
46 |
43 |
47 // Cache for incomplete handshake messages. |
44 // Cache for incomplete handshake messages. |
48 private ByteBuffer handshakeBuffer = null; |
45 private ByteBuffer handshakeBuffer = null; |
49 |
46 |
82 int len = 0; |
79 int len = 0; |
83 |
80 |
84 /* |
81 /* |
85 * If we have already verified previous packets, we can |
82 * If we have already verified previous packets, we can |
86 * ignore the verifications steps, and jump right to the |
83 * ignore the verifications steps, and jump right to the |
87 * determination. Otherwise, try one last hueristic to |
84 * determination. Otherwise, try one last heuristic to |
88 * see if it's SSL/TLS. |
85 * see if it's SSL/TLS. |
89 */ |
86 */ |
90 if (formatVerified || |
87 if (formatVerified || |
91 (byteZero == ContentType.HANDSHAKE.id) || |
88 (byteZero == ContentType.HANDSHAKE.id) || |
92 (byteZero == ContentType.ALERT.id)) { |
89 (byteZero == ContentType.ALERT.id)) { |