VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.4/test/recipes/20-test_enc_more.t@ 102863

Last change on this file since 102863 was 102863, checked in by vboxsync, 13 months ago

openssl-3.1.4: Applied and adjusted our OpenSSL changes to 3.1.3. bugref:10577

File size: 2.2 KB
Line 
1#! /usr/bin/env perl
2# Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
3# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
4#
5# Licensed under the Apache License 2.0 (the "License"). You may not use
6# this file except in compliance with the License. You can obtain a copy
7# in the file LICENSE in the source distribution or at
8# https://www.openssl.org/source/license.html
9
10
11use strict;
12use warnings;
13
14use File::Spec::Functions qw/catfile/;
15use File::Copy;
16use File::Compare qw/compare_text/;
17use File::Basename;
18use OpenSSL::Test qw/:DEFAULT srctop_file bldtop_dir/;
19use OpenSSL::Test::Utils;
20
21
22setup("test_evp_more");
23
24my $testsrc = srctop_file("test", "recipes", basename($0));
25
26my $cipherlist = undef;
27my $plaintext = catfile(".", "testdatafile");
28my $fail = "";
29my $cmd = "openssl";
30my $provpath = bldtop_dir("providers");
31my @prov = ("-provider-path", $provpath, "-provider", "default");
32push @prov, ("-provider", "legacy") unless disabled("legacy");
33
34my $ciphersstatus = undef;
35my @ciphers =
36 grep(! /wrap|^$|^[^-]/,
37 (map { split /\s+/ }
38 run(app([$cmd, "enc", "-list"]),
39 capture => 1, statusvar => \$ciphersstatus)));
40@ciphers = grep {!/^-(bf|blowfish|cast|des$|des-cbc|des-cfb|des-ecb|des-ofb
41 |desx|idea|rc2|rc4|seed)/x} @ciphers
42 if disabled("legacy");
43
44plan tests => 2 + scalar @ciphers;
45
46SKIP: {
47 skip "Problems getting ciphers...", 1 + scalar(@ciphers)
48 unless ok($ciphersstatus, "Running 'openssl enc -list'");
49 unless (ok(copy($testsrc, $plaintext), "Copying $testsrc to $plaintext")) {
50 diag($!);
51 skip "Not initialized, skipping...", scalar(@ciphers);
52 }
53
54 foreach my $cipher (@ciphers) {
55 my $ciphername = substr $cipher, 1;
56 my $cipherfile = "$plaintext.$ciphername.cipher";
57 my $clearfile = "$plaintext.$ciphername.clear";
58 my @common = ( $cmd, "enc", "$cipher", "-k", "test" );
59
60 ok(run(app([@common, @prov, "-e", "-in", $plaintext, "-out", $cipherfile]))
61 && compare_text($plaintext, $cipherfile) != 0
62 && run(app([@common, @prov, "-d", "-in", $cipherfile, "-out", $clearfile]))
63 && compare_text($plaintext, $clearfile) == 0
64 , $ciphername);
65 }
66}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette