From: Tim Kientzle Date: Sun, 16 Oct 2011 22:27:38 +0000 (-0400) Subject: First part of libmd support for FreeBSD. X-Git-Tag: v3.0.0a~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b71f29f34606339db08bf65acbf78d1634b4d623;p=thirdparty%2Flibarchive.git First part of libmd support for FreeBSD. SVN-Revision: 3736 --- diff --git a/libarchive/archive_crypto.c b/libarchive/archive_crypto.c index db5b4bd2e..c20bf4d1b 100644 --- a/libarchive/archive_crypto.c +++ b/libarchive/archive_crypto.c @@ -124,6 +124,30 @@ __archive_libc_md5final(archive_md5_ctx *ctx, void *md) return (ARCHIVE_OK); } +#elif defined(ARCHIVE_CRYPTO_MD5_LIBMD) + +static int +__archive_libc_md5init(archive_md5_ctx *ctx) +{ + MD5Init(ctx); + return (ARCHIVE_OK); +} + +static int +__archive_libc_md5update(archive_md5_ctx *ctx, const void *indata, + size_t insize) +{ + MD5Update(ctx, indata, insize); + return (ARCHIVE_OK); +} + +static int +__archive_libc_md5final(archive_md5_ctx *ctx, void *md) +{ + MD5Final(md, ctx); + return (ARCHIVE_OK); +} + #elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) static int @@ -378,6 +402,30 @@ __archive_libc_sha1final(archive_sha1_ctx *ctx, void *md) return (ARCHIVE_OK); } +#elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD) + +static int +__archive_libc_sha1init(archive_sha1_ctx *ctx) +{ + SHA1_Init(ctx); + return (ARCHIVE_OK); +} + +static int +__archive_libc_sha1update(archive_sha1_ctx *ctx, const void *indata, + size_t insize) +{ + SHA1_Update(ctx, indata, insize); + return (ARCHIVE_OK); +} + +static int +__archive_libc_sha1final(archive_sha1_ctx *ctx, void *md) +{ + SHA1_Final(md, ctx); + return (ARCHIVE_OK); +} + #elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) static int @@ -578,6 +626,30 @@ __archive_libc3_sha256final(archive_sha256_ctx *ctx, void *md) return (ARCHIVE_OK); } +#elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD) + +static int +__archive_libc_sha256init(archive_sha256_ctx *ctx) +{ + SHA256_Init(ctx); + return (ARCHIVE_OK); +} + +static int +__archive_libc_sha256update(archive_sha256_ctx *ctx, const void *indata, + size_t insize) +{ + SHA256_Update(ctx, indata, insize); + return (ARCHIVE_OK); +} + +static int +__archive_libc_sha256final(archive_sha256_ctx *ctx, void *md) +{ + SHA256_Final(md, ctx); + return (ARCHIVE_OK); +} + #elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) static int @@ -968,6 +1040,30 @@ __archive_libc3_sha512final(archive_sha512_ctx *ctx, void *md) return (ARCHIVE_OK); } +#elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD) + +static int +__archive_libc_sha512init(archive_sha512_ctx *ctx) +{ + SHA512_Init(ctx); + return (ARCHIVE_OK); +} + +static int +__archive_libc_sha512update(archive_sha512_ctx *ctx, const void *indata, + size_t insize) +{ + SHA512_Update(ctx, indata, insize); + return (ARCHIVE_OK); +} + +static int +__archive_libc_sha512final(archive_sha512_ctx *ctx, void *md) +{ + SHA512_Final(md, ctx); + return (ARCHIVE_OK); +} + #elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM) static int diff --git a/libarchive/archive_crypto_private.h b/libarchive/archive_crypto_private.h index 4a7f2d40e..902561079 100644 --- a/libarchive/archive_crypto_private.h +++ b/libarchive/archive_crypto_private.h @@ -42,9 +42,9 @@ * - MD5, SHA1 and SHA2 in libc: without _ after algorithm name * - OpenBSD 4.4 and earlier have SHA2 in libc with _ after algorithm name * - * DragonFly and FreeBSD (XXX not used yet): - * - MD5 and SHA1 in libmd: without _ after algorithm name - * - SHA256: with _ after algorithm name + * DragonFly and FreeBSD: + * - MD5 libmd: without _ after algorithm name + * - SHA1, SHA256 and SHA512 in libmd: with _ after algorithm name * * Mac OS X (10.4 and later): * - MD5, SHA1 and SHA2 in libSystem: with CC_ prefix and _ after algorithm name @@ -78,6 +78,20 @@ #include #endif +/* libmd crypto headers */ +#if defined(ARCHIVE_CRYPTO_MD5_LIBMD) +#include +#endif +#if defined(ARCHIVE_CRYPTO_SHA1_LIBMD) +#include +#endif +#if defined(ARCHIVE_CRYPTO_SHA256_LIBMD) +#include +#endif +#if defined(ARCHIVE_CRYPTO_SHA512_LIBMD) +#include +#endif + /* libSystem crypto headers */ #if defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) ||\ defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) ||\ @@ -128,6 +142,8 @@ typedef struct { /* typedefs */ #if defined(ARCHIVE_CRYPTO_MD5_LIBC) typedef MD5_CTX archive_md5_ctx; +#elif defined(ARCHIVE_CRYPTO_MD5_LIBMD) +typedef MD5_CTX archive_md5_ctx; #elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) typedef CC_MD5_CTX archive_md5_ctx; #elif defined(ARCHIVE_CRYPTO_MD5_NETTLE) @@ -152,6 +168,8 @@ typedef unsigned char archive_rmd160_ctx; #if defined(ARCHIVE_CRYPTO_SHA1_LIBC) typedef SHA1_CTX archive_sha1_ctx; +#elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD) +typedef SHA1_CTX archive_sha1_ctx; #elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) typedef CC_SHA1_CTX archive_sha1_ctx; #elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE) @@ -170,6 +188,8 @@ typedef SHA256_CTX archive_sha256_ctx; typedef SHA256_CTX archive_sha256_ctx; #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC3) typedef SHA2_CTX archive_sha256_ctx; +#elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD) +typedef SHA256_CTX archive_sha256_ctx; #elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) typedef CC_SHA256_CTX archive_sha256_ctx; #elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE) @@ -206,6 +226,8 @@ typedef SHA512_CTX archive_sha512_ctx; typedef SHA512_CTX archive_sha512_ctx; #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC3) typedef SHA2_CTX archive_sha512_ctx; +#elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD) +typedef SHA512_CTX archive_sha512_ctx; #elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM) typedef CC_SHA512_CTX archive_sha512_ctx; #elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE) @@ -220,6 +242,7 @@ typedef unsigned char archive_sha512_ctx; /* defines */ #if defined(ARCHIVE_CRYPTO_MD5_LIBC) ||\ + defined(ARCHIVE_CRYPTO_MD5_LIBMD) || \ defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) ||\ defined(ARCHIVE_CRYPTO_MD5_NETTLE) ||\ defined(ARCHIVE_CRYPTO_MD5_OPENSSL) ||\ @@ -246,6 +269,7 @@ typedef unsigned char archive_sha512_ctx; __archive_crypto.rmd160update(ctx, buf, n) #if defined(ARCHIVE_CRYPTO_SHA1_LIBC) ||\ + defined(ARCHIVE_CRYPTO_SHA1_LIBMD) || \ defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) ||\ defined(ARCHIVE_CRYPTO_SHA1_NETTLE) ||\ defined(ARCHIVE_CRYPTO_SHA1_OPENSSL) ||\ @@ -262,6 +286,7 @@ typedef unsigned char archive_sha512_ctx; #if defined(ARCHIVE_CRYPTO_SHA256_LIBC) ||\ defined(ARCHIVE_CRYPTO_SHA256_LIBC2) ||\ defined(ARCHIVE_CRYPTO_SHA256_LIBC3) ||\ + defined(ARCHIVE_CRYPTO_SHA256_LIBMD) ||\ defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) ||\ defined(ARCHIVE_CRYPTO_SHA256_NETTLE) ||\ defined(ARCHIVE_CRYPTO_SHA256_OPENSSL) ||\ @@ -294,6 +319,7 @@ typedef unsigned char archive_sha512_ctx; #if defined(ARCHIVE_CRYPTO_SHA512_LIBC) ||\ defined(ARCHIVE_CRYPTO_SHA512_LIBC2) ||\ defined(ARCHIVE_CRYPTO_SHA512_LIBC3) ||\ + defined(ARCHIVE_CRYPTO_SHA512_LIBMD) ||\ defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM) ||\ defined(ARCHIVE_CRYPTO_SHA512_NETTLE) ||\ defined(ARCHIVE_CRYPTO_SHA512_OPENSSL) ||\