FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/sha3.c
/* Calculate the SHA-3 hash based on all the message data seen.
 *
 * sha3  wc_Sha3 object holding state.
 * hash  Buffer to hold the hash result.
 * p     Number of 64-bit numbers in a block of data to process.
 * len   Number of bytes in output.
 * returns 0 on success.
 */
Calculate the SHA-3 hash based on all the message data seen.
sha3  wc_Sha3 object holding state.
hash  Buffer to hold the hash result.
p     Number of 64-bit numbers in a block of data to process.
len   Number of bytes in output.
returns 0 on success.
Calculate the SHA - 3 hash based on all the message data seen . sha3 wc_Sha3 object holding state . hash Buffer to hold the hash result . p Number of 64 - bit numbers in a block of data to process . len Number of bytes in output . returns 0 on success .
static int Sha3Final(wc_Sha3* sha3, byte padChar, byte* hash, byte p, byte l)
{
    byte i;
    byte *s8 = (byte *)sha3->s;
    sha3->t[p * 8 - 1]  = 0x00;
#ifdef WOLFSSL_HASH_FLAGS
    if (p == WC_SHA3_256_COUNT && sha3->flags & WC_HASH_SHA3_KECCAK256) {
        padChar = 0x01;
    }
#endif
    sha3->t[  sha3->i]  = padChar;
    sha3->t[p * 8 - 1] |= 0x80;
    for (i=sha3->i + 1; i < p * 8 - 1; i++)
        sha3->t[i] = 0;
    for (i = 0; i < p; i++)
        sha3->s[i] ^= Load64BitBigEndian(sha3->t + 8 * i);
    BlockSha3(sha3->s);
#if defined(BIG_ENDIAN_ORDER)
    ByteReverseWords64(sha3->s, sha3->s, ((l+7)/8)*8);
#endif
    for (i = 0; i < l; i++)
        hash[i] = s8[i];
    return 0;
}
static int Sha3Final ( wc_Sha3 * sha3 , byte padChar , byte * hash , byte p , byte l ) { byte i ; byte * s8 = ( byte * ) sha3 -> s ; sha3 -> t [ p * 8 - 1 ] = 0x00 ; #ifdef WOLFSSL_HASH_FLAGS if ( p == WC_SHA3_256_COUNT && sha3 -> flags & WC_HASH_SHA3_KECCAK256 ) { padChar = 0x01 ; } #endif sha3 -> t [ sha3 -> i ] = padChar ; sha3 -> t [ p * 8 - 1 ] |= 0x80 ; for ( i = sha3 -> i + 1 ; i < p * 8 - 1 ; i ++ ) sha3 -> t [ i ] = 0 ; for ( i = 0 ; i < p ; i ++ ) sha3 -> s [ i ] ^= Load64BitBigEndian ( sha3 -> t + 8 * i ) ; BlockSha3 ( sha3 -> s ) ; #if defined ( BIG_ENDIAN_ORDER ) ByteReverseWords64 ( sha3 -> s , sha3 -> s , ( ( l + 7 ) / 8 ) * 8 ) ; #endif for ( i = 0 ; i < l ; i ++ ) hash [ i ] = s8 [ i ] ; return 0 ; }
Calculate the SHA-3 hash based on all the message data seen.
Calculate the SHA - 3 hash based on all the message data seen .