1 1.1 christos # -*- mode: perl; -*- 2 1.1 christos # Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos # 4 1.1 christos # Licensed under the Apache License 2.0 (the "License"). You may not use 5 1.1 christos # this file except in compliance with the License. You can obtain a copy 6 1.1 christos # in the file LICENSE in the source distribution or at 7 1.1 christos # https://www.openssl.org/source/license.html 8 1.1 christos 9 1.1 christos 10 1.1 christos ## Test packet fragmentation 11 1.1 christos 12 1.1 christos use strict; 13 1.1 christos use warnings; 14 1.1 christos 15 1.1 christos package ssltests; 16 1.1 christos 17 1.1 christos 18 1.1 christos our @tests = ( 19 1.1 christos # Default fragment size is 512. 20 1.1 christos { 21 1.1 christos name => "one-fragment-minus-app-data", 22 1.1 christos server => { }, 23 1.1 christos client => { }, 24 1.1 christos test => { 25 1.1 christos ApplicationData => 511, 26 1.1 christos } 27 1.1 christos }, 28 1.1 christos { 29 1.1 christos name => "one-fragment-app-data", 30 1.1 christos server => { }, 31 1.1 christos client => { }, 32 1.1 christos test => { 33 1.1 christos ApplicationData => 512, 34 1.1 christos } 35 1.1 christos }, 36 1.1 christos { 37 1.1 christos name => "one-fragment-plus-app-data", 38 1.1 christos server => { }, 39 1.1 christos client => { }, 40 1.1 christos test => { 41 1.1 christos ApplicationData => 513, 42 1.1 christos } 43 1.1 christos }, 44 1.1 christos { 45 1.1 christos name => "small-app-data", 46 1.1 christos server => { }, 47 1.1 christos client => { }, 48 1.1 christos test => { 49 1.1 christos ApplicationData => 4 * 1024 + 1, 50 1.1 christos } 51 1.1 christos }, 52 1.1 christos { 53 1.1 christos name => "small-app-data-large-fragment-size", 54 1.1 christos server => { }, 55 1.1 christos client => { }, 56 1.1 christos test => { 57 1.1 christos ApplicationData => 4 * 1024 + 1, 58 1.1 christos MaxFragmentSize => 16384, 59 1.1 christos } 60 1.1 christos }, 61 1.1 christos { 62 1.1 christos name => "medium-app-data", 63 1.1 christos server => { }, 64 1.1 christos client => { }, 65 1.1 christos test => { 66 1.1 christos ApplicationData => 32 * 1024 + 7, 67 1.1 christos } 68 1.1 christos }, 69 1.1 christos # Exceeds the 64kB write buffer size. 70 1.1 christos { 71 1.1 christos name => "medium-plus-app-data", 72 1.1 christos server => { }, 73 1.1 christos client => { }, 74 1.1 christos test => { 75 1.1 christos ApplicationData => 128 * 1024 - 3, 76 1.1 christos } 77 1.1 christos }, 78 1.1 christos { 79 1.1 christos name => "large-app-data", 80 1.1 christos server => { }, 81 1.1 christos client => { }, 82 1.1 christos test => { 83 1.1 christos ApplicationData => 1024 * 1024, 84 1.1 christos } 85 1.1 christos }, 86 1.1 christos { 87 1.1 christos name => "large-app-data-large-fragment-size", 88 1.1 christos server => { }, 89 1.1 christos client => { }, 90 1.1 christos test => { 91 1.1 christos ApplicationData => 1024 * 1024, 92 1.1 christos MaxFragmentSize => 16384, 93 1.1 christos } 94 1.1 christos }, 95 1.1 christos { 96 1.1 christos name => "large-app-data-odd-fragment-size", 97 1.1 christos server => { }, 98 1.1 christos client => { }, 99 1.1 christos test => { 100 1.1 christos ApplicationData => 1024 * 1024, 101 1.1 christos MaxFragmentSize => 5 * 1024 - 5, 102 1.1 christos } 103 1.1 christos }, 104 1.1 christos # When the buffer / fragment size ratio is sufficiently large, 105 1.1 christos # multi-buffer code kicks in on some platforms for AES-SHA. The 106 1.1 christos # exact minimum ratio depends on the platform, and is usually 107 1.1 christos # around 4. Since the test buffer is 64kB, a 4kB fragment is 108 1.1 christos # easily sufficient. 109 1.1 christos # 110 1.1 christos # (We run this test on all platforms though it's only true multibuffer 111 1.1 christos # on some of them.) 112 1.1 christos { 113 1.1 christos name => "large-app-data-aes-sha1-multibuffer", 114 1.1 christos server => { }, 115 1.1 christos client => { 116 1.1 christos CipherString => "AES128-SHA", 117 1.1 christos MaxProtocol => "TLSv1.2" 118 1.1 christos }, 119 1.1 christos test => { 120 1.1 christos ApplicationData => 1024 * 1024, 121 1.1 christos MaxFragmentSize => 4 * 1024, 122 1.1 christos } 123 1.1 christos }, 124 1.1 christos { 125 1.1 christos name => "large-app-data-aes-sha2-multibuffer", 126 1.1 christos server => { }, 127 1.1 christos client => { 128 1.1 christos CipherString => "AES128-SHA256", 129 1.1 christos MaxProtocol => "TLSv1.2" 130 1.1 christos }, 131 1.1 christos test => { 132 1.1 christos ApplicationData => 1024 * 1024, 133 1.1 christos MaxFragmentSize => 4 * 1024, 134 1.1 christos } 135 1.1 christos }, 136 1.1 christos { 137 1.1 christos name => "large-app-data-aes-sha1-multibuffer-odd-fragment", 138 1.1 christos server => { }, 139 1.1 christos client => { 140 1.1 christos CipherString => "AES128-SHA", 141 1.1 christos MaxProtocol => "TLSv1.2" 142 1.1 christos }, 143 1.1 christos test => { 144 1.1 christos ApplicationData => 1024 * 1024 + 3, 145 1.1 christos MaxFragmentSize => 5 * 1024 - 5, 146 1.1 christos } 147 1.1 christos }, 148 1.1 christos { 149 1.1 christos name => "large-app-data-aes-sha2-multibuffer-odd-fragment", 150 1.1 christos server => { }, 151 1.1 christos client => { 152 1.1 christos CipherString => "AES128-SHA256", 153 1.1 christos MaxProtocol => "TLSv1.2" 154 1.1 christos }, 155 1.1 christos test => { 156 1.1 christos ApplicationData => 1024 * 1024 - 3, 157 1.1 christos MaxFragmentSize => 5 * 1024 + 5, 158 1.1 christos } 159 1.1 christos }, 160 1.1 christos # Test that multibuffer-capable code also handles small data correctly. 161 1.1 christos # Here fragment size == app data size < buffer size, 162 1.1 christos # so no multibuffering should happen. 163 1.1 christos { 164 1.1 christos name => "small-app-data-aes-sha1-multibuffer", 165 1.1 christos server => { }, 166 1.1 christos client => { 167 1.1 christos CipherString => "AES128-SHA", 168 1.1 christos MaxProtocol => "TLSv1.2" 169 1.1 christos }, 170 1.1 christos test => { 171 1.1 christos ApplicationData => 4 * 1024, 172 1.1 christos MaxFragmentSize => 4 * 1024, 173 1.1 christos } 174 1.1 christos }, 175 1.1 christos { 176 1.1 christos name => "small-app-data-aes-sha2-multibuffer", 177 1.1 christos server => { }, 178 1.1 christos client => { 179 1.1 christos CipherString => "AES128-SHA256", 180 1.1 christos MaxProtocol => "TLSv1.2" 181 1.1 christos }, 182 1.1 christos test => { 183 1.1 christos ApplicationData => 4 * 1024, 184 1.1 christos MaxFragmentSize => 4 * 1024, 185 1.1 christos } 186 1.1 christos }, 187 1.1 christos ############################################ 188 1.1 christos # Default (Max) Fragment Size is 512. 189 1.1 christos # Default Application data size is 256. 190 1.1 christos { 191 1.1 christos name => "Maximum Fragment Len extension set to 1024 w. FragmentSize disabled", 192 1.1 christos server => { }, 193 1.1 christos client => { 194 1.1 christos extra => { 195 1.1 christos MaxFragmentLenExt => 1024, 196 1.1 christos }, 197 1.1 christos }, 198 1.1 christos test => { 199 1.1 christos ApplicationData => 3072, 200 1.1 christos MaxFragmentSize => 16384, 201 1.1 christos } 202 1.1 christos }, 203 1.1 christos { 204 1.1 christos name => "Maximum Fragment Len extension equal FragmentSize to 2048", 205 1.1 christos server => { }, 206 1.1 christos client => { 207 1.1 christos extra => { 208 1.1 christos MaxFragmentLenExt => 2048, 209 1.1 christos }, 210 1.1 christos }, 211 1.1 christos test => { 212 1.1 christos ApplicationData => 3072, 213 1.1 christos MaxFragmentSize => 2048, 214 1.1 christos } 215 1.1 christos }, 216 1.1 christos { 217 1.1 christos name => "Maximum Fragment Len extension 512 lower than FragmentSize 1024", 218 1.1 christos server => { }, 219 1.1 christos client => { 220 1.1 christos extra => { 221 1.1 christos MaxFragmentLenExt => 512, 222 1.1 christos }, 223 1.1 christos }, 224 1.1 christos test => { 225 1.1 christos ApplicationData => 3072, 226 1.1 christos MaxFragmentSize => 1024, 227 1.1 christos } 228 1.1 christos }, 229 1.1 christos { 230 1.1 christos name => "Maximum Fragment Len extension 1024 lower than FragmentSize 1024", 231 1.1 christos server => { }, 232 1.1 christos client => { 233 1.1 christos extra => { 234 1.1 christos MaxFragmentLenExt => 2048, 235 1.1 christos }, 236 1.1 christos }, 237 1.1 christos test => { 238 1.1 christos ApplicationData => 3072, 239 1.1 christos MaxFragmentSize => 1024, 240 1.1 christos } 241 1.1 christos }, 242 1.1 christos { 243 1.1 christos name => "Maximum Fragment Len extension 4096 greater than FragmentSize 2048", 244 1.1 christos server => { }, 245 1.1 christos client => { 246 1.1 christos extra => { 247 1.1 christos MaxFragmentLenExt => 4096, 248 1.1 christos }, 249 1.1 christos }, 250 1.1 christos test => { 251 1.1 christos ApplicationData => 8196, 252 1.1 christos MaxFragmentSize => 2048, 253 1.1 christos } 254 1.1 christos }, 255 1.1 christos { 256 1.1 christos name => "Maximum Fragment Len extension 2048 greater than FragmentSize 1024", 257 1.1 christos server => { }, 258 1.1 christos client => { 259 1.1 christos extra => { 260 1.1 christos MaxFragmentLenExt => 2048, 261 1.1 christos }, 262 1.1 christos }, 263 1.1 christos test => { 264 1.1 christos ApplicationData => 3072, 265 1.1 christos MaxFragmentSize => 1024, 266 1.1 christos } 267 1.1 christos }, 268 1.1 christos ); 269