70-test_sslskewith0p.t 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (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)$/;
  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. my $proxy = TLSProxy::Proxy->new(
  25. \&ske_0_p_filter,
  26. cmdstr(app(["openssl"]), display => 1),
  27. srctop_file("apps", "server.pem"),
  28. (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
  29. );
  30. #We must use an anon DHE cipher for this test
  31. $proxy->cipherc('ADH-AES128-SHA:@SECLEVEL=0');
  32. $proxy->ciphers('ADH-AES128-SHA:@SECLEVEL=0');
  33. $proxy->clientflags("-no_tls1_3");
  34. $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
  35. plan tests => 1;
  36. ok(TLSProxy::Message->fail, "ServerKeyExchange with 0 p");
  37. sub ske_0_p_filter
  38. {
  39. my $proxy = shift;
  40. # We're only interested in the SKE - always in flight 1
  41. if ($proxy->flight != 1) {
  42. return;
  43. }
  44. foreach my $message (@{$proxy->message_list}) {
  45. if ($message->mt == TLSProxy::Message::MT_SERVER_KEY_EXCHANGE) {
  46. #Set p to a value of 0
  47. $message->p(pack('C', 0));
  48. $message->repack();
  49. }
  50. }
  51. }