alt-sha256.cpp revision 2941e0b052a22ff7c978763a3fadc814b2b34e18
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * IPRT - SHA-256 and SHA-224 hash functions, Alternative Implementation.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Copyright (C) 2009-2014 Oracle Corporation
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * available from http://www.virtualbox.org. This file is free software;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * General Public License (GPL) as published by the Free Software
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * The contents of this file may alternatively be used under the terms
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * of the Common Development and Distribution License Version 1.0
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VirtualBox OSE distribution, in which case the provisions of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * CDDL are applicable instead of those of the GPL.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * You may elect to license modified versions of this file under the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * terms and conditions of either the GPL or the CDDL or both.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/*******************************************************************************
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync* Defined Constants And Macros *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync*******************************************************************************/
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** The SHA-256 block size (in bytes). */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** Enables the unrolled code. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/*******************************************************************************
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync* Header Files *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync*******************************************************************************/
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** Our private context structure. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /** The W array.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Buffering happens in the first 16 words, converted from big endian to host
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * endian immediately before processing. The amount of buffered data is kept
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * in the 6 least significant bits of cbMessage. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /** The message length (in bytes). */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /** The 8 hash values. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncAssertCompile(RT_SIZEOFMEMB(RTSHA256CONTEXT, abPadding) >= RT_SIZEOFMEMB(RTSHA256CONTEXT, AltPrivate));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncAssertCompileMemberSize(RTSHA256ALTPRIVATECTX, auH, RTSHA256_HASH_SIZE);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/*******************************************************************************
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync* Global Variables *
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync*******************************************************************************/
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** The K constants */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x428a2f98), UINT32_C(0x71374491), UINT32_C(0xb5c0fbcf), UINT32_C(0xe9b5dba5),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x3956c25b), UINT32_C(0x59f111f1), UINT32_C(0x923f82a4), UINT32_C(0xab1c5ed5),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0xd807aa98), UINT32_C(0x12835b01), UINT32_C(0x243185be), UINT32_C(0x550c7dc3),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x72be5d74), UINT32_C(0x80deb1fe), UINT32_C(0x9bdc06a7), UINT32_C(0xc19bf174),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0xe49b69c1), UINT32_C(0xefbe4786), UINT32_C(0x0fc19dc6), UINT32_C(0x240ca1cc),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x2de92c6f), UINT32_C(0x4a7484aa), UINT32_C(0x5cb0a9dc), UINT32_C(0x76f988da),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x983e5152), UINT32_C(0xa831c66d), UINT32_C(0xb00327c8), UINT32_C(0xbf597fc7),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0xc6e00bf3), UINT32_C(0xd5a79147), UINT32_C(0x06ca6351), UINT32_C(0x14292967),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x27b70a85), UINT32_C(0x2e1b2138), UINT32_C(0x4d2c6dfc), UINT32_C(0x53380d13),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x650a7354), UINT32_C(0x766a0abb), UINT32_C(0x81c2c92e), UINT32_C(0x92722c85),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0xa2bfe8a1), UINT32_C(0xa81a664b), UINT32_C(0xc24b8b70), UINT32_C(0xc76c51a3),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0xd192e819), UINT32_C(0xd6990624), UINT32_C(0xf40e3585), UINT32_C(0x106aa070),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x19a4c116), UINT32_C(0x1e376c08), UINT32_C(0x2748774c), UINT32_C(0x34b0bcb5),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x391c0cb3), UINT32_C(0x4ed8aa4a), UINT32_C(0x5b9cca4f), UINT32_C(0x682e6ff3),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x748f82ee), UINT32_C(0x78a5636f), UINT32_C(0x84c87814), UINT32_C(0x8cc70208),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x90befffa), UINT32_C(0xa4506ceb), UINT32_C(0xbef9a3f7), UINT32_C(0xc67178f2),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif /* !RTSHA256_UNROLLED */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync/** Function 4.2. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncDECL_FORCE_INLINE(uint32_t) rtSha256Ch(uint32_t uX, uint32_t uY, uint32_t uZ)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync /* Optimization that saves one operation and probably a temporary variable. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync /* The original. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync/** Function 4.3. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncDECL_FORCE_INLINE(uint32_t) rtSha256Maj(uint32_t uX, uint32_t uY, uint32_t uZ)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync /* Optimization that save one operation and probably a temporary variable. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync /* The original. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync/** Function 4.4. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncDECL_FORCE_INLINE(uint32_t) rtSha256CapitalSigma0(uint32_t uX)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync/** Function 4.5. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncDECL_FORCE_INLINE(uint32_t) rtSha256CapitalSigma1(uint32_t uX)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync/** Function 4.6. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncDECL_FORCE_INLINE(uint32_t) rtSha256SmallSigma0(uint32_t uX)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync/** Function 4.7. */
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncDECL_FORCE_INLINE(uint32_t) rtSha256SmallSigma1(uint32_t uX)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync * Initializes the auW array from the specfied input block.
9f997e760f610c92e3a365be21ead6972bc46130vboxsync * @param pCtx The SHA-256 context.
9f997e760f610c92e3a365be21ead6972bc46130vboxsync * @param pbBlock The block. Must be arch-bit-width aligned.
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncDECLINLINE(void) rtSha256BlockInit(PRTSHA256CONTEXT pCtx, uint8_t const *pbBlock)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync /* Copy and byte-swap the block. Initializing the rest of the Ws are done
9f997e760f610c92e3a365be21ead6972bc46130vboxsync in the processing loop. */
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync# if 0 /* Just an idea... very little gain as this isn't the expensive code. */
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync __m128i const uBSwapConst = { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync __m128i *puDst = (__m128i *)&pCtx->AltPrivate.auW[0];
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync _mm_storeu_si128(puDst, _mm_shuffle_epi8(_mm_loadu_si128(puSrc), uBSwapConst)); puDst++; puSrc++;
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync _mm_storeu_si128(puDst, _mm_shuffle_epi8(_mm_loadu_si128(puSrc), uBSwapConst)); puDst++; puSrc++;
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync _mm_storeu_si128(puDst, _mm_shuffle_epi8(_mm_loadu_si128(puSrc), uBSwapConst)); puDst++; puSrc++;
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync _mm_storeu_si128(puDst, _mm_shuffle_epi8(_mm_loadu_si128(puSrc), uBSwapConst)); puDst++; puSrc++;
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync uint64_t *puW = (uint64_t *)&pCtx->AltPrivate.auW[0];
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync /* b0 b1 b2 b3 b4 b5 b6 b7 --bwap--> b7 b6 b5 b4 b3 b2 b1 b0 --ror--> b3 b2 b1 b0 b7 b6 b5 b4; */
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *puW++ = ASMRotateRightU64(ASMByteSwapU64(*puSrc++), 32);
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *puW++ = ASMRotateRightU64(ASMByteSwapU64(*puSrc++), 32);
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *puW++ = ASMRotateRightU64(ASMByteSwapU64(*puSrc++), 32);
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *puW++ = ASMRotateRightU64(ASMByteSwapU64(*puSrc++), 32);
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *puW++ = ASMRotateRightU64(ASMByteSwapU64(*puSrc++), 32);
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *puW++ = ASMRotateRightU64(ASMByteSwapU64(*puSrc++), 32);
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *puW++ = ASMRotateRightU64(ASMByteSwapU64(*puSrc++), 32);
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync *puW++ = ASMRotateRightU64(ASMByteSwapU64(*puSrc++), 32);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# else /* RT_BIG_ENDIAN */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync memcpy(&pCtx->AltPrivate.auW[0], pbBlock, RTSHA256_BLOCK_SIZE);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync# endif /* RT_BIG_ENDIAN */
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync#else /* !RTSHA256_UNROLLED */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync uint32_t const *pu32Block = (uint32_t const *)pbBlock;
9f997e760f610c92e3a365be21ead6972bc46130vboxsync pCtx->AltPrivate.auW[iWord] = RT_BE2H_U32(pu32Block[iWord]);
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync for (; iWord < RT_ELEMENTS(pCtx->AltPrivate.auW); iWord++)
30f07af559efcbd967e801903746fc21f81ee533vboxsync uint32_t u32 = rtSha256SmallSigma1(pCtx->AltPrivate.auW[iWord - 2]);
30f07af559efcbd967e801903746fc21f81ee533vboxsync u32 += rtSha256SmallSigma0(pCtx->AltPrivate.auW[iWord - 15]);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif /* !RTSHA256_UNROLLED */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync * Initializes the auW array from data buffered in the first part of the array.
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync * @param pCtx The SHA-256 context.
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncDECLINLINE(void) rtSha256BlockInitBuffered(PRTSHA256CONTEXT pCtx)
30f07af559efcbd967e801903746fc21f81ee533vboxsync /* Do the byte swap if necessary. Initializing the rest of the Ws are done
30f07af559efcbd967e801903746fc21f81ee533vboxsync in the processing loop. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync uint64_t *puW = (uint64_t *)&pCtx->AltPrivate.auW[0];
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* b0 b1 b2 b3 b4 b5 b6 b7 --bwap--> b7 b6 b5 b4 b3 b2 b1 b0 --ror--> b3 b2 b1 b0 b7 b6 b5 b4; */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *puW = ASMRotateRightU64(ASMByteSwapU64(*puW), 32); puW++;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *puW = ASMRotateRightU64(ASMByteSwapU64(*puW), 32); puW++;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *puW = ASMRotateRightU64(ASMByteSwapU64(*puW), 32); puW++;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *puW = ASMRotateRightU64(ASMByteSwapU64(*puW), 32); puW++;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *puW = ASMRotateRightU64(ASMByteSwapU64(*puW), 32); puW++;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *puW = ASMRotateRightU64(ASMByteSwapU64(*puW), 32); puW++;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *puW = ASMRotateRightU64(ASMByteSwapU64(*puW), 32); puW++;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync *puW = ASMRotateRightU64(ASMByteSwapU64(*puW), 32); puW++;
9f997e760f610c92e3a365be21ead6972bc46130vboxsync#else /* !RTSHA256_UNROLLED */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync pCtx->AltPrivate.auW[iWord] = RT_BE2H_U32(pCtx->AltPrivate.auW[iWord]);
9f997e760f610c92e3a365be21ead6972bc46130vboxsync for (; iWord < RT_ELEMENTS(pCtx->AltPrivate.auW); iWord++)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync uint32_t u32 = rtSha256SmallSigma1(pCtx->AltPrivate.auW[iWord - 2]);
9f997e760f610c92e3a365be21ead6972bc46130vboxsync u32 += rtSha256SmallSigma0(pCtx->AltPrivate.auW[iWord - 15]);
9f997e760f610c92e3a365be21ead6972bc46130vboxsync#endif /* !RTSHA256_UNROLLED */
9f997e760f610c92e3a365be21ead6972bc46130vboxsync * Process the current block.
9f997e760f610c92e3a365be21ead6972bc46130vboxsync * Requires one of the rtSha256BlockInit functions to be called first.
9f997e760f610c92e3a365be21ead6972bc46130vboxsync * @param pCtx The SHA-256 context.
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncstatic void rtSha256BlockProcess(PRTSHA256CONTEXT pCtx)
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync# define RTSHA256_BODY(a_iWord, a_uK, a_uA, a_uB, a_uC, a_uD, a_uE, a_uF, a_uG, a_uH) \
9f997e760f610c92e3a365be21ead6972bc46130vboxsync } while (0)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync# define RTSHA256_EIGHT(a_uK0, a_uK1, a_uK2, a_uK3, a_uK4, a_uK5, a_uK6, a_uK7, a_iFirst) \
9f997e760f610c92e3a365be21ead6972bc46130vboxsync RTSHA256_BODY(a_iFirst + 0, a_uK0, uA, uB, uC, uD, uE, uF, uG, uH); \
9f997e760f610c92e3a365be21ead6972bc46130vboxsync RTSHA256_BODY(a_iFirst + 1, a_uK1, uH, uA, uB, uC, uD, uE, uF, uG); \
9f997e760f610c92e3a365be21ead6972bc46130vboxsync RTSHA256_BODY(a_iFirst + 2, a_uK2, uG, uH, uA, uB, uC, uD, uE, uF); \
9f997e760f610c92e3a365be21ead6972bc46130vboxsync RTSHA256_BODY(a_iFirst + 3, a_uK3, uF, uG, uH, uA, uB, uC, uD, uE); \
9f997e760f610c92e3a365be21ead6972bc46130vboxsync RTSHA256_BODY(a_iFirst + 4, a_uK4, uE, uF, uG, uH, uA, uB, uC, uD); \
9f997e760f610c92e3a365be21ead6972bc46130vboxsync RTSHA256_BODY(a_iFirst + 5, a_uK5, uD, uE, uF, uG, uH, uA, uB, uC); \
9f997e760f610c92e3a365be21ead6972bc46130vboxsync RTSHA256_BODY(a_iFirst + 6, a_uK6, uC, uD, uE, uF, uG, uH, uA, uB); \
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync RTSHA256_BODY(a_iFirst + 7, a_uK7, uB, uC, uD, uE, uF, uG, uH, uA); \
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync } while (0)
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync RTSHA256_EIGHT(UINT32_C(0x428a2f98), UINT32_C(0x71374491), UINT32_C(0xb5c0fbcf), UINT32_C(0xe9b5dba5),
79a6b20f984859d9cc49305172355d6c3901f1c5vboxsync UINT32_C(0x3956c25b), UINT32_C(0x59f111f1), UINT32_C(0x923f82a4), UINT32_C(0xab1c5ed5), 0);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTSHA256_EIGHT(UINT32_C(0xd807aa98), UINT32_C(0x12835b01), UINT32_C(0x243185be), UINT32_C(0x550c7dc3),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x72be5d74), UINT32_C(0x80deb1fe), UINT32_C(0x9bdc06a7), UINT32_C(0xc19bf174), 8);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTSHA256_EIGHT(UINT32_C(0xe49b69c1), UINT32_C(0xefbe4786), UINT32_C(0x0fc19dc6), UINT32_C(0x240ca1cc),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x2de92c6f), UINT32_C(0x4a7484aa), UINT32_C(0x5cb0a9dc), UINT32_C(0x76f988da), 16);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTSHA256_EIGHT(UINT32_C(0x983e5152), UINT32_C(0xa831c66d), UINT32_C(0xb00327c8), UINT32_C(0xbf597fc7),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0xc6e00bf3), UINT32_C(0xd5a79147), UINT32_C(0x06ca6351), UINT32_C(0x14292967), 24);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTSHA256_EIGHT(UINT32_C(0x27b70a85), UINT32_C(0x2e1b2138), UINT32_C(0x4d2c6dfc), UINT32_C(0x53380d13),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x650a7354), UINT32_C(0x766a0abb), UINT32_C(0x81c2c92e), UINT32_C(0x92722c85), 32);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTSHA256_EIGHT(UINT32_C(0xa2bfe8a1), UINT32_C(0xa81a664b), UINT32_C(0xc24b8b70), UINT32_C(0xc76c51a3),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0xd192e819), UINT32_C(0xd6990624), UINT32_C(0xf40e3585), UINT32_C(0x106aa070), 40);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTSHA256_EIGHT(UINT32_C(0x19a4c116), UINT32_C(0x1e376c08), UINT32_C(0x2748774c), UINT32_C(0x34b0bcb5),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x391c0cb3), UINT32_C(0x4ed8aa4a), UINT32_C(0x5b9cca4f), UINT32_C(0x682e6ff3), 48);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTSHA256_EIGHT(UINT32_C(0x748f82ee), UINT32_C(0x78a5636f), UINT32_C(0x84c87814), UINT32_C(0x8cc70208),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync UINT32_C(0x90befffa), UINT32_C(0xa4506ceb), UINT32_C(0xbef9a3f7), UINT32_C(0xc67178f2), 56);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#else /* !RTSHA256_UNROLLED */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync for (unsigned iWord = 0; iWord < RT_ELEMENTS(pCtx->AltPrivate.auW); iWord++)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync#endif /* !RTSHA256_UNROLLED */
9f997e760f610c92e3a365be21ead6972bc46130vboxsyncRTDECL(void) RTSha256Update(PRTSHA256CONTEXT pCtx, const void *pvBuf, size_t cbBuf)
9f997e760f610c92e3a365be21ead6972bc46130vboxsync Assert(pCtx->AltPrivate.cbMessage < UINT64_MAX / 8);
9f997e760f610c92e3a365be21ead6972bc46130vboxsync * Deal with buffered bytes first.
9f997e760f610c92e3a365be21ead6972bc46130vboxsync size_t cbBuffered = (size_t)pCtx->AltPrivate.cbMessage & (RTSHA256_BLOCK_SIZE - 1U);
9f997e760f610c92e3a365be21ead6972bc46130vboxsync size_t cbMissing = RTSHA256_BLOCK_SIZE - cbBuffered;
9f997e760f610c92e3a365be21ead6972bc46130vboxsync memcpy((uint8_t *)&pCtx->AltPrivate.auW[0] + cbBuffered, pbBuf, cbMissing);
if (cbBuf > 0)
unsigned cbMissing = RTSHA256_BLOCK_SIZE - ((unsigned)pCtx->AltPrivate.cbMessage & (RTSHA256_BLOCK_SIZE - 1U));
* Process the last buffered block constructed/completed above.