70-test_sslskewith0p.t 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #! /usr/bin/env perl
  2. # Copyright 2015-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_sslskewith0p";
  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 => "dh is not supported by this OpenSSL build"
  19. if disabled("dh");
  20. plan skip_all => "$test_name needs the sock feature enabled"
  21. if disabled("sock");
  22. plan skip_all => "$test_name needs TLS enabled"
  23. if alldisabled(available_protocols("tls"));
  24. $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
  25. my $proxy = TLSProxy::Proxy->new(
  26. \&ske_0_p_filter,
  27. cmdstr(app(["openssl"]), display => 1),
  28. srctop_file("apps", "server.pem"),
  29. (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
  30. );
  31. #We must use an anon DHE cipher for this test
  32. $proxy->cipherc('ADH-AES128-SHA:@SECLEVEL=0');
  33. $proxy->ciphers('ADH-AES128-SHA:@SECLEVEL=0');
  34. $proxy->clientflags("-no_tls1_3");
  35. $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
  36. plan tests => 1;
  37. ok(TLSProxy::Message->fail, "ServerKeyExchange with 0 p");
  38. sub ske_0_p_filter
  39. {
  40. my $proxy = shift;
  41. # We're only interested in the SKE - always in flight 1
  42. if ($proxy->flight != 1) {
  43. return;
  44. }
  45. foreach my $message (@{$proxy->message_list}) {
  46. if ($message->mt == TLSProxy::Message::MT_SERVER_KEY_EXCHANGE) {
  47. #Set p to a value of 0
  48. $message->p(pack('C', 0));
  49. $message->repack();
  50. }
  51. }
  52. }