1 /* Copyright (C) 2018 Björn Esser <besser82@fedoraproject.org>
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted.
5 *
6 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16 * SUCH DAMAGE.
17 */
18
19 #include "crypt-port.h"
20
21 #include <stdio.h>
22
23 #if INCLUDE_nt
24
25 int
26 main (void)
27 {
28 const char *prefix = "$3$";
29 const char *crypt_exp = "$3$$be8cb5d74036075bbe5344cb8ad248b0";
30 char output[CRYPT_GENSALT_OUTPUT_SIZE];
31 struct crypt_data cd;
32 int retval = 0;
33
34 crypt_gensalt_rn (prefix, 0, NULL, 0,
35 output, CRYPT_GENSALT_OUTPUT_SIZE);
36
37 if (strcmp (prefix, output))
38 retval = 1;
39
40 fprintf (stderr, "%s: gensalt: expected \"%s\", got \"%s\"\n",
41 retval == 0 ? "PASS" : "FAIL", prefix, output);
42
43 if (retval != 0)
44 return retval;
45
46 crypt_r ("top secret", output, &cd);
47
48 if (strcmp (crypt_exp, cd.output))
49 retval = 1;
50
51 fprintf (stderr, "%s: crypt: expected \"%s\", got \"%s\"\n",
52 retval == 0 ? "PASS" : "FAIL", crypt_exp, cd.output);
53
54 return retval;
55 }
56
57 #else
58
59 int
60 main (void)
61 {
62 return 77; /* UNSUPPORTED */
63 }
64
65 #endif /* INCLUDE_nt */