* sysdeps/powerpc/fpu/fenv_libc.h: Add libm_hidden_proto for
[glibc.git] / crypt / sha512c-test.c
blobc829242e2a80f0e12cf822059bcfef6ae9199930
1 #include <crypt.h>
2 #include <stdio.h>
3 #include <string.h>
5 static const struct
7 const char *salt;
8 const char *input;
9 const char *expected;
10 } tests[] =
12 { "$6$saltstring", "Hello world!",
13 "$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJu"
14 "esI68u4OTLiBFdcbYEdFCoEOfaS35inz1" },
15 { "$6$rounds=10000$saltstringsaltstring", "Hello world!",
16 "$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sb"
17 "HbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v." },
18 { "$6$rounds=5000$toolongsaltstring", "This is just a test",
19 "$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQ"
20 "zQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0" },
21 { "$6$rounds=1400$anotherlongsaltstring",
22 "a very much longer text to encrypt. This one even stretches over more"
23 "than one line.",
24 "$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wP"
25 "vMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1" },
26 { "$6$rounds=77777$short",
27 "we have a short salt string but not a short password",
28 "$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0g"
29 "ge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0" },
30 { "$6$rounds=123456$asaltof16chars..", "a short string",
31 "$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwc"
32 "elCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1" },
33 { "$6$rounds=10$roundstoolow", "the minimum number is still observed",
34 "$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1x"
35 "hLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX." },
37 #define ntests (sizeof (tests) / sizeof (tests[0]))
40 static int
41 do_test (void)
43 int result = 0;
44 int i;
46 for (i = 0; i < ntests; ++i)
48 char *cp = crypt (tests[i].input, tests[i].salt);
50 if (strcmp (cp, tests[i].expected) != 0)
52 printf ("test %d: expected \"%s\", got \"%s\"\n",
53 i, tests[i].expected, cp);
54 result = 1;
58 return result;
61 #define TIMEOUT 6
62 #define TEST_FUNCTION do_test ()
63 #include "../test-skeleton.c"