1#! /usr/bin/env perl 2# Copyright 2015-2024 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 9use strict; 10use warnings; 11use OpenSSL::Test; 12use OpenSSL::Test::Utils; 13use OpenSSL::Test qw/:DEFAULT srctop_file/; 14 15plan tests => 6; 16setup("test_rand"); 17 18ok(run(test(["rand_test", srctop_file("test", "default.cnf")]))); 19 20SKIP: { 21 skip "Skipping FIPS test in this build", 1 if disabled('fips'); 22 23 ok(run(test(["rand_test", srctop_file("test", "fips.cnf")]))); 24} 25 26ok(run(test(["drbgtest"]))); 27ok(run(test(["rand_status_test"]))); 28 29SKIP: { 30 skip "engine is not supported by this OpenSSL build", 2 31 if disabled("engine") || disabled("dynamic-engine"); 32 33 my $success; 34 my @randdata; 35 my $expected = '0102030405060708090a0b0c0d0e0f10'; 36 37 @randdata = run(app(['openssl', 'rand', '-engine', 'ossltest', '-hex', '16' ]), 38 capture => 1, statusvar => \$success); 39 chomp(@randdata); 40 ok($success && $randdata[0] eq $expected, 41 "rand with ossltest: Check rand output is as expected"); 42 43 @randdata = run(app(['openssl', 'rand', '-hex', '2K' ]), 44 capture => 1, statusvar => \$success); 45 chomp(@randdata); 46 47 @randdata = run(app(['openssl', 'rand', '-engine', 'dasync', '-hex', '16' ]), 48 capture => 1, statusvar => \$success); 49 chomp(@randdata); 50 ok($success && length($randdata[0]) == 32, 51 "rand with dasync: Check rand output is of expected length"); 52} 53