2
0

70-test_renegotiation.t 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #! /usr/bin/env perl
  2. # Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the OpenSSL license (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. use strict;
  9. use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
  10. use OpenSSL::Test::Utils;
  11. use TLSProxy::Proxy;
  12. my $test_name = "test_renegotiation";
  13. setup($test_name);
  14. plan skip_all => "TLSProxy isn't usable on $^O"
  15. if $^O =~ /^(VMS|MSWin32)$/;
  16. plan skip_all => "$test_name needs the dynamic engine feature enabled"
  17. if disabled("engine") || disabled("dynamic-engine");
  18. plan skip_all => "$test_name needs the sock feature enabled"
  19. if disabled("sock");
  20. plan skip_all => "$test_name needs TLS <= 1.2 enabled"
  21. if alldisabled(("ssl3", "tls1", "tls1_1", "tls1_2"));
  22. $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
  23. my $proxy = TLSProxy::Proxy->new(
  24. undef,
  25. cmdstr(app(["openssl"]), display => 1),
  26. srctop_file("apps", "server.pem"),
  27. (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
  28. );
  29. #Test 1: A basic renegotiation test
  30. $proxy->clientflags("-no_tls1_3");
  31. $proxy->reneg(1);
  32. $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
  33. plan tests => 2;
  34. ok(TLSProxy::Message->success(), "Basic renegotiation");
  35. #Test 2: Client does not send the Reneg SCSV. Reneg should fail
  36. $proxy->clear();
  37. $proxy->filter(\&reneg_filter);
  38. $proxy->clientflags("-no_tls1_3");
  39. $proxy->reneg(1);
  40. $proxy->start();
  41. ok(TLSProxy::Message->fail(), "No client SCSV");
  42. sub reneg_filter
  43. {
  44. my $proxy = shift;
  45. # We're only interested in the initial ClientHello message
  46. if ($proxy->flight != 0) {
  47. return;
  48. }
  49. foreach my $message (@{$proxy->message_list}) {
  50. if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
  51. #Remove any SCSV ciphersuites - just leave AES128-SHA (0x002f)
  52. my @ciphersuite = (0x002f);
  53. $message->ciphersuites(\@ciphersuite);
  54. $message->ciphersuite_len(2);
  55. $message->repack();
  56. }
  57. }
  58. }