1e1051a39Sopenharmony_ci#! /usr/bin/env perl 2e1051a39Sopenharmony_ci# Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci# 4e1051a39Sopenharmony_ci# Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci# this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci# in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci# https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci 9e1051a39Sopenharmony_ciuse strict; 10e1051a39Sopenharmony_ciuse warnings; 11e1051a39Sopenharmony_ciuse OpenSSL::Test; 12e1051a39Sopenharmony_ciuse OpenSSL::Test::Utils; 13e1051a39Sopenharmony_ci 14e1051a39Sopenharmony_ciplan tests => 5; 15e1051a39Sopenharmony_cisetup("test_rand"); 16e1051a39Sopenharmony_ci 17e1051a39Sopenharmony_ciok(run(test(["rand_test"]))); 18e1051a39Sopenharmony_ciok(run(test(["drbgtest"]))); 19e1051a39Sopenharmony_ciok(run(test(["rand_status_test"]))); 20e1051a39Sopenharmony_ci 21e1051a39Sopenharmony_ciSKIP: { 22e1051a39Sopenharmony_ci skip "engine is not supported by this OpenSSL build", 2 23e1051a39Sopenharmony_ci if disabled("engine") || disabled("dynamic-engine"); 24e1051a39Sopenharmony_ci 25e1051a39Sopenharmony_ci my $success; 26e1051a39Sopenharmony_ci my @randdata; 27e1051a39Sopenharmony_ci my $expected = '0102030405060708090a0b0c0d0e0f10'; 28e1051a39Sopenharmony_ci 29e1051a39Sopenharmony_ci @randdata = run(app(['openssl', 'rand', '-engine', 'ossltest', '-hex', '16' ]), 30e1051a39Sopenharmony_ci capture => 1, statusvar => \$success); 31e1051a39Sopenharmony_ci chomp(@randdata); 32e1051a39Sopenharmony_ci ok($success and $randdata[0] eq $expected, 33e1051a39Sopenharmony_ci "rand with ossltest: Check rand output is as expected"); 34e1051a39Sopenharmony_ci 35e1051a39Sopenharmony_ci @randdata = run(app(['openssl', 'rand', '-engine', 'dasync', '-hex', '16' ]), 36e1051a39Sopenharmony_ci capture => 1, statusvar => \$success); 37e1051a39Sopenharmony_ci chomp(@randdata); 38e1051a39Sopenharmony_ci ok($success and length($randdata[0]) == 32, 39e1051a39Sopenharmony_ci "rand with dasync: Check rand output is of expected length"); 40e1051a39Sopenharmony_ci} 41