]> WPIA git - cassiopeia.git/blob - lib/openssl/test/recipes/20-test_passwd.t
upd: openssl to 1.1.0
[cassiopeia.git] / lib / openssl / test / recipes / 20-test_passwd.t
1 #! /usr/bin/env perl
2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the OpenSSL license (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
9
10 use strict;
11 use warnings;
12
13 use OpenSSL::Test;
14 use OpenSSL::Test::Utils;
15
16 setup("test_passwd");
17
18 plan tests => disabled("des") ? 4 : 6;
19
20 ok(compare1stline([qw{openssl passwd password}], '^.{13}\R$'),
21    'crypt password with random salt') if !disabled("des");
22 ok(compare1stline([qw{openssl passwd -1 password}], '^\$1\$.{8}\$.{22}\R$'),
23    'BSD style MD5 password with random salt');
24 ok(compare1stline([qw{openssl passwd -apr1 password}], '^\$apr1\$.{8}\$.{22}\R$'),
25    'Apache style MD5 password with random salt');
26 ok(compare1stline([qw{openssl passwd -salt xx password}], '^xxj31ZMTZzkVA\R$'),
27    'crypt password with salt xx') if !disabled("des");
28 ok(compare1stline([qw{openssl passwd -salt xxxxxxxx -1 password}], '^\$1\$xxxxxxxx\$UYCIxa628\.9qXjpQCjM4a\.\R$'),
29    'BSD style MD5 password with salt xxxxxxxx');
30 ok(compare1stline([qw{openssl passwd -salt xxxxxxxx -apr1 password}], '^\$apr1\$xxxxxxxx\$dxHfLAsjHkDRmG83UXe8K0\R$'),
31    'Apache style MD5 password with salt xxxxxxxx');
32
33
34 sub compare1stline {
35     my ($cmdarray, $regexp) = @_;
36     my @lines = run(app($cmdarray), capture => 1);
37
38     return $lines[0] =~ m|$regexp|;
39 }