diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2014-11-01 22:00:46 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2014-11-01 22:00:46 +0000 |
commit | 4c8d4de868c4f3c1a1f45037cc7a028ea00be0b4 (patch) | |
tree | f394b56ab91aa1235d41dd43d7eac06a6ce1564f /contrib | |
parent | 6a4bfd1397f944e58cd05f381cdcbe6f29849240 (diff) | |
download | src-4c8d4de868c4f3c1a1f45037cc7a028ea00be0b4.tar.gz src-4c8d4de868c4f3c1a1f45037cc7a028ea00be0b4.zip |
Port h_hash and t_sha2 to FreeBSD
t_sha2 contains dirty copy-paste hacks that need to be fixed with the openssh
OpenBSD compat layer
Submitted by: pho
Notes
Notes:
svn path=/head/; revision=273952
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/hash/h_hash.c | 20 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/hash/t_sha2.c | 14 |
2 files changed, 34 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/hash/h_hash.c b/contrib/netbsd-tests/lib/libc/hash/h_hash.c index 33b9f9a62497..6e20a4889a25 100644 --- a/contrib/netbsd-tests/lib/libc/hash/h_hash.c +++ b/contrib/netbsd-tests/lib/libc/hash/h_hash.c @@ -35,8 +35,13 @@ #include <unistd.h> #include <string.h> #include <md5.h> +#ifdef __NetBSD__ #include <sha1.h> +#endif +#ifdef __FreeBSD__ +#include <sha.h> +#endif int mflag, rflag, sflag, tflag; @@ -102,17 +107,32 @@ regress(void) MD5Final(out, &ctx); outlen = 16; } else { +#ifdef __FreeBSD__ + SHA_CTX ctx; + + SHA1_Init(&ctx); + SHA1_Update(&ctx, buf, len); +#else SHA1_CTX ctx; SHA1Init(&ctx); SHA1Update(&ctx, buf, len); +#endif while (!last && fgets((char *)buf, sizeof(buf), stdin) != NULL) { len = strlen((char *)buf); CHOMP(buf, len, last); +#ifdef __FreeBSD__ + SHA1_Update(&ctx, buf, len); +#else SHA1Update(&ctx, buf, len); +#endif } +#ifdef __FreeBSD__ + SHA1_Final(out, &ctx); +#else SHA1Final(out, &ctx); +#endif outlen = 20; } hexdump(out, outlen); diff --git a/contrib/netbsd-tests/lib/libc/hash/t_sha2.c b/contrib/netbsd-tests/lib/libc/hash/t_sha2.c index a45e82ac57d3..ce2c80d31a80 100644 --- a/contrib/netbsd-tests/lib/libc/hash/t_sha2.c +++ b/contrib/netbsd-tests/lib/libc/hash/t_sha2.c @@ -36,9 +36,23 @@ __RCSID("$NetBSD: t_sha2.c,v 1.3 2012/09/26 22:23:30 joerg Exp $"); #include <atf-c.h> #include <sys/types.h> +#ifdef __NetBSD__ #include <sha2.h> +#endif #include <string.h> +#ifdef __FreeBSD__ +#include <openssl/sha.h> +typedef SHA512_CTX SHA384_CTX; +/* From /usr/src/crypto/openssh/openbsd-compat/sha2.h */ +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA384_DIGEST_LENGTH 48 +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) +#endif + ATF_TC(t_sha256); ATF_TC(t_sha384); ATF_TC(t_sha512); |