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