alt-sha1.cpp revision 32551b58cc5cc616b772ab398081407bae75546e
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * IPRT - SHA-1 hash functions, Alternative Implementation.
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * Copyright (C) 2009-2014 Oracle Corporation
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * available from http://www.virtualbox.org. This file is free software;
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * you can redistribute it and/or modify it under the terms of the GNU
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * General Public License (GPL) as published by the Free Software
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * The contents of this file may alternatively be used under the terms
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * of the Common Development and Distribution License Version 1.0
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * VirtualBox OSE distribution, in which case the provisions of the
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * CDDL are applicable instead of those of the GPL.
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * You may elect to license modified versions of this file under the
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * terms and conditions of either the GPL or the CDDL or both.
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync/*******************************************************************************
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync* Defined Constants And Macros *
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync*******************************************************************************/
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync/** The SHA-1 block size (in bytes). */
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync/*******************************************************************************
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync* Header Files *
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync*******************************************************************************/
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync/** Our private context structure. */
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync /** The W array.
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * Buffering happens in the first 16 words, converted from big endian to host
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * endian immediately before processing. The amount of buffered data is kept
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * in the 6 least significant bits of cbMessage. */
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync /** The message length (in bytes). */
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync /** The 5 hash values. */
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsyncAssertCompile(RT_SIZEOFMEMB(RTSHA1CONTEXT, abPadding) >= RT_SIZEOFMEMB(RTSHA1CONTEXT, AltPrivate));
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsyncAssertCompileMemberSize(RTSHA1ALTPRIVATECTX, auH, RTSHA1_HASH_SIZE);
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * Initializes the auW array from the specfied input block.
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * @param pCtx The SHA1 context.
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync * @param pbBlock The block. Must be 32-bit aligned.
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsyncDECLINLINE(void) rtSha1BlockInit(PRTSHA1CONTEXT pCtx, uint8_t const *pbBlock)
086f30e697aef37b4dbc818a42ecde0533bcc1d8vboxsync uint32_t const *pu32Block = (uint32_t const *)pbBlock;
unsigned iWord;
unsigned iWord;
return uResult;
return uResult;
return uResult;
# if 0 /* Variation that reduces the code size by a factor of 4 without much loss in preformance. */
do { unsigned i = 4; while (i-- > 0) FIVE_ITERATIONS(a_iFirst + (3 - i) * 5, a_uK, a_fnFt); } while (0)
unsigned iWord = 0;
if (cbBuffered)
if (cbBuf > 0)
unsigned cbMissing = RTSHA1_BLOCK_SIZE - ((unsigned)pCtx->AltPrivate.cbMessage & (RTSHA1_BLOCK_SIZE - 1U));
* Process the last buffered block constructed/completed above.