From patchwork Fri Oct 28 20:05:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 80022 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1352816qge; Fri, 28 Oct 2016 13:05:30 -0700 (PDT) X-Received: by 10.99.54.74 with SMTP id d71mr23370975pga.34.1477685130168; Fri, 28 Oct 2016 13:05:30 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z70si634648pff.228.2016.10.28.13.05.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Oct 2016 13:05:30 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-74203-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-74203-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-74203-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=Y5Hx rItFP+xJIW+AdI7pkmNQcSaR/npZWcz7bqp0KpmhAoQDJj7mSdWEeCj4sUN04lsU /PtmN0p3H9SCllRL3mobyIBV/DyEv72x/8BAS1fTJv9gNoCimYoWZWcVVT2OwC6w I6pinI6VrZ94GRGBwg66KF4SOxwafAs8aPWUUJs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=DuTgSyrC24 39E6o3qdErwXlqNxY=; b=Cr9eBq9L99cKbe626Gb9vVqMgW4CihSJAfmS0M28fd PbODGLBsme49r4F4DxRwCFlWJX9SPmcq32582mpSwuxbI0qQ1B+HX9RZ0x2fijsU fJOSB75Cv6M5evGbLuMXTgnrbV/wsYL4TmxmtmV+w193XtSR7F5xBmEmYutIP6m4 Q= Received: (qmail 13998 invoked by alias); 28 Oct 2016 20:05:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 13983 invoked by uid 89); 28 Oct 2016 20:05:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Subject: Re: [PATCH] crypt: Use internal names for the SHA-2 block functions To: Adhemerval Zanella , libc-alpha@sourceware.org References: From: Florian Weimer Message-ID: Date: Fri, 28 Oct 2016 22:05:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: On 10/28/2016 03:31 PM, Adhemerval Zanella wrote: >> -extern void sha256_process_block (const void *buffer, size_t len, >> - struct sha256_ctx *ctx); >> -sparc_libc_ifunc(sha256_process_block, cpu_supports_sha256(hwcap) ? __sha256_process_block_crop : sha256_process_block_generic); >> +extern void __sha256_process_block (const void *buffer, size_t len, >> + struct sha256_ctx *ctx); >> +sparc_libc_ifunc (__sha256_process_block, >> + cpu_supports_sha256(hwcap) ? __sha256_process_block_crop >> + : sha256_process_block_generic); > > It should __sha256_process_block_generic here. Right, thanks. I have tested as far as possible on Debian's sparc64 porterbox. (I'm not sure if there are tests for the extended salts.) I'm attaching what I've committed. Florian crypt: Use internal names for the SHA-2 block functions These functions are externally visible with a static libcrypt library. 2016-10-28 Florian Weimer * crypt/sha256.c, crypt/sha256-block.c, sysdeps/sparc/sparc64/multiarch/sha256-block.c: Rename sha256_process_block to __sha256_process_block. * crypt/sha512.c, crypt/sha512-block.c, sysdeps/sparc/sparc64/multiarch/sha512-block.c: Rename sha512_process_block to __sha512_process_block. diff --git a/crypt/sha256-block.c b/crypt/sha256-block.c index 8a77096..a44fe01 100644 --- a/crypt/sha256-block.c +++ b/crypt/sha256-block.c @@ -3,7 +3,7 @@ /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. */ void -sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) +__sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) { const uint32_t *words = buffer; size_t nwords = len / sizeof (uint32_t); diff --git a/crypt/sha256.c b/crypt/sha256.c index e858f4b..b5497d9 100644 --- a/crypt/sha256.c +++ b/crypt/sha256.c @@ -81,8 +81,7 @@ static const uint32_t K[64] = 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; -void -sha256_process_block (const void *, size_t, struct sha256_ctx *); +void __sha256_process_block (const void *, size_t, struct sha256_ctx *); /* Initialize structure containing state of computation. (FIPS 180-2:5.3.2) */ @@ -131,7 +130,7 @@ __sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf) #endif /* Process last bytes. */ - sha256_process_block (ctx->buffer, bytes + pad + 8, ctx); + __sha256_process_block (ctx->buffer, bytes + pad + 8, ctx); /* Put result from CTX in first 32 bytes following RESBUF. */ for (unsigned int i = 0; i < 8; ++i) @@ -156,7 +155,7 @@ __sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) if (ctx->buflen > 64) { - sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx); + __sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx); ctx->buflen &= 63; /* The regions in the following copy operation cannot overlap. */ @@ -182,14 +181,14 @@ __sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) if (UNALIGNED_P (buffer)) while (len > 64) { - sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); + __sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); buffer = (const char *) buffer + 64; len -= 64; } else #endif { - sha256_process_block (buffer, len & ~63, ctx); + __sha256_process_block (buffer, len & ~63, ctx); buffer = (const char *) buffer + (len & ~63); len &= 63; } @@ -204,7 +203,7 @@ __sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) left_over += len; if (left_over >= 64) { - sha256_process_block (ctx->buffer, 64, ctx); + __sha256_process_block (ctx->buffer, 64, ctx); left_over -= 64; memcpy (ctx->buffer, &ctx->buffer[64], left_over); } diff --git a/crypt/sha512-block.c b/crypt/sha512-block.c index c542db1..577839f 100644 --- a/crypt/sha512-block.c +++ b/crypt/sha512-block.c @@ -3,7 +3,7 @@ /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 128 == 0. */ void -sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx) +__sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx) { const uint64_t *words = buffer; size_t nwords = len / sizeof (uint64_t); diff --git a/crypt/sha512.c b/crypt/sha512.c index 47f3f7c..dd2af3c 100644 --- a/crypt/sha512.c +++ b/crypt/sha512.c @@ -101,8 +101,8 @@ static const uint64_t K[80] = UINT64_C (0x5fcb6fab3ad6faec), UINT64_C (0x6c44198c4a475817) }; -void -sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx); +void __sha512_process_block (const void *buffer, size_t len, + struct sha512_ctx *ctx); /* Initialize structure containing state of computation. (FIPS 180-2:5.3.3) */ @@ -153,7 +153,7 @@ __sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf) (ctx->total[TOTAL128_low] >> 61)); /* Process last bytes. */ - sha512_process_block (ctx->buffer, bytes + pad + 16, ctx); + __sha512_process_block (ctx->buffer, bytes + pad + 16, ctx); /* Put result from CTX in first 64 bytes following RESBUF. */ for (unsigned int i = 0; i < 8; ++i) @@ -178,7 +178,7 @@ __sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) if (ctx->buflen > 128) { - sha512_process_block (ctx->buffer, ctx->buflen & ~127, ctx); + __sha512_process_block (ctx->buffer, ctx->buflen & ~127, ctx); ctx->buflen &= 127; /* The regions in the following copy operation cannot overlap. */ @@ -204,7 +204,7 @@ __sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) if (UNALIGNED_P (buffer)) while (len > 128) { - sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128, + __sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128, ctx); buffer = (const char *) buffer + 128; len -= 128; @@ -212,7 +212,7 @@ __sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) else #endif { - sha512_process_block (buffer, len & ~127, ctx); + __sha512_process_block (buffer, len & ~127, ctx); buffer = (const char *) buffer + (len & ~127); len &= 127; } @@ -227,7 +227,7 @@ __sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) left_over += len; if (left_over >= 128) { - sha512_process_block (ctx->buffer, 128, ctx); + __sha512_process_block (ctx->buffer, 128, ctx); left_over -= 128; memcpy (ctx->buffer, &ctx->buffer[128], left_over); } diff --git a/sysdeps/sparc/sparc64/multiarch/sha256-block.c b/sysdeps/sparc/sparc64/multiarch/sha256-block.c index 79966b9..9d65315 100644 --- a/sysdeps/sparc/sparc64/multiarch/sha256-block.c +++ b/sysdeps/sparc/sparc64/multiarch/sha256-block.c @@ -1,12 +1,12 @@ #include -#define sha256_process_block sha256_process_block_generic -extern void sha256_process_block_generic (const void *buffer, size_t len, - struct sha256_ctx *ctx); +#define __sha256_process_block __sha256_process_block_generic +extern void __sha256_process_block_generic (const void *buffer, size_t len, + struct sha256_ctx *ctx); #include -#undef sha256_process_block +#undef __sha256_process_block extern void __sha256_process_block_crop (const void *buffer, size_t len, struct sha256_ctx *ctx); @@ -25,6 +25,8 @@ static bool cpu_supports_sha256(int hwcap) return false; } -extern void sha256_process_block (const void *buffer, size_t len, - struct sha256_ctx *ctx); -sparc_libc_ifunc(sha256_process_block, cpu_supports_sha256(hwcap) ? __sha256_process_block_crop : sha256_process_block_generic); +extern void __sha256_process_block (const void *buffer, size_t len, + struct sha256_ctx *ctx); +sparc_libc_ifunc (__sha256_process_block, + cpu_supports_sha256(hwcap) ? __sha256_process_block_crop + : __sha256_process_block_generic); diff --git a/sysdeps/sparc/sparc64/multiarch/sha512-block.c b/sysdeps/sparc/sparc64/multiarch/sha512-block.c index 0d1c3dd..2863e05 100644 --- a/sysdeps/sparc/sparc64/multiarch/sha512-block.c +++ b/sysdeps/sparc/sparc64/multiarch/sha512-block.c @@ -1,12 +1,12 @@ #include -#define sha512_process_block sha512_process_block_generic -extern void sha512_process_block_generic (const void *buffer, size_t len, - struct sha512_ctx *ctx); +#define __sha512_process_block __sha512_process_block_generic +extern void __sha512_process_block_generic (const void *buffer, size_t len, + struct sha512_ctx *ctx); #include -#undef sha512_process_block +#undef __sha512_process_block extern void __sha512_process_block_crop (const void *buffer, size_t len, struct sha512_ctx *ctx); @@ -25,6 +25,8 @@ static bool cpu_supports_sha512(int hwcap) return false; } -extern void sha512_process_block (const void *buffer, size_t len, - struct sha512_ctx *ctx); -sparc_libc_ifunc(sha512_process_block, cpu_supports_sha512(hwcap) ? __sha512_process_block_crop : sha512_process_block_generic); +extern void __sha512_process_block (const void *buffer, size_t len, + struct sha512_ctx *ctx); +sparc_libc_ifunc (__sha512_process_block, + cpu_supports_sha512(hwcap) ? __sha512_process_block_crop + : __sha512_process_block_generic);