2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
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
14 use OpenSSL::Test::Utils;
18 plan tests => disabled("des") ? 4 : 6;
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');
35 my ($cmdarray, $regexp) = @_;
36 my @lines = run(app($cmdarray), capture => 1);
38 return $lines[0] =~ m|$regexp|;