add sm3 module

This commit is contained in:
Zhi Guan
2017-02-14 17:16:13 +08:00
parent 4d0495ed29
commit 4e49434209
26 changed files with 1784 additions and 22 deletions

View File

@@ -23,7 +23,7 @@ ensures that one gets tested well enough as well.
EOF
my $outfile = "rsa_$$.pem";
ok(run(app(["openssl", "genrsa", "-passout", "pass:password", "-aes128",
ok(run(app(["gmssl", "genrsa", "-passout", "pass:password", "-aes128",
"-out", $outfile])),
"Checking that genrsa with a password works properly");

View File

@@ -0,0 +1,12 @@
#! /usr/bin/env perl
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use OpenSSL::Test::Simple;
simple_test("test_sm3", "sm3test", "sm3");

View File

@@ -22,7 +22,7 @@ require_ok(srctop_file('test','recipes','tconversion.pl'));
ok(run(test(["rsa_test"])), "running rsatest");
ok(run(app([ 'openssl', 'rsa', '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])), "rsa -check");
ok(run(app([ 'gmssl', 'rsa', '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])), "rsa -check");
SKIP: {
skip "Skipping rsa conversion test", 3

View File

@@ -17,17 +17,17 @@ setup("test_passwd");
plan tests => disabled("des") ? 4 : 6;
ok(compare1stline([qw{openssl passwd password}], '^.{13}\R$'),
ok(compare1stline([qw{gmssl passwd password}], '^.{13}\R$'),
'crypt password with random salt') if !disabled("des");
ok(compare1stline([qw{openssl passwd -1 password}], '^\$1\$.{8}\$.{22}\R$'),
ok(compare1stline([qw{gmssl passwd -1 password}], '^\$1\$.{8}\$.{22}\R$'),
'BSD style MD5 password with random salt');
ok(compare1stline([qw{openssl passwd -apr1 password}], '^\$apr1\$.{8}\$.{22}\R$'),
ok(compare1stline([qw{gmssl passwd -apr1 password}], '^\$apr1\$.{8}\$.{22}\R$'),
'Apache style MD5 password with random salt');
ok(compare1stline([qw{openssl passwd -salt xx password}], '^xxj31ZMTZzkVA\R$'),
ok(compare1stline([qw{gmssl passwd -salt xx password}], '^xxj31ZMTZzkVA\R$'),
'crypt password with salt xx') if !disabled("des");
ok(compare1stline([qw{openssl passwd -salt xxxxxxxx -1 password}], '^\$1\$xxxxxxxx\$UYCIxa628\.9qXjpQCjM4a\.\R$'),
ok(compare1stline([qw{gmssl passwd -salt xxxxxxxx -1 password}], '^\$1\$xxxxxxxx\$UYCIxa628\.9qXjpQCjM4a\.\R$'),
'BSD style MD5 password with salt xxxxxxxx');
ok(compare1stline([qw{openssl passwd -salt xxxxxxxx -apr1 password}], '^\$apr1\$xxxxxxxx\$dxHfLAsjHkDRmG83UXe8K0\R$'),
ok(compare1stline([qw{gmssl passwd -salt xxxxxxxx -apr1 password}], '^\$apr1\$xxxxxxxx\$dxHfLAsjHkDRmG83UXe8K0\R$'),
'Apache style MD5 password with salt xxxxxxxx');

View File

@@ -34,11 +34,11 @@ subtest "generating certificate requests" => sub {
plan tests => 2;
ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
ok(run(app(["gmssl", "req", "-config", srctop_file("test", "test.cnf"),
@req_new, "-out", "testreq.pem"])),
"Generating request");
ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
ok(run(app(["gmssl", "req", "-config", srctop_file("test", "test.cnf"),
"-verify", "-in", "testreq.pem", "-noout"])),
"Verifying signature on request");
};
@@ -57,7 +57,7 @@ sub run_conversion {
my $reqfile = shift;
subtest $title => sub {
run(app(["openssl", @openssl_args,
run(app(["gmssl", @openssl_args,
"-in", $reqfile, "-inform", "p",
"-noout", "-text"],
stderr => "req-check.err", stdout => undef));

View File

@@ -17,7 +17,7 @@ setup("test_verify");
sub verify {
my ($cert, $purpose, $trusted, $untrusted, @opts) = @_;
my @args = qw(openssl verify -auth_level 1 -purpose);
my @args = qw(gmssl verify -auth_level 1 -purpose);
my @path = qw(test certs);
push(@args, "$purpose", @opts);
for (@$trusted) { push(@args, "-trusted", srctop_file(@path, "$_.pem")) }

View File

@@ -41,7 +41,7 @@ sub tconversion {
$totaltests-- if ($testtype eq "p7d"); # no comparison of original test file
plan tests => $totaltests;
my @cmd = ("openssl", @openssl_args);
my @cmd = ("gmssl", @openssl_args);
my $init;
if (scalar @openssl_args > 0 && $openssl_args[0] eq "pkey") {