xcrypt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +106 -0
- data/ext/libxcrypt/AUTHORS +38 -0
- data/ext/libxcrypt/COPYING.LIB +502 -0
- data/ext/libxcrypt/ChangeLog +239 -0
- data/ext/libxcrypt/INSTALL +380 -0
- data/ext/libxcrypt/LICENSING +152 -0
- data/ext/libxcrypt/Makefile.am +704 -0
- data/ext/libxcrypt/Makefile.in +4110 -0
- data/ext/libxcrypt/NEWS +630 -0
- data/ext/libxcrypt/README +1 -0
- data/ext/libxcrypt/README.md +179 -0
- data/ext/libxcrypt/THANKS +13 -0
- data/ext/libxcrypt/TODO +1 -0
- data/ext/libxcrypt/TODO.md +100 -0
- data/ext/libxcrypt/aclocal.m4 +2617 -0
- data/ext/libxcrypt/autogen.sh +33 -0
- data/ext/libxcrypt/autom4te.cache/output.0 +19884 -0
- data/ext/libxcrypt/autom4te.cache/output.1 +19884 -0
- data/ext/libxcrypt/autom4te.cache/output.2 +19884 -0
- data/ext/libxcrypt/autom4te.cache/output.3 +19885 -0
- data/ext/libxcrypt/autom4te.cache/requests +714 -0
- data/ext/libxcrypt/autom4te.cache/traces.0 +4088 -0
- data/ext/libxcrypt/autom4te.cache/traces.1 +1060 -0
- data/ext/libxcrypt/autom4te.cache/traces.2 +4088 -0
- data/ext/libxcrypt/autom4te.cache/traces.3 +1060 -0
- data/ext/libxcrypt/build-aux/ci/ci-log-dependency-versions +79 -0
- data/ext/libxcrypt/build-aux/ci/ci-log-logfiles +22 -0
- data/ext/libxcrypt/build-aux/ci/clang-gcov-wrapper +2 -0
- data/ext/libxcrypt/build-aux/ci/configure-wrapper +10 -0
- data/ext/libxcrypt/build-aux/ci/summarize-coverage +24 -0
- data/ext/libxcrypt/build-aux/m4/ax_append_compile_flags.m4 +46 -0
- data/ext/libxcrypt/build-aux/m4/ax_append_flag.m4 +50 -0
- data/ext/libxcrypt/build-aux/m4/ax_check_compile_flag.m4 +53 -0
- data/ext/libxcrypt/build-aux/m4/ax_check_vscript.m4 +142 -0
- data/ext/libxcrypt/build-aux/m4/ax_gcc_func_attribute.m4 +246 -0
- data/ext/libxcrypt/build-aux/m4/ax_require_defined.m4 +37 -0
- data/ext/libxcrypt/build-aux/m4/ax_valgrind_check.m4 +239 -0
- data/ext/libxcrypt/build-aux/m4/libtool.m4 +8488 -0
- data/ext/libxcrypt/build-aux/m4/ltoptions.m4 +467 -0
- data/ext/libxcrypt/build-aux/m4/ltsugar.m4 +124 -0
- data/ext/libxcrypt/build-aux/m4/ltversion.m4 +24 -0
- data/ext/libxcrypt/build-aux/m4/lt~obsolete.m4 +99 -0
- data/ext/libxcrypt/build-aux/m4/pkg_compat.m4 +88 -0
- data/ext/libxcrypt/build-aux/m4/zw_alignment.m4 +90 -0
- data/ext/libxcrypt/build-aux/m4/zw_automodern.m4 +307 -0
- data/ext/libxcrypt/build-aux/m4/zw_detect_asan.m4 +24 -0
- data/ext/libxcrypt/build-aux/m4/zw_endianness.m4 +152 -0
- data/ext/libxcrypt/build-aux/m4/zw_ld_wrap.m4 +47 -0
- data/ext/libxcrypt/build-aux/m4/zw_prog_perl.m4 +40 -0
- data/ext/libxcrypt/build-aux/m4/zw_simple_warnings.m4 +150 -0
- data/ext/libxcrypt/build-aux/m4/zw_static_assert.m4 +68 -0
- data/ext/libxcrypt/build-aux/m4-autogen/compile +364 -0
- data/ext/libxcrypt/build-aux/m4-autogen/config.guess +1815 -0
- data/ext/libxcrypt/build-aux/m4-autogen/config.sub +2354 -0
- data/ext/libxcrypt/build-aux/m4-autogen/depcomp +792 -0
- data/ext/libxcrypt/build-aux/m4-autogen/install-sh +541 -0
- data/ext/libxcrypt/build-aux/m4-autogen/ltmain.sh +11524 -0
- data/ext/libxcrypt/build-aux/m4-autogen/missing +236 -0
- data/ext/libxcrypt/build-aux/m4-autogen/test-driver +160 -0
- data/ext/libxcrypt/build-aux/scripts/BuildCommon.pm +712 -0
- data/ext/libxcrypt/build-aux/scripts/check-perlcritic-config +76 -0
- data/ext/libxcrypt/build-aux/scripts/compute-symver-floor +116 -0
- data/ext/libxcrypt/build-aux/scripts/expand-selected-hashes +80 -0
- data/ext/libxcrypt/build-aux/scripts/gen-crypt-h +131 -0
- data/ext/libxcrypt/build-aux/scripts/gen-crypt-hashes-h +141 -0
- data/ext/libxcrypt/build-aux/scripts/gen-crypt-symbol-vers-h +150 -0
- data/ext/libxcrypt/build-aux/scripts/gen-libcrypt-map +67 -0
- data/ext/libxcrypt/build-aux/scripts/move-if-change +84 -0
- data/ext/libxcrypt/build-aux/scripts/skip-if-exec-format-error +78 -0
- data/ext/libxcrypt/codecov.yml +4 -0
- data/ext/libxcrypt/config.h.in +303 -0
- data/ext/libxcrypt/configure +19885 -0
- data/ext/libxcrypt/configure.ac +549 -0
- data/ext/libxcrypt/doc/crypt.3 +512 -0
- data/ext/libxcrypt/doc/crypt.5 +343 -0
- data/ext/libxcrypt/doc/crypt_checksalt.3 +106 -0
- data/ext/libxcrypt/doc/crypt_gensalt.3 +285 -0
- data/ext/libxcrypt/doc/crypt_gensalt_ra.3 +1 -0
- data/ext/libxcrypt/doc/crypt_gensalt_rn.3 +1 -0
- data/ext/libxcrypt/doc/crypt_preferred_method.3 +68 -0
- data/ext/libxcrypt/doc/crypt_r.3 +1 -0
- data/ext/libxcrypt/doc/crypt_ra.3 +1 -0
- data/ext/libxcrypt/doc/crypt_rn.3 +1 -0
- data/ext/libxcrypt/lib/alg-des-tables.c +3858 -0
- data/ext/libxcrypt/lib/alg-des.c +269 -0
- data/ext/libxcrypt/lib/alg-des.h +74 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-const.h +313 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-core.c +238 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-core.h +51 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-hmac.c +78 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-hmac.h +46 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-precalc.h +1426 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-ref.h +67 -0
- data/ext/libxcrypt/lib/alg-hmac-sha1.c +140 -0
- data/ext/libxcrypt/lib/alg-hmac-sha1.h +35 -0
- data/ext/libxcrypt/lib/alg-md4.c +270 -0
- data/ext/libxcrypt/lib/alg-md4.h +43 -0
- data/ext/libxcrypt/lib/alg-md5.c +291 -0
- data/ext/libxcrypt/lib/alg-md5.h +43 -0
- data/ext/libxcrypt/lib/alg-sha1.c +288 -0
- data/ext/libxcrypt/lib/alg-sha1.h +34 -0
- data/ext/libxcrypt/lib/alg-sha256.c +630 -0
- data/ext/libxcrypt/lib/alg-sha256.h +123 -0
- data/ext/libxcrypt/lib/alg-sha512.c +311 -0
- data/ext/libxcrypt/lib/alg-sha512.h +81 -0
- data/ext/libxcrypt/lib/alg-sm3-hmac.c +113 -0
- data/ext/libxcrypt/lib/alg-sm3-hmac.h +42 -0
- data/ext/libxcrypt/lib/alg-sm3.c +449 -0
- data/ext/libxcrypt/lib/alg-sm3.h +63 -0
- data/ext/libxcrypt/lib/alg-yescrypt-common.c +713 -0
- data/ext/libxcrypt/lib/alg-yescrypt-opt.c +1568 -0
- data/ext/libxcrypt/lib/alg-yescrypt-platform.c +106 -0
- data/ext/libxcrypt/lib/alg-yescrypt.h +360 -0
- data/ext/libxcrypt/lib/byteorder.h +164 -0
- data/ext/libxcrypt/lib/crypt-bcrypt.c +1061 -0
- data/ext/libxcrypt/lib/crypt-des-obsolete.c +215 -0
- data/ext/libxcrypt/lib/crypt-des.c +491 -0
- data/ext/libxcrypt/lib/crypt-gensalt-static.c +40 -0
- data/ext/libxcrypt/lib/crypt-gost-yescrypt.c +182 -0
- data/ext/libxcrypt/lib/crypt-md5.c +232 -0
- data/ext/libxcrypt/lib/crypt-nthash.c +134 -0
- data/ext/libxcrypt/lib/crypt-obsolete.h +40 -0
- data/ext/libxcrypt/lib/crypt-pbkdf1-sha1.c +260 -0
- data/ext/libxcrypt/lib/crypt-port.h +514 -0
- data/ext/libxcrypt/lib/crypt-scrypt.c +247 -0
- data/ext/libxcrypt/lib/crypt-sha256.c +308 -0
- data/ext/libxcrypt/lib/crypt-sha512.c +323 -0
- data/ext/libxcrypt/lib/crypt-sm3-yescrypt.c +189 -0
- data/ext/libxcrypt/lib/crypt-sm3.c +308 -0
- data/ext/libxcrypt/lib/crypt-static.c +44 -0
- data/ext/libxcrypt/lib/crypt-sunmd5.c +314 -0
- data/ext/libxcrypt/lib/crypt-yescrypt.c +177 -0
- data/ext/libxcrypt/lib/crypt.c +421 -0
- data/ext/libxcrypt/lib/crypt.h.in +249 -0
- data/ext/libxcrypt/lib/gen-des-tables.c +363 -0
- data/ext/libxcrypt/lib/hashes.conf +59 -0
- data/ext/libxcrypt/lib/libcrypt.map.in +48 -0
- data/ext/libxcrypt/lib/libcrypt.minver +97 -0
- data/ext/libxcrypt/lib/libxcrypt.pc.in +15 -0
- data/ext/libxcrypt/lib/util-base64.c +26 -0
- data/ext/libxcrypt/lib/util-gensalt-sha.c +88 -0
- data/ext/libxcrypt/lib/util-get-random-bytes.c +154 -0
- data/ext/libxcrypt/lib/util-make-failure-token.c +48 -0
- data/ext/libxcrypt/lib/util-xbzero.c +43 -0
- data/ext/libxcrypt/lib/util-xstrcpy.c +42 -0
- data/ext/libxcrypt/lib/xcrypt.h.in +58 -0
- data/ext/libxcrypt/libxcrypt.spec.rpkg +481 -0
- data/ext/libxcrypt/rpkg.conf +2 -0
- data/ext/libxcrypt/rpkg.macros +86 -0
- data/ext/libxcrypt/test/TestCommon.pm +326 -0
- data/ext/libxcrypt/test/alg-des.c +80 -0
- data/ext/libxcrypt/test/alg-gost3411-2012-hmac.c +90 -0
- data/ext/libxcrypt/test/alg-gost3411-2012.c +191 -0
- data/ext/libxcrypt/test/alg-hmac-sha1.c +187 -0
- data/ext/libxcrypt/test/alg-md4.c +111 -0
- data/ext/libxcrypt/test/alg-md5.c +134 -0
- data/ext/libxcrypt/test/alg-pbkdf-hmac-sha256.c +269 -0
- data/ext/libxcrypt/test/alg-sha1.c +111 -0
- data/ext/libxcrypt/test/alg-sha256.c +141 -0
- data/ext/libxcrypt/test/alg-sha512.c +170 -0
- data/ext/libxcrypt/test/alg-sm3-hmac.c +149 -0
- data/ext/libxcrypt/test/alg-sm3.c +168 -0
- data/ext/libxcrypt/test/alg-yescrypt.c +466 -0
- data/ext/libxcrypt/test/badsalt.c +726 -0
- data/ext/libxcrypt/test/badsetting.c +350 -0
- data/ext/libxcrypt/test/byteorder.c +254 -0
- data/ext/libxcrypt/test/checksalt.c +265 -0
- data/ext/libxcrypt/test/compile-strong-alias.c +43 -0
- data/ext/libxcrypt/test/crypt-badargs.c +392 -0
- data/ext/libxcrypt/test/crypt-gost-yescrypt.c +149 -0
- data/ext/libxcrypt/test/crypt-nested-call.c +180 -0
- data/ext/libxcrypt/test/crypt-sm3-yescrypt.c +149 -0
- data/ext/libxcrypt/test/crypt-too-long-phrase.c +157 -0
- data/ext/libxcrypt/test/des-cases.h +196 -0
- data/ext/libxcrypt/test/des-obsolete.c +206 -0
- data/ext/libxcrypt/test/des-obsolete_r.c +207 -0
- data/ext/libxcrypt/test/explicit-bzero.c +334 -0
- data/ext/libxcrypt/test/gensalt-bcrypt_x.c +54 -0
- data/ext/libxcrypt/test/gensalt-extradata.c +246 -0
- data/ext/libxcrypt/test/gensalt-nested-call.c +126 -0
- data/ext/libxcrypt/test/gensalt-nthash.c +65 -0
- data/ext/libxcrypt/test/gensalt.c +599 -0
- data/ext/libxcrypt/test/getrandom-fallbacks.c +295 -0
- data/ext/libxcrypt/test/getrandom-interface.c +211 -0
- data/ext/libxcrypt/test/ka-table-gen.py +945 -0
- data/ext/libxcrypt/test/ka-table.inc +5849 -0
- data/ext/libxcrypt/test/ka-tester.c +240 -0
- data/ext/libxcrypt/test/preferred-method.c +133 -0
- data/ext/libxcrypt/test/short-outbuf.c +119 -0
- data/ext/libxcrypt/test/special-char-salt.c +1160 -0
- data/ext/libxcrypt/test/symbols-compat.pl +137 -0
- data/ext/libxcrypt/test/symbols-renames.pl +107 -0
- data/ext/libxcrypt/test/symbols-static.pl +87 -0
- data/ext/xcrypt/xcrypt.c +9 -0
- data/lib/xcrypt/ffi.rb +76 -0
- data/lib/xcrypt/version.rb +5 -0
- data/lib/xcrypt.rb +89 -0
- metadata +267 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Written by Zack Weinberg <zackw at panix.com> in 2020.
|
|
2
|
+
# To the extent possible under law, Zack Weinberg has waived all
|
|
3
|
+
# copyright and related or neighboring rights to this work.
|
|
4
|
+
#
|
|
5
|
+
# See https://creativecommons.org/publicdomain/zero/1.0/ for further
|
|
6
|
+
# details.
|
|
7
|
+
|
|
8
|
+
# Code shared among all of the Perl-language tests in this directory.
|
|
9
|
+
|
|
10
|
+
package TestCommon;
|
|
11
|
+
|
|
12
|
+
use v5.14; # implicit use strict, use feature ':5.14'
|
|
13
|
+
use warnings FATAL => 'all';
|
|
14
|
+
use utf8;
|
|
15
|
+
use open qw(:utf8);
|
|
16
|
+
|
|
17
|
+
no if $] >= 5.022, warnings => 'experimental::re_strict';
|
|
18
|
+
use if $] >= 5.022, re => 'strict';
|
|
19
|
+
|
|
20
|
+
use Cwd qw(realpath);
|
|
21
|
+
use File::Spec::Functions qw(
|
|
22
|
+
catdir
|
|
23
|
+
catpath
|
|
24
|
+
splitpath
|
|
25
|
+
);
|
|
26
|
+
use FindBin ();
|
|
27
|
+
use POSIX ();
|
|
28
|
+
|
|
29
|
+
use lib "$FindBin::Bin/../build-aux/scripts";
|
|
30
|
+
## ProhibitUnusedImport does not notice uses from @EXPORT_OK.
|
|
31
|
+
## no critic (TooMuchCode::ProhibitUnusedImport)
|
|
32
|
+
use BuildCommon qw(
|
|
33
|
+
ensure_C_locale
|
|
34
|
+
error
|
|
35
|
+
popen
|
|
36
|
+
sh_split
|
|
37
|
+
sh_quote
|
|
38
|
+
subprocess_error
|
|
39
|
+
which
|
|
40
|
+
);
|
|
41
|
+
## use critic
|
|
42
|
+
|
|
43
|
+
our @EXPORT_OK;
|
|
44
|
+
use Exporter qw(import);
|
|
45
|
+
|
|
46
|
+
BEGIN {
|
|
47
|
+
# Re-export all the subprocess handling routines from BuildCommon
|
|
48
|
+
# as a convenience for individual tests.
|
|
49
|
+
@EXPORT_OK = qw(
|
|
50
|
+
compare_symbol_lists
|
|
51
|
+
ensure_C_locale
|
|
52
|
+
error
|
|
53
|
+
fail
|
|
54
|
+
find_real_library
|
|
55
|
+
get_symbols
|
|
56
|
+
popen
|
|
57
|
+
sh_quote
|
|
58
|
+
sh_split
|
|
59
|
+
skip
|
|
60
|
+
subprocess_error
|
|
61
|
+
which
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Diagnostics: report that the test has failed.
|
|
66
|
+
sub fail { ## no critic (Subroutines::RequireArgUnpacking)
|
|
67
|
+
my $msg = join q{ }, @_;
|
|
68
|
+
print {*STDERR} $FindBin::Script, ': FAIL: ', $msg, "\n";
|
|
69
|
+
exit 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Diagnostics: report that the test should be 'skipped' because
|
|
73
|
+
# some piece of infrastructure we need is missing.
|
|
74
|
+
sub skip { ## no critic (Subroutines::RequireArgUnpacking)
|
|
75
|
+
my $msg = join q{ }, @_;
|
|
76
|
+
print {*STDERR} $FindBin::Script, ': skipping test: ', $msg, "\n";
|
|
77
|
+
exit 77;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Parse a .la file (arg 1) and determine the name of the actual .a or
|
|
81
|
+
# .so file it refers to (arg 2: 'static' for .a, 'shared' for .so)
|
|
82
|
+
sub find_real_library {
|
|
83
|
+
my ($lib_la, $type) = @_;
|
|
84
|
+
|
|
85
|
+
state @SH;
|
|
86
|
+
if (!@SH) {
|
|
87
|
+
@SH = which($ENV{SHELL} || $ENV{CONFIG_SHELL} || '/bin/sh');
|
|
88
|
+
error('no shell available???') if !@SH;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
my $param;
|
|
92
|
+
if ($type eq 'shared') {
|
|
93
|
+
$param = 'dlname';
|
|
94
|
+
} elsif ($type eq 'static') {
|
|
95
|
+
$param = 'old_library';
|
|
96
|
+
} else {
|
|
97
|
+
error("unknown library type: '$type'");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# We're going to interpolate $lib_la into a shell command.
|
|
101
|
+
# Save the unmangled directory part first, then quote it.
|
|
102
|
+
my ($vol, $dir, undef) = splitpath($lib_la);
|
|
103
|
+
$lib_la = sh_quote($lib_la);
|
|
104
|
+
|
|
105
|
+
# .la files are shell script fragments. The easiest way to learn
|
|
106
|
+
# the name of the actual library is to ask a shell to parse the
|
|
107
|
+
# fragment for us.
|
|
108
|
+
my $fh = popen('-|', @SH, '-c', ". $lib_la; printf %s \"\$$param\"");
|
|
109
|
+
my $real_library;
|
|
110
|
+
{
|
|
111
|
+
local $/ = undef; # slurp
|
|
112
|
+
$real_library = <$fh>;
|
|
113
|
+
}
|
|
114
|
+
close $fh or subprocess_error($SH[0]);
|
|
115
|
+
|
|
116
|
+
chomp $real_library;
|
|
117
|
+
$real_library = catpath($vol, catdir($dir, '.libs'), $real_library);
|
|
118
|
+
error("'$real_library' does not exist") unless -f $real_library;
|
|
119
|
+
return realpath($real_library);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# In some object file formats, all symbols defined in C have an
|
|
123
|
+
# underscore prepended to their names. The configure script detects
|
|
124
|
+
# this and the Makefiles set this environment variable appropriately.
|
|
125
|
+
my $symbol_prefix = $ENV{SYMBOL_PREFIX} || q{};
|
|
126
|
+
|
|
127
|
+
# Return a hashset of symbols exported by the library $_[0], using readelf.
|
|
128
|
+
# If it is a dynamic library, annotate each symbol with its version tag.
|
|
129
|
+
sub get_symbols_readelf {
|
|
130
|
+
my $lib = shift;
|
|
131
|
+
my $filter = shift // sub { 1 };
|
|
132
|
+
|
|
133
|
+
state $readelf_works = 1;
|
|
134
|
+
die "readelf doesn't work\n" unless $readelf_works;
|
|
135
|
+
|
|
136
|
+
state @READELF;
|
|
137
|
+
if (!@READELF) {
|
|
138
|
+
@READELF = which($ENV{READELF} || 'readelf');
|
|
139
|
+
die "readelf not available\n" unless @READELF;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
my @opts = ('--wide');
|
|
143
|
+
my $want_version_tags = 0;
|
|
144
|
+
if ($lib =~ /\.(?:a|lib)$/) {
|
|
145
|
+
push @opts, '--syms';
|
|
146
|
+
} else {
|
|
147
|
+
push @opts, '--dyn-syms';
|
|
148
|
+
$want_version_tags = 1;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
my $fh = popen('-|', @READELF, @opts, $lib);
|
|
152
|
+
|
|
153
|
+
local $_;
|
|
154
|
+
my %symbols;
|
|
155
|
+
my $saw_version_tags = 0;
|
|
156
|
+
while (<$fh>) {
|
|
157
|
+
chomp;
|
|
158
|
+
s/\s+$//;
|
|
159
|
+
next if /^(?:$|File:|Symbol table)/;
|
|
160
|
+
next if /^\s*Num:\s+Value\s+Size\s+Type\s+Bind\s+Vis\s+Ndx\s+Name$/;
|
|
161
|
+
|
|
162
|
+
my ($num, $value, $size, $type, $bind, $vis, $ndx, $name) = split;
|
|
163
|
+
|
|
164
|
+
# We are only interested in globally visible, defined,
|
|
165
|
+
# non-absolute symbols.
|
|
166
|
+
next
|
|
167
|
+
if $ndx eq 'UND'
|
|
168
|
+
|| $ndx eq 'ABS'
|
|
169
|
+
|| $bind eq 'LOCAL';
|
|
170
|
+
|
|
171
|
+
# Strip the symbol prefix, if any, from each symbol.
|
|
172
|
+
$name =~ s/^$symbol_prefix// if $symbol_prefix ne q{};
|
|
173
|
+
|
|
174
|
+
$saw_version_tags = 1 if $name =~ /@[A-Z_]+[0-9]/;
|
|
175
|
+
|
|
176
|
+
if (&{$filter}($name)) {
|
|
177
|
+
print {*STDERR} "|+ $name\n";
|
|
178
|
+
$symbols{$name} = 1;
|
|
179
|
+
} else {
|
|
180
|
+
print {*STDERR} "|- $name\n";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (!close $fh) {
|
|
184
|
+
# If it ran but exited 1 or 2, don't give up yet, we still
|
|
185
|
+
# have nm to try.
|
|
186
|
+
if ($! == 0 && ($? == 256 || $? == 512)) {
|
|
187
|
+
$readelf_works = 0;
|
|
188
|
+
die "$READELF[0] exited " . ($? >> 2) . "\n";
|
|
189
|
+
}
|
|
190
|
+
subprocess_error($READELF[0]);
|
|
191
|
+
}
|
|
192
|
+
if ($want_version_tags && !$saw_version_tags) {
|
|
193
|
+
$readelf_works = 0;
|
|
194
|
+
die "$READELF[0] did not print version tags\n";
|
|
195
|
+
}
|
|
196
|
+
return \%symbols;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
# Return a hashset of symbols exported by the library $_[0], using nm.
|
|
200
|
+
# If it is a dynamic library, annotate each symbol with its version tag.
|
|
201
|
+
sub get_symbols_nm {
|
|
202
|
+
my $lib = shift;
|
|
203
|
+
my $filter = shift // sub { 1 };
|
|
204
|
+
|
|
205
|
+
state $nm_works = 1;
|
|
206
|
+
die "nm doesn't work\n" unless $nm_works;
|
|
207
|
+
|
|
208
|
+
state @NM;
|
|
209
|
+
if (!@NM) {
|
|
210
|
+
@NM = which($ENV{NM} || 'nm');
|
|
211
|
+
die "nm not available\n" unless @NM;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
my @opts = qw(--format=bsd --extern-only --defined-only);
|
|
215
|
+
my $want_version_tags = 0;
|
|
216
|
+
if ($lib !~ /\.(?:a|lib)$/) {
|
|
217
|
+
push @opts, qw(--dynamic --with-symbol-versions);
|
|
218
|
+
$want_version_tags = 1;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
my $fh = popen('-|', @NM, @opts, $lib);
|
|
222
|
+
local $_;
|
|
223
|
+
my %symbols;
|
|
224
|
+
my $saw_version_tags = 0;
|
|
225
|
+
while (<$fh>) {
|
|
226
|
+
chomp;
|
|
227
|
+
s/\s+$//;
|
|
228
|
+
next unless $_;
|
|
229
|
+
|
|
230
|
+
# BSD-format nm output, when restricted to external, defined
|
|
231
|
+
# symbols, has three fields per line: address type name.
|
|
232
|
+
# We shouldn't ever see symbols with the address field blank,
|
|
233
|
+
# but just in case, discard them.
|
|
234
|
+
next unless /^([0-9a-fA-F]+)\s+([A-Za-z])\s+(\S+)$/;
|
|
235
|
+
my $addr = $1;
|
|
236
|
+
my $type = $2;
|
|
237
|
+
my $name = $3;
|
|
238
|
+
|
|
239
|
+
# Symbols whose address is 0 and type is A are uninteresting;
|
|
240
|
+
# they define the set of symbol version tags.
|
|
241
|
+
next if $addr =~ /^0+$/ && $type eq 'A';
|
|
242
|
+
|
|
243
|
+
# Strip the symbol prefix, if any, from each symbol.
|
|
244
|
+
$name =~ s/^$symbol_prefix// if $symbol_prefix;
|
|
245
|
+
|
|
246
|
+
# Compensate for a bug in some versions of GNU nm
|
|
247
|
+
# where the symbol version is printed twice.
|
|
248
|
+
$name =~ s/(@+[A-Z0-9_.]+)\1$/$1/;
|
|
249
|
+
|
|
250
|
+
$saw_version_tags = 1 if $name =~ /@[A-Z_]+[0-9]/;
|
|
251
|
+
|
|
252
|
+
if (&{$filter}($name)) {
|
|
253
|
+
print {*STDERR} "|+ $name\n";
|
|
254
|
+
$symbols{$name} = 1;
|
|
255
|
+
} else {
|
|
256
|
+
print {*STDERR} "|- $name\n";
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (!close $fh) {
|
|
260
|
+
# If it ran but exited 1 or 2, don't give up yet, we still
|
|
261
|
+
# have readelf to try.
|
|
262
|
+
if ($! == 0 && ($? == 256 || $? == 512)) {
|
|
263
|
+
$nm_works = 0;
|
|
264
|
+
die "$NM[0] exited " . ($? >> 8) . "\n";
|
|
265
|
+
}
|
|
266
|
+
subprocess_error($NM[0]);
|
|
267
|
+
}
|
|
268
|
+
if ($want_version_tags && !$saw_version_tags) {
|
|
269
|
+
$nm_works = 0;
|
|
270
|
+
die "$NM[0] did not print version tags\n";
|
|
271
|
+
}
|
|
272
|
+
return \%symbols;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
# Return a hashset of symbols exported by the library $_[0], using
|
|
276
|
+
# readelf or nm, whichever works on this system. If it is a dynamic
|
|
277
|
+
# library, annotate each symbol with its version tag. If $_[1] is
|
|
278
|
+
# defined, it is a filter procedure; only symbols for which the filter
|
|
279
|
+
# returns true are included in the hashset.
|
|
280
|
+
sub get_symbols { ## no critic (Subroutines::RequireArgUnpacking)
|
|
281
|
+
my $result;
|
|
282
|
+
|
|
283
|
+
$result = eval { get_symbols_nm(@_); };
|
|
284
|
+
return $result if $result;
|
|
285
|
+
print {*STDERR} "get_symbols_nm: $@";
|
|
286
|
+
|
|
287
|
+
$result = eval { get_symbols_readelf(@_); };
|
|
288
|
+
return $result if $result;
|
|
289
|
+
print {*STDERR} "get_symbols_readelf: $@";
|
|
290
|
+
|
|
291
|
+
skip('cannot get symbols using either readelf or nm');
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
sub compare_symbol_lists {
|
|
295
|
+
my ($found, $expected, $tag, $extra_allowed) = @_;
|
|
296
|
+
my @extra;
|
|
297
|
+
my @missing;
|
|
298
|
+
local $_;
|
|
299
|
+
for (keys %{$expected}) {
|
|
300
|
+
push @missing, $_ unless exists $found->{$_};
|
|
301
|
+
}
|
|
302
|
+
for (keys %{$found}) {
|
|
303
|
+
push @extra, $_ unless exists $expected->{$_};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
my $error = 0;
|
|
307
|
+
if (@extra) {
|
|
308
|
+
$error = 1 unless $extra_allowed;
|
|
309
|
+
print {*STDERR} "*** Extra $tag:\n";
|
|
310
|
+
for (sort @extra) {
|
|
311
|
+
s/^_crypt_//;
|
|
312
|
+
print {*STDERR} " $_\n";
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (@missing) {
|
|
316
|
+
$error = 1;
|
|
317
|
+
print {*STDERR} "*** Missing $tag:\n";
|
|
318
|
+
for (sort @missing) {
|
|
319
|
+
s/^_crypt_//;
|
|
320
|
+
print {*STDERR} " $_\n";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return $error;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
1;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This crypt(3) validation program shipped with UFC-crypt
|
|
3
|
+
* is derived from one distributed with Phil Karns PD DES package.
|
|
4
|
+
*
|
|
5
|
+
* @(#)cert.c 1.8 11 Aug 1996
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "crypt-port.h"
|
|
9
|
+
#include "alg-des.h"
|
|
10
|
+
#include "des-cases.h"
|
|
11
|
+
|
|
12
|
+
#include <stdio.h>
|
|
13
|
+
|
|
14
|
+
#if INCLUDE_descrypt || INCLUDE_bsdicrypt || INCLUDE_bigcrypt
|
|
15
|
+
|
|
16
|
+
static void
|
|
17
|
+
v_print (const unsigned char v[8])
|
|
18
|
+
{
|
|
19
|
+
for (int i = 0; i < 8; i++)
|
|
20
|
+
printf ("%02x", (unsigned int)v[i]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static void
|
|
24
|
+
report_failure (size_t n, bool decrypt,
|
|
25
|
+
const struct des_testcase *tc, const unsigned char got[8])
|
|
26
|
+
{
|
|
27
|
+
printf ("FAIL: %zu/%s: k=", n, decrypt ? "de" : "en");
|
|
28
|
+
v_print (tc->key);
|
|
29
|
+
fputs (" exp ", stdout);
|
|
30
|
+
if (decrypt)
|
|
31
|
+
v_print (tc->plain);
|
|
32
|
+
else
|
|
33
|
+
v_print (tc->answer);
|
|
34
|
+
fputs (" got ", stdout);
|
|
35
|
+
v_print (got);
|
|
36
|
+
putchar ('\n');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
int
|
|
40
|
+
main (void)
|
|
41
|
+
{
|
|
42
|
+
struct des_ctx ctx;
|
|
43
|
+
const struct des_testcase *tc;
|
|
44
|
+
unsigned char got[8];
|
|
45
|
+
size_t t;
|
|
46
|
+
int status = 0;
|
|
47
|
+
|
|
48
|
+
des_set_salt (&ctx, 0);
|
|
49
|
+
|
|
50
|
+
for (t = 0; t < N_DES_TESTCASES; t++)
|
|
51
|
+
{
|
|
52
|
+
tc = &des_testcases[t];
|
|
53
|
+
des_set_key (&ctx, tc->key);
|
|
54
|
+
des_crypt_block (&ctx, got, tc->plain, 0, false);
|
|
55
|
+
if (memcmp (got, tc->answer, 8) != 0)
|
|
56
|
+
{
|
|
57
|
+
status = 1;
|
|
58
|
+
report_failure (t, false, tc, got);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
des_crypt_block (&ctx, got, tc->answer, 0, true);
|
|
62
|
+
if (memcmp (got, tc->plain, 8) != 0)
|
|
63
|
+
{
|
|
64
|
+
status = 1;
|
|
65
|
+
report_failure (t, true, tc, got);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return status;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#else
|
|
73
|
+
|
|
74
|
+
int
|
|
75
|
+
main (void)
|
|
76
|
+
{
|
|
77
|
+
return 77; /* UNSUPPORTED */
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
#endif
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/* Copyright (C) 2018 vt@altlinux.org
|
|
2
|
+
* Copyright (C) 2018 Björn Esser besser82@fedoraproject.org
|
|
3
|
+
*
|
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
|
5
|
+
* modification, are permitted.
|
|
6
|
+
*
|
|
7
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
8
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
9
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
10
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
11
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
12
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
13
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
14
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
15
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
16
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
17
|
+
* SUCH DAMAGE.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#include "crypt-port.h"
|
|
21
|
+
|
|
22
|
+
#if INCLUDE_gost_yescrypt
|
|
23
|
+
|
|
24
|
+
#include "alg-gost3411-2012-hmac.h"
|
|
25
|
+
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
|
|
28
|
+
static void
|
|
29
|
+
dumphex(const void *ptr, size_t size)
|
|
30
|
+
{
|
|
31
|
+
size_t i;
|
|
32
|
+
|
|
33
|
+
for (i = 0; i < size; i++)
|
|
34
|
+
printf("%02x", ((const unsigned char *)ptr)[i]);
|
|
35
|
+
printf("\n");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static int
|
|
39
|
+
test_gost2012_hmac(const char *subject, const char *k, size_t ksize,
|
|
40
|
+
const char *t, size_t tlen, const char *match)
|
|
41
|
+
{
|
|
42
|
+
uint8_t digest[32];
|
|
43
|
+
gost_hmac_256_t gostbuf;
|
|
44
|
+
|
|
45
|
+
gost_hmac256((const uint8_t *)k, ksize,
|
|
46
|
+
(const uint8_t *)t, tlen, digest, &gostbuf);
|
|
47
|
+
|
|
48
|
+
if (memcmp(digest, match, sizeof(digest)))
|
|
49
|
+
{
|
|
50
|
+
fprintf(stderr, "ERROR: %s\n", subject);
|
|
51
|
+
printf(" key: ");
|
|
52
|
+
dumphex(k, ksize);
|
|
53
|
+
printf(" t: ");
|
|
54
|
+
dumphex(t, tlen);
|
|
55
|
+
printf(" hmac=");
|
|
56
|
+
dumphex(digest, sizeof(digest));
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
fprintf(stderr, " ok: %s\n", subject);
|
|
61
|
+
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
int
|
|
66
|
+
main (void)
|
|
67
|
+
{
|
|
68
|
+
int result = 0;
|
|
69
|
+
|
|
70
|
+
result |= test_gost2012_hmac(
|
|
71
|
+
"HMAC_GOSTR3411_2012_256 test vector from P 50.1.113-2016",
|
|
72
|
+
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
|
|
73
|
+
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", 32,
|
|
74
|
+
"\x01\x26\xbd\xb8\x78\x00\xaf\x21\x43\x41\x45\x65\x63\x78\x01\x00", 16,
|
|
75
|
+
"\xa1\xaa\x5f\x7d\xe4\x02\xd7\xb3\xd3\x23\xf2\x99\x1c\x8d\x45\x34"
|
|
76
|
+
"\x01\x31\x37\x01\x0a\x83\x75\x4f\xd0\xaf\x6d\x7c\xd4\x92\x2e\xd9"
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#else
|
|
83
|
+
|
|
84
|
+
int
|
|
85
|
+
main (void)
|
|
86
|
+
{
|
|
87
|
+
return 77; /* UNSUPPORTED */
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#endif /* INCLUDE_gost_yescrypt */
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/* Copyright (C) 2018 vt@altlinux.org
|
|
2
|
+
* Copyright (C) 2018 Björn Esser besser82@fedoraproject.org
|
|
3
|
+
*
|
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
|
5
|
+
* modification, are permitted.
|
|
6
|
+
*
|
|
7
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
8
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
9
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
10
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
11
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
12
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
13
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
14
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
15
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
16
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
17
|
+
* SUCH DAMAGE.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#include "crypt-port.h"
|
|
21
|
+
|
|
22
|
+
#if INCLUDE_gost_yescrypt
|
|
23
|
+
|
|
24
|
+
#include "alg-gost3411-2012-hmac.h"
|
|
25
|
+
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
|
|
28
|
+
static void
|
|
29
|
+
dumphex(const void *ptr, size_t size)
|
|
30
|
+
{
|
|
31
|
+
size_t i;
|
|
32
|
+
|
|
33
|
+
for (i = 0; i < size; i++)
|
|
34
|
+
printf("%02x", ((const unsigned char *)ptr)[i]);
|
|
35
|
+
printf("\n");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static int
|
|
39
|
+
test_gost2012_hash(const char *subject, const char *t, const char *match)
|
|
40
|
+
{
|
|
41
|
+
size_t i;
|
|
42
|
+
uint8_t digest[32];
|
|
43
|
+
GOST34112012Context ctx;
|
|
44
|
+
|
|
45
|
+
gost_hash256((const uint8_t *)t, strlen(t), digest, &ctx);
|
|
46
|
+
|
|
47
|
+
char dgt[32 * 2 + 1];
|
|
48
|
+
for (i = 0; i < sizeof(digest); i++)
|
|
49
|
+
sprintf(&dgt[i * 2], "%02x", digest[i]);
|
|
50
|
+
|
|
51
|
+
if (strcmp(dgt, match) != 0)
|
|
52
|
+
{
|
|
53
|
+
fprintf(stderr, "ERROR: %s\n", subject);
|
|
54
|
+
printf(" t[%zu] = ", strlen(t));
|
|
55
|
+
dumphex(t, strlen(t));
|
|
56
|
+
printf(" digest(%zu) = %s",
|
|
57
|
+
sizeof(digest), dgt);
|
|
58
|
+
printf(" expected(%zu) = %s\n",
|
|
59
|
+
strlen(match) / 2, match);
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
else
|
|
63
|
+
fprintf(stderr, " ok: %s\n", subject);
|
|
64
|
+
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static int
|
|
69
|
+
test_gost2012_hash512(const char *subject, const char *t, const char *match)
|
|
70
|
+
{
|
|
71
|
+
size_t i;
|
|
72
|
+
size_t len = strlen(t);
|
|
73
|
+
size_t lh = len / 2;
|
|
74
|
+
uint8_t digest[64];
|
|
75
|
+
GOST34112012Context ctx;
|
|
76
|
+
|
|
77
|
+
GOST34112012Init(&ctx, GOSTR3411_2012_BITS * 2);
|
|
78
|
+
|
|
79
|
+
/* Operate on len < 64 for coverage */
|
|
80
|
+
GOST34112012Update(&ctx, (const uint8_t *)t, lh);
|
|
81
|
+
GOST34112012Update(&ctx, (const uint8_t *)t + lh, len - lh);
|
|
82
|
+
|
|
83
|
+
GOST34112012Final(&ctx, digest);
|
|
84
|
+
|
|
85
|
+
char dgt[64 * 2 + 1];
|
|
86
|
+
for (i = 0; i < sizeof(digest); i++)
|
|
87
|
+
sprintf(&dgt[i * 2], "%02x", digest[i]);
|
|
88
|
+
|
|
89
|
+
if (strcmp(dgt, match) != 0)
|
|
90
|
+
{
|
|
91
|
+
fprintf(stderr, "ERROR: %s\n", subject);
|
|
92
|
+
printf(" t[%zu] = ", strlen(t));
|
|
93
|
+
dumphex(t, strlen(t));
|
|
94
|
+
printf(" digest(%zu) = %s",
|
|
95
|
+
sizeof(digest), dgt);
|
|
96
|
+
printf(" expected(%zu) = %s\n",
|
|
97
|
+
strlen(match) / 2, match);
|
|
98
|
+
return 1;
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
fprintf(stderr, " ok: %s\n", subject);
|
|
102
|
+
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
int
|
|
107
|
+
main (void)
|
|
108
|
+
{
|
|
109
|
+
int result = 0;
|
|
110
|
+
|
|
111
|
+
result |= test_gost2012_hash(
|
|
112
|
+
"test vector from example A.1 from GOST-34.11-2012 (256 Bit)",
|
|
113
|
+
"012345678901234567890123456789012345678901234567890123456789012",
|
|
114
|
+
"9d151eefd8590b89daa6ba6cb74af9275dd051026bb149a452fd84e5e57b5500");
|
|
115
|
+
|
|
116
|
+
result |= !test_gost2012_hash(
|
|
117
|
+
"false positive test vector (256 Bit)",
|
|
118
|
+
"012345678901234567890123456789012345678901234567890123456789012",
|
|
119
|
+
"012345678901234567890123456789012345678901234567890123456789012");
|
|
120
|
+
|
|
121
|
+
result |= test_gost2012_hash(
|
|
122
|
+
"test vector from example A.2 from GOST-34.11-2012 (256 Bit)",
|
|
123
|
+
"\xD1\xE5\x20\xE2\xE5\xF2\xF0\xE8\x2C\x20\xD1\xF2\xF0\xE8\xE1\xEE"
|
|
124
|
+
"\xE6\xE8\x20\xE2\xED\xF3\xF6\xE8\x2C\x20\xE2\xE5\xFE\xF2\xFA\x20"
|
|
125
|
+
"\xF1\x20\xEC\xEE\xF0\xFF\x20\xF1\xF2\xF0\xE5\xEB\xE0\xEC\xE8\x20"
|
|
126
|
+
"\xED\xE0\x20\xF5\xF0\xE0\xE1\xF0\xFB\xFF\x20\xEF\xEB\xFA\xEA\xFB"
|
|
127
|
+
"\x20\xC8\xE3\xEE\xF0\xE5\xE2\xFB",
|
|
128
|
+
"9dd2fe4e90409e5da87f53976d7405b0c0cac628fc669a741d50063c557e8f50");
|
|
129
|
+
|
|
130
|
+
/* carry test */
|
|
131
|
+
result |= test_gost2012_hash(
|
|
132
|
+
"carry test vector from gost-engine (256 Bit)",
|
|
133
|
+
"\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
|
|
134
|
+
"\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
|
|
135
|
+
"\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
|
|
136
|
+
"\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
|
|
137
|
+
"\x16\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11"
|
|
138
|
+
"\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11"
|
|
139
|
+
"\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11"
|
|
140
|
+
"\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x16",
|
|
141
|
+
"81bb632fa31fcc38b4c379a662dbc58b9bed83f50d3a1b2ce7271ab02d25babb");
|
|
142
|
+
|
|
143
|
+
/* 512 bit hash test for completeness */
|
|
144
|
+
result |= test_gost2012_hash512(
|
|
145
|
+
"test vector from example A.1 from GOST-34.11-2012 (512 bit)",
|
|
146
|
+
"012345678901234567890123456789012345678901234567890123456789012",
|
|
147
|
+
"1b54d01a4af5b9d5cc3d86d68d285462b19abc2475222f35c085122be4ba1ffa"
|
|
148
|
+
"00ad30f8767b3a82384c6574f024c311e2a481332b08ef7f41797891c1646f48");
|
|
149
|
+
|
|
150
|
+
result |= !test_gost2012_hash512(
|
|
151
|
+
"false positive test vector (512 bit)",
|
|
152
|
+
"012345678901234567890123456789012345678901234567890123456789012",
|
|
153
|
+
"0123456789012345678901234567890123456789012345678901234567890120"
|
|
154
|
+
"1234567890123456789012345678901234567890123456789012345678901234");
|
|
155
|
+
|
|
156
|
+
result |= test_gost2012_hash512(
|
|
157
|
+
"test vector from example A.2 from GOST-34.11-2012 (512 bit)",
|
|
158
|
+
"\xD1\xE5\x20\xE2\xE5\xF2\xF0\xE8\x2C\x20\xD1\xF2\xF0\xE8\xE1\xEE"
|
|
159
|
+
"\xE6\xE8\x20\xE2\xED\xF3\xF6\xE8\x2C\x20\xE2\xE5\xFE\xF2\xFA\x20"
|
|
160
|
+
"\xF1\x20\xEC\xEE\xF0\xFF\x20\xF1\xF2\xF0\xE5\xEB\xE0\xEC\xE8\x20"
|
|
161
|
+
"\xED\xE0\x20\xF5\xF0\xE0\xE1\xF0\xFB\xFF\x20\xEF\xEB\xFA\xEA\xFB"
|
|
162
|
+
"\x20\xC8\xE3\xEE\xF0\xE5\xE2\xFB",
|
|
163
|
+
"1e88e62226bfca6f9994f1f2d51569e0daf8475a3b0fe61a5300eee46d961376"
|
|
164
|
+
"035fe83549ada2b8620fcd7c496ce5b33f0cb9dddc2b6460143b03dabac9fb28");
|
|
165
|
+
|
|
166
|
+
/* carry test */
|
|
167
|
+
result |= test_gost2012_hash512(
|
|
168
|
+
"carry test vector from gost-engine (512 Bit)",
|
|
169
|
+
"\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
|
|
170
|
+
"\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
|
|
171
|
+
"\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
|
|
172
|
+
"\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE\xEE"
|
|
173
|
+
"\x16\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11"
|
|
174
|
+
"\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11"
|
|
175
|
+
"\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11"
|
|
176
|
+
"\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x16",
|
|
177
|
+
"8b06f41e59907d9636e892caf5942fcdfb71fa31169a5e70f0edb873664df41c"
|
|
178
|
+
"2cce6e06dc6755d15a61cdeb92bd607cc4aaca6732bf3568a23a210dd520fd41");
|
|
179
|
+
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
#else
|
|
184
|
+
|
|
185
|
+
int
|
|
186
|
+
main (void)
|
|
187
|
+
{
|
|
188
|
+
return 77; /* UNSUPPORTED */
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
#endif /* INCLUDE_gost_yescrypt */
|