Return-Path: X-Original-To: apmail-apr-commits-archive@www.apache.org Delivered-To: apmail-apr-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5A09BFB3F for ; Sun, 24 Mar 2013 08:04:56 +0000 (UTC) Received: (qmail 27419 invoked by uid 500); 24 Mar 2013 08:04:55 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 27303 invoked by uid 500); 24 Mar 2013 08:04:54 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 27272 invoked by uid 99); 24 Mar 2013 08:04:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Mar 2013 08:04:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Mar 2013 08:04:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0F3AF238889B; Sun, 24 Mar 2013 08:04:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1460281 - in /apr/apr-util/branches/1.5.x: ./ CHANGES crypto/apr_md5.c test/testmd5.c Date: Sun, 24 Mar 2013 08:04:28 -0000 To: commits@apr.apache.org From: sf@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130324080429.0F3AF238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sf Date: Sun Mar 24 08:04:28 2013 New Revision: 1460281 URL: http://svn.apache.org/r1460281 Log: Merge r1460244: speed-up md5 by avoiding some memcopies PR: 49011 Submitted by: Stefan Fritsch, Stefan Fuhrmann Modified: apr/apr-util/branches/1.5.x/ (props changed) apr/apr-util/branches/1.5.x/CHANGES apr/apr-util/branches/1.5.x/crypto/apr_md5.c apr/apr-util/branches/1.5.x/test/testmd5.c Propchange: apr/apr-util/branches/1.5.x/ ------------------------------------------------------------------------------ Merged /apr/apr/trunk:r1460244 Modified: apr/apr-util/branches/1.5.x/CHANGES URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/CHANGES?rev=1460281&r1=1460280&r2=1460281&view=diff ============================================================================== --- apr/apr-util/branches/1.5.x/CHANGES [utf-8] (original) +++ apr/apr-util/branches/1.5.x/CHANGES [utf-8] Sun Mar 24 08:04:28 2013 @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with APR-util 1.5.2 + *) Speedup md5 calculation by avoiding some copying on little endian + architectures. PR 49011. [Stefan Fritsch, Stefan Fuhrmann + ] + *) Use heap memory for crypt in apr_password_validate(), to reduce stack usage. PR 54572. [Stefan Fritsch] Modified: apr/apr-util/branches/1.5.x/crypto/apr_md5.c URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/crypto/apr_md5.c?rev=1460281&r1=1460280&r2=1460281&view=diff ============================================================================== --- apr/apr-util/branches/1.5.x/crypto/apr_md5.c (original) +++ apr/apr-util/branches/1.5.x/crypto/apr_md5.c Sun Mar 24 08:04:28 2013 @@ -338,9 +338,18 @@ APU_DECLARE(apr_status_t) apr_md5(unsign static void MD5Transform(apr_uint32_t state[4], const unsigned char block[64]) { apr_uint32_t a = state[0], b = state[1], c = state[2], d = state[3], - x[APR_MD5_DIGESTSIZE]; + tmpbuf[APR_MD5_DIGESTSIZE]; + const apr_uint32_t *x; - Decode(x, block, 64); +#if !APR_IS_BIGENDIAN + if ((apr_uintptr_t)block % sizeof(apr_uint32_t) == 0) { + x = (apr_uint32_t *)block; + } else +#endif + { + Decode(tmpbuf, block, 64); + x = tmpbuf; + } /* Round 1 */ FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */ @@ -419,8 +428,13 @@ static void MD5Transform(apr_uint32_t st state[2] += c; state[3] += d; - /* Zeroize sensitive information. */ - memset(x, 0, sizeof(x)); +#if !APR_IS_BIGENDIAN + if (x == tmpbuf) +#endif + { + /* Zeroize sensitive information. */ + memset(tmpbuf, 0, sizeof(tmpbuf)); + } } /* Encodes input (apr_uint32_t) into output (unsigned char). Assumes len is Modified: apr/apr-util/branches/1.5.x/test/testmd5.c URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/test/testmd5.c?rev=1460281&r1=1460280&r2=1460281&view=diff ============================================================================== --- apr/apr-util/branches/1.5.x/test/testmd5.c (original) +++ apr/apr-util/branches/1.5.x/test/testmd5.c Sun Mar 24 08:04:28 2013 @@ -66,6 +66,30 @@ static void test_md5sum(abts_case *tc, v (memcmp(digest, sum, APR_MD5_DIGESTSIZE) == 0)); } +static void test_md5sum_unaligned(abts_case *tc, void *data) +{ + apr_md5_ctx_t context; + const char *string = "abcdefghijklmnopqrstuvwxyz01234" + "abcdefghijklmnopqrstuvwxyz01234" + "abcdefghijklmnopqrstuvwxyz01234" + "abcdefghijklmnopqrstuvwxyz01234_"; + const char *sum = + "\x93\x17\x22\x78\xee\x30\x82\xb3\xeb\x95\x33\xec\xea\x78\xb7\x89"; + unsigned char digest[APR_MD5_DIGESTSIZE]; + unsigned int i; + + ABTS_ASSERT(tc, "apr_md5_init", (apr_md5_init(&context) == 0)); + for (i = 0; i < 10; i++) { + ABTS_ASSERT(tc, "apr_md5_update", + (apr_md5_update(&context, string, strlen(string)) == 0)); + string++; + } + ABTS_ASSERT(tc, "apr_md5_final", (apr_md5_final(digest, &context) + == 0)); + ABTS_ASSERT(tc, "check for correct md5 digest of unaligned data", + (memcmp(digest, sum, APR_MD5_DIGESTSIZE) == 0)); +} + abts_suite *testmd5(abts_suite *suite) { suite = ADD_SUITE(suite); @@ -73,6 +97,7 @@ abts_suite *testmd5(abts_suite *suite) for (count=0; count < num_sums; count++) { abts_run_test(suite, test_md5sum, NULL); } + abts_run_test(suite, test_md5sum_unaligned, NULL); return suite; }