1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
diff -burN android-openssl.orig/include/openssl/tls1.h android-openssl/include/openssl/tls1.h
--- android-openssl.orig/include/openssl/tls1.h 2014-04-07 17:20:17.990940592 -0700
+++ android-openssl/include/openssl/tls1.h 2014-04-07 17:22:32.432921935 -0700
@@ -230,6 +230,12 @@
/* ExtensionType value from RFC5620 */
#define TLSEXT_TYPE_heartbeat 15
+/* ExtensionType value for TLS padding extension.
+ * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml
+ * http://tools.ietf.org/html/draft-agl-tls-padding-03
+ */
+#define TLSEXT_TYPE_padding 21
+
/* ExtensionType value from RFC4507 */
#define TLSEXT_TYPE_session_ticket 35
diff -burN android-openssl.orig/ssl/s23_clnt.c android-openssl/ssl/s23_clnt.c
--- android-openssl.orig/ssl/s23_clnt.c 2014-04-07 17:20:17.990940592 -0700
+++ android-openssl/ssl/s23_clnt.c 2014-04-07 17:21:55.042370926 -0700
@@ -466,7 +466,10 @@
{
/* create Client Hello in SSL 3.0/TLS 1.0 format */
- /* do the record header (5 bytes) and handshake message header (4 bytes) last */
+ /* do the record header (5 bytes) and handshake message
+ * header (4 bytes) last. Note: the code to add the
+ * padding extension in t1_lib.c depends on the size of
+ * this prefix. */
d = p = &(buf[9]);
*(p++) = version_major;
diff -burN android-openssl.orig/ssl/s3_clnt.c android-openssl/ssl/s3_clnt.c
--- android-openssl.orig/ssl/s3_clnt.c 2014-04-07 17:20:18.040941329 -0700
+++ android-openssl/ssl/s3_clnt.c 2014-04-07 17:21:55.042370926 -0700
@@ -758,7 +758,9 @@
if (RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4) <= 0)
goto err;
- /* Do the message type and length last */
+ /* Do the message type and length last.
+ * Note: the code to add the padding extension in t1_lib.c
+ * depends on the size of this prefix. */
d=p= &(buf[4]);
/* version indicates the negotiated version: for example from
diff -burN android-openssl.orig/ssl/t1_lib.c android-openssl/ssl/t1_lib.c
--- android-openssl.orig/ssl/t1_lib.c 2014-04-07 17:20:18.000940737 -0700
+++ android-openssl/ssl/t1_lib.c 2014-04-07 17:21:55.042370926 -0700
@@ -680,6 +680,31 @@
}
#endif
+ /* Add padding to workaround bugs in F5 terminators.
+ * See https://tools.ietf.org/html/draft-agl-tls-padding-02 */
+ {
+ int hlen = ret - (unsigned char *)s->init_buf->data;
+ /* The code in s23_clnt.c to build ClientHello messages includes the
+ * 5-byte record header in the buffer, while the code in s3_clnt.c does
+ * not. */
+ if (s->state == SSL23_ST_CW_CLNT_HELLO_A)
+ hlen -= 5;
+ if (hlen > 0xff && hlen < 0x200)
+ {
+ hlen = 0x200 - hlen;
+ if (hlen >= 4)
+ hlen -= 4;
+ else
+ hlen = 0;
+
+ s2n(TLSEXT_TYPE_padding, ret);
+ s2n(hlen, ret);
+ memset(ret, 0, hlen);
+ ret += hlen;
+ }
+ }
+
+
if ((extdatalen = ret-p-2)== 0)
return p;
diff -burN android-openssl.orig/ssl/tls1.h android-openssl/ssl/tls1.h
--- android-openssl.orig/ssl/tls1.h 2014-04-07 17:20:18.000940737 -0700
+++ android-openssl/ssl/tls1.h 2014-04-07 17:21:55.042370926 -0700
@@ -230,6 +230,12 @@
/* ExtensionType value from RFC5620 */
#define TLSEXT_TYPE_heartbeat 15
+/* ExtensionType value for TLS padding extension.
+ * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml
+ * http://tools.ietf.org/html/draft-agl-tls-padding-03
+ */
+#define TLSEXT_TYPE_padding 21
+
/* ExtensionType value from RFC4507 */
#define TLSEXT_TYPE_session_ticket 35
|