1e0c4386eSCy Schubert# -*- mode: perl; -*- 2*a7148ab3SEnji Cooper# Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved. 3e0c4386eSCy Schubert# 4e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License"). You may not use 5e0c4386eSCy Schubert# this file except in compliance with the License. You can obtain a copy 6e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at 7e0c4386eSCy Schubert# https://www.openssl.org/source/license.html 8e0c4386eSCy Schubert 9e0c4386eSCy Schubert 10e0c4386eSCy Schubert## Test version negotiation 11e0c4386eSCy Schubert 12e0c4386eSCy Schubertuse strict; 13e0c4386eSCy Schubertuse warnings; 14e0c4386eSCy Schubert 15e0c4386eSCy Schubertpackage ssltests; 16e0c4386eSCy Schubert 17e0c4386eSCy Schubert 18e0c4386eSCy Schubertour @tests = ( 19e0c4386eSCy Schubert { 20e0c4386eSCy Schubert name => "alpn-simple", 21e0c4386eSCy Schubert server => { 22e0c4386eSCy Schubert extra => { 23e0c4386eSCy Schubert "ALPNProtocols" => "foo", 24e0c4386eSCy Schubert }, 25e0c4386eSCy Schubert }, 26e0c4386eSCy Schubert client => { 27e0c4386eSCy Schubert extra => { 28e0c4386eSCy Schubert "ALPNProtocols" => "foo", 29e0c4386eSCy Schubert }, 30e0c4386eSCy Schubert }, 31e0c4386eSCy Schubert test => { 32e0c4386eSCy Schubert "ExpectedALPNProtocol" => "foo", 33e0c4386eSCy Schubert }, 34e0c4386eSCy Schubert }, 35e0c4386eSCy Schubert { 36e0c4386eSCy Schubert name => "alpn-server-finds-match", 37e0c4386eSCy Schubert server => { 38e0c4386eSCy Schubert extra => { 39e0c4386eSCy Schubert "ALPNProtocols" => "baz,bar", 40e0c4386eSCy Schubert }, 41e0c4386eSCy Schubert }, 42e0c4386eSCy Schubert client => { 43e0c4386eSCy Schubert extra => { 44e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar", 45e0c4386eSCy Schubert }, 46e0c4386eSCy Schubert }, 47e0c4386eSCy Schubert test => { 48e0c4386eSCy Schubert "ExpectedALPNProtocol" => "bar", 49e0c4386eSCy Schubert }, 50e0c4386eSCy Schubert }, 51e0c4386eSCy Schubert { 52e0c4386eSCy Schubert name => "alpn-server-honours-server-pref", 53e0c4386eSCy Schubert server => { 54e0c4386eSCy Schubert extra => { 55e0c4386eSCy Schubert "ALPNProtocols" => "bar,foo", 56e0c4386eSCy Schubert }, 57e0c4386eSCy Schubert }, 58e0c4386eSCy Schubert client => { 59e0c4386eSCy Schubert extra => { 60e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar", 61e0c4386eSCy Schubert }, 62e0c4386eSCy Schubert }, 63e0c4386eSCy Schubert test => { 64e0c4386eSCy Schubert "ExpectedALPNProtocol" => "bar", 65e0c4386eSCy Schubert }, 66e0c4386eSCy Schubert }, 67e0c4386eSCy Schubert { 68e0c4386eSCy Schubert name => "alpn-alert-on-mismatch", 69e0c4386eSCy Schubert server => { 70e0c4386eSCy Schubert extra => { 71e0c4386eSCy Schubert "ALPNProtocols" => "baz", 72e0c4386eSCy Schubert }, 73e0c4386eSCy Schubert }, 74e0c4386eSCy Schubert client => { 75e0c4386eSCy Schubert extra => { 76e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar", 77e0c4386eSCy Schubert }, 78e0c4386eSCy Schubert }, 79e0c4386eSCy Schubert test => { 80e0c4386eSCy Schubert "ExpectedResult" => "ServerFail", 81e0c4386eSCy Schubert "ExpectedServerAlert" => "NoApplicationProtocol", 82e0c4386eSCy Schubert }, 83e0c4386eSCy Schubert }, 84e0c4386eSCy Schubert { 85e0c4386eSCy Schubert name => "alpn-no-server-support", 86e0c4386eSCy Schubert server => { }, 87e0c4386eSCy Schubert client => { 88e0c4386eSCy Schubert extra => { 89e0c4386eSCy Schubert "ALPNProtocols" => "foo", 90e0c4386eSCy Schubert }, 91e0c4386eSCy Schubert }, 92e0c4386eSCy Schubert test => { 93e0c4386eSCy Schubert "ExpectedALPNProtocol" => undef, 94e0c4386eSCy Schubert }, 95e0c4386eSCy Schubert }, 96e0c4386eSCy Schubert { 97e0c4386eSCy Schubert name => "alpn-no-client-support", 98e0c4386eSCy Schubert server => { 99e0c4386eSCy Schubert extra => { 100e0c4386eSCy Schubert "ALPNProtocols" => "foo", 101e0c4386eSCy Schubert }, 102e0c4386eSCy Schubert }, 103e0c4386eSCy Schubert client => { }, 104e0c4386eSCy Schubert test => { 105e0c4386eSCy Schubert "ExpectedALPNProtocol" => undef, 106e0c4386eSCy Schubert }, 107e0c4386eSCy Schubert }, 108e0c4386eSCy Schubert { 109e0c4386eSCy Schubert name => "alpn-with-sni-no-context-switch", 110e0c4386eSCy Schubert server => { 111e0c4386eSCy Schubert extra => { 112e0c4386eSCy Schubert "ALPNProtocols" => "foo", 113e0c4386eSCy Schubert "ServerNameCallback" => "IgnoreMismatch", 114e0c4386eSCy Schubert }, 115e0c4386eSCy Schubert }, 116e0c4386eSCy Schubert server2 => { 117e0c4386eSCy Schubert extra => { 118e0c4386eSCy Schubert "ALPNProtocols" => "bar", 119e0c4386eSCy Schubert }, 120e0c4386eSCy Schubert }, 121e0c4386eSCy Schubert client => { 122e0c4386eSCy Schubert extra => { 123e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar", 124e0c4386eSCy Schubert "ServerName" => "server1", 125e0c4386eSCy Schubert }, 126e0c4386eSCy Schubert }, 127e0c4386eSCy Schubert test => { 128e0c4386eSCy Schubert "ExpectedServerName" => "server1", 129e0c4386eSCy Schubert "ExpectedALPNProtocol" => "foo", 130e0c4386eSCy Schubert }, 131e0c4386eSCy Schubert }, 132e0c4386eSCy Schubert { 133e0c4386eSCy Schubert name => "alpn-with-sni-context-switch", 134e0c4386eSCy Schubert server => { 135e0c4386eSCy Schubert extra => { 136e0c4386eSCy Schubert "ALPNProtocols" => "foo", 137e0c4386eSCy Schubert "ServerNameCallback" => "IgnoreMismatch", 138e0c4386eSCy Schubert }, 139e0c4386eSCy Schubert }, 140e0c4386eSCy Schubert server2 => { 141e0c4386eSCy Schubert extra => { 142e0c4386eSCy Schubert "ALPNProtocols" => "bar", 143e0c4386eSCy Schubert }, 144e0c4386eSCy Schubert }, 145e0c4386eSCy Schubert client => { 146e0c4386eSCy Schubert extra => { 147e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar", 148e0c4386eSCy Schubert "ServerName" => "server2", 149e0c4386eSCy Schubert }, 150e0c4386eSCy Schubert }, 151e0c4386eSCy Schubert test => { 152e0c4386eSCy Schubert "ExpectedServerName" => "server2", 153e0c4386eSCy Schubert "ExpectedALPNProtocol" => "bar", 154e0c4386eSCy Schubert }, 155e0c4386eSCy Schubert }, 156e0c4386eSCy Schubert { 157e0c4386eSCy Schubert name => "alpn-selected-sni-server-supports-alpn", 158e0c4386eSCy Schubert server => { 159e0c4386eSCy Schubert extra => { 160e0c4386eSCy Schubert "ServerNameCallback" => "IgnoreMismatch", 161e0c4386eSCy Schubert }, 162e0c4386eSCy Schubert }, 163e0c4386eSCy Schubert server2 => { 164e0c4386eSCy Schubert extra => { 165e0c4386eSCy Schubert "ALPNProtocols" => "bar", 166e0c4386eSCy Schubert }, 167e0c4386eSCy Schubert }, 168e0c4386eSCy Schubert client => { 169e0c4386eSCy Schubert extra => { 170e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar", 171e0c4386eSCy Schubert "ServerName" => "server2", 172e0c4386eSCy Schubert }, 173e0c4386eSCy Schubert }, 174e0c4386eSCy Schubert test => { 175e0c4386eSCy Schubert "ExpectedServerName" => "server2", 176e0c4386eSCy Schubert "ExpectedALPNProtocol" => "bar", 177e0c4386eSCy Schubert }, 178e0c4386eSCy Schubert }, 179e0c4386eSCy Schubert { 180e0c4386eSCy Schubert name => "alpn-selected-sni-server-does-not-support-alpn", 181e0c4386eSCy Schubert server => { 182e0c4386eSCy Schubert extra => { 183e0c4386eSCy Schubert "ALPNProtocols" => "bar", 184e0c4386eSCy Schubert "ServerNameCallback" => "IgnoreMismatch", 185e0c4386eSCy Schubert }, 186e0c4386eSCy Schubert }, 187e0c4386eSCy Schubert server2 => { }, 188e0c4386eSCy Schubert client => { 189e0c4386eSCy Schubert extra => { 190e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar", 191e0c4386eSCy Schubert "ServerName" => "server2", 192e0c4386eSCy Schubert }, 193e0c4386eSCy Schubert }, 194e0c4386eSCy Schubert test => { 195e0c4386eSCy Schubert "ExpectedServerName" => "server2", 196e0c4386eSCy Schubert "ExpectedALPNProtocol" => undef, 197e0c4386eSCy Schubert }, 198e0c4386eSCy Schubert }, 199e0c4386eSCy Schubert { 200e0c4386eSCy Schubert name => "alpn-simple-resumption", 201e0c4386eSCy Schubert server => { 202e0c4386eSCy Schubert extra => { 203e0c4386eSCy Schubert "ALPNProtocols" => "foo", 204e0c4386eSCy Schubert }, 205e0c4386eSCy Schubert }, 206e0c4386eSCy Schubert client => { 207e0c4386eSCy Schubert extra => { 208e0c4386eSCy Schubert "ALPNProtocols" => "foo", 209e0c4386eSCy Schubert }, 210e0c4386eSCy Schubert }, 211e0c4386eSCy Schubert test => { 212e0c4386eSCy Schubert "HandshakeMode" => "Resume", 213e0c4386eSCy Schubert "ResumptionExpected" => "Yes", 214e0c4386eSCy Schubert "ExpectedALPNProtocol" => "foo", 215e0c4386eSCy Schubert }, 216e0c4386eSCy Schubert }, 217e0c4386eSCy Schubert { 218e0c4386eSCy Schubert name => "alpn-server-switch-resumption", 219e0c4386eSCy Schubert server => { 220e0c4386eSCy Schubert extra => { 221e0c4386eSCy Schubert "ALPNProtocols" => "bar,foo", 222e0c4386eSCy Schubert }, 223e0c4386eSCy Schubert }, 224e0c4386eSCy Schubert resume_server => { 225e0c4386eSCy Schubert extra => { 226e0c4386eSCy Schubert "ALPNProtocols" => "baz,foo", 227e0c4386eSCy Schubert }, 228e0c4386eSCy Schubert }, 229e0c4386eSCy Schubert client => { 230e0c4386eSCy Schubert extra => { 231e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar,baz", 232e0c4386eSCy Schubert }, 233e0c4386eSCy Schubert }, 234e0c4386eSCy Schubert test => { 235e0c4386eSCy Schubert "HandshakeMode" => "Resume", 236e0c4386eSCy Schubert "ResumptionExpected" => "Yes", 237e0c4386eSCy Schubert "ExpectedALPNProtocol" => "baz", 238e0c4386eSCy Schubert }, 239e0c4386eSCy Schubert }, 240e0c4386eSCy Schubert { 241e0c4386eSCy Schubert name => "alpn-client-switch-resumption", 242e0c4386eSCy Schubert server => { 243e0c4386eSCy Schubert extra => { 244e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar,baz", 245e0c4386eSCy Schubert }, 246e0c4386eSCy Schubert }, 247e0c4386eSCy Schubert client => { 248e0c4386eSCy Schubert extra => { 249e0c4386eSCy Schubert "ALPNProtocols" => "foo,baz", 250e0c4386eSCy Schubert }, 251e0c4386eSCy Schubert }, 252e0c4386eSCy Schubert resume_client => { 253e0c4386eSCy Schubert extra => { 254e0c4386eSCy Schubert "ALPNProtocols" => "bar,baz", 255e0c4386eSCy Schubert }, 256e0c4386eSCy Schubert }, 257e0c4386eSCy Schubert test => { 258e0c4386eSCy Schubert "HandshakeMode" => "Resume", 259e0c4386eSCy Schubert "ResumptionExpected" => "Yes", 260e0c4386eSCy Schubert "ExpectedALPNProtocol" => "bar", 261e0c4386eSCy Schubert }, 262e0c4386eSCy Schubert }, 263e0c4386eSCy Schubert { 264e0c4386eSCy Schubert name => "alpn-alert-on-mismatch-resumption", 265e0c4386eSCy Schubert server => { 266e0c4386eSCy Schubert extra => { 267e0c4386eSCy Schubert "ALPNProtocols" => "bar", 268e0c4386eSCy Schubert }, 269e0c4386eSCy Schubert }, 270e0c4386eSCy Schubert resume_server => { 271e0c4386eSCy Schubert extra => { 272e0c4386eSCy Schubert "ALPNProtocols" => "baz", 273e0c4386eSCy Schubert }, 274e0c4386eSCy Schubert }, 275e0c4386eSCy Schubert client => { 276e0c4386eSCy Schubert extra => { 277e0c4386eSCy Schubert "ALPNProtocols" => "foo,bar", 278e0c4386eSCy Schubert }, 279e0c4386eSCy Schubert }, 280e0c4386eSCy Schubert test => { 281e0c4386eSCy Schubert "HandshakeMode" => "Resume", 282e0c4386eSCy Schubert "ExpectedResult" => "ServerFail", 283e0c4386eSCy Schubert "ExpectedServerAlert" => "NoApplicationProtocol", 284e0c4386eSCy Schubert }, 285e0c4386eSCy Schubert }, 286e0c4386eSCy Schubert { 287e0c4386eSCy Schubert name => "alpn-no-server-support-resumption", 288e0c4386eSCy Schubert server => { 289e0c4386eSCy Schubert extra => { 290e0c4386eSCy Schubert "ALPNProtocols" => "foo", 291e0c4386eSCy Schubert }, 292e0c4386eSCy Schubert }, 293e0c4386eSCy Schubert resume_server => { }, 294e0c4386eSCy Schubert client => { 295e0c4386eSCy Schubert extra => { 296e0c4386eSCy Schubert "ALPNProtocols" => "foo", 297e0c4386eSCy Schubert }, 298e0c4386eSCy Schubert }, 299e0c4386eSCy Schubert test => { 300e0c4386eSCy Schubert "HandshakeMode" => "Resume", 301e0c4386eSCy Schubert "ResumptionExpected" => "Yes", 302e0c4386eSCy Schubert "ExpectedALPNProtocol" => undef, 303e0c4386eSCy Schubert }, 304e0c4386eSCy Schubert }, 305e0c4386eSCy Schubert { 306e0c4386eSCy Schubert name => "alpn-no-client-support-resumption", 307e0c4386eSCy Schubert server => { 308e0c4386eSCy Schubert extra => { 309e0c4386eSCy Schubert "ALPNProtocols" => "foo", 310e0c4386eSCy Schubert }, 311e0c4386eSCy Schubert }, 312e0c4386eSCy Schubert client => { 313e0c4386eSCy Schubert extra => { 314e0c4386eSCy Schubert "ALPNProtocols" => "foo", 315e0c4386eSCy Schubert }, 316e0c4386eSCy Schubert }, 317e0c4386eSCy Schubert resume_client => { 318e0c4386eSCy Schubert }, 319e0c4386eSCy Schubert test => { 320e0c4386eSCy Schubert "HandshakeMode" => "Resume", 321e0c4386eSCy Schubert "ResumptionExpected" => "Yes", 322e0c4386eSCy Schubert "ExpectedALPNProtocol" => undef, 323e0c4386eSCy Schubert }, 324e0c4386eSCy Schubert }, 325*a7148ab3SEnji Cooper { 326*a7148ab3SEnji Cooper name => "alpn-empty-client-list", 327*a7148ab3SEnji Cooper server => { 328*a7148ab3SEnji Cooper extra => { 329*a7148ab3SEnji Cooper "ALPNProtocols" => "foo", 330*a7148ab3SEnji Cooper }, 331*a7148ab3SEnji Cooper }, 332*a7148ab3SEnji Cooper client => { 333*a7148ab3SEnji Cooper extra => { 334*a7148ab3SEnji Cooper "ALPNProtocols" => "", 335*a7148ab3SEnji Cooper }, 336*a7148ab3SEnji Cooper }, 337*a7148ab3SEnji Cooper test => { 338*a7148ab3SEnji Cooper "ExpectedALPNProtocol" => undef, 339*a7148ab3SEnji Cooper }, 340*a7148ab3SEnji Cooper }, 341*a7148ab3SEnji Cooper { 342*a7148ab3SEnji Cooper name => "alpn-empty-server-list", 343*a7148ab3SEnji Cooper server => { 344*a7148ab3SEnji Cooper extra => { 345*a7148ab3SEnji Cooper "ALPNProtocols" => "", 346*a7148ab3SEnji Cooper }, 347*a7148ab3SEnji Cooper }, 348*a7148ab3SEnji Cooper client => { 349*a7148ab3SEnji Cooper extra => { 350*a7148ab3SEnji Cooper "ALPNProtocols" => "foo", 351*a7148ab3SEnji Cooper }, 352*a7148ab3SEnji Cooper }, 353*a7148ab3SEnji Cooper test => { 354*a7148ab3SEnji Cooper "ExpectedResult" => "ServerFail", 355*a7148ab3SEnji Cooper "ExpectedServerAlert" => "NoApplicationProtocol", 356*a7148ab3SEnji Cooper }, 357*a7148ab3SEnji Cooper }, 358e0c4386eSCy Schubert); 359