2016-04-22 19:21:51 +08:00
|
|
|
#! /usr/bin/env perl
|
2020-04-23 20:55:52 +08:00
|
|
|
# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
|
2016-04-22 19:21:51 +08:00
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-04-22 19:21:51 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2017-06-28 00:04:37 +08:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use OpenSSL::Test;
|
2020-07-22 10:55:31 +08:00
|
|
|
use OpenSSL::Test::Utils;
|
2024-07-11 08:54:05 +08:00
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
2015-04-18 02:04:19 +08:00
|
|
|
|
2024-07-11 08:54:05 +08:00
|
|
|
plan tests => 6;
|
2017-06-28 00:04:37 +08:00
|
|
|
setup("test_rand");
|
2015-04-18 02:04:19 +08:00
|
|
|
|
2024-07-11 08:54:05 +08:00
|
|
|
ok(run(test(["rand_test", srctop_file("test", "default.cnf")])));
|
|
|
|
|
|
|
|
SKIP: {
|
|
|
|
skip "Skipping FIPS test in this build", 1 if disabled('fips');
|
|
|
|
|
|
|
|
ok(run(test(["rand_test", srctop_file("test", "fips.cnf")])));
|
|
|
|
}
|
|
|
|
|
2017-06-28 00:04:37 +08:00
|
|
|
ok(run(test(["drbgtest"])));
|
2020-08-26 12:11:49 +08:00
|
|
|
ok(run(test(["rand_status_test"])));
|
2022-04-02 19:41:12 +08:00
|
|
|
|
|
|
|
SKIP: {
|
|
|
|
skip "engine is not supported by this OpenSSL build", 2
|
|
|
|
if disabled("engine") || disabled("dynamic-engine");
|
|
|
|
|
|
|
|
my $success;
|
|
|
|
my @randdata;
|
|
|
|
my $expected = '0102030405060708090a0b0c0d0e0f10';
|
|
|
|
|
|
|
|
@randdata = run(app(['openssl', 'rand', '-engine', 'ossltest', '-hex', '16' ]),
|
|
|
|
capture => 1, statusvar => \$success);
|
|
|
|
chomp(@randdata);
|
2023-10-10 18:32:40 +08:00
|
|
|
ok($success && $randdata[0] eq $expected,
|
2022-04-02 19:41:12 +08:00
|
|
|
"rand with ossltest: Check rand output is as expected");
|
|
|
|
|
2023-11-06 06:51:38 +08:00
|
|
|
@randdata = run(app(['openssl', 'rand', '-hex', '2K' ]),
|
|
|
|
capture => 1, statusvar => \$success);
|
|
|
|
chomp(@randdata);
|
|
|
|
|
2022-04-02 19:41:12 +08:00
|
|
|
@randdata = run(app(['openssl', 'rand', '-engine', 'dasync', '-hex', '16' ]),
|
|
|
|
capture => 1, statusvar => \$success);
|
|
|
|
chomp(@randdata);
|
2023-10-10 18:32:40 +08:00
|
|
|
ok($success && length($randdata[0]) == 32,
|
2022-04-02 19:41:12 +08:00
|
|
|
"rand with dasync: Check rand output is of expected length");
|
|
|
|
}
|