Latest update.
This commit is contained in:
@@ -9,6 +9,14 @@
|
||||
|
||||
Changes between 1.1.1 and 1.1.2 [xx XXX xxxx]
|
||||
|
||||
*) Instead of having the source directories listed in Configure, add
|
||||
a 'build.info' keyword SUBDIRS to indicate what sub-directories to
|
||||
look into.
|
||||
[Richard Levitte]
|
||||
|
||||
*) Add GMAC to EVP_MAC.
|
||||
[Paul Dale]
|
||||
|
||||
*) Ported the HMAC, CMAC and SipHash EVP_PKEY_METHODs to EVP_MAC.
|
||||
[Richard Levitte]
|
||||
|
||||
|
||||
+11
-1
@@ -400,7 +400,13 @@ $sourcedir and $builddir, which are the locations of the source
|
||||
directory for the current build.info file and the corresponding build
|
||||
directory, all relative to the top of the build tree.
|
||||
|
||||
To begin with, things to be built are declared by setting specific
|
||||
'Configure' only knows inherently about the top build.info file. For
|
||||
any other directory that has one, further directories to look into
|
||||
must be indicated like this:
|
||||
|
||||
SUBDIRS=something someelse
|
||||
|
||||
On to things to be built; they are declared by setting specific
|
||||
variables:
|
||||
|
||||
PROGRAMS=foo bar
|
||||
@@ -467,6 +473,10 @@ include paths the build of their source files should use:
|
||||
|
||||
INCLUDE[foo]=include
|
||||
|
||||
It's also possible to specify C macros that should be defined:
|
||||
|
||||
DEFINE[foo]=FOO BAR=1
|
||||
|
||||
In some cases, one might want to generate some source files from
|
||||
others, that's done as follows:
|
||||
|
||||
|
||||
@@ -41,9 +41,10 @@ end products. There are variants for them with '_NO_INST' as suffix
|
||||
(PROGRAM_NO_INST etc) to specify end products that shouldn't get
|
||||
installed.
|
||||
|
||||
The variables SOURCE, DEPEND and INCLUDE are indexed by a produced
|
||||
file, and their values are the source used to produce that particular
|
||||
produced file, extra dependencies, and include directories needed.
|
||||
The variables SOURCE, DEPEND, INCLUDE and DEFINE are indexed by a
|
||||
produced file, and their values are the source used to produce that
|
||||
particular produced file, extra dependencies, include directories
|
||||
needed, or C macros to be defined.
|
||||
|
||||
All their values in all the build.info throughout the source tree are
|
||||
collected together and form a set of programs, libraries, engines and
|
||||
|
||||
@@ -85,6 +85,8 @@
|
||||
deps => $unified_info{depends}->{$src},
|
||||
incs => [ @{$unified_info{includes}->{$obj}},
|
||||
@{$unified_info{includes}->{$bin}} ],
|
||||
defs => [ @{$unified_info{defines}->{$obj}},
|
||||
@{$unified_info{defines}->{$bin}} ],
|
||||
%opts);
|
||||
foreach (@{$unified_info{depends}->{$src}}) {
|
||||
dogenerate($_, $obj, $bin, %opts);
|
||||
@@ -107,6 +109,8 @@
|
||||
deps => $unified_info{depends}->{$obj},
|
||||
incs => [ @{$unified_info{includes}->{$obj}},
|
||||
@{$unified_info{includes}->{$bin}} ],
|
||||
defs => [ @{$unified_info{defines}->{$obj}},
|
||||
@{$unified_info{defines}->{$bin}} ],
|
||||
%opts);
|
||||
foreach ((@{$unified_info{sources}->{$obj}},
|
||||
@{$unified_info{depends}->{$obj}})) {
|
||||
|
||||
@@ -199,7 +199,8 @@ ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
|
||||
CNF_ASFLAGS={- join('', $target{asflags} || (),
|
||||
@{$config{asflags}}) -}
|
||||
CNF_DEFINES={- our $defines2 = join('', map { ",$_" } @{$target{defines}},
|
||||
@{$config{defines}}) -}
|
||||
@{$config{defines}},
|
||||
"'extradefines'") -}
|
||||
CNF_INCLUDES={- our $includes2 = join(',', @{$target{includes}},
|
||||
@{$config{includes}}) -}
|
||||
CNF_CPPFLAGS={- our $cppflags2 = join('', $target{cppflags} || (),
|
||||
@@ -810,6 +811,7 @@ EOF
|
||||
@{$args{incs}});
|
||||
my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
|
||||
my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
|
||||
my $defs = join("", map { ",".$_ } @{$args{defs}});
|
||||
if (defined($generator)) {
|
||||
# If the target is named foo.S in build.info, we want to
|
||||
# end up generating foo.s in two steps.
|
||||
@@ -818,8 +820,10 @@ EOF
|
||||
$target : $args{generator}->[0] $deps
|
||||
$generator \$\@-S
|
||||
\@ $incs_on
|
||||
\@ extradefines = "$defs"
|
||||
PIPE \$(CPP) $cppflags \$\@-S | -
|
||||
\$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i
|
||||
\@ DELETE/SYMBOL/LOCAL extradefines
|
||||
\@ $incs_off
|
||||
RENAME \$\@-i \$\@
|
||||
DELETE \$\@-S
|
||||
@@ -834,9 +838,11 @@ EOF
|
||||
return <<"EOF";
|
||||
$target : $args{generator}->[0] $deps
|
||||
\@ $incs_on
|
||||
\@ extradefines = "$defs"
|
||||
SHOW SYMBOL qual_includes
|
||||
PIPE \$(CPP) $cppflags $args{generator}->[0] | -
|
||||
\$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
|
||||
\@ DELETE/SYMBOL/LOCAL extradefines
|
||||
\@ $incs_off
|
||||
EOF
|
||||
}
|
||||
@@ -894,6 +900,7 @@ EOF
|
||||
lib => '$(LIB_CPPFLAGS)',
|
||||
dso => '$(DSO_CPPFLAGS)',
|
||||
bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
|
||||
my $defs = join("", map { ",".$_ } @{$args{defs}});
|
||||
|
||||
my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
|
||||
lib => '$(LIB_INCLUDES)',
|
||||
@@ -914,7 +921,9 @@ $obj.OBJ : $deps
|
||||
${before}
|
||||
SET DEFAULT $forward
|
||||
\@ $incs_on
|
||||
\@ extradefines = "$defs"
|
||||
\$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
|
||||
\@ DELETE/SYMBOL/LOCAL extradefines
|
||||
\@ $incs_off
|
||||
SET DEFAULT $backward
|
||||
${after}
|
||||
|
||||
@@ -996,6 +996,7 @@ reconfigure reconf:
|
||||
my $generator = join(" ", @{$args{generator}});
|
||||
my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
|
||||
my $incs = join("", map { " -I".$_ } @{$args{incs}});
|
||||
my $defs = join("", map { " -D".$_ } @{$args{defs}});
|
||||
my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
|
||||
|
||||
if ($args{src} =~ /\.ld$/) {
|
||||
@@ -1049,7 +1050,7 @@ EOF
|
||||
}
|
||||
return <<"EOF";
|
||||
$args{src}: $args{generator}->[0] $deps
|
||||
\$(CC) $incs $cppflags -E $args{generator}->[0] | \\
|
||||
\$(CC) $incs $cppflags $defs -E $args{generator}->[0] | \\
|
||||
\$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
|
||||
EOF
|
||||
}
|
||||
@@ -1065,6 +1066,7 @@ EOF
|
||||
my $srcs = join(" ", @srcs);
|
||||
my $deps = join(" ", @srcs, @{$args{deps}});
|
||||
my $incs = join("", map { " -I".$_ } @{$args{incs}});
|
||||
my $defs = join("", map { " -D".$_ } @{$args{defs}});
|
||||
my $cmd;
|
||||
my $cmdflags;
|
||||
my $cmdcompile;
|
||||
@@ -1106,13 +1108,13 @@ EOF
|
||||
# hardly a point to drag it along...
|
||||
$recipe .= <<"EOF";
|
||||
$obj$objext: $deps
|
||||
$cmd $incs $cmdflags -c -o \$\@ $srcs
|
||||
$cmd $incs $defs $cmdflags -c -o \$\@ $srcs
|
||||
EOF
|
||||
} elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
|
||||
&& !grep /\.rc$/, @srcs) {
|
||||
$recipe .= <<"EOF";
|
||||
$obj$objext: $deps
|
||||
$cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
|
||||
$cmd $incs $defs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
|
||||
\@touch $obj$depext.tmp
|
||||
\@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
|
||||
rm -f $obj$depext.tmp; \\
|
||||
@@ -1123,7 +1125,7 @@ EOF
|
||||
} else {
|
||||
$recipe .= <<"EOF";
|
||||
$obj$objext: $deps
|
||||
$cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
|
||||
$cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
|
||||
EOF
|
||||
if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
|
||||
$recipe .= <<"EOF";
|
||||
|
||||
@@ -501,6 +501,7 @@ reconfigure reconf:
|
||||
my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
|
||||
my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
|
||||
my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
|
||||
my $defs = join("", map { " /D".$_ } @{$args{defs}});
|
||||
my $deps = @{$args{deps}} ?
|
||||
'"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
|
||||
|
||||
@@ -558,7 +559,7 @@ EOF
|
||||
$target: "$args{generator}->[0]" $deps
|
||||
set ASM=\$(AS)
|
||||
$generator \$@.S
|
||||
\$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
|
||||
\$(CPP) $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
|
||||
del /Q \$@.S
|
||||
EOF
|
||||
}
|
||||
@@ -571,7 +572,7 @@ EOF
|
||||
}
|
||||
return <<"EOF";
|
||||
$target: "$args{generator}->[0]" $deps
|
||||
\$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
|
||||
\$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
|
||||
EOF
|
||||
}
|
||||
}
|
||||
@@ -583,6 +584,7 @@ EOF
|
||||
my $srcs = '"'.join('" "', @srcs).'"';
|
||||
my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
|
||||
my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
|
||||
my $defs = join("", map { " /D".$_ } @{$args{defs}});
|
||||
my $cflags = { shlib => ' $(LIB_CFLAGS)',
|
||||
lib => ' $(LIB_CFLAGS)',
|
||||
dso => ' $(DSO_CFLAGS)',
|
||||
@@ -612,15 +614,15 @@ EOF
|
||||
} elsif ($srcs[0] =~ /.S$/) {
|
||||
return <<"EOF";
|
||||
$obj$objext: $deps
|
||||
\$(CC) /EP /D__ASSEMBLER__ $cflags $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
|
||||
\$(CC) /EP /D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
|
||||
EOF
|
||||
}
|
||||
my $recipe = <<"EOF";
|
||||
$obj$objext: $deps
|
||||
\$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
|
||||
\$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
|
||||
EOF
|
||||
$recipe .= <<"EOF" unless $disabled{makedepend};
|
||||
\$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
|
||||
\$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $obj$depext
|
||||
EOF
|
||||
return $recipe;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use Config;
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/util/perl";
|
||||
use File::Basename;
|
||||
use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
|
||||
use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs splitdir/;
|
||||
use File::Path qw/mkpath/;
|
||||
use OpenSSL::Glob;
|
||||
|
||||
@@ -298,21 +298,6 @@ $config{libdir}="";
|
||||
my $auto_threads=1; # enable threads automatically? true by default
|
||||
my $default_ranlib;
|
||||
|
||||
# Top level directories to build
|
||||
$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "util", "tools", "fuzz" ];
|
||||
# crypto/ subdirectories to build
|
||||
$config{sdirs} = [
|
||||
"objects",
|
||||
"md2", "md4", "md5", "sha", "mdc2", "hmac", "ripemd", "whrlpool", "poly1305", "blake2", "siphash", "sm3",
|
||||
"des", "aes", "rc2", "rc4", "rc5", "idea", "aria", "bf", "cast", "camellia", "seed", "sm4", "chacha", "modes",
|
||||
"bn", "ec", "rsa", "dsa", "dh", "sm2", "dso", "engine",
|
||||
"buffer", "bio", "stack", "lhash", "rand", "err",
|
||||
"evp", "asn1", "pem", "x509", "x509v3", "conf", "txt_db", "pkcs7", "pkcs12", "comp", "ocsp", "ui",
|
||||
"cms", "ts", "srp", "cmac", "ct", "async", "kdf", "store"
|
||||
];
|
||||
# test/ subdirectories to build
|
||||
$config{tdirs} = [ "ossl_shim" ];
|
||||
|
||||
# Known TLS and DTLS protocols
|
||||
my @tls = qw(ssl3 tls1 tls1_1 tls1_2 tls1_3);
|
||||
my @dtls = qw(dtls1 dtls1_2);
|
||||
@@ -606,10 +591,8 @@ $config{lflags} = [ env('__CNF_LDFLAGS') || () ];
|
||||
$config{ex_libs} = [ env('__CNF_LDLIBS') || () ];
|
||||
|
||||
$config{openssl_api_defines}=[];
|
||||
$config{openssl_algorithm_defines}=[];
|
||||
$config{openssl_thread_defines}=[];
|
||||
$config{openssl_sys_defines}=[];
|
||||
$config{openssl_other_defines}=[];
|
||||
$config{openssl_feature_defines}=[];
|
||||
$config{options}="";
|
||||
$config{build_type} = "release";
|
||||
my $target="";
|
||||
@@ -1027,7 +1010,7 @@ INSTALL instructions and the RAND_DRBG(7) manual page for more details.
|
||||
|
||||
_____
|
||||
}
|
||||
push @{$config{openssl_other_defines}},
|
||||
push @{$config{openssl_feature_defines}},
|
||||
map { (my $x = $_) =~ tr|[\-a-z]|[_A-Z]|; "OPENSSL_RAND_SEED_$x" }
|
||||
@seed_sources;
|
||||
|
||||
@@ -1173,6 +1156,19 @@ foreach (keys %user) {
|
||||
# Allow overriding the build file name
|
||||
$config{build_file} = env('BUILDFILE') || $target{build_file} || "Makefile";
|
||||
|
||||
######################################################################
|
||||
# Build up information for skipping certain directories depending on disabled
|
||||
# features, as well as setting up macros for disabled features.
|
||||
|
||||
# This is a tentative database of directories to skip. Some entries may not
|
||||
# correspond to anything real, but that's ok, they will simply be ignored.
|
||||
# The actual processing of these entries is done in the build.info lookup
|
||||
# loop further down.
|
||||
#
|
||||
# The key is a Unix formated path in the source tree, the value is an index
|
||||
# into %disabled_info, so any existing path gets added to a corresponding
|
||||
# 'skipped' entry in there with the list of skipped directories.
|
||||
my %skipdir = ();
|
||||
my %disabled_info = (); # For configdata.pm
|
||||
foreach my $what (sort keys %disabled) {
|
||||
$config{options} .= " no-$what";
|
||||
@@ -1181,32 +1177,18 @@ foreach my $what (sort keys %disabled) {
|
||||
'dynamic-engine', 'makedepend',
|
||||
'zlib-dynamic', 'zlib', 'sse2' )) {
|
||||
(my $WHAT = uc $what) =~ s|-|_|g;
|
||||
|
||||
# Fix up C macro end names
|
||||
$WHAT = "RMD160" if $what eq "ripemd";
|
||||
my $skipdir = $what;
|
||||
|
||||
# fix-up crypto/directory name(s)
|
||||
$what = "ripemd" if $what eq "rmd160";
|
||||
$what = "whrlpool" if $what eq "whirlpool";
|
||||
$skipdir = "ripemd" if $what eq "rmd160";
|
||||
$skipdir = "whrlpool" if $what eq "whirlpool";
|
||||
|
||||
my $macro = $disabled_info{$what}->{macro} = "OPENSSL_NO_$WHAT";
|
||||
push @{$config{openssl_feature_defines}}, $macro;
|
||||
|
||||
if ((grep { $what eq $_ } @{$config{sdirs}})
|
||||
&& $what ne 'async' && $what ne 'err') {
|
||||
@{$config{sdirs}} = grep { $what ne $_} @{$config{sdirs}};
|
||||
$disabled_info{$what}->{skipped} = [ catdir('crypto', $what) ];
|
||||
|
||||
if ($what ne 'engine') {
|
||||
push @{$config{openssl_algorithm_defines}}, $macro;
|
||||
} else {
|
||||
@{$config{dirs}} = grep !/^engines$/, @{$config{dirs}};
|
||||
push @{$disabled_info{engine}->{skipped}}, catdir('engines');
|
||||
push @{$config{openssl_other_defines}}, $macro;
|
||||
}
|
||||
} else {
|
||||
push @{$config{openssl_other_defines}}, $macro;
|
||||
}
|
||||
|
||||
$skipdir{engines} = $what if $what eq 'engine';
|
||||
$skipdir{"crypto/$skipdir"} = $what
|
||||
unless $what eq 'async' || $what eq 'err';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1284,7 +1266,7 @@ unless ($disabled{threads}) {
|
||||
# If threads still aren't disabled, add a C macro to ensure the source
|
||||
# code knows about it. Any other flag is taken care of by the configs.
|
||||
unless($disabled{threads}) {
|
||||
push @{$config{openssl_thread_defines}}, "OPENSSL_THREADS";
|
||||
push @{$config{openssl_feature_defines}}, "OPENSSL_THREADS";
|
||||
}
|
||||
|
||||
# With "deprecated" disable all deprecated features.
|
||||
@@ -1303,10 +1285,10 @@ if ($target{shared_target} eq "")
|
||||
}
|
||||
|
||||
if ($disabled{"dynamic-engine"}) {
|
||||
push @{$config{openssl_other_defines}}, "OPENSSL_NO_DYNAMIC_ENGINE";
|
||||
push @{$config{openssl_feature_defines}}, "OPENSSL_NO_DYNAMIC_ENGINE";
|
||||
$config{dynamic_engines} = 0;
|
||||
} else {
|
||||
push @{$config{openssl_other_defines}}, "OPENSSL_NO_STATIC_ENGINE";
|
||||
push @{$config{openssl_feature_defines}}, "OPENSSL_NO_STATIC_ENGINE";
|
||||
$config{dynamic_engines} = 1;
|
||||
}
|
||||
|
||||
@@ -1576,7 +1558,7 @@ unless ($disabled{afalgeng}) {
|
||||
}
|
||||
}
|
||||
|
||||
push @{$config{openssl_other_defines}}, "OPENSSL_NO_AFALGENG" if ($disabled{afalgeng});
|
||||
push @{$config{openssl_feature_defines}}, "OPENSSL_NO_AFALGENG" if ($disabled{afalgeng});
|
||||
|
||||
# Finish up %config by appending things the user gave us on the command line
|
||||
# apart from "make variables"
|
||||
@@ -1677,34 +1659,26 @@ if ($builder eq "unified") {
|
||||
cleanfile($srcdir, catfile("Configurations", "common.tmpl"),
|
||||
$blddir) ];
|
||||
|
||||
my @build_infos = ( [ ".", "build.info" ] );
|
||||
foreach (@{$config{dirs}}) {
|
||||
push @build_infos, [ $_, "build.info" ]
|
||||
if (-f catfile($srcdir, $_, "build.info"));
|
||||
}
|
||||
foreach (@{$config{sdirs}}) {
|
||||
push @build_infos, [ catdir("crypto", $_), "build.info" ]
|
||||
if (-f catfile($srcdir, "crypto", $_, "build.info"));
|
||||
}
|
||||
foreach (@{$config{engdirs}}) {
|
||||
push @build_infos, [ catdir("engines", $_), "build.info" ]
|
||||
if (-f catfile($srcdir, "engines", $_, "build.info"));
|
||||
}
|
||||
foreach (@{$config{tdirs}}) {
|
||||
push @build_infos, [ catdir("test", $_), "build.info" ]
|
||||
if (-f catfile($srcdir, "test", $_, "build.info"));
|
||||
}
|
||||
my @build_dirs = ( [ ] ); # current directory
|
||||
|
||||
$config{build_infos} = [ ];
|
||||
|
||||
my %ordinals = ();
|
||||
foreach (@build_infos) {
|
||||
my $sourced = catdir($srcdir, $_->[0]);
|
||||
my $buildd = catdir($blddir, $_->[0]);
|
||||
while (@build_dirs) {
|
||||
my @curd = @{shift @build_dirs};
|
||||
my $sourced = catdir($srcdir, @curd);
|
||||
my $buildd = catdir($blddir, @curd);
|
||||
|
||||
my $unixdir = join('/', @curd);
|
||||
if (exists $skipdir{$unixdir}) {
|
||||
my $what = $skipdir{$unixdir};
|
||||
push @{$disabled_info{$what}->{skipped}}, catdir(@curd);
|
||||
next;
|
||||
}
|
||||
|
||||
mkpath($buildd);
|
||||
|
||||
my $f = $_->[1];
|
||||
my $f = 'build.info';
|
||||
# The basic things we're trying to build
|
||||
my @programs = ();
|
||||
my @programs_install = ();
|
||||
@@ -1722,6 +1696,7 @@ if ($builder eq "unified") {
|
||||
my %sources = ();
|
||||
my %shared_sources = ();
|
||||
my %includes = ();
|
||||
my %defines = ();
|
||||
my %depends = ();
|
||||
my %renames = ();
|
||||
my %sharednames = ();
|
||||
@@ -1782,6 +1757,14 @@ if ($builder eq "unified") {
|
||||
qr/^\s*ENDIF\s*$/
|
||||
=> sub { die "ENDIF out of scope" if ! @skip;
|
||||
pop @skip; },
|
||||
qr/^\s*SUBDIRS\s*=\s*(.*)\s*$/
|
||||
=> sub {
|
||||
if (!@skip || $skip[$#skip] > 0) {
|
||||
foreach (tokenize($1)) {
|
||||
push @build_dirs, [ @curd, splitdir($_, 1) ];
|
||||
}
|
||||
}
|
||||
},
|
||||
qr/^\s*PROGRAMS(_NO_INST)?\s*=\s*(.*)\s*$/
|
||||
=> sub {
|
||||
if (!@skip || $skip[$#skip] > 0) {
|
||||
@@ -1837,6 +1820,9 @@ if ($builder eq "unified") {
|
||||
qr/^\s*INCLUDE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
|
||||
=> sub { push @{$includes{$1}}, tokenize($2)
|
||||
if !@skip || $skip[$#skip] > 0 },
|
||||
qr/^\s*DEFINE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
|
||||
=> sub { push @{$defines{$1}}, tokenize($2)
|
||||
if !@skip || $skip[$#skip] > 0 },
|
||||
qr/^\s*DEPEND\[((?:\\.|[^\\\]])*)\]\s*=\s*(.*)\s*$/
|
||||
=> sub { push @{$depends{$1}}, tokenize($2)
|
||||
if !@skip || $skip[$#skip] > 0 },
|
||||
@@ -2169,6 +2155,27 @@ EOF
|
||||
unless grep { $_ eq $ib } @{$unified_info{includes}->{$ddest}->{build}};
|
||||
}
|
||||
}
|
||||
|
||||
foreach (keys %defines) {
|
||||
my $dest = $_;
|
||||
my $ddest = cleanfile($sourced, $_, $blddir);
|
||||
|
||||
# If the destination doesn't exist in source, it can only be
|
||||
# a generated file in the build tree.
|
||||
if (! -f $ddest) {
|
||||
$ddest = cleanfile($buildd, $_, $blddir);
|
||||
if ($unified_info{rename}->{$ddest}) {
|
||||
$ddest = $unified_info{rename}->{$ddest};
|
||||
}
|
||||
}
|
||||
foreach (@{$defines{$dest}}) {
|
||||
m|^([^=]*)(=.*)?$|;
|
||||
die "0 length macro name not permitted\n" if $1 eq "";
|
||||
die "$1 defined more than once\n"
|
||||
if defined $unified_info{defines}->{$ddest}->{$1};
|
||||
$unified_info{defines}->{$ddest}->{$1} = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $ordinals_text = join(', ', sort keys %ordinals);
|
||||
@@ -2311,6 +2318,12 @@ EOF
|
||||
}
|
||||
}
|
||||
}
|
||||
# Defines
|
||||
foreach my $dest (sort keys %{$unified_info{defines}}) {
|
||||
$unified_info{defines}->{$dest}
|
||||
= [ map { $_.$unified_info{defines}->{$dest}->{$_} }
|
||||
sort keys %{$unified_info{defines}->{$dest}} ];
|
||||
}
|
||||
# Includes
|
||||
foreach my $dest (sort keys %{$unified_info{includes}}) {
|
||||
if (defined($unified_info{includes}->{$dest}->{build})) {
|
||||
@@ -2344,7 +2357,7 @@ EOF
|
||||
my %dirs = ();
|
||||
my $pd = dirname($product);
|
||||
|
||||
foreach (@{$unified_info{sources}->{$product}},
|
||||
foreach (@{$unified_info{sources}->{$product} // []},
|
||||
@{$unified_info{shared_sources}->{$product} // []}) {
|
||||
my $d = dirname($_);
|
||||
|
||||
|
||||
+3
-3
@@ -369,7 +369,7 @@ typedef struct string_int_pair_st {
|
||||
# define OPT_FMT_SMIME (1L << 3)
|
||||
# define OPT_FMT_ENGINE (1L << 4)
|
||||
# define OPT_FMT_MSBLOB (1L << 5)
|
||||
# define OPT_FMT_NETSCAPE (1L << 6)
|
||||
/* (1L << 6) was OPT_FMT_NETSCAPE, but wasn't used */
|
||||
# define OPT_FMT_NSS (1L << 7)
|
||||
# define OPT_FMT_TEXT (1L << 8)
|
||||
# define OPT_FMT_HTTP (1L << 9)
|
||||
@@ -378,8 +378,8 @@ typedef struct string_int_pair_st {
|
||||
# define OPT_FMT_PDS (OPT_FMT_PEMDER | OPT_FMT_SMIME)
|
||||
# define OPT_FMT_ANY ( \
|
||||
OPT_FMT_PEMDER | OPT_FMT_PKCS12 | OPT_FMT_SMIME | \
|
||||
OPT_FMT_ENGINE | OPT_FMT_MSBLOB | OPT_FMT_NETSCAPE | \
|
||||
OPT_FMT_NSS | OPT_FMT_TEXT | OPT_FMT_HTTP | OPT_FMT_PVK)
|
||||
OPT_FMT_ENGINE | OPT_FMT_MSBLOB | OPT_FMT_NSS | \
|
||||
OPT_FMT_TEXT | OPT_FMT_HTTP | OPT_FMT_PVK)
|
||||
|
||||
char *opt_progname(const char *argv0);
|
||||
char *opt_getprog(void);
|
||||
|
||||
+20
-1
@@ -297,6 +297,20 @@ static void list_md_fn(const EVP_MD *m,
|
||||
}
|
||||
}
|
||||
|
||||
static void list_mac_fn(const EVP_MAC *m,
|
||||
const char *from, const char *to, void *arg)
|
||||
{
|
||||
if (m != NULL) {
|
||||
BIO_printf(arg, "%s\n", EVP_MAC_name(m));
|
||||
} else {
|
||||
if (from == NULL)
|
||||
from = "<undefined>";
|
||||
if (to == NULL)
|
||||
to = "<undefined>";
|
||||
BIO_printf(arg, "%s => %s\n", from, to);
|
||||
}
|
||||
}
|
||||
|
||||
static void list_missing_help(void)
|
||||
{
|
||||
const FUNCTION *fp;
|
||||
@@ -396,7 +410,7 @@ static void list_options_for_command(const char *command)
|
||||
/* Unified enum for help and list commands. */
|
||||
typedef enum HELPLIST_CHOICE {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE,
|
||||
OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_OPTIONS,
|
||||
OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
|
||||
OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
|
||||
OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_DISABLED, OPT_MISSING_HELP,
|
||||
OPT_OBJECTS
|
||||
@@ -410,6 +424,8 @@ const OPTIONS list_options[] = {
|
||||
"List of message digest commands"},
|
||||
{"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
|
||||
"List of message digest algorithms"},
|
||||
{"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
|
||||
"List of message authentication code algorithms"},
|
||||
{"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
|
||||
{"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
|
||||
"List of cipher algorithms"},
|
||||
@@ -457,6 +473,9 @@ opthelp:
|
||||
case OPT_DIGEST_ALGORITHMS:
|
||||
EVP_MD_do_all_sorted(list_md_fn, bio_out);
|
||||
break;
|
||||
case OPT_MAC_ALGORITHMS:
|
||||
EVP_MAC_do_all_sorted(list_mac_fn, bio_out);
|
||||
break;
|
||||
case OPT_CIPHER_COMMANDS:
|
||||
list_type(FT_cipher, one);
|
||||
break;
|
||||
|
||||
@@ -168,7 +168,6 @@ static OPT_PAIR formats[] = {
|
||||
{"smime", OPT_FMT_SMIME},
|
||||
{"engine", OPT_FMT_ENGINE},
|
||||
{"msblob", OPT_FMT_MSBLOB},
|
||||
{"netscape", OPT_FMT_NETSCAPE},
|
||||
{"nss", OPT_FMT_NSS},
|
||||
{"text", OPT_FMT_TEXT},
|
||||
{"http", OPT_FMT_HTTP},
|
||||
|
||||
+2
-2
@@ -38,8 +38,8 @@ typedef enum OPTION_choice {
|
||||
|
||||
const OPTIONS rsa_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format, one of DER NET PEM"},
|
||||
{"outform", OPT_OUTFORM, 'f', "Output format, one of DER NET PEM PVK"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format, one of DER PEM"},
|
||||
{"outform", OPT_OUTFORM, 'f', "Output format, one of DER PEM PVK"},
|
||||
{"in", OPT_IN, 's', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
|
||||
|
||||
+2
-2
@@ -67,10 +67,10 @@ typedef enum OPTION_choice {
|
||||
const OPTIONS x509_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'f',
|
||||
"Input format - default PEM (one of DER, NET or PEM)"},
|
||||
"Input format - default PEM (one of DER or PEM)"},
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"outform", OPT_OUTFORM, 'f',
|
||||
"Output format - default PEM (one of DER, NET or PEM)"},
|
||||
"Output format - default PEM (one of DER or PEM)"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"keyform", OPT_KEYFORM, 'F', "Private key format - default PEM"},
|
||||
{"passin", OPT_PASSIN, 's', "Private key password/pass-phrase source"},
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# Note that some of these directories are filtered in Configure. Look for
|
||||
# %skipdir there for further explanations.
|
||||
SUBDIRS=crypto ssl apps test util tools fuzz engines
|
||||
|
||||
{-
|
||||
use File::Spec::Functions;
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# Note that these directories are filtered in Configure. Look for %skipdir
|
||||
# there for further explanations.
|
||||
SUBDIRS=objects buffer bio stack lhash rand evp asn1 pem x509 x509v3 conf \
|
||||
txt_db pkcs7 pkcs12 ui kdf store \
|
||||
md2 md4 md5 sha mdc2 gmac hmac ripemd whrlpool poly1305 blake2 \
|
||||
siphash sm3 des aes rc2 rc4 rc5 idea aria bf cast camellia \
|
||||
seed sm4 chacha modes bn ec rsa dsa dh sm2 dso engine \
|
||||
err comp ocsp cms ts srp cmac ct async
|
||||
|
||||
LIBS=../libcrypto
|
||||
SOURCE[../libcrypto]=\
|
||||
cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c cpt_err.c \
|
||||
|
||||
@@ -223,6 +223,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
|
||||
} while (BN_is_zero(k));
|
||||
|
||||
BN_set_flags(k, BN_FLG_CONSTTIME);
|
||||
BN_set_flags(l, BN_FLG_CONSTTIME);
|
||||
|
||||
if (dsa->flags & DSA_FLAG_CACHE_MONT_P) {
|
||||
if (!BN_MONT_CTX_set_locked(&dsa->method_mont_p,
|
||||
|
||||
@@ -28,6 +28,13 @@
|
||||
# define CHECK_BSD_STYLE_MACROS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ONE global file descriptor for all sessions. This allows operations
|
||||
* such as digest session data copying (see digest_copy()), but is also
|
||||
* saner... why re-open /dev/crypto for every session?
|
||||
*/
|
||||
static int cfd;
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Ciphers
|
||||
@@ -39,7 +46,6 @@
|
||||
*****/
|
||||
|
||||
struct cipher_ctx {
|
||||
int cfd;
|
||||
struct session_op sess;
|
||||
|
||||
/* to pass from init to do_cipher */
|
||||
@@ -135,19 +141,13 @@ static int cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const struct cipher_data_st *cipher_d =
|
||||
get_cipher_data(EVP_CIPHER_CTX_nid(ctx));
|
||||
|
||||
if ((cipher_ctx->cfd = open("/dev/crypto", O_RDWR, 0)) < 0) {
|
||||
SYSerr(SYS_F_OPEN, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&cipher_ctx->sess, 0, sizeof(cipher_ctx->sess));
|
||||
cipher_ctx->sess.cipher = cipher_d->devcryptoid;
|
||||
cipher_ctx->sess.keylen = cipher_d->keylen;
|
||||
cipher_ctx->sess.key = (void *)key;
|
||||
cipher_ctx->op = enc ? COP_ENCRYPT : COP_DECRYPT;
|
||||
if (ioctl(cipher_ctx->cfd, CIOCGSESSION, &cipher_ctx->sess) < 0) {
|
||||
if (ioctl(cfd, CIOCGSESSION, &cipher_ctx->sess) < 0) {
|
||||
SYSerr(SYS_F_IOCTL, errno);
|
||||
close(cipher_ctx->cfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ static int cipher_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
cryp.flags = COP_FLAG_WRITE_IV;
|
||||
#endif
|
||||
|
||||
if (ioctl(cipher_ctx->cfd, CIOCCRYPT, &cryp) < 0) {
|
||||
if (ioctl(cfd, CIOCCRYPT, &cryp) < 0) {
|
||||
SYSerr(SYS_F_IOCTL, errno);
|
||||
return 0;
|
||||
}
|
||||
@@ -212,14 +212,10 @@ static int cipher_cleanup(EVP_CIPHER_CTX *ctx)
|
||||
struct cipher_ctx *cipher_ctx =
|
||||
(struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx);
|
||||
|
||||
if (ioctl(cipher_ctx->cfd, CIOCFSESSION, &cipher_ctx->sess.ses) < 0) {
|
||||
if (ioctl(cfd, CIOCFSESSION, &cipher_ctx->sess.ses) < 0) {
|
||||
SYSerr(SYS_F_IOCTL, errno);
|
||||
return 0;
|
||||
}
|
||||
if (close(cipher_ctx->cfd) < 0) {
|
||||
SYSerr(SYS_F_CLOSE, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -233,14 +229,10 @@ static int known_cipher_nids[OSSL_NELEM(cipher_data)];
|
||||
static int known_cipher_nids_amount = -1; /* -1 indicates not yet initialised */
|
||||
static EVP_CIPHER *known_cipher_methods[OSSL_NELEM(cipher_data)] = { NULL, };
|
||||
|
||||
static void prepare_cipher_methods()
|
||||
static void prepare_cipher_methods(void)
|
||||
{
|
||||
size_t i;
|
||||
struct session_op sess;
|
||||
int cfd;
|
||||
|
||||
if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0)
|
||||
return;
|
||||
|
||||
memset(&sess, 0, sizeof(sess));
|
||||
sess.key = (void *)"01234567890123456789012345678901234567890123456789";
|
||||
@@ -281,8 +273,6 @@ static void prepare_cipher_methods()
|
||||
cipher_data[i].nid;
|
||||
}
|
||||
}
|
||||
|
||||
close(cfd);
|
||||
}
|
||||
|
||||
static const EVP_CIPHER *get_cipher_method(int nid)
|
||||
@@ -308,7 +298,7 @@ static void destroy_cipher_method(int nid)
|
||||
known_cipher_methods[i] = NULL;
|
||||
}
|
||||
|
||||
static void destroy_all_cipher_methods()
|
||||
static void destroy_all_cipher_methods(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -329,11 +319,12 @@ static int devcrypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
|
||||
|
||||
/*
|
||||
* We only support digests if the cryptodev implementation supports multiple
|
||||
* data updates. Otherwise, we would be forced to maintain a cache, which is
|
||||
* perilous if there's a lot of data coming in (if someone wants to checksum
|
||||
* an OpenSSL tarball, for example).
|
||||
* data updates and session copying. Otherwise, we would be forced to maintain
|
||||
* a cache, which is perilous if there's a lot of data coming in (if someone
|
||||
* wants to checksum an OpenSSL tarball, for example).
|
||||
*/
|
||||
#if defined(COP_FLAG_UPDATE) && defined(COP_FLAG_FINAL)
|
||||
#if defined(CIOCCPHASH) && defined(COP_FLAG_UPDATE) && defined(COP_FLAG_FINAL)
|
||||
#define IMPLEMENT_DIGEST
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
@@ -346,7 +337,6 @@ static int devcrypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
|
||||
*****/
|
||||
|
||||
struct digest_ctx {
|
||||
int cfd;
|
||||
struct session_op sess;
|
||||
int init;
|
||||
};
|
||||
@@ -413,19 +403,12 @@ static int digest_init(EVP_MD_CTX *ctx)
|
||||
const struct digest_data_st *digest_d =
|
||||
get_digest_data(EVP_MD_CTX_type(ctx));
|
||||
|
||||
if (digest_ctx->init == 0
|
||||
&& (digest_ctx->cfd = open("/dev/crypto", O_RDWR, 0)) < 0) {
|
||||
SYSerr(SYS_F_OPEN, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
digest_ctx->init = 1;
|
||||
|
||||
memset(&digest_ctx->sess, 0, sizeof(digest_ctx->sess));
|
||||
digest_ctx->sess.mac = digest_d->devcryptoid;
|
||||
if (ioctl(digest_ctx->cfd, CIOCGSESSION, &digest_ctx->sess) < 0) {
|
||||
if (ioctl(cfd, CIOCGSESSION, &digest_ctx->sess) < 0) {
|
||||
SYSerr(SYS_F_IOCTL, errno);
|
||||
close(digest_ctx->cfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -444,7 +427,7 @@ static int digest_op(struct digest_ctx *ctx, const void *src, size_t srclen,
|
||||
cryp.dst = NULL;
|
||||
cryp.mac = res;
|
||||
cryp.flags = flags;
|
||||
return ioctl(ctx->cfd, CIOCCRYPT, &cryp);
|
||||
return ioctl(cfd, CIOCCRYPT, &cryp);
|
||||
}
|
||||
|
||||
static int digest_update(EVP_MD_CTX *ctx, const void *data, size_t count)
|
||||
@@ -472,7 +455,7 @@ static int digest_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
SYSerr(SYS_F_IOCTL, errno);
|
||||
return 0;
|
||||
}
|
||||
if (ioctl(digest_ctx->cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
|
||||
if (ioctl(cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
|
||||
SYSerr(SYS_F_IOCTL, errno);
|
||||
return 0;
|
||||
}
|
||||
@@ -480,16 +463,38 @@ static int digest_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int digest_cleanup(EVP_MD_CTX *ctx)
|
||||
static int digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from)
|
||||
{
|
||||
struct digest_ctx *digest_ctx =
|
||||
(struct digest_ctx *)EVP_MD_CTX_md_data(ctx);
|
||||
struct digest_ctx *digest_from =
|
||||
(struct digest_ctx *)EVP_MD_CTX_md_data(from);
|
||||
struct digest_ctx *digest_to =
|
||||
(struct digest_ctx *)EVP_MD_CTX_md_data(to);
|
||||
struct cphash_op cphash;
|
||||
|
||||
if (close(digest_ctx->cfd) < 0) {
|
||||
SYSerr(SYS_F_CLOSE, errno);
|
||||
if (digest_from == NULL)
|
||||
return 1;
|
||||
|
||||
if (digest_from->init != 1) {
|
||||
SYSerr(SYS_F_IOCTL, EINVAL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!digest_init(to)) {
|
||||
SYSerr(SYS_F_IOCTL, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cphash.src_ses = digest_from->sess.ses;
|
||||
cphash.dst_ses = digest_to->sess.ses;
|
||||
if (ioctl(cfd, CIOCCPHASH, &cphash) < 0) {
|
||||
SYSerr(SYS_F_IOCTL, errno);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int digest_cleanup(EVP_MD_CTX *ctx)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -502,14 +507,10 @@ static int known_digest_nids[OSSL_NELEM(digest_data)];
|
||||
static int known_digest_nids_amount = -1; /* -1 indicates not yet initialised */
|
||||
static EVP_MD *known_digest_methods[OSSL_NELEM(digest_data)] = { NULL, };
|
||||
|
||||
static void prepare_digest_methods()
|
||||
static void prepare_digest_methods(void)
|
||||
{
|
||||
size_t i;
|
||||
struct session_op sess;
|
||||
int cfd;
|
||||
|
||||
if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0)
|
||||
return;
|
||||
|
||||
memset(&sess, 0, sizeof(sess));
|
||||
|
||||
@@ -532,6 +533,7 @@ static void prepare_digest_methods()
|
||||
|| !EVP_MD_meth_set_init(known_digest_methods[i], digest_init)
|
||||
|| !EVP_MD_meth_set_update(known_digest_methods[i], digest_update)
|
||||
|| !EVP_MD_meth_set_final(known_digest_methods[i], digest_final)
|
||||
|| !EVP_MD_meth_set_copy(known_digest_methods[i], digest_copy)
|
||||
|| !EVP_MD_meth_set_cleanup(known_digest_methods[i], digest_cleanup)
|
||||
|| !EVP_MD_meth_set_app_datasize(known_digest_methods[i],
|
||||
sizeof(struct digest_ctx))) {
|
||||
@@ -541,8 +543,6 @@ static void prepare_digest_methods()
|
||||
known_digest_nids[known_digest_nids_amount++] = digest_data[i].nid;
|
||||
}
|
||||
}
|
||||
|
||||
close(cfd);
|
||||
}
|
||||
|
||||
static const EVP_MD *get_digest_method(int nid)
|
||||
@@ -568,7 +568,7 @@ static void destroy_digest_method(int nid)
|
||||
known_digest_methods[i] = NULL;
|
||||
}
|
||||
|
||||
static void destroy_all_digest_methods()
|
||||
static void destroy_all_digest_methods(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -598,9 +598,12 @@ static int devcrypto_digests(ENGINE *e, const EVP_MD **digest,
|
||||
static int devcrypto_unload(ENGINE *e)
|
||||
{
|
||||
destroy_all_cipher_methods();
|
||||
#if defined(COP_FLAG_UPDATE) && defined(COP_FLAG_FINAL)
|
||||
#ifdef IMPLEMENT_DIGEST
|
||||
destroy_all_digest_methods();
|
||||
#endif
|
||||
|
||||
close(cfd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
@@ -611,23 +614,30 @@ void engine_load_devcrypto_int()
|
||||
{
|
||||
ENGINE *e = NULL;
|
||||
|
||||
if (access("/dev/crypto", R_OK | W_OK) < 0) {
|
||||
fprintf(stderr,
|
||||
"/dev/crypto not present, not enabling devcrypto engine\n");
|
||||
if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0) {
|
||||
fprintf(stderr, "Could not open /dev/crypto: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
prepare_cipher_methods();
|
||||
#if defined(COP_FLAG_UPDATE) && defined(COP_FLAG_FINAL)
|
||||
#ifdef IMPLEMENT_DIGEST
|
||||
prepare_digest_methods();
|
||||
#endif
|
||||
|
||||
if ((e = ENGINE_new()) == NULL)
|
||||
if ((e = ENGINE_new()) == NULL
|
||||
|| !ENGINE_set_destroy_function(e, devcrypto_unload)) {
|
||||
ENGINE_free(e);
|
||||
/*
|
||||
* We know that devcrypto_unload() won't be called when one of the
|
||||
* above two calls have failed, so we close cfd explicitly here to
|
||||
* avoid leaking resources.
|
||||
*/
|
||||
close(cfd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ENGINE_set_id(e, "devcrypto")
|
||||
|| !ENGINE_set_name(e, "/dev/crypto engine")
|
||||
|| !ENGINE_set_destroy_function(e, devcrypto_unload)
|
||||
|
||||
/*
|
||||
* Asymmetric ciphers aren't well supported with /dev/crypto. Among the BSD
|
||||
@@ -664,7 +674,7 @@ void engine_load_devcrypto_int()
|
||||
# endif
|
||||
#endif
|
||||
|| !ENGINE_set_ciphers(e, devcrypto_ciphers)
|
||||
#if defined(COP_FLAG_UPDATE) && defined(COP_FLAG_FINAL)
|
||||
#ifdef IMPLEMENT_DIGEST
|
||||
|| !ENGINE_set_digests(e, devcrypto_digests)
|
||||
#endif
|
||||
) {
|
||||
|
||||
@@ -801,6 +801,7 @@ EVP_F_EVP_PKEY_VERIFY_RECOVER:144:EVP_PKEY_verify_recover
|
||||
EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT:145:EVP_PKEY_verify_recover_init
|
||||
EVP_F_EVP_SIGNFINAL:107:EVP_SignFinal
|
||||
EVP_F_EVP_VERIFYFINAL:108:EVP_VerifyFinal
|
||||
EVP_F_GMAC_CTRL:215:gmac_ctrl
|
||||
EVP_F_INT_CTX_NEW:157:int_ctx_new
|
||||
EVP_F_OK_NEW:200:ok_new
|
||||
EVP_F_PKCS5_PBE_KEYIVGEN:117:PKCS5_PBE_keyivgen
|
||||
@@ -809,6 +810,7 @@ EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN:164:PKCS5_v2_PBKDF2_keyivgen
|
||||
EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN:180:PKCS5_v2_scrypt_keyivgen
|
||||
EVP_F_PKEY_MAC_INIT:214:pkey_mac_init
|
||||
EVP_F_PKEY_SET_TYPE:158:pkey_set_type
|
||||
EVP_F_POLY1305_CTRL:216:poly1305_ctrl
|
||||
EVP_F_RC2_MAGIC_TO_METH:109:rc2_magic_to_meth
|
||||
EVP_F_RC5_CTRL:125:rc5_ctrl
|
||||
EVP_F_S390X_AES_GCM_CTRL:201:s390x_aes_gcm_ctrl
|
||||
@@ -2223,6 +2225,7 @@ EVP_R_ARIA_KEY_SETUP_FAILED:176:aria key setup failed
|
||||
EVP_R_BAD_DECRYPT:100:bad decrypt
|
||||
EVP_R_BUFFER_TOO_SMALL:155:buffer too small
|
||||
EVP_R_CAMELLIA_KEY_SETUP_FAILED:157:camellia key setup failed
|
||||
EVP_R_CIPHER_NOT_GCM_MODE:184:cipher not gcm mode
|
||||
EVP_R_CIPHER_PARAMETER_ERROR:122:cipher parameter error
|
||||
EVP_R_COMMAND_NOT_SUPPORTED:147:command not supported
|
||||
EVP_R_COPY_ERROR:173:copy error
|
||||
|
||||
@@ -15,8 +15,12 @@ void openssl_add_all_macs_int(void)
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
EVP_add_mac(&cmac_meth);
|
||||
#endif
|
||||
EVP_add_mac(&gmac_meth);
|
||||
EVP_add_mac(&hmac_meth);
|
||||
#ifndef OPENSSL_NO_SIPHASH
|
||||
EVP_add_mac(&siphash_meth);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_POLY1305
|
||||
EVP_add_mac(&poly1305_meth);
|
||||
#endif
|
||||
}
|
||||
@@ -141,6 +141,7 @@ static const ERR_STRING_DATA EVP_str_functs[] = {
|
||||
"EVP_PKEY_verify_recover_init"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_SIGNFINAL, 0), "EVP_SignFinal"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_VERIFYFINAL, 0), "EVP_VerifyFinal"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_GMAC_CTRL, 0), "gmac_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_INT_CTX_NEW, 0), "int_ctx_new"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_OK_NEW, 0), "ok_new"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_PKCS5_PBE_KEYIVGEN, 0), "PKCS5_PBE_keyivgen"},
|
||||
@@ -152,6 +153,7 @@ static const ERR_STRING_DATA EVP_str_functs[] = {
|
||||
"PKCS5_v2_scrypt_keyivgen"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_PKEY_MAC_INIT, 0), "pkey_mac_init"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_PKEY_SET_TYPE, 0), "pkey_set_type"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_POLY1305_CTRL, 0), "poly1305_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_RC2_MAGIC_TO_METH, 0), "rc2_magic_to_meth"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_RC5_CTRL, 0), "rc5_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_S390X_AES_GCM_CTRL, 0), "s390x_aes_gcm_ctrl"},
|
||||
@@ -170,6 +172,8 @@ static const ERR_STRING_DATA EVP_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_BUFFER_TOO_SMALL), "buffer too small"},
|
||||
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_CAMELLIA_KEY_SETUP_FAILED),
|
||||
"camellia key setup failed"},
|
||||
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_CIPHER_NOT_GCM_MODE),
|
||||
"cipher not gcm mode"},
|
||||
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_CIPHER_PARAMETER_ERROR),
|
||||
"cipher parameter error"},
|
||||
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_COMMAND_NOT_SUPPORTED),
|
||||
|
||||
@@ -425,3 +425,36 @@ const EVP_PKEY_METHOD siphash_pkey_meth = {
|
||||
pkey_mac_ctrl,
|
||||
pkey_mac_ctrl_str
|
||||
};
|
||||
|
||||
const EVP_PKEY_METHOD poly1305_pkey_meth = {
|
||||
EVP_PKEY_POLY1305,
|
||||
EVP_PKEY_FLAG_SIGCTX_CUSTOM,
|
||||
pkey_mac_init,
|
||||
pkey_mac_copy,
|
||||
pkey_mac_cleanup,
|
||||
|
||||
0, 0,
|
||||
|
||||
0,
|
||||
pkey_mac_keygen,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
pkey_mac_signctx_init,
|
||||
pkey_mac_signctx,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
pkey_mac_ctrl,
|
||||
pkey_mac_ctrl_str
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=gmac.c
|
||||
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright 2018 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
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <openssl/evp.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/evp_int.h"
|
||||
|
||||
/* typedef EVP_MAC_IMPL */
|
||||
struct evp_mac_impl_st {
|
||||
EVP_CIPHER *cipher; /* Cache GCM cipher */
|
||||
EVP_CIPHER_CTX *ctx; /* Cipher context */
|
||||
ENGINE *engine; /* Engine implementating the algorithm */
|
||||
};
|
||||
|
||||
static void gmac_free(EVP_MAC_IMPL *gctx)
|
||||
{
|
||||
if (gctx != NULL) {
|
||||
EVP_CIPHER_CTX_free(gctx->ctx);
|
||||
OPENSSL_free(gctx);
|
||||
}
|
||||
}
|
||||
|
||||
static EVP_MAC_IMPL *gmac_new(void)
|
||||
{
|
||||
EVP_MAC_IMPL *gctx;
|
||||
|
||||
if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) == NULL
|
||||
|| (gctx->ctx = EVP_CIPHER_CTX_new()) == NULL) {
|
||||
gmac_free(gctx);
|
||||
return NULL;
|
||||
}
|
||||
return gctx;
|
||||
}
|
||||
|
||||
static int gmac_copy(EVP_MAC_IMPL *gdst, EVP_MAC_IMPL *gsrc)
|
||||
{
|
||||
gdst->cipher = gsrc->cipher;
|
||||
gdst->engine = gsrc->engine;
|
||||
return EVP_CIPHER_CTX_copy(gdst->ctx, gsrc->ctx);
|
||||
}
|
||||
|
||||
static size_t gmac_size(EVP_MAC_IMPL *gctx)
|
||||
{
|
||||
return EVP_GCM_TLS_TAG_LEN;
|
||||
}
|
||||
|
||||
static int gmac_init(EVP_MAC_IMPL *gctx)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int gmac_update(EVP_MAC_IMPL *gctx, const unsigned char *data,
|
||||
size_t datalen)
|
||||
{
|
||||
EVP_CIPHER_CTX *ctx = gctx->ctx;
|
||||
int outlen;
|
||||
|
||||
while (datalen > INT_MAX) {
|
||||
if (!EVP_EncryptUpdate(ctx, NULL, &outlen, data, INT_MAX))
|
||||
return 0;
|
||||
data += INT_MAX;
|
||||
datalen -= INT_MAX;
|
||||
}
|
||||
return EVP_EncryptUpdate(ctx, NULL, &outlen, data, datalen);
|
||||
}
|
||||
|
||||
static int gmac_final(EVP_MAC_IMPL *gctx, unsigned char *out)
|
||||
{
|
||||
int hlen;
|
||||
|
||||
if (!EVP_EncryptFinal_ex(gctx->ctx, out, &hlen)
|
||||
|| !EVP_CIPHER_CTX_ctrl(gctx->ctx, EVP_CTRL_AEAD_GET_TAG,
|
||||
gmac_size(gctx), out))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int gmac_ctrl(EVP_MAC_IMPL *gctx, int cmd, va_list args)
|
||||
{
|
||||
const unsigned char *p;
|
||||
size_t len;
|
||||
EVP_CIPHER_CTX *ctx = gctx->ctx;
|
||||
const EVP_CIPHER *cipher;
|
||||
ENGINE *engine;
|
||||
|
||||
switch (cmd) {
|
||||
case EVP_MAC_CTRL_SET_CIPHER:
|
||||
cipher = va_arg(args, const EVP_CIPHER *);
|
||||
if (cipher == NULL)
|
||||
return 0;
|
||||
if (EVP_CIPHER_mode(cipher) != EVP_CIPH_GCM_MODE) {
|
||||
EVPerr(EVP_F_GMAC_CTRL, EVP_R_CIPHER_NOT_GCM_MODE);
|
||||
return 0;
|
||||
}
|
||||
return EVP_EncryptInit_ex(ctx, cipher, NULL, NULL, NULL);
|
||||
|
||||
case EVP_MAC_CTRL_SET_KEY:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len != (size_t)EVP_CIPHER_CTX_key_length(ctx)) {
|
||||
EVPerr(EVP_F_GMAC_CTRL, EVP_R_INVALID_KEY_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
return EVP_EncryptInit_ex(ctx, NULL, NULL, p, NULL);
|
||||
|
||||
case EVP_MAC_CTRL_SET_IV:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, len, NULL)
|
||||
&& EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, p);
|
||||
|
||||
case EVP_MAC_CTRL_SET_ENGINE:
|
||||
engine = va_arg(args, ENGINE *);
|
||||
return EVP_EncryptInit_ex(ctx, NULL, engine, NULL, NULL);
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
static int gmac_ctrl_int(EVP_MAC_IMPL *gctx, int cmd, ...)
|
||||
{
|
||||
int rv;
|
||||
va_list args;
|
||||
|
||||
va_start(args, cmd);
|
||||
rv = gmac_ctrl(gctx, cmd, args);
|
||||
va_end(args);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int gmac_ctrl_str_cb(void *gctx, int cmd, void *buf, size_t buflen)
|
||||
{
|
||||
return gmac_ctrl_int(gctx, cmd, buf, buflen);
|
||||
}
|
||||
|
||||
static int gmac_ctrl_str(EVP_MAC_IMPL *gctx, const char *type,
|
||||
const char *value)
|
||||
{
|
||||
if (!value)
|
||||
return 0;
|
||||
if (strcmp(type, "cipher") == 0) {
|
||||
const EVP_CIPHER *c = EVP_get_cipherbyname(value);
|
||||
|
||||
if (c == NULL)
|
||||
return 0;
|
||||
return gmac_ctrl_int(gctx, EVP_MAC_CTRL_SET_CIPHER, c);
|
||||
}
|
||||
if (strcmp(type, "key") == 0)
|
||||
return EVP_str2ctrl(gmac_ctrl_str_cb, gctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "hexkey") == 0)
|
||||
return EVP_hex2ctrl(gmac_ctrl_str_cb, gctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "iv") == 0)
|
||||
return EVP_str2ctrl(gmac_ctrl_str_cb, gctx, EVP_MAC_CTRL_SET_IV,
|
||||
value);
|
||||
if (strcmp(type, "hexiv") == 0)
|
||||
return EVP_hex2ctrl(gmac_ctrl_str_cb, gctx, EVP_MAC_CTRL_SET_IV,
|
||||
value);
|
||||
return -2;
|
||||
}
|
||||
|
||||
const EVP_MAC gmac_meth = {
|
||||
EVP_MAC_GMAC,
|
||||
gmac_new,
|
||||
gmac_copy,
|
||||
gmac_free,
|
||||
gmac_size,
|
||||
gmac_init,
|
||||
gmac_update,
|
||||
gmac_final,
|
||||
gmac_ctrl,
|
||||
gmac_ctrl_str
|
||||
};
|
||||
@@ -129,8 +129,10 @@ struct evp_mac_st {
|
||||
};
|
||||
|
||||
extern const EVP_MAC cmac_meth;
|
||||
extern const EVP_MAC gmac_meth;
|
||||
extern const EVP_MAC hmac_meth;
|
||||
extern const EVP_MAC siphash_meth;
|
||||
extern const EVP_MAC poly1305_meth;
|
||||
|
||||
/*
|
||||
* This function is internal for now, but can be made external when needed.
|
||||
|
||||
@@ -45,9 +45,9 @@ size_t rand_drbg_get_nonce(RAND_DRBG *drbg,
|
||||
void rand_drbg_cleanup_nonce(RAND_DRBG *drbg,
|
||||
unsigned char *out, size_t outlen);
|
||||
|
||||
size_t rand_drbg_get_additional_data(unsigned char **pout, size_t max_len);
|
||||
size_t rand_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout);
|
||||
|
||||
void rand_drbg_cleanup_additional_data(unsigned char *out, size_t outlen);
|
||||
void rand_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out);
|
||||
|
||||
/*
|
||||
* RAND_POOL functions
|
||||
@@ -59,6 +59,7 @@ void rand_pool_free(RAND_POOL *pool);
|
||||
|
||||
const unsigned char *rand_pool_buffer(RAND_POOL *pool);
|
||||
unsigned char *rand_pool_detach(RAND_POOL *pool);
|
||||
void rand_pool_reattach(RAND_POOL *pool, unsigned char *buffer);
|
||||
|
||||
size_t rand_pool_entropy(RAND_POOL *pool);
|
||||
size_t rand_pool_length(RAND_POOL *pool);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
/* Serialized OID's */
|
||||
static const unsigned char so[7762] = {
|
||||
static const unsigned char so[7767] = {
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */
|
||||
@@ -1076,9 +1076,10 @@ static const unsigned char so[7762] = {
|
||||
0x2A,0x85,0x03,0x07,0x01,0x02,0x01,0x01,0x04, /* [ 7736] OBJ_id_tc26_gost_3410_2012_256_paramSetD */
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0C, /* [ 7745] OBJ_hmacWithSHA512_224 */
|
||||
0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0D, /* [ 7753] OBJ_hmacWithSHA512_256 */
|
||||
0x28,0xCC,0x45,0x03,0x04, /* [ 7761] OBJ_gmac */
|
||||
};
|
||||
|
||||
#define NUM_NID 1196
|
||||
#define NUM_NID 1197
|
||||
static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
||||
{"UNDEF", "undefined", NID_undef},
|
||||
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
|
||||
@@ -2275,10 +2276,11 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
||||
{"magma-mac", "magma-mac", NID_magma_mac},
|
||||
{"hmacWithSHA512-224", "hmacWithSHA512-224", NID_hmacWithSHA512_224, 8, &so[7745]},
|
||||
{"hmacWithSHA512-256", "hmacWithSHA512-256", NID_hmacWithSHA512_256, 8, &so[7753]},
|
||||
{"GMAC", "gmac", NID_gmac, 5, &so[7761]},
|
||||
{"ChaCha20-Poly1305-D", "chacha20-poly1305-draft", NID_chacha20_poly1305_draft },
|
||||
};
|
||||
|
||||
#define NUM_SN 1187
|
||||
#define NUM_SN 1188
|
||||
static const unsigned int sn_objs[NUM_SN] = {
|
||||
364, /* "AD_DVCS" */
|
||||
419, /* "AES-128-CBC" */
|
||||
@@ -2396,7 +2398,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
417, /* "CSPName" */
|
||||
1019, /* "ChaCha20" */
|
||||
1018, /* "ChaCha20-Poly1305" */
|
||||
1195, /* "chacha20-poly1305-draft" */
|
||||
1196, /* "chacha20-poly1305-draft" */
|
||||
367, /* "CrlID" */
|
||||
391, /* "DC" */
|
||||
31, /* "DES-CBC" */
|
||||
@@ -2426,6 +2428,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
297, /* "DVCS" */
|
||||
1087, /* "ED25519" */
|
||||
1088, /* "ED448" */
|
||||
1195, /* "GMAC" */
|
||||
99, /* "GN" */
|
||||
1036, /* "HKDF" */
|
||||
855, /* "HMAC" */
|
||||
@@ -3469,7 +3472,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
1093, /* "x509ExtAdmission" */
|
||||
};
|
||||
|
||||
#define NUM_LN 1187
|
||||
#define NUM_LN 1188
|
||||
static const unsigned int ln_objs[NUM_LN] = {
|
||||
363, /* "AD Time Stamping" */
|
||||
405, /* "ANSI X9.62" */
|
||||
@@ -3848,7 +3851,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
883, /* "certificateRevocationList" */
|
||||
1019, /* "chacha20" */
|
||||
1018, /* "chacha20-poly1305" */
|
||||
1195, /* "ChaCha20-Poly1305-D" */
|
||||
1196, /* "ChaCha20-Poly1305-D" */
|
||||
54, /* "challengePassword" */
|
||||
407, /* "characteristic-two-field" */
|
||||
395, /* "clearance" */
|
||||
@@ -3964,6 +3967,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
509, /* "generationQualifier" */
|
||||
601, /* "generic cryptogram" */
|
||||
99, /* "givenName" */
|
||||
1195, /* "gmac" */
|
||||
976, /* "gost-mac-12" */
|
||||
1009, /* "gost89-cbc" */
|
||||
814, /* "gost89-cnt" */
|
||||
@@ -4660,7 +4664,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
125, /* "zlib compression" */
|
||||
};
|
||||
|
||||
#define NUM_OBJ 1071
|
||||
#define NUM_OBJ 1072
|
||||
static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
0, /* OBJ_undef 0 */
|
||||
181, /* OBJ_iso 1 */
|
||||
@@ -4907,6 +4911,7 @@ static const unsigned int obj_objs[NUM_OBJ] = {
|
||||
637, /* OBJ_set_brand_Diners 2 23 42 8 30 */
|
||||
638, /* OBJ_set_brand_AmericanExpress 2 23 42 8 34 */
|
||||
639, /* OBJ_set_brand_JCB 2 23 42 8 35 */
|
||||
1195, /* OBJ_gmac 1 0 9797 3 4 */
|
||||
1141, /* OBJ_oscca 1 2 156 10197 */
|
||||
805, /* OBJ_cryptopro 1 2 643 2 2 */
|
||||
806, /* OBJ_cryptocom 1 2 643 2 9 */
|
||||
|
||||
@@ -1192,4 +1192,5 @@ magma_cfb 1191
|
||||
magma_mac 1192
|
||||
hmacWithSHA512_224 1193
|
||||
hmacWithSHA512_256 1194
|
||||
chacha20_poly1305_draft 1195
|
||||
gmac 1195
|
||||
chacha20_poly1305_draft 1196
|
||||
@@ -11,6 +11,9 @@ iso 2 : member-body : ISO Member Body
|
||||
|
||||
iso 3 : identified-organization
|
||||
|
||||
# GMAC OID
|
||||
iso 0 9797 3 4 : GMAC : gmac
|
||||
|
||||
# HMAC OIDs
|
||||
identified-organization 6 1 5 5 8 1 1 : HMAC-MD5 : hmac-md5
|
||||
identified-organization 6 1 5 5 8 1 2 : HMAC-SHA1 : hmac-sha1
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=\
|
||||
poly1305_pmeth.c \
|
||||
poly1305_ameth.c \
|
||||
poly1305_meth.c \
|
||||
poly1305.c {- $target{poly1305_asm_src} -}
|
||||
|
||||
GENERATE[poly1305-sparcv9.S]=asm/poly1305-sparcv9.pl $(PERLASM_SCHEME)
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright 2018 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
|
||||
*/
|
||||
#include <openssl/evp.h>
|
||||
#include "internal/evp_int.h"
|
||||
#include "internal/poly1305.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include "poly1305_local.h"
|
||||
|
||||
/* typedef EVP_MAC_IMPL */
|
||||
struct evp_mac_impl_st {
|
||||
POLY1305 *ctx; /* poly1305 context */
|
||||
};
|
||||
|
||||
static EVP_MAC_IMPL *poly1305_new(void)
|
||||
{
|
||||
EVP_MAC_IMPL *ctx;
|
||||
|
||||
if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL
|
||||
|| (ctx->ctx = OPENSSL_zalloc(sizeof(POLY1305))) == NULL) {
|
||||
OPENSSL_free(ctx);
|
||||
return 0;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void poly1305_free(EVP_MAC_IMPL *ctx)
|
||||
{
|
||||
if (ctx != NULL) {
|
||||
OPENSSL_free(ctx->ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
static int poly1305_copy(EVP_MAC_IMPL *dst, EVP_MAC_IMPL *src)
|
||||
{
|
||||
*dst->ctx = *src->ctx;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static size_t poly1305_size(EVP_MAC_IMPL *ctx)
|
||||
{
|
||||
return POLY1305_DIGEST_SIZE;
|
||||
}
|
||||
|
||||
static int poly1305_init(EVP_MAC_IMPL *ctx)
|
||||
{
|
||||
/* initialize the context in MAC_ctrl function */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int poly1305_update(EVP_MAC_IMPL *ctx, const unsigned char *data,
|
||||
size_t datalen)
|
||||
{
|
||||
POLY1305 *poly_ctx = ctx->ctx;
|
||||
|
||||
/* poly1305 has nothing to return in its update function */
|
||||
Poly1305_Update(poly_ctx, data, datalen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int poly1305_final(EVP_MAC_IMPL *ctx, unsigned char *out)
|
||||
{
|
||||
POLY1305 *poly_ctx = ctx->ctx;
|
||||
|
||||
Poly1305_Final(poly_ctx, out);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int poly1305_ctrl(EVP_MAC_IMPL *ctx, int cmd, va_list args)
|
||||
{
|
||||
POLY1305 *poly_ctx = ctx->ctx;
|
||||
unsigned char *key;
|
||||
size_t keylen;
|
||||
|
||||
switch (cmd) {
|
||||
case EVP_MAC_CTRL_SET_KEY:
|
||||
key = va_arg(args, unsigned char *);
|
||||
keylen = va_arg(args, size_t);
|
||||
|
||||
if (keylen != POLY1305_KEY_SIZE) {
|
||||
EVPerr(EVP_F_POLY1305_CTRL, EVP_R_INVALID_KEY_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
Poly1305_Init(poly_ctx, key);
|
||||
return 1;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int poly1305_ctrl_int(EVP_MAC_IMPL *ctx, int cmd, ...)
|
||||
{
|
||||
int rv;
|
||||
va_list args;
|
||||
|
||||
va_start(args, cmd);
|
||||
rv = poly1305_ctrl(ctx, cmd, args);
|
||||
va_end(args);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int poly1305_ctrl_str_cb(void *ctx, int cmd, void *buf, size_t buflen)
|
||||
{
|
||||
return poly1305_ctrl_int(ctx, cmd, buf, buflen);
|
||||
}
|
||||
|
||||
static int poly1305_ctrl_str(EVP_MAC_IMPL *ctx,
|
||||
const char *type, const char *value)
|
||||
{
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
if (strcmp(type, "key") == 0)
|
||||
return EVP_str2ctrl(poly1305_ctrl_str_cb, ctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "hexkey") == 0)
|
||||
return EVP_hex2ctrl(poly1305_ctrl_str_cb, ctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
return -2;
|
||||
}
|
||||
|
||||
const EVP_MAC poly1305_meth = {
|
||||
EVP_MAC_POLY1305,
|
||||
poly1305_new,
|
||||
poly1305_copy,
|
||||
poly1305_free,
|
||||
poly1305_size,
|
||||
poly1305_init,
|
||||
poly1305_update,
|
||||
poly1305_final,
|
||||
poly1305_ctrl,
|
||||
poly1305_ctrl_str
|
||||
};
|
||||
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007-2018 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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/err.h>
|
||||
#include "internal/poly1305.h"
|
||||
#include "poly1305_local.h"
|
||||
#include "internal/evp_int.h"
|
||||
|
||||
/* POLY1305 pkey context structure */
|
||||
|
||||
typedef struct {
|
||||
ASN1_OCTET_STRING ktmp; /* Temp storage for key */
|
||||
POLY1305 ctx;
|
||||
} POLY1305_PKEY_CTX;
|
||||
|
||||
static int pkey_poly1305_init(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
POLY1305_PKEY_CTX *pctx;
|
||||
|
||||
if ((pctx = OPENSSL_zalloc(sizeof(*pctx))) == NULL) {
|
||||
CRYPTOerr(CRYPTO_F_PKEY_POLY1305_INIT, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
pctx->ktmp.type = V_ASN1_OCTET_STRING;
|
||||
|
||||
EVP_PKEY_CTX_set_data(ctx, pctx);
|
||||
EVP_PKEY_CTX_set0_keygen_info(ctx, NULL, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void pkey_poly1305_cleanup(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
POLY1305_PKEY_CTX *pctx = EVP_PKEY_CTX_get_data(ctx);
|
||||
|
||||
if (pctx != NULL) {
|
||||
OPENSSL_clear_free(pctx->ktmp.data, pctx->ktmp.length);
|
||||
OPENSSL_clear_free(pctx, sizeof(*pctx));
|
||||
EVP_PKEY_CTX_set_data(ctx, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static int pkey_poly1305_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
{
|
||||
POLY1305_PKEY_CTX *sctx, *dctx;
|
||||
|
||||
/* allocate memory for dst->data and a new POLY1305_CTX in dst->data->ctx */
|
||||
if (!pkey_poly1305_init(dst))
|
||||
return 0;
|
||||
sctx = EVP_PKEY_CTX_get_data(src);
|
||||
dctx = EVP_PKEY_CTX_get_data(dst);
|
||||
if (ASN1_STRING_get0_data(&sctx->ktmp) != NULL &&
|
||||
!ASN1_STRING_copy(&dctx->ktmp, &sctx->ktmp)) {
|
||||
/* cleanup and free the POLY1305_PKEY_CTX in dst->data */
|
||||
pkey_poly1305_cleanup(dst);
|
||||
return 0;
|
||||
}
|
||||
memcpy(&dctx->ctx, &sctx->ctx, sizeof(POLY1305));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_poly1305_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
{
|
||||
ASN1_OCTET_STRING *key;
|
||||
POLY1305_PKEY_CTX *pctx = EVP_PKEY_CTX_get_data(ctx);
|
||||
|
||||
if (ASN1_STRING_get0_data(&pctx->ktmp) == NULL)
|
||||
return 0;
|
||||
key = ASN1_OCTET_STRING_dup(&pctx->ktmp);
|
||||
if (key == NULL)
|
||||
return 0;
|
||||
return EVP_PKEY_assign_POLY1305(pkey, key);
|
||||
}
|
||||
|
||||
static int int_update(EVP_MD_CTX *ctx, const void *data, size_t count)
|
||||
{
|
||||
POLY1305_PKEY_CTX *pctx = EVP_PKEY_CTX_get_data(EVP_MD_CTX_pkey_ctx(ctx));
|
||||
|
||||
Poly1305_Update(&pctx->ctx, data, count);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int poly1305_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
|
||||
{
|
||||
POLY1305_PKEY_CTX *pctx = ctx->data;
|
||||
ASN1_OCTET_STRING *key = (ASN1_OCTET_STRING *)ctx->pkey->pkey.ptr;
|
||||
|
||||
if (key->length != POLY1305_KEY_SIZE)
|
||||
return 0;
|
||||
EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT);
|
||||
EVP_MD_CTX_set_update_fn(mctx, int_update);
|
||||
Poly1305_Init(&pctx->ctx, key->data);
|
||||
return 1;
|
||||
}
|
||||
static int poly1305_signctx(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
|
||||
EVP_MD_CTX *mctx)
|
||||
{
|
||||
POLY1305_PKEY_CTX *pctx = ctx->data;
|
||||
|
||||
*siglen = POLY1305_DIGEST_SIZE;
|
||||
if (sig != NULL)
|
||||
Poly1305_Final(&pctx->ctx, sig);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_poly1305_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
{
|
||||
POLY1305_PKEY_CTX *pctx = EVP_PKEY_CTX_get_data(ctx);
|
||||
const unsigned char *key;
|
||||
size_t len;
|
||||
|
||||
switch (type) {
|
||||
|
||||
case EVP_PKEY_CTRL_MD:
|
||||
/* ignore */
|
||||
break;
|
||||
|
||||
case EVP_PKEY_CTRL_SET_MAC_KEY:
|
||||
case EVP_PKEY_CTRL_DIGESTINIT:
|
||||
if (type == EVP_PKEY_CTRL_SET_MAC_KEY) {
|
||||
/* user explicitly setting the key */
|
||||
key = p2;
|
||||
len = p1;
|
||||
} else {
|
||||
/* user indirectly setting the key via EVP_DigestSignInit */
|
||||
key = EVP_PKEY_get0_poly1305(EVP_PKEY_CTX_get0_pkey(ctx), &len);
|
||||
}
|
||||
if (key == NULL || len != POLY1305_KEY_SIZE ||
|
||||
!ASN1_OCTET_STRING_set(&pctx->ktmp, key, len))
|
||||
return 0;
|
||||
Poly1305_Init(&pctx->ctx, ASN1_STRING_get0_data(&pctx->ktmp));
|
||||
break;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_poly1305_ctrl_str(EVP_PKEY_CTX *ctx,
|
||||
const char *type, const char *value)
|
||||
{
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
if (strcmp(type, "key") == 0)
|
||||
return EVP_PKEY_CTX_str2ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, value);
|
||||
if (strcmp(type, "hexkey") == 0)
|
||||
return EVP_PKEY_CTX_hex2ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, value);
|
||||
return -2;
|
||||
}
|
||||
|
||||
const EVP_PKEY_METHOD poly1305_pkey_meth = {
|
||||
EVP_PKEY_POLY1305,
|
||||
EVP_PKEY_FLAG_SIGCTX_CUSTOM, /* we don't deal with a separate MD */
|
||||
pkey_poly1305_init,
|
||||
pkey_poly1305_copy,
|
||||
pkey_poly1305_cleanup,
|
||||
|
||||
0, 0,
|
||||
|
||||
0,
|
||||
pkey_poly1305_keygen,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
poly1305_signctx_init,
|
||||
poly1305_signctx,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
0, 0,
|
||||
|
||||
pkey_poly1305_ctrl,
|
||||
pkey_poly1305_ctrl_str
|
||||
};
|
||||
+27
-11
@@ -158,8 +158,10 @@ int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags)
|
||||
}
|
||||
|
||||
/* If set is called multiple times - clear the old one */
|
||||
if (type != drbg->type && drbg->type != 0 && drbg->meth != NULL) {
|
||||
if (drbg->type != 0 && (type != drbg->type || flags != drbg->flags)) {
|
||||
drbg->meth->uninstantiate(drbg);
|
||||
rand_pool_free(drbg->adin_pool);
|
||||
drbg->adin_pool = NULL;
|
||||
}
|
||||
|
||||
drbg->state = DRBG_UNINITIALISED;
|
||||
@@ -168,6 +170,7 @@ int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags)
|
||||
|
||||
if (type == 0) {
|
||||
/* Uninitialized; that's okay. */
|
||||
drbg->meth = NULL;
|
||||
return 1;
|
||||
} else if (is_ctr(type)) {
|
||||
ret = drbg_ctr_init(drbg);
|
||||
@@ -177,12 +180,17 @@ int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags)
|
||||
else
|
||||
ret = drbg_hash_init(drbg);
|
||||
} else {
|
||||
drbg->type = 0;
|
||||
drbg->flags = 0;
|
||||
drbg->meth = NULL;
|
||||
RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_UNSUPPORTED_DRBG_TYPE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
if (ret == 0) {
|
||||
drbg->state = DRBG_ERROR;
|
||||
RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_ERROR_INITIALISING_DRBG);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -287,10 +295,7 @@ static RAND_DRBG *rand_drbg_new(int secure,
|
||||
return drbg;
|
||||
|
||||
err:
|
||||
if (drbg->secure)
|
||||
OPENSSL_secure_free(drbg);
|
||||
else
|
||||
OPENSSL_free(drbg);
|
||||
RAND_DRBG_free(drbg);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -315,6 +320,7 @@ void RAND_DRBG_free(RAND_DRBG *drbg)
|
||||
|
||||
if (drbg->meth != NULL)
|
||||
drbg->meth->uninstantiate(drbg);
|
||||
rand_pool_free(drbg->adin_pool);
|
||||
CRYPTO_THREAD_lock_free(drbg->lock);
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DRBG, drbg, &drbg->ex_data);
|
||||
|
||||
@@ -431,6 +437,7 @@ int RAND_DRBG_uninstantiate(RAND_DRBG *drbg)
|
||||
{
|
||||
int index = -1, type, flags;
|
||||
if (drbg->meth == NULL) {
|
||||
drbg->state = DRBG_ERROR;
|
||||
RANDerr(RAND_F_RAND_DRBG_UNINSTANTIATE,
|
||||
RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED);
|
||||
return 0;
|
||||
@@ -722,9 +729,18 @@ int RAND_DRBG_bytes(RAND_DRBG *drbg, unsigned char *out, size_t outlen)
|
||||
unsigned char *additional = NULL;
|
||||
size_t additional_len;
|
||||
size_t chunk;
|
||||
size_t ret;
|
||||
size_t ret = 0;
|
||||
|
||||
additional_len = rand_drbg_get_additional_data(&additional, drbg->max_adinlen);
|
||||
if (drbg->adin_pool == NULL) {
|
||||
if (drbg->type == 0)
|
||||
goto err;
|
||||
drbg->adin_pool = rand_pool_new(0, 0, drbg->max_adinlen);
|
||||
if (drbg->adin_pool == NULL)
|
||||
goto err;
|
||||
}
|
||||
|
||||
additional_len = rand_drbg_get_additional_data(drbg->adin_pool,
|
||||
&additional);
|
||||
|
||||
for ( ; outlen > 0; outlen -= chunk, out += chunk) {
|
||||
chunk = outlen;
|
||||
@@ -736,9 +752,9 @@ int RAND_DRBG_bytes(RAND_DRBG *drbg, unsigned char *out, size_t outlen)
|
||||
}
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
if (additional_len != 0)
|
||||
OPENSSL_secure_clear_free(additional, additional_len);
|
||||
err:
|
||||
if (additional != NULL)
|
||||
rand_drbg_cleanup_additional_data(drbg->adin_pool, additional);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -205,6 +205,11 @@ struct rand_drbg_st {
|
||||
*/
|
||||
struct rand_pool_st *pool;
|
||||
|
||||
/*
|
||||
* Auxiliary pool for additional data.
|
||||
*/
|
||||
struct rand_pool_st *adin_pool;
|
||||
|
||||
/*
|
||||
* The following parameters are setup by the per-type "init" function.
|
||||
*
|
||||
|
||||
+25
-12
@@ -279,14 +279,9 @@ void rand_drbg_cleanup_nonce(RAND_DRBG *drbg,
|
||||
* On success it allocates a buffer at |*pout| and returns the length of
|
||||
* the data. The buffer should get freed using OPENSSL_secure_clear_free().
|
||||
*/
|
||||
size_t rand_drbg_get_additional_data(unsigned char **pout, size_t max_len)
|
||||
size_t rand_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout)
|
||||
{
|
||||
size_t ret = 0;
|
||||
RAND_POOL *pool;
|
||||
|
||||
pool = rand_pool_new(0, 0, max_len);
|
||||
if (pool == NULL)
|
||||
return 0;
|
||||
|
||||
if (rand_pool_add_additional_data(pool) == 0)
|
||||
goto err;
|
||||
@@ -295,14 +290,12 @@ size_t rand_drbg_get_additional_data(unsigned char **pout, size_t max_len)
|
||||
*pout = rand_pool_detach(pool);
|
||||
|
||||
err:
|
||||
rand_pool_free(pool);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void rand_drbg_cleanup_additional_data(unsigned char *out, size_t outlen)
|
||||
void rand_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out)
|
||||
{
|
||||
OPENSSL_secure_clear_free(out, outlen);
|
||||
rand_pool_reattach(pool, out);
|
||||
}
|
||||
|
||||
void rand_fork(void)
|
||||
@@ -536,17 +529,27 @@ size_t rand_pool_length(RAND_POOL *pool)
|
||||
/*
|
||||
* Detach the |pool| buffer and return it to the caller.
|
||||
* It's the responsibility of the caller to free the buffer
|
||||
* using OPENSSL_secure_clear_free().
|
||||
* using OPENSSL_secure_clear_free() or to re-attach it
|
||||
* again to the pool using rand_pool_reattach().
|
||||
*/
|
||||
unsigned char *rand_pool_detach(RAND_POOL *pool)
|
||||
{
|
||||
unsigned char *ret = pool->buffer;
|
||||
pool->buffer = NULL;
|
||||
pool->len = 0;
|
||||
pool->entropy = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-attach the |pool| buffer. It is only allowed to pass
|
||||
* the |buffer| which was previously detached from the same pool.
|
||||
*/
|
||||
void rand_pool_reattach(RAND_POOL *pool, unsigned char *buffer)
|
||||
{
|
||||
pool->buffer = buffer;
|
||||
OPENSSL_cleanse(pool->buffer, pool->len);
|
||||
pool->len = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If |entropy_factor| bits contain 1 bit of entropy, how many bytes does one
|
||||
@@ -643,6 +646,11 @@ int rand_pool_add(RAND_POOL *pool,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pool->buffer == NULL) {
|
||||
RANDerr(RAND_F_RAND_POOL_ADD, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
memcpy(pool->buffer + pool->len, buffer, len);
|
||||
pool->len += len;
|
||||
@@ -674,6 +682,11 @@ unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pool->buffer == NULL) {
|
||||
RANDerr(RAND_F_RAND_POOL_ADD_BEGIN, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pool->buffer + pool->len;
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -7,19 +7,17 @@
|
||||
#
|
||||
# LD_LIBRARY_PATH=../.. ./aesccm
|
||||
# LD_LIBRARY_PATH=../.. ./aesgcm
|
||||
# LD_LIBRARY_PATH=../.. ./gmac
|
||||
|
||||
CFLAGS = $(OPENSSL_INCS_LOCATION)
|
||||
LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto
|
||||
|
||||
all: aesccm aesgcm gmac
|
||||
all: aesccm aesgcm
|
||||
|
||||
aesccm: aesccm.o
|
||||
aesgcm: aesgcm.o
|
||||
gmac: gmac.o
|
||||
|
||||
aesccm aesgcm gmac:
|
||||
aesccm aesgcm:
|
||||
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
$(RM) aesccm aesgcm gmac *.o
|
||||
$(RM) aesccm aesgcm *.o
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Simple AES GMAC test program, uses the same NIST data used for the FIPS
|
||||
* self test but uses the application level EVP APIs.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
/* AES-GMAC test data from NIST public test vectors */
|
||||
|
||||
static const unsigned char gmac_key[] = { 0x77, 0xbe, 0x63, 0x70, 0x89, 0x71, 0xc4, 0xe2,
|
||||
0x40, 0xd1, 0xcb, 0x79, 0xe8, 0xd7, 0x7f, 0xeb };
|
||||
static const unsigned char gmac_iv[] = { 0xe0, 0xe0, 0x0f, 0x19, 0xfe, 0xd7, 0xba, 0x01,
|
||||
0x36, 0xa7, 0x97, 0xf3 };
|
||||
static const unsigned char gmac_aad[] = { 0x7a, 0x43, 0xec, 0x1d, 0x9c, 0x0a, 0x5a, 0x78,
|
||||
0xa0, 0xb1, 0x65, 0x33, 0xa6, 0x21, 0x3c, 0xab };
|
||||
|
||||
static const unsigned char gmac_tag[] = { 0x20, 0x9f, 0xcc, 0x8d, 0x36, 0x75, 0xed, 0x93,
|
||||
0x8e, 0x9c, 0x71, 0x66, 0x70, 0x9d, 0xd9, 0x46 };
|
||||
|
||||
static int aes_gmac(void)
|
||||
{
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
int outlen, tmplen;
|
||||
unsigned char outbuf[1024];
|
||||
int ret = 0;
|
||||
|
||||
printf("AES GMAC:\n");
|
||||
printf("Authenticated Data:\n");
|
||||
BIO_dump_fp(stdout, gmac_aad, sizeof(gmac_aad));
|
||||
|
||||
if ((ctx = EVP_CIPHER_CTX_new()) == NULL) {
|
||||
printf("EVP_CIPHER_CTX_new: failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Set cipher type and mode */
|
||||
if (!EVP_EncryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, NULL, NULL)) {
|
||||
printf("EVP_EncryptInit_ex: failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Set IV length if default 96 bits is not appropriate */
|
||||
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, sizeof(gmac_iv),
|
||||
NULL)) {
|
||||
printf("EVP_CIPHER_CTX_ctrl: set IV length failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Initialise key and IV */
|
||||
if (!EVP_EncryptInit_ex(ctx, NULL, NULL, gmac_key, gmac_iv)) {
|
||||
printf("EVP_EncryptInit_ex: set key and IV failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Zero or more calls to specify any AAD */
|
||||
if (!EVP_EncryptUpdate(ctx, NULL, &outlen, gmac_aad, sizeof(gmac_aad))) {
|
||||
printf("EVP_EncryptUpdate: setting AAD failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Finalise: note get no output for GMAC */
|
||||
if (!EVP_EncryptFinal_ex(ctx, outbuf, &outlen)) {
|
||||
printf("EVP_EncryptFinal_ex: failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Get tag */
|
||||
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, 16, outbuf)) {
|
||||
printf("EVP_CIPHER_CTX_ctrl: failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Output tag */
|
||||
printf("Tag:\n");
|
||||
BIO_dump_fp(stdout, outbuf, 16);
|
||||
|
||||
/* Is the tag correct? */
|
||||
if (memcmp(outbuf, gmac_tag, sizeof(gmac_tag)) != 0) {
|
||||
printf("Expected:\n");
|
||||
BIO_dump_fp(stdout, gmac_tag, sizeof(gmac_tag));
|
||||
} else
|
||||
ret = 1;
|
||||
err:
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return aes_gmac() ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
+11
-6
@@ -13,6 +13,7 @@ B<openssl list>
|
||||
[B<-commands>]
|
||||
[B<-digest-commands>]
|
||||
[B<-digest-algorithms>]
|
||||
[B<-mac-algorithms>]
|
||||
[B<-cipher-commands>]
|
||||
[B<-cipher-algorithms>]
|
||||
[B<-public-key-algorithms>]
|
||||
@@ -49,9 +50,14 @@ as input to the L<dgst(1)> or L<speed(1)> commands.
|
||||
=item B<-digest-algorithms>
|
||||
|
||||
Display a list of message digest algorithms.
|
||||
If a line is of the form
|
||||
foo => bar
|
||||
then B<foo> is an alias for the official algorithm name, B<bar>.
|
||||
If a line is of the form C<foo =E<gt> bar> then B<foo> is an alias for the
|
||||
official algorithm name, B<bar>.
|
||||
|
||||
=item B<-mac-algorithms>
|
||||
|
||||
Display a list of message authentication code algorithms.
|
||||
If a line is of the form C<foo =E<gt> bar> then B<foo> is an alias for the
|
||||
official algorithm name, B<bar>.
|
||||
|
||||
=item B<-cipher-commands>
|
||||
|
||||
@@ -61,9 +67,8 @@ to the L<dgst(1)> or L<speed(1)> commands.
|
||||
=item B<-cipher-algorithms>
|
||||
|
||||
Display a list of cipher algorithms.
|
||||
If a line is of the form
|
||||
foo => bar
|
||||
then B<foo> is an alias for the official algorithm name, B<bar>.
|
||||
If a line is of the form C<foo =E<gt> bar> then B<foo> is an alias for the
|
||||
official algorithm name, B<bar>.
|
||||
|
||||
=item B<-public-key-algorithms>
|
||||
|
||||
|
||||
+5
-20
@@ -9,8 +9,8 @@ rsa - RSA key processing tool
|
||||
|
||||
B<openssl> B<rsa>
|
||||
[B<-help>]
|
||||
[B<-inform PEM|NET|DER>]
|
||||
[B<-outform PEM|NET|DER>]
|
||||
[B<-inform PEM|DER>]
|
||||
[B<-outform PEM|DER>]
|
||||
[B<-in filename>]
|
||||
[B<-passin arg>]
|
||||
[B<-out filename>]
|
||||
@@ -53,16 +53,15 @@ utility.
|
||||
|
||||
Print out a usage message.
|
||||
|
||||
=item B<-inform DER|NET|PEM>
|
||||
=item B<-inform DER|PEM>
|
||||
|
||||
This specifies the input format. The B<DER> option uses an ASN1 DER encoded
|
||||
form compatible with the PKCS#1 RSAPrivateKey or SubjectPublicKeyInfo format.
|
||||
The B<PEM> form is the default format: it consists of the B<DER> format base64
|
||||
encoded with additional header and footer lines. On input PKCS#8 format private
|
||||
keys are also accepted. The B<NET> form is a format is described in the B<NOTES>
|
||||
section.
|
||||
keys are also accepted.
|
||||
|
||||
=item B<-outform DER|NET|PEM>
|
||||
=item B<-outform DER|PEM>
|
||||
|
||||
This specifies the output format, the options have the same meaning and default
|
||||
as the B<-inform> option.
|
||||
@@ -158,17 +157,6 @@ The PEM B<RSAPublicKey> format uses the header and footer lines:
|
||||
-----BEGIN RSA PUBLIC KEY-----
|
||||
-----END RSA PUBLIC KEY-----
|
||||
|
||||
The B<NET> form is a format compatible with older Netscape servers
|
||||
and Microsoft IIS .key files, this uses unsalted RC4 for its encryption.
|
||||
It is not very secure and so should only be used when necessary.
|
||||
|
||||
Some newer version of IIS have additional data in the exported .key
|
||||
files. To use these with the utility, view the file with a binary editor
|
||||
and look for the string "private-key", then trace back to the byte
|
||||
sequence 0x30, 0x82 (this is an ASN1 SEQUENCE). Copy all the data
|
||||
from this point onwards to another file and use that as the input
|
||||
to the B<rsa> utility with the B<-inform NET> option.
|
||||
|
||||
=head1 EXAMPLES
|
||||
|
||||
To remove the pass phrase on an RSA private key:
|
||||
@@ -197,9 +185,6 @@ Output the public part of a private key in B<RSAPublicKey> format:
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
The command line password arguments don't currently work with
|
||||
B<NET> format.
|
||||
|
||||
There should be an option that automatically handles .key files,
|
||||
without having to manually edit them.
|
||||
|
||||
|
||||
+5
-6
@@ -9,8 +9,8 @@ x509 - Certificate display and signing utility
|
||||
|
||||
B<openssl> B<x509>
|
||||
[B<-help>]
|
||||
[B<-inform DER|PEM|NET>]
|
||||
[B<-outform DER|PEM|NET>]
|
||||
[B<-inform DER|PEM>]
|
||||
[B<-outform DER|PEM>]
|
||||
[B<-keyform DER|PEM>]
|
||||
[B<-CAform DER|PEM>]
|
||||
[B<-CAkeyform DER|PEM>]
|
||||
@@ -86,16 +86,15 @@ various sections.
|
||||
|
||||
Print out a usage message.
|
||||
|
||||
=item B<-inform DER|PEM|NET>
|
||||
=item B<-inform DER|PEM>
|
||||
|
||||
This specifies the input format normally the command will expect an X509
|
||||
certificate but this can change if other options such as B<-req> are
|
||||
present. The DER format is the DER encoding of the certificate and PEM
|
||||
is the base64 encoding of the DER encoding with header and footer lines
|
||||
added. The NET option is an obscure Netscape server format that is now
|
||||
obsolete. The default format is PEM.
|
||||
added. The default format is PEM.
|
||||
|
||||
=item B<-outform DER|PEM|NET>
|
||||
=item B<-outform DER|PEM>
|
||||
|
||||
This specifies the output format, the options have the same meaning and default
|
||||
as the B<-inform> option.
|
||||
|
||||
@@ -163,6 +163,12 @@ For MACs that use an underlying computation algorithm, the algorithm
|
||||
I<must> be set first, see B<EVP_MAC_CTRL_SET_ENGINE>,
|
||||
B<EVP_MAC_CTRL_SET_MD> and B<EVP_MAC_CTRL_SET_CIPHER> below.
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_IV>
|
||||
|
||||
This control expects two arguments: C<unsigned char *key>, C<size_t keylen>
|
||||
|
||||
Some MAC implementations require an IV, this control sets the IV.
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_FLAGS>
|
||||
|
||||
This control expects one arguments: C<unsigned long flags>
|
||||
@@ -327,8 +333,10 @@ F<./foo>)
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<EVP_MAC_CMAC(7)>,
|
||||
L<EVP_MAC_GMAC(7)>,
|
||||
L<EVP_MAC_HMAC(7)>,
|
||||
L<EVP_MAC_SIPHASH(7)>
|
||||
L<EVP_MAC_SIPHASH(7)>,
|
||||
L<EVP_MAC_POLY1305(7)>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ The supported controls are:
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_KEY>
|
||||
|
||||
EVP_MAC_ctrl_str() takes to type string for this control:
|
||||
EVP_MAC_ctrl_str() takes two type strings for this control:
|
||||
|
||||
=over 4
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
EVP_MAC_GMAC - The GMAC EVP_MAC implementation
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Support for computing GMAC MACs through the B<EVP_MAC> API.
|
||||
|
||||
=head2 Numeric identity
|
||||
|
||||
B<EVP_MAC_GMAC> is the numeric identity for this implementation, and
|
||||
can be used in functions like EVP_MAC_CTX_new_id() and
|
||||
EVP_get_macbynid().
|
||||
|
||||
=head2 Supported controls
|
||||
|
||||
The supported controls are:
|
||||
|
||||
=over 4
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_KEY>
|
||||
|
||||
EVP_MAC_ctrl_str() takes two type strings for this control:
|
||||
|
||||
=over 4
|
||||
|
||||
=item "key"
|
||||
|
||||
The value string is used as is.
|
||||
|
||||
=item "hexkey"
|
||||
|
||||
The value string is expected to be a hexadecimal number, which will be
|
||||
decoded before passing on as control value.
|
||||
|
||||
=back
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_IV>
|
||||
|
||||
EVP_MAC_ctrl_str() takes two type strings for this control:
|
||||
|
||||
=over 4
|
||||
|
||||
=item "iv"
|
||||
|
||||
The value string is used as is.
|
||||
|
||||
=item "hexiv"
|
||||
|
||||
The value string is expected to be a hexadecimal number, which will be
|
||||
decoded before passing on as control value.
|
||||
|
||||
=back
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_ENGINE>
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_CIPHER>
|
||||
|
||||
These work as described in L<EVP_MAC(3)/CONTROLS> with the restriction that the
|
||||
cipher must be an AEAD one.
|
||||
|
||||
EVP_MAC_ctrl_str() type string for B<EVP_MAC_CTRL_SET_CIPHER>: "cipher"
|
||||
|
||||
The value is expected to be the name of a cipher.
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<EVP_MAC_ctrl(3)>, L<EVP_MAC(3)/CONTROLS>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2018 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
|
||||
L<https://www.openssl.org/source/license.html>.
|
||||
|
||||
=cut
|
||||
@@ -22,7 +22,7 @@ The supported controls are:
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_KEY>
|
||||
|
||||
EVP_MAC_ctrl_str() takes to type string for this control:
|
||||
EVP_MAC_ctrl_str() takes two type strings for this control:
|
||||
|
||||
=over 4
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
EVP_MAC_POLY1305 - The Poly1305 EVP_MAC implementation
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Support for computing Poly1305 MACs through the B<EVP_MAC> API.
|
||||
|
||||
=head2 Numeric identity
|
||||
|
||||
B<EVP_MAC_POLY1305> is the numeric identity for this implementation,
|
||||
and can be used in functions like EVP_MAC_CTX_new_id() and
|
||||
EVP_get_macbynid().
|
||||
|
||||
=head2 Supported controls
|
||||
|
||||
The supported controls are:
|
||||
|
||||
=over 4
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_KEY>
|
||||
|
||||
EVP_MAC_ctrl_str() takes two type strings for this control:
|
||||
|
||||
=over 4
|
||||
|
||||
=item "key"
|
||||
|
||||
The value string is used as is.
|
||||
|
||||
=item "hexkey"
|
||||
|
||||
The value string is expected to be a hexadecimal number, which will be
|
||||
decoded before passing on as control value.
|
||||
|
||||
=back
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<EVP_MAC_ctrl(3)>, L<EVP_MAC(3)/CONTROLS>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2018 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
|
||||
L<https://www.openssl.org/source/license.html>.
|
||||
|
||||
=cut
|
||||
@@ -28,7 +28,7 @@ The value string is expected to contain a decimal number.
|
||||
|
||||
=item B<EVP_MAC_CTRL_SET_KEY>
|
||||
|
||||
EVP_MAC_ctrl_str() takes to type string for this control:
|
||||
EVP_MAC_ctrl_str() takes two type strings for this control:
|
||||
|
||||
=over 4
|
||||
|
||||
|
||||
@@ -1063,3 +1063,4 @@ OBJ_id_tc26_gost_3410_2012_256_paramSetC="\x2A\x85\x03\x07\x01\x02\x01\x01\x03"
|
||||
OBJ_id_tc26_gost_3410_2012_256_paramSetD="\x2A\x85\x03\x07\x01\x02\x01\x01\x04"
|
||||
OBJ_hmacWithSHA512_224="\x2A\x86\x48\x86\xF7\x0D\x02\x0C"
|
||||
OBJ_hmacWithSHA512_256="\x2A\x86\x48\x86\xF7\x0D\x02\x0D"
|
||||
OBJ_gmac="\x28\xCC\x45\x03\x04"
|
||||
@@ -57,6 +57,7 @@
|
||||
# define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed)
|
||||
# define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed)
|
||||
# define tsan_counter(ptr) atomic_fetch_add_explicit((ptr), 1, memory_order_relaxed)
|
||||
# define tsan_decr(ptr) atomic_fetch_add_explicit((ptr), -1, memory_order_relaxed)
|
||||
# define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire)
|
||||
# define tsan_st_rel(ptr, val) atomic_store_explicit((ptr), (val), memory_order_release)
|
||||
# endif
|
||||
@@ -69,6 +70,7 @@
|
||||
# define tsan_load(ptr) __atomic_load_n((ptr), __ATOMIC_RELAXED)
|
||||
# define tsan_store(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELAXED)
|
||||
# define tsan_counter(ptr) __atomic_fetch_add((ptr), 1, __ATOMIC_RELAXED)
|
||||
# define tsan_decr(ptr) __atomic_fetch_add((ptr), -1, __ATOMIC_RELAXED)
|
||||
# define tsan_ld_acq(ptr) __atomic_load_n((ptr), __ATOMIC_ACQUIRE)
|
||||
# define tsan_st_rel(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELEASE)
|
||||
# endif
|
||||
@@ -113,8 +115,11 @@
|
||||
# pragma intrinsic(_InterlockedExchangeAdd64)
|
||||
# define tsan_counter(ptr) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), 1) \
|
||||
: _InterlockedExchangeAdd((ptr), 1))
|
||||
# define tsan_decr(ptr) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), -1) \
|
||||
: _InterlockedExchangeAdd((ptr), -1))
|
||||
# else
|
||||
# define tsan_counter(ptr) _InterlockedExchangeAdd((ptr), 1)
|
||||
# define tsan_decr(ptr) _InterlockedExchangeAdd((ptr), -1)
|
||||
# endif
|
||||
# if !defined(_ISO_VOLATILE)
|
||||
# define tsan_ld_acq(ptr) (*(ptr))
|
||||
@@ -129,6 +134,7 @@
|
||||
# define tsan_load(ptr) (*(ptr))
|
||||
# define tsan_store(ptr, val) (*(ptr) = (val))
|
||||
# define tsan_counter(ptr) ((*(ptr))++)
|
||||
# define tsan_decr(ptr) ((*(ptr))--)
|
||||
/*
|
||||
* Lack of tsan_ld_acq and tsan_ld_rel means that compiler support is not
|
||||
* sophisticated enough to support them. Code that relies on them should be
|
||||
|
||||
@@ -989,8 +989,10 @@ void EVP_MD_do_all_sorted(void (*fn)
|
||||
/* MAC stuff */
|
||||
|
||||
# define EVP_MAC_CMAC NID_cmac
|
||||
# define EVP_MAC_GMAC NID_gmac
|
||||
# define EVP_MAC_HMAC NID_hmac
|
||||
# define EVP_MAC_SIPHASH NID_siphash
|
||||
# define EVP_MAC_POLY1305 NID_poly1305
|
||||
|
||||
EVP_MAC_CTX *EVP_MAC_CTX_new(const EVP_MAC *mac);
|
||||
EVP_MAC_CTX *EVP_MAC_CTX_new_id(int nid);
|
||||
@@ -1023,8 +1025,9 @@ void EVP_MAC_do_all_sorted(void (*fn)
|
||||
# define EVP_MAC_CTRL_SET_FLAGS 0x02 /* unsigned long */
|
||||
# define EVP_MAC_CTRL_SET_ENGINE 0x03 /* ENGINE * */
|
||||
# define EVP_MAC_CTRL_SET_MD 0x04 /* EVP_MD * */
|
||||
# define EVP_MAC_CTRL_SET_CIPHER 0x04 /* EVP_CIPHER * */
|
||||
# define EVP_MAC_CTRL_SET_SIZE 0x05 /* size_t */
|
||||
# define EVP_MAC_CTRL_SET_CIPHER 0x05 /* EVP_CIPHER * */
|
||||
# define EVP_MAC_CTRL_SET_SIZE 0x06 /* size_t */
|
||||
# define EVP_MAC_CTRL_SET_IV 0x07 /* unsigned char *, size_t */
|
||||
|
||||
/* PKEY stuff */
|
||||
int EVP_PKEY_decrypt_old(unsigned char *dec_key,
|
||||
|
||||
@@ -111,6 +111,7 @@ int ERR_load_EVP_strings(void);
|
||||
# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT 145
|
||||
# define EVP_F_EVP_SIGNFINAL 107
|
||||
# define EVP_F_EVP_VERIFYFINAL 108
|
||||
# define EVP_F_GMAC_CTRL 215
|
||||
# define EVP_F_INT_CTX_NEW 157
|
||||
# define EVP_F_OK_NEW 200
|
||||
# define EVP_F_PKCS5_PBE_KEYIVGEN 117
|
||||
@@ -119,6 +120,7 @@ int ERR_load_EVP_strings(void);
|
||||
# define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN 180
|
||||
# define EVP_F_PKEY_MAC_INIT 214
|
||||
# define EVP_F_PKEY_SET_TYPE 158
|
||||
# define EVP_F_POLY1305_CTRL 216
|
||||
# define EVP_F_RC2_MAGIC_TO_METH 109
|
||||
# define EVP_F_RC5_CTRL 125
|
||||
# define EVP_F_S390X_AES_GCM_CTRL 201
|
||||
@@ -133,6 +135,7 @@ int ERR_load_EVP_strings(void);
|
||||
# define EVP_R_BAD_DECRYPT 100
|
||||
# define EVP_R_BUFFER_TOO_SMALL 155
|
||||
# define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157
|
||||
# define EVP_R_CIPHER_NOT_GCM_MODE 184
|
||||
# define EVP_R_CIPHER_PARAMETER_ERROR 122
|
||||
# define EVP_R_COMMAND_NOT_SUPPORTED 147
|
||||
# define EVP_R_COPY_ERROR 173
|
||||
|
||||
@@ -44,6 +44,11 @@
|
||||
#define NID_identified_organization 676
|
||||
#define OBJ_identified_organization OBJ_iso,3L
|
||||
|
||||
#define SN_gmac "GMAC"
|
||||
#define LN_gmac "gmac"
|
||||
#define NID_gmac 1195
|
||||
#define OBJ_gmac OBJ_iso,0L,9797L,3L,4L
|
||||
|
||||
#define SN_hmac_md5 "HMAC-MD5"
|
||||
#define LN_hmac_md5 "hmac-md5"
|
||||
#define NID_hmac_md5 780
|
||||
|
||||
@@ -34,22 +34,8 @@ extern "C" {
|
||||
(my $macro, my $value) = $_ =~ /^(.*?)=(.*?)$/;
|
||||
$OUT .= "#define $macro $value\n";
|
||||
}
|
||||
if (@{$config{openssl_algorithm_defines}}) {
|
||||
foreach (@{$config{openssl_algorithm_defines}}) {
|
||||
$OUT .= "#ifndef $_\n";
|
||||
$OUT .= "# define $_\n";
|
||||
$OUT .= "#endif\n";
|
||||
}
|
||||
}
|
||||
if (@{$config{openssl_thread_defines}}) {
|
||||
foreach (@{$config{openssl_thread_defines}}) {
|
||||
$OUT .= "#ifndef $_\n";
|
||||
$OUT .= "# define $_\n";
|
||||
$OUT .= "#endif\n";
|
||||
}
|
||||
}
|
||||
if (@{$config{openssl_other_defines}}) {
|
||||
foreach (@{$config{openssl_other_defines}}) {
|
||||
if (@{$config{openssl_feature_defines}}) {
|
||||
foreach (@{$config{openssl_feature_defines}}) {
|
||||
$OUT .= "#ifndef $_\n";
|
||||
$OUT .= "# define $_\n";
|
||||
$OUT .= "#endif\n";
|
||||
|
||||
+4
-3
@@ -5172,7 +5172,8 @@ static int nss_keylog_int(const char *prefix,
|
||||
size_t i;
|
||||
size_t prefix_len;
|
||||
|
||||
if (ssl->ctx->keylog_callback == NULL) return 1;
|
||||
if (ssl->ctx->keylog_callback == NULL)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* Our output buffer will contain the following strings, rendered with
|
||||
@@ -5183,7 +5184,7 @@ static int nss_keylog_int(const char *prefix,
|
||||
* hexadecimal, so we need a buffer that is twice their lengths.
|
||||
*/
|
||||
prefix_len = strlen(prefix);
|
||||
out_len = prefix_len + (2*parameter_1_len) + (2*parameter_2_len) + 3;
|
||||
out_len = prefix_len + (2 * parameter_1_len) + (2 * parameter_2_len) + 3;
|
||||
if ((out = cursor = OPENSSL_malloc(out_len)) == NULL) {
|
||||
SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, SSL_F_NSS_KEYLOG_INT,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
@@ -5207,7 +5208,7 @@ static int nss_keylog_int(const char *prefix,
|
||||
*cursor = '\0';
|
||||
|
||||
ssl->ctx->keylog_callback(ssl, (const char *)out);
|
||||
OPENSSL_free(out);
|
||||
OPENSSL_clear_free(out, out_len);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
@@ -962,7 +962,7 @@ static int final_server_name(SSL *s, unsigned int context, int sent)
|
||||
*/
|
||||
if (SSL_IS_FIRST_HANDSHAKE(s) && s->ctx != s->session_ctx) {
|
||||
tsan_counter(&s->ctx->stats.sess_accept);
|
||||
tsan_counter(&s->session_ctx->stats.sess_accept);
|
||||
tsan_decr(&s->session_ctx->stats.sess_accept);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
SUBDIRS=ossl_shim
|
||||
{-
|
||||
use File::Spec::Functions;
|
||||
sub rebase_files
|
||||
|
||||
+43
-24
@@ -581,6 +581,8 @@ static void reset_drbg_hook_ctx(void)
|
||||
* 1: it is expected that the specified DRBG is reseeded
|
||||
* 0: it is expected that the specified DRBG is not reseeded
|
||||
* -1: don't check whether the specified DRBG was reseeded or not
|
||||
* |reseed_time|: if nonzero, used instead of time(NULL) to set the
|
||||
* |before_reseed| time.
|
||||
*/
|
||||
static int test_drbg_reseed(int expect_success,
|
||||
RAND_DRBG *master,
|
||||
@@ -588,7 +590,8 @@ static int test_drbg_reseed(int expect_success,
|
||||
RAND_DRBG *private,
|
||||
int expect_master_reseed,
|
||||
int expect_public_reseed,
|
||||
int expect_private_reseed
|
||||
int expect_private_reseed,
|
||||
time_t reseed_time
|
||||
)
|
||||
{
|
||||
unsigned char buf[32];
|
||||
@@ -614,8 +617,11 @@ static int test_drbg_reseed(int expect_success,
|
||||
* step 2: generate random output
|
||||
*/
|
||||
|
||||
if (reseed_time == 0)
|
||||
reseed_time = time(NULL);
|
||||
|
||||
/* Generate random output from the public and private DRBG */
|
||||
before_reseed = expect_master_reseed == 1 ? time(NULL) : 0;
|
||||
before_reseed = expect_master_reseed == 1 ? reseed_time : 0;
|
||||
if (!TEST_int_eq(RAND_bytes(buf, sizeof(buf)), expect_success)
|
||||
|| !TEST_int_eq(RAND_priv_bytes(buf, sizeof(buf)), expect_success))
|
||||
return 0;
|
||||
@@ -682,6 +688,7 @@ static int test_rand_drbg_reseed(void)
|
||||
RAND_DRBG *master, *public, *private;
|
||||
unsigned char rand_add_buf[256];
|
||||
int rv=0;
|
||||
time_t before_reseed;
|
||||
|
||||
/* Check whether RAND_OpenSSL() is the default method */
|
||||
if (!TEST_ptr_eq(RAND_get_rand_method(), RAND_OpenSSL()))
|
||||
@@ -716,7 +723,7 @@ static int test_rand_drbg_reseed(void)
|
||||
/*
|
||||
* Test initial seeding of shared DRBGs
|
||||
*/
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 1, 1, 1)))
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 1, 1, 1, 0)))
|
||||
goto error;
|
||||
reset_drbg_hook_ctx();
|
||||
|
||||
@@ -724,7 +731,7 @@ static int test_rand_drbg_reseed(void)
|
||||
/*
|
||||
* Test initial state of shared DRBGs
|
||||
*/
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 0)))
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 0, 0)))
|
||||
goto error;
|
||||
reset_drbg_hook_ctx();
|
||||
|
||||
@@ -733,7 +740,7 @@ static int test_rand_drbg_reseed(void)
|
||||
* reseed counters differ from the master's reseed counter.
|
||||
*/
|
||||
master->reseed_prop_counter++;
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 1, 1)))
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 1, 1, 0)))
|
||||
goto error;
|
||||
reset_drbg_hook_ctx();
|
||||
|
||||
@@ -743,7 +750,7 @@ static int test_rand_drbg_reseed(void)
|
||||
*/
|
||||
master->reseed_prop_counter++;
|
||||
private->reseed_prop_counter++;
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 1, 0)))
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 1, 0, 0)))
|
||||
goto error;
|
||||
reset_drbg_hook_ctx();
|
||||
|
||||
@@ -753,7 +760,7 @@ static int test_rand_drbg_reseed(void)
|
||||
*/
|
||||
master->reseed_prop_counter++;
|
||||
public->reseed_prop_counter++;
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 1)))
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 1, 0)))
|
||||
goto error;
|
||||
reset_drbg_hook_ctx();
|
||||
|
||||
@@ -762,10 +769,17 @@ static int test_rand_drbg_reseed(void)
|
||||
memset(rand_add_buf, 'r', sizeof(rand_add_buf));
|
||||
|
||||
/*
|
||||
* Test whether all three DRBGs are reseeded by RAND_add()
|
||||
* Test whether all three DRBGs are reseeded by RAND_add().
|
||||
* The before_reseed time has to be measured here and passed into the
|
||||
* test_drbg_reseed() test, because the master DRBG gets already reseeded
|
||||
* in RAND_add(), whence the check for the condition
|
||||
* before_reseed <= master->reseed_time will fail if the time value happens
|
||||
* to increase between the RAND_add() and the test_drbg_reseed() call.
|
||||
*/
|
||||
before_reseed = time(NULL);
|
||||
RAND_add(rand_add_buf, sizeof(rand_add_buf), sizeof(rand_add_buf));
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 1, 1, 1)))
|
||||
if (!TEST_true(test_drbg_reseed(1, master, public, private, 1, 1, 1,
|
||||
before_reseed)))
|
||||
goto error;
|
||||
reset_drbg_hook_ctx();
|
||||
|
||||
@@ -776,7 +790,7 @@ static int test_rand_drbg_reseed(void)
|
||||
master_ctx.fail = 1;
|
||||
master->reseed_prop_counter++;
|
||||
RAND_add(rand_add_buf, sizeof(rand_add_buf), sizeof(rand_add_buf));
|
||||
if (!TEST_true(test_drbg_reseed(0, master, public, private, 0, 0, 0)))
|
||||
if (!TEST_true(test_drbg_reseed(0, master, public, private, 0, 0, 0, 0)))
|
||||
goto error;
|
||||
reset_drbg_hook_ctx();
|
||||
|
||||
@@ -799,12 +813,15 @@ static void run_multi_thread_test(void)
|
||||
{
|
||||
unsigned char buf[256];
|
||||
time_t start = time(NULL);
|
||||
RAND_DRBG *public, *private;
|
||||
RAND_DRBG *public = NULL, *private = NULL;
|
||||
|
||||
public = RAND_DRBG_get0_public();
|
||||
private = RAND_DRBG_get0_private();
|
||||
RAND_DRBG_set_reseed_time_interval(public, 1);
|
||||
if (!TEST_ptr(public = RAND_DRBG_get0_public())
|
||||
|| !TEST_ptr(private = RAND_DRBG_get0_private())) {
|
||||
multi_thread_rand_bytes_succeeded = 0;
|
||||
return;
|
||||
}
|
||||
RAND_DRBG_set_reseed_time_interval(private, 1);
|
||||
RAND_DRBG_set_reseed_time_interval(public, 1);
|
||||
|
||||
do {
|
||||
if (RAND_bytes(buf, sizeof(buf)) <= 0)
|
||||
@@ -936,13 +953,16 @@ static size_t rand_drbg_seedlen(RAND_DRBG *drbg)
|
||||
*/
|
||||
static int test_rand_seed(void)
|
||||
{
|
||||
RAND_DRBG *master = RAND_DRBG_get0_master();
|
||||
RAND_DRBG *master = NULL;
|
||||
unsigned char rand_buf[256];
|
||||
size_t rand_buflen;
|
||||
#ifdef OPENSSL_RAND_SEED_NONE
|
||||
size_t required_seed_buflen = rand_drbg_seedlen(master);
|
||||
#else
|
||||
size_t required_seed_buflen = 0;
|
||||
|
||||
if (!TEST_ptr(master = RAND_DRBG_get0_master()))
|
||||
return 0;
|
||||
|
||||
#ifdef OPENSSL_RAND_SEED_NONE
|
||||
required_seed_buflen = rand_drbg_seedlen(master);
|
||||
#endif
|
||||
|
||||
memset(rand_buf, 0xCD, sizeof(rand_buf));
|
||||
@@ -1025,14 +1045,13 @@ err:
|
||||
|
||||
static int test_set_defaults(void)
|
||||
{
|
||||
RAND_DRBG *master, *public, *private;
|
||||
|
||||
master = RAND_DRBG_get0_master();
|
||||
public = RAND_DRBG_get0_public();
|
||||
private = RAND_DRBG_get0_private();
|
||||
RAND_DRBG *master = NULL, *public = NULL, *private = NULL;
|
||||
|
||||
/* Check the default type and flags for master, public and private */
|
||||
return TEST_int_eq(master->type, RAND_DRBG_TYPE)
|
||||
return TEST_ptr(master = RAND_DRBG_get0_master())
|
||||
&& TEST_ptr(public = RAND_DRBG_get0_public())
|
||||
&& TEST_ptr(private = RAND_DRBG_get0_private())
|
||||
&& TEST_int_eq(master->type, RAND_DRBG_TYPE)
|
||||
&& TEST_int_eq(master->flags,
|
||||
RAND_DRBG_FLAGS | RAND_DRBG_FLAG_MASTER)
|
||||
&& TEST_int_eq(public->type, RAND_DRBG_TYPE)
|
||||
|
||||
@@ -838,6 +838,9 @@ typedef struct mac_data_st {
|
||||
/* MAC key */
|
||||
unsigned char *key;
|
||||
size_t key_len;
|
||||
/* MAC IV (GMAC) */
|
||||
unsigned char *iv;
|
||||
size_t iv_len;
|
||||
/* Input to MAC */
|
||||
unsigned char *input;
|
||||
size_t input_len;
|
||||
@@ -925,6 +928,7 @@ static void mac_test_cleanup(EVP_TEST *t)
|
||||
sk_OPENSSL_STRING_pop_free(mdat->controls, openssl_free);
|
||||
OPENSSL_free(mdat->alg);
|
||||
OPENSSL_free(mdat->key);
|
||||
OPENSSL_free(mdat->iv);
|
||||
OPENSSL_free(mdat->input);
|
||||
OPENSSL_free(mdat->output);
|
||||
}
|
||||
@@ -936,6 +940,8 @@ static int mac_test_parse(EVP_TEST *t,
|
||||
|
||||
if (strcmp(keyword, "Key") == 0)
|
||||
return parse_bin(value, &mdata->key, &mdata->key_len);
|
||||
if (strcmp(keyword, "IV") == 0)
|
||||
return parse_bin(value, &mdata->iv, &mdata->iv_len);
|
||||
if (strcmp(keyword, "Algorithm") == 0) {
|
||||
mdata->alg = OPENSSL_strdup(value);
|
||||
if (!mdata->alg)
|
||||
@@ -1119,6 +1125,18 @@ static int mac_test_run_mac(EVP_TEST *t)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (expected->iv != NULL) {
|
||||
rv = EVP_MAC_ctrl(ctx, EVP_MAC_CTRL_SET_IV,
|
||||
expected->iv, expected->iv_len);
|
||||
if (rv == -2) {
|
||||
t->err = "MAC_CTRL_INVALID";
|
||||
goto err;
|
||||
} else if (rv <= 0) {
|
||||
t->err = "MAC_CTRL_ERROR";
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EVP_MAC_init(ctx)) {
|
||||
t->err = "MAC_INIT_ERROR";
|
||||
goto err;
|
||||
|
||||
@@ -386,6 +386,75 @@ Key = 89BCD952A8C8AB371AF48AC7D07085D5EFF702E6D62CDC23
|
||||
Input = FA620C1BBE97319E9A0CF0492121F7A20EB08A6A709DCBD00AAF38E4F99E754E
|
||||
Output = 8F49A1B7D6AA2258
|
||||
|
||||
|
||||
Title = GMAC Tests (from NIST)
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-128-GCM
|
||||
Key = 77BE63708971C4E240D1CB79E8D77FEB
|
||||
IV = E0E00F19FED7BA0136A797F3
|
||||
Input = 7A43EC1D9C0A5A78A0B16533A6213CAB
|
||||
Output = 209FCC8D3675ED938E9C7166709DD946
|
||||
|
||||
Title = GMAC Tests (from http://www.ieee802.org/1/files/public/docs2011/bn-randall-test-vectors-0511-v1.pdf)
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-128-GCM
|
||||
Key = AD7A2BD03EAC835A6F620FDCB506B345
|
||||
IV = 12153524C0895E81B2C28465
|
||||
Input = D609B1F056637A0D46DF998D88E5222AB2C2846512153524C0895E8108000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F30313233340001
|
||||
Output = F09478A9B09007D06F46E9B6A1DA25DD
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-256-GCM
|
||||
Key = E3C08A8F06C6E3AD95A70557B23F75483CE33021A9C72B7025666204C69C0B72
|
||||
IV = 12153524C0895E81B2C28465
|
||||
Input = D609B1F056637A0D46DF998D88E5222AB2C2846512153524C0895E8108000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F30313233340001
|
||||
Output = 2F0BC5AF409E06D609EA8B7D0FA5EA50
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-128-GCM
|
||||
Key = 071B113B0CA743FECCCF3D051F737382
|
||||
IV = F0761E8DCD3D000176D457ED
|
||||
Input = E20106D7CD0DF0761E8DCD3D88E5400076D457ED08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0003
|
||||
Output = 0C017BC73B227DFCC9BAFA1C41ACC353
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-256-GCM
|
||||
Key = 691D3EE909D7F54167FD1CA0B5D769081F2BDE1AEE655FDBAB80BD5295AE6BE7
|
||||
IV = F0761E8DCD3D000176D457ED
|
||||
Input = E20106D7CD0DF0761E8DCD3D88E5400076D457ED08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A0003
|
||||
Output = 35217C774BBC31B63166BCF9D4ABED07
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-128-GCM
|
||||
Key = 013FE00B5F11BE7F866D0CBBC55A7A90
|
||||
IV = 7CFDE9F9E33724C68932D612
|
||||
Input = 84C5D513D2AAF6E5BBD2727788E523008932D6127CFDE9F9E33724C608000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F0005
|
||||
Output = 217867E50C2DAD74C28C3B50ABDF695A
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-256-GCM
|
||||
Key = 83C093B58DE7FFE1C0DA926AC43FB3609AC1C80FEE1B624497EF942E2F79A823
|
||||
IV = 7CFDE9F9E33724C68932D612
|
||||
Input = 84C5D513D2AAF6E5BBD2727788E523008932D6127CFDE9F9E33724C608000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F0005
|
||||
Output = 6EE160E8FAECA4B36C86B234920CA975
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-128-GCM
|
||||
Key = 88EE087FD95DA9FBF6725AA9D757B0CD
|
||||
IV = 7AE8E2CA4EC500012E58495C
|
||||
Input = 68F2E77696CE7AE8E2CA4EC588E541002E58495C08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D0007
|
||||
Output = 07922B8EBCF10BB2297588CA4C614523
|
||||
|
||||
MAC = GMAC
|
||||
Algorithm = AES-256-GCM
|
||||
Key = 4C973DBC7364621674F8B5B89E5C15511FCED9216490FB1C1A2CAA0FFE0407E5
|
||||
IV = 7AE8E2CA4EC500012E58495C
|
||||
Input = 68F2E77696CE7AE8E2CA4EC588E541002E58495C08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D0007
|
||||
Output = 00BDA1B7E87608BCBF470F12157F4C07
|
||||
|
||||
|
||||
Title = Poly1305 Tests (from RFC 7539 and others)
|
||||
|
||||
MAC = Poly1305
|
||||
@@ -641,3 +710,23 @@ Input = e33594d7505e43b900000000000000003394d7505e4379cd010000000000000000000000
|
||||
Key = 0100000000000000040000000000000000000000000000000000000000000000
|
||||
Output = 13000000000000000000000000000000
|
||||
|
||||
# Here are 4 duplicated cases for Poly1305 by EVP_PKEY
|
||||
MAC = Poly1305 by EVP_PKEY
|
||||
Key = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
Input = 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
Output = 00000000000000000000000000000000
|
||||
|
||||
MAC = Poly1305 by EVP_PKEY
|
||||
Key = 0000000000000000000000000000000036e5f6b5c5e06070f0efca96227a863e
|
||||
Input = 416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f
|
||||
Output = 36e5f6b5c5e06070f0efca96227a863e
|
||||
|
||||
MAC = Poly1305 by EVP_PKEY
|
||||
Key = 36e5f6b5c5e06070f0efca96227a863e00000000000000000000000000000000
|
||||
Input = 416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f
|
||||
Output = f3477e7cd95417af89a6b8794c310cf0
|
||||
|
||||
MAC = Poly1305 by EVP_PKEY
|
||||
Key = 1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0
|
||||
Input = 2754776173206272696c6c69672c20616e642074686520736c6974687920746f7665730a446964206779726520616e642067696d626c6520696e2074686520776162653a0a416c6c206d696d737920776572652074686520626f726f676f7665732c0a416e6420746865206d6f6d65207261746873206f757467726162652e
|
||||
Output = 4541669a7eaaee61e708dc7cbcc5eb62
|
||||
Reference in New Issue
Block a user