bos.pegtoken/include/sha3.h
static inline int hash(uint8_t* out, size_t outlen,
        const uint8_t* in, size_t inlen,
        size_t rate, uint8_t delim)
{
    if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) {
        return -1;
    }
    uint8_t a[Plen] = { 0 };
    // Absorb input.
    foldP(in, inlen, xorin);
    // Xor in the DS and pad frame.
    a[inlen] ^= delim;
    a[rate - 1] ^= 0x80;
    // Xor in the last block.
    xorin(a, in, inlen);
    // Apply P
    P(a);
    // Squeeze output.
    foldP(out, outlen, setout);
    setout(a, out, outlen);
    memset(a, 0, 200);
    return 0;
}
/** The sponge-based hash construction. **/
The sponge-based hash construction.
The sponge - based hash construction .
static inline int hash(uint8_t* out, size_t outlen,
        const uint8_t* in, size_t inlen,
        size_t rate, uint8_t delim)
{
    if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) {
        return -1;
    }
    uint8_t a[Plen] = { 0 };
    foldP(in, inlen, xorin);
    a[inlen] ^= delim;
    a[rate - 1] ^= 0x80;
    xorin(a, in, inlen);
    P(a);
    foldP(out, outlen, setout);
    setout(a, out, outlen);
    memset(a, 0, 200);
    return 0;
}
static inline int hash ( uint8_t * out , size_t outlen , const uint8_t * in , size_t inlen , size_t rate , uint8_t delim ) { if ( ( out == NULL ) || ( ( in == NULL ) && inlen != 0 ) || ( rate >= Plen ) ) { return -1 ; } uint8_t a [ Plen ] = { 0 } ; foldP ( in , inlen , xorin ) ; a [ inlen ] ^= delim ; a [ rate - 1 ] ^= 0x80 ; xorin ( a , in , inlen ) ; P ( a ) ; foldP ( out , outlen , setout ) ; setout ( a , out , outlen ) ; memset ( a , 0 , 200 ) ; return 0 ; }
The sponge-based hash construction.
The sponge - based hash construction .
// Absorb input. // Xor in the DS and pad frame. // Xor in the last block. // Apply P // Squeeze output.