05-test_rand.t 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2020 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 warnings;
  10. use OpenSSL::Test;
  11. use OpenSSL::Test::Utils;
  12. plan tests => 5;
  13. setup("test_rand");
  14. ok(run(test(["rand_test"])));
  15. ok(run(test(["drbgtest"])));
  16. ok(run(test(["rand_status_test"])));
  17. SKIP: {
  18. skip "engine is not supported by this OpenSSL build", 2
  19. if disabled("engine") || disabled("dynamic-engine");
  20. my $success;
  21. my @randdata;
  22. my $expected = '0102030405060708090a0b0c0d0e0f10';
  23. @randdata = run(app(['openssl', 'rand', '-engine', 'ossltest', '-hex', '16' ]),
  24. capture => 1, statusvar => \$success);
  25. chomp(@randdata);
  26. ok($success and $randdata[0] eq $expected,
  27. "rand with ossltest: Check rand output is as expected");
  28. @randdata = run(app(['openssl', 'rand', '-engine', 'dasync', '-hex', '16' ]),
  29. capture => 1, statusvar => \$success);
  30. chomp(@randdata);
  31. ok($success and length($randdata[0]) == 32,
  32. "rand with dasync: Check rand output is of expected length");
  33. }