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,149 @@
|
|
|
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
|
+
/* redefine outer hmac to this function to test entropy bypass */
|
|
29
|
+
static void
|
|
30
|
+
test_outer_hmac (const uint8_t *k, size_t n, const uint8_t *t, size_t len,
|
|
31
|
+
uint8_t *out32, gost_hmac_256_t *gostbuf);
|
|
32
|
+
#define outer_gost_hmac256 test_outer_hmac
|
|
33
|
+
#include "../lib/crypt-gost-yescrypt.c"
|
|
34
|
+
|
|
35
|
+
static int test_mode = 0;
|
|
36
|
+
|
|
37
|
+
static void
|
|
38
|
+
test_outer_hmac (const uint8_t *k, size_t n, const uint8_t *t, size_t len,
|
|
39
|
+
uint8_t *out32, gost_hmac_256_t *gostbuf)
|
|
40
|
+
{
|
|
41
|
+
const uint8_t zero[32] = {0};
|
|
42
|
+
|
|
43
|
+
/* Zero one of arguments to outer hmac. */
|
|
44
|
+
if (test_mode & 1)
|
|
45
|
+
{
|
|
46
|
+
k = zero;
|
|
47
|
+
n = sizeof (zero);
|
|
48
|
+
}
|
|
49
|
+
if (test_mode & 2)
|
|
50
|
+
{
|
|
51
|
+
t = zero;
|
|
52
|
+
len = sizeof (zero);
|
|
53
|
+
}
|
|
54
|
+
gost_hmac256 (k, n, t, len, out32, gostbuf);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static int
|
|
58
|
+
test_crypt_raw (int m, int p, int s, char **a, size_t *a_size)
|
|
59
|
+
{
|
|
60
|
+
char output[CRYPT_OUTPUT_SIZE];
|
|
61
|
+
char pass[CRYPT_MAX_PASSPHRASE_SIZE];
|
|
62
|
+
char pref[CRYPT_GENSALT_OUTPUT_SIZE];
|
|
63
|
+
char scratch[ALG_SPECIFIC_SIZE];
|
|
64
|
+
char *salt;
|
|
65
|
+
|
|
66
|
+
test_mode = m;
|
|
67
|
+
fprintf (stderr, ".");
|
|
68
|
+
snprintf (pass, sizeof (pass), "%d", p);
|
|
69
|
+
snprintf (pref, sizeof (pref), "%15d", s);
|
|
70
|
+
salt = crypt_gensalt ("$gy$", 0, pref, (int) strlen(pref) + 1);
|
|
71
|
+
if (!salt || salt[0] == '*')
|
|
72
|
+
{
|
|
73
|
+
fprintf(stderr, "ERROR: entropy test (gensalt) [%s]\n", pref);
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
crypt_gost_yescrypt_rn (pass, strlen (pass), salt, strlen (salt),
|
|
77
|
+
(uint8_t *) output, sizeof (output),
|
|
78
|
+
scratch, sizeof (scratch));
|
|
79
|
+
if (output[0] == '*')
|
|
80
|
+
{
|
|
81
|
+
fprintf(stderr, "ERROR: entropy test (crypt)\n");
|
|
82
|
+
return 1;
|
|
83
|
+
}
|
|
84
|
+
char *h = strrchr (output, '$') + 1;
|
|
85
|
+
if (*a && strstr (*a, h))
|
|
86
|
+
{
|
|
87
|
+
fprintf (stderr, "ERROR: duplicated hash %s\n", output);
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
size_t len = strlen(h);
|
|
91
|
+
*a = realloc (*a, *a_size + len + 1);
|
|
92
|
+
strcpy (*a + *a_size, h);
|
|
93
|
+
*a_size += len;
|
|
94
|
+
(*a)[*a_size] = '\0';
|
|
95
|
+
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
int
|
|
100
|
+
main (void)
|
|
101
|
+
{
|
|
102
|
+
int result = 0;
|
|
103
|
+
|
|
104
|
+
/* Entropy tests
|
|
105
|
+
* Replace left then right argument of outer hmac() with constant
|
|
106
|
+
* and do hashing, verifying that output hashes are still different
|
|
107
|
+
* when password or salt are changing.
|
|
108
|
+
* Thus, we prove that entropy is still passing to the output not
|
|
109
|
+
* depending on yescrypt. */
|
|
110
|
+
|
|
111
|
+
int m, pp, ss;
|
|
112
|
+
int etest = 0;
|
|
113
|
+
char **a = malloc (sizeof (char*));
|
|
114
|
+
size_t *a_size = malloc (sizeof (size_t));
|
|
115
|
+
|
|
116
|
+
*a = malloc (sizeof (char));
|
|
117
|
+
(*a)[0] = '\0';
|
|
118
|
+
*a_size = 0;
|
|
119
|
+
|
|
120
|
+
for (m = 1; m < 3; m++)
|
|
121
|
+
{
|
|
122
|
+
for (pp = 0; pp < 22; pp++)
|
|
123
|
+
etest |= test_crypt_raw (m, pp, 0, a, a_size);
|
|
124
|
+
for (ss = 0; ss < 22; ss++)
|
|
125
|
+
etest |= test_crypt_raw (m, pp, ss, a, a_size);
|
|
126
|
+
}
|
|
127
|
+
fprintf (stderr, "\n");
|
|
128
|
+
if (etest)
|
|
129
|
+
fprintf (stderr, "ERROR: entropy test failed.\n");
|
|
130
|
+
else
|
|
131
|
+
fprintf (stderr, " ok: entropy test\n");
|
|
132
|
+
result |= etest;
|
|
133
|
+
|
|
134
|
+
free (*a);
|
|
135
|
+
free (a);
|
|
136
|
+
free (a_size);
|
|
137
|
+
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#else
|
|
142
|
+
|
|
143
|
+
int
|
|
144
|
+
main (void)
|
|
145
|
+
{
|
|
146
|
+
return 77; /* UNSUPPORTED */
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#endif /* INCLUDE_gost_yescrypt */
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Björn Esser <besser82 at fedoraproject.org>
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose with or without fee is hereby granted.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#include "crypt-port.h"
|
|
18
|
+
#include <stdlib.h>
|
|
19
|
+
#include <stdio.h>
|
|
20
|
+
|
|
21
|
+
#define PASSW "alexander"
|
|
22
|
+
|
|
23
|
+
static const char *settings[] =
|
|
24
|
+
{
|
|
25
|
+
#if INCLUDE_descrypt
|
|
26
|
+
"Mp",
|
|
27
|
+
#endif
|
|
28
|
+
#if INCLUDE_bigcrypt
|
|
29
|
+
"Mp............",
|
|
30
|
+
#endif
|
|
31
|
+
#if INCLUDE_bsdicrypt
|
|
32
|
+
"_J9..MJHn",
|
|
33
|
+
#endif
|
|
34
|
+
#if INCLUDE_md5crypt
|
|
35
|
+
"$1$MJHnaAke",
|
|
36
|
+
#endif
|
|
37
|
+
#if INCLUDE_nt
|
|
38
|
+
"$3$",
|
|
39
|
+
#endif
|
|
40
|
+
#if INCLUDE_sunmd5
|
|
41
|
+
"$md5$BPm.fm03$",
|
|
42
|
+
#endif
|
|
43
|
+
#if INCLUDE_sm3crypt
|
|
44
|
+
"$sm3$MJHnaAkegEVYHsFK",
|
|
45
|
+
#endif
|
|
46
|
+
#if INCLUDE_sha1crypt
|
|
47
|
+
"$sha1$248488$ggu.H673kaZ5$",
|
|
48
|
+
#endif
|
|
49
|
+
#if INCLUDE_sha256crypt
|
|
50
|
+
"$5$MJHnaAkegEVYHsFK",
|
|
51
|
+
#endif
|
|
52
|
+
#if INCLUDE_sha512crypt
|
|
53
|
+
"$6$MJHnaAkegEVYHsFK",
|
|
54
|
+
#endif
|
|
55
|
+
#if INCLUDE_bcrypt_a
|
|
56
|
+
"$2a$05$UBVLHeMpJ/QQCv3XqJx8zO",
|
|
57
|
+
#endif
|
|
58
|
+
#if INCLUDE_bcrypt
|
|
59
|
+
"$2b$05$UBVLHeMpJ/QQCv3XqJx8zO",
|
|
60
|
+
#endif
|
|
61
|
+
#if INCLUDE_bcrypt_y
|
|
62
|
+
"$2y$05$UBVLHeMpJ/QQCv3XqJx8zO",
|
|
63
|
+
#endif
|
|
64
|
+
#if INCLUDE_bcrypt_x
|
|
65
|
+
"$2x$05$UBVLHeMpJ/QQCv3XqJx8zO",
|
|
66
|
+
#endif
|
|
67
|
+
#if INCLUDE_yescrypt
|
|
68
|
+
"$y$j9T$MJHnaAkegEVYHsFKkmfzJ1",
|
|
69
|
+
#endif
|
|
70
|
+
#if INCLUDE_scrypt
|
|
71
|
+
"$7$CU..../....MJHnaAkegEVYHsFKkmfzJ1",
|
|
72
|
+
#endif
|
|
73
|
+
#if INCLUDE_gost_yescrypt
|
|
74
|
+
"$gy$j9T$MJHnaAkegEVYHsFKkmfzJ1",
|
|
75
|
+
#endif
|
|
76
|
+
#if INCLUDE_sm3_yescrypt
|
|
77
|
+
"$sm3y$j9T$MJHnaAkegEVYHsFKkmfzJ1",
|
|
78
|
+
#endif
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
int
|
|
82
|
+
main (void)
|
|
83
|
+
{
|
|
84
|
+
char *retval = NULL;
|
|
85
|
+
int status = 0;
|
|
86
|
+
struct crypt_data cd;
|
|
87
|
+
struct crypt_data *p = &cd;
|
|
88
|
+
int cd_size = (int) sizeof (cd);
|
|
89
|
+
|
|
90
|
+
for (size_t i = 0; i < ARRAY_SIZE (settings); i++)
|
|
91
|
+
{
|
|
92
|
+
retval = crypt (PASSW, settings[i]);
|
|
93
|
+
retval = crypt (PASSW, retval);
|
|
94
|
+
|
|
95
|
+
if (!retval || *retval == '*')
|
|
96
|
+
{
|
|
97
|
+
printf ("Subsequent call to crypt(3) with output as setting "
|
|
98
|
+
"failed for prefix \"%s\".\n",
|
|
99
|
+
settings[i]);
|
|
100
|
+
status = 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// coverity[var_deref_model]
|
|
104
|
+
retval = crypt (retval, settings[i]);
|
|
105
|
+
|
|
106
|
+
if (!retval || *retval == '*')
|
|
107
|
+
{
|
|
108
|
+
printf ("Subsequent call to crypt(3) with output as key "
|
|
109
|
+
"failed for prefix \"%s\".\n",
|
|
110
|
+
settings[i]);
|
|
111
|
+
status = 1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
retval = crypt_r (PASSW, settings[i], p);
|
|
115
|
+
retval = crypt_r (PASSW, retval, p);
|
|
116
|
+
|
|
117
|
+
if (!retval || *retval == '*')
|
|
118
|
+
{
|
|
119
|
+
printf ("Subsequent call to crypt_r(3) with output as setting "
|
|
120
|
+
"failed for prefix \"%s\".\n",
|
|
121
|
+
settings[i]);
|
|
122
|
+
status = 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
retval = crypt_r (retval, settings[i], p);
|
|
126
|
+
|
|
127
|
+
if (!retval || *retval == '*')
|
|
128
|
+
{
|
|
129
|
+
printf ("Subsequent call to crypt_r(3) with output as key "
|
|
130
|
+
"failed for prefix \"%s\".\n",
|
|
131
|
+
settings[i]);
|
|
132
|
+
status = 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
retval = crypt_rn (PASSW, settings[i], p, cd_size);
|
|
136
|
+
retval = crypt_rn (PASSW, retval, p, cd_size);
|
|
137
|
+
|
|
138
|
+
if (!retval || *retval == '*')
|
|
139
|
+
{
|
|
140
|
+
printf ("Subsequent call to crypt_rn(3) with output as setting "
|
|
141
|
+
"failed for prefix \"%s\".\n",
|
|
142
|
+
settings[i]);
|
|
143
|
+
status = 1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
retval = crypt_rn (retval, settings[i], p, cd_size);
|
|
147
|
+
|
|
148
|
+
if (!retval || *retval == '*')
|
|
149
|
+
{
|
|
150
|
+
printf ("Subsequent call to crypt_rn(3) with output as key "
|
|
151
|
+
"failed for prefix \"%s\".\n",
|
|
152
|
+
settings[i]);
|
|
153
|
+
status = 1;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
retval = crypt_ra (PASSW, settings[i], (void **) &p, &cd_size);
|
|
157
|
+
retval = crypt_ra (PASSW, retval, (void **) &p, &cd_size);
|
|
158
|
+
|
|
159
|
+
if (!retval || *retval == '*')
|
|
160
|
+
{
|
|
161
|
+
printf ("Subsequent call to crypt_ra(3) with output as setting "
|
|
162
|
+
"failed for prefix \"%s\".\n",
|
|
163
|
+
settings[i]);
|
|
164
|
+
status = 1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
retval = crypt_ra (retval, settings[i], (void **) &p, &cd_size);
|
|
168
|
+
|
|
169
|
+
if (!retval || *retval == '*')
|
|
170
|
+
{
|
|
171
|
+
printf ("Subsequent call to crypt_ra(3) with output as key "
|
|
172
|
+
"failed for prefix \"%s\".\n",
|
|
173
|
+
settings[i]);
|
|
174
|
+
status = 1;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
explicit_bzero (&cd, sizeof cd);
|
|
179
|
+
return status;
|
|
180
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/* Copyright (C) 2018 vt@altlinux.org
|
|
2
|
+
* Copyright (C) 2018, 2024 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_sm3_yescrypt
|
|
23
|
+
|
|
24
|
+
#include "alg-sm3-hmac.h"
|
|
25
|
+
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
|
|
28
|
+
/* redefine outer hmac to this function to test entropy bypass */
|
|
29
|
+
static void
|
|
30
|
+
test_outer_hmac (const uint8_t *k, size_t n, const uint8_t *t, size_t len,
|
|
31
|
+
uint8_t *out, sm3_hmac_ctx_t *sm3buf);
|
|
32
|
+
#define outer_sm3_hmac test_outer_hmac
|
|
33
|
+
#include "../lib/crypt-sm3-yescrypt.c"
|
|
34
|
+
|
|
35
|
+
static int test_mode = 0;
|
|
36
|
+
|
|
37
|
+
static void
|
|
38
|
+
test_outer_hmac (const uint8_t *k, size_t n, const uint8_t *t, size_t len,
|
|
39
|
+
uint8_t *out, sm3_hmac_ctx_t *sm3buf)
|
|
40
|
+
{
|
|
41
|
+
const uint8_t zero[32] = {0};
|
|
42
|
+
|
|
43
|
+
/* Zero one of arguments to outer hmac. */
|
|
44
|
+
if (test_mode & 1)
|
|
45
|
+
{
|
|
46
|
+
k = zero;
|
|
47
|
+
n = sizeof (zero);
|
|
48
|
+
}
|
|
49
|
+
if (test_mode & 2)
|
|
50
|
+
{
|
|
51
|
+
t = zero;
|
|
52
|
+
len = sizeof (zero);
|
|
53
|
+
}
|
|
54
|
+
sm3_hmac (k, n, t, len, out, sm3buf);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static int
|
|
58
|
+
test_crypt_raw (int m, int p, int s, char **a, size_t *a_size)
|
|
59
|
+
{
|
|
60
|
+
char output[CRYPT_OUTPUT_SIZE];
|
|
61
|
+
char pass[CRYPT_MAX_PASSPHRASE_SIZE];
|
|
62
|
+
char pref[CRYPT_GENSALT_OUTPUT_SIZE];
|
|
63
|
+
char scratch[ALG_SPECIFIC_SIZE];
|
|
64
|
+
char *salt;
|
|
65
|
+
|
|
66
|
+
test_mode = m;
|
|
67
|
+
fprintf (stderr, ".");
|
|
68
|
+
snprintf (pass, sizeof (pass), "%d", p);
|
|
69
|
+
snprintf (pref, sizeof (pref), "%15d", s);
|
|
70
|
+
salt = crypt_gensalt ("$sm3y$", 0, pref, (int) strlen(pref) + 1);
|
|
71
|
+
if (!salt || salt[0] == '*')
|
|
72
|
+
{
|
|
73
|
+
fprintf(stderr, "ERROR: entropy test (gensalt) [%s]\n", pref);
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
crypt_sm3_yescrypt_rn (pass, strlen (pass), salt, strlen (salt),
|
|
77
|
+
(uint8_t *) output, sizeof (output),
|
|
78
|
+
scratch, sizeof (scratch));
|
|
79
|
+
if (output[0] == '*')
|
|
80
|
+
{
|
|
81
|
+
fprintf(stderr, "ERROR: entropy test (crypt)\n");
|
|
82
|
+
return 1;
|
|
83
|
+
}
|
|
84
|
+
char *h = strrchr (output, '$') + 1;
|
|
85
|
+
if (*a && strstr (*a, h))
|
|
86
|
+
{
|
|
87
|
+
fprintf (stderr, "ERROR: duplicated hash %s\n", output);
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
size_t len = strlen(h);
|
|
91
|
+
*a = realloc (*a, *a_size + len + 1);
|
|
92
|
+
strcpy (*a + *a_size, h);
|
|
93
|
+
*a_size += len;
|
|
94
|
+
(*a)[*a_size] = '\0';
|
|
95
|
+
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
int
|
|
100
|
+
main (void)
|
|
101
|
+
{
|
|
102
|
+
int result = 0;
|
|
103
|
+
|
|
104
|
+
/* Entropy tests
|
|
105
|
+
* Replace left then right argument of outer hmac() with constant
|
|
106
|
+
* and do hashing, verifying that output hashes are still different
|
|
107
|
+
* when password or salt are changing.
|
|
108
|
+
* Thus, we prove that entropy is still passing to the output not
|
|
109
|
+
* depending on yescrypt. */
|
|
110
|
+
|
|
111
|
+
int m, pp, ss;
|
|
112
|
+
int etest = 0;
|
|
113
|
+
char **a = malloc (sizeof (char*));
|
|
114
|
+
size_t *a_size = malloc (sizeof (size_t));
|
|
115
|
+
|
|
116
|
+
*a = malloc (sizeof (char));
|
|
117
|
+
(*a)[0] = '\0';
|
|
118
|
+
*a_size = 0;
|
|
119
|
+
|
|
120
|
+
for (m = 1; m < 3; m++)
|
|
121
|
+
{
|
|
122
|
+
for (pp = 0; pp < 22; pp++)
|
|
123
|
+
etest |= test_crypt_raw (m, pp, 0, a, a_size);
|
|
124
|
+
for (ss = 0; ss < 22; ss++)
|
|
125
|
+
etest |= test_crypt_raw (m, pp, ss, a, a_size);
|
|
126
|
+
}
|
|
127
|
+
fprintf (stderr, "\n");
|
|
128
|
+
if (etest)
|
|
129
|
+
fprintf (stderr, "ERROR: entropy test failed.\n");
|
|
130
|
+
else
|
|
131
|
+
fprintf (stderr, " ok: entropy test\n");
|
|
132
|
+
result |= etest;
|
|
133
|
+
|
|
134
|
+
free (*a);
|
|
135
|
+
free (a);
|
|
136
|
+
free (a_size);
|
|
137
|
+
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#else
|
|
142
|
+
|
|
143
|
+
int
|
|
144
|
+
main (void)
|
|
145
|
+
{
|
|
146
|
+
return 77; /* UNSUPPORTED */
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#endif /* INCLUDE_sm3_yescrypt */
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Björn Esser <besser82 at fedoraproject.org>
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose with or without fee is hereby granted.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#include "crypt-port.h"
|
|
18
|
+
#include <errno.h>
|
|
19
|
+
#include <stdlib.h>
|
|
20
|
+
#include <stdio.h>
|
|
21
|
+
|
|
22
|
+
static const char *settings[] =
|
|
23
|
+
{
|
|
24
|
+
#if INCLUDE_descrypt
|
|
25
|
+
"Mp",
|
|
26
|
+
#endif
|
|
27
|
+
#if INCLUDE_bigcrypt
|
|
28
|
+
"Mp............",
|
|
29
|
+
#endif
|
|
30
|
+
#if INCLUDE_bsdicrypt
|
|
31
|
+
"_J9..MJHn",
|
|
32
|
+
#endif
|
|
33
|
+
#if INCLUDE_md5crypt
|
|
34
|
+
"$1$MJHnaAke",
|
|
35
|
+
#endif
|
|
36
|
+
#if INCLUDE_nt
|
|
37
|
+
"$3$",
|
|
38
|
+
#endif
|
|
39
|
+
#if INCLUDE_sunmd5
|
|
40
|
+
"$md5$BPm.fm03$",
|
|
41
|
+
#endif
|
|
42
|
+
#if INCLUDE_sm3crypt
|
|
43
|
+
"$sm3$MJHnaAkegEVYHsFK",
|
|
44
|
+
#endif
|
|
45
|
+
#if INCLUDE_sha1crypt
|
|
46
|
+
"$sha1$248488$ggu.H673kaZ5$",
|
|
47
|
+
#endif
|
|
48
|
+
#if INCLUDE_sha256crypt
|
|
49
|
+
"$5$MJHnaAkegEVYHsFK",
|
|
50
|
+
#endif
|
|
51
|
+
#if INCLUDE_sha512crypt
|
|
52
|
+
"$6$MJHnaAkegEVYHsFK",
|
|
53
|
+
#endif
|
|
54
|
+
#if INCLUDE_bcrypt_a
|
|
55
|
+
"$2a$05$UBVLHeMpJ/QQCv3XqJx8zO",
|
|
56
|
+
#endif
|
|
57
|
+
#if INCLUDE_bcrypt
|
|
58
|
+
"$2b$05$UBVLHeMpJ/QQCv3XqJx8zO",
|
|
59
|
+
#endif
|
|
60
|
+
#if INCLUDE_bcrypt_y
|
|
61
|
+
"$2y$05$UBVLHeMpJ/QQCv3XqJx8zO",
|
|
62
|
+
#endif
|
|
63
|
+
#if INCLUDE_bcrypt_x
|
|
64
|
+
"$2x$05$UBVLHeMpJ/QQCv3XqJx8zO",
|
|
65
|
+
#endif
|
|
66
|
+
#if INCLUDE_yescrypt
|
|
67
|
+
"$y$j9T$MJHnaAkegEVYHsFKkmfzJ1",
|
|
68
|
+
#endif
|
|
69
|
+
#if INCLUDE_scrypt
|
|
70
|
+
"$7$CU..../....MJHnaAkegEVYHsFKkmfzJ1",
|
|
71
|
+
#endif
|
|
72
|
+
#if INCLUDE_gost_yescrypt
|
|
73
|
+
"$gy$j9T$MJHnaAkegEVYHsFKkmfzJ1",
|
|
74
|
+
#endif
|
|
75
|
+
#if INCLUDE_sm3_yescrypt
|
|
76
|
+
"$sm3y$j9T$MJHnaAkegEVYHsFKkmfzJ1",
|
|
77
|
+
#endif
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
int
|
|
81
|
+
main (void)
|
|
82
|
+
{
|
|
83
|
+
char *retval = NULL;
|
|
84
|
+
char phrase[CRYPT_MAX_PASSPHRASE_SIZE * 2];
|
|
85
|
+
int status = 0;
|
|
86
|
+
struct crypt_data crypt_ctx;
|
|
87
|
+
|
|
88
|
+
memset (phrase, 'a', sizeof phrase);
|
|
89
|
+
phrase[sizeof phrase - 1] = '\0';
|
|
90
|
+
|
|
91
|
+
for (size_t i = 0; i < ARRAY_SIZE (settings); i++)
|
|
92
|
+
{
|
|
93
|
+
struct crypt_data *cd = &crypt_ctx;
|
|
94
|
+
void **data = (void **) &cd;
|
|
95
|
+
int size = sizeof crypt_ctx;
|
|
96
|
+
|
|
97
|
+
memset (cd, 0, sizeof crypt_ctx);
|
|
98
|
+
errno = 0;
|
|
99
|
+
retval = crypt (phrase, settings[i]);
|
|
100
|
+
|
|
101
|
+
if ((retval && retval[0] != '*') || errno != ERANGE)
|
|
102
|
+
{
|
|
103
|
+
printf ("crypt(3) returned unexpectedly.\n"
|
|
104
|
+
"setting: %s\ngot: %s\nERRNO: %d, %s\n",
|
|
105
|
+
settings[i], retval, errno, strerror (errno));
|
|
106
|
+
status = 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
errno = 0;
|
|
110
|
+
retval = crypt_r (phrase, settings[i], cd);
|
|
111
|
+
|
|
112
|
+
if ((retval && retval[0] != '*') || errno != ERANGE)
|
|
113
|
+
{
|
|
114
|
+
printf ("crypt_r(3) returned unexpectedly.\n"
|
|
115
|
+
"setting: %s\ngot: %s\nERRNO: %d, %s\n",
|
|
116
|
+
settings[i], retval, errno, strerror (errno));
|
|
117
|
+
status = 1;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
errno = 0;
|
|
121
|
+
retval = crypt_rn (phrase, settings[i], cd, size);
|
|
122
|
+
|
|
123
|
+
if (retval || errno != ERANGE)
|
|
124
|
+
{
|
|
125
|
+
printf ("crypt_rn(3) returned unexpectedly.\n"
|
|
126
|
+
"setting: %s\ngot: %s\nERRNO: %d, %s\n",
|
|
127
|
+
settings[i], retval, errno, strerror (errno));
|
|
128
|
+
status = 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
errno = 0;
|
|
132
|
+
retval = crypt_ra (phrase, settings[i], data, &size);
|
|
133
|
+
|
|
134
|
+
if (retval || errno != ERANGE)
|
|
135
|
+
{
|
|
136
|
+
printf ("crypt_ra(3) (pre-alloc) returned unexpectedly.\n"
|
|
137
|
+
"setting: %s\ngot: %s\nERRNO: %d, %s\n",
|
|
138
|
+
settings[i], retval, errno, strerror (errno));
|
|
139
|
+
status = 1;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
*data = NULL;
|
|
143
|
+
size = 0;
|
|
144
|
+
errno = 0;
|
|
145
|
+
retval = crypt_ra (phrase, settings[i], data, &size);
|
|
146
|
+
|
|
147
|
+
if (retval || errno != ERANGE)
|
|
148
|
+
{
|
|
149
|
+
printf ("crypt_ra(3) (new alloc) returned unexpectedly.\n"
|
|
150
|
+
"setting: %s\ngot: %s\nERRNO: %d, %s\n",
|
|
151
|
+
settings[i], retval, errno, strerror (errno));
|
|
152
|
+
status = 1;
|
|
153
|
+
}
|
|
154
|
+
free (*data);
|
|
155
|
+
}
|
|
156
|
+
return status;
|
|
157
|
+
}
|