openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libgcrypt/1.8.4-r0/libgcrypt-1.8.4/cipher/sha256.c
static void sha256_final(void* context)
{
    SHA256_CONTEXT* hd = context;
    u32 t, th, msb, lsb;
    byte* p;
    unsigned int burn;

    _gcry_md_block_write(hd, NULL, 0); /* flush */
    ;

    t = hd->bctx.nblocks;
    if (sizeof t == sizeof hd->bctx.nblocks)
        th = hd->bctx.nblocks_high;
    else
        th = hd->bctx.nblocks >> 32;

    /* multiply by 64 to make a byte count */
    lsb = t << 6;
    msb = (th << 6) | (t >> 26);
    /* add the count */
    t = lsb;
    if ((lsb += hd->bctx.count) < t)
        msb++;
    /* multiply by 8 to make a bit count */
    t = lsb;
    lsb <<= 3;
    msb <<= 3;
    msb |= t >> 29;

    if (hd->bctx.count < 56)
    {                                          /* enough room */
        hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
        while (hd->bctx.count < 56)
            hd->bctx.buf[hd->bctx.count++] = 0; /* pad */
    }
    else
    {                                          /* need one extra block */
        hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
        while (hd->bctx.count < 64)
            hd->bctx.buf[hd->bctx.count++] = 0;
        _gcry_md_block_write(hd, NULL, 0); /* flush */
        ;
        memset(hd->bctx.buf, 0, 56); /* fill next block with zeroes */
    }
    /* append the 64 bit count */
    buf_put_be32(hd->bctx.buf + 56, msb);
    buf_put_be32(hd->bctx.buf + 60, lsb);
    burn = transform(hd, hd->bctx.buf, 1);
    _gcry_burn_stack(burn);

    p = hd->bctx.buf;
#define X(a)                                                                   \
    do                                                                         \
    {                                                                          \
        buf_put_be32(p, hd->h##a);                                             \
        p += 4;                                                                \
    } while (0)
    X(0);
    X(1);
    X(2);
    X(3);
    X(4);
    X(5);
    X(6);
    X(7);
#undef X
}
/*
   The routine finally terminates the computation and returns the
   digest.  The handle is prepared for a new cycle, but adding bytes
   to the handle will the destroy the returned buffer.  Returns: 32
   bytes with the message the digest.  */
The routine finally terminates the computation and returns the
digest.  The handle is prepared for a new cycle, but adding bytes
to the handle will the destroy the returned buffer.  Returns: 32
bytes with the message the digest.
The routine finally terminates the computation and returns the digest . The handle is prepared for a new cycle but adding bytes to the handle will the destroy the returned buffer . Returns : 32 bytes with the message the digest .
static void sha256_final(void* context)
{
    SHA256_CONTEXT* hd = context;
    u32 t, th, msb, lsb;
    byte* p;
    unsigned int burn;
    _gcry_md_block_write(hd, NULL, 0); 
    ;
    t = hd->bctx.nblocks;
    if (sizeof t == sizeof hd->bctx.nblocks)
        th = hd->bctx.nblocks_high;
    else
        th = hd->bctx.nblocks >> 32;
    lsb = t << 6;
    msb = (th << 6) | (t >> 26);
    t = lsb;
    if ((lsb += hd->bctx.count) < t)
        msb++;
    t = lsb;
    lsb <<= 3;
    msb <<= 3;
    msb |= t >> 29;
    if (hd->bctx.count < 56)
    {                                          
        hd->bctx.buf[hd->bctx.count++] = 0x80; 
        while (hd->bctx.count < 56)
            hd->bctx.buf[hd->bctx.count++] = 0; 
    }
    else
    {                                          
        hd->bctx.buf[hd->bctx.count++] = 0x80; 
        while (hd->bctx.count < 64)
            hd->bctx.buf[hd->bctx.count++] = 0;
        _gcry_md_block_write(hd, NULL, 0); 
        ;
        memset(hd->bctx.buf, 0, 56); 
    }
    buf_put_be32(hd->bctx.buf + 56, msb);
    buf_put_be32(hd->bctx.buf + 60, lsb);
    burn = transform(hd, hd->bctx.buf, 1);
    _gcry_burn_stack(burn);
    p = hd->bctx.buf;
#define X(a)                                                                   \
    do                                                                         \
    {                                                                          \
        buf_put_be32(p, hd->h##a);                                             \
        p += 4;                                                                \
    } while (0)
    X(0);
    X(1);
    X(2);
    X(3);
    X(4);
    X(5);
    X(6);
    X(7);
#undef X
}
static void sha256_final ( void * context ) { SHA256_CONTEXT * hd = context ; u32 t , th , msb , lsb ; byte * p ; unsigned int burn ; _gcry_md_block_write ( hd , NULL , 0 ) ; ; t = hd -> bctx . nblocks ; if ( sizeof t == sizeof hd -> bctx . nblocks ) th = hd -> bctx . nblocks_high ; else th = hd -> bctx . nblocks >> 32 ; lsb = t << 6 ; msb = ( th << 6 ) | ( t >> 26 ) ; t = lsb ; if ( ( lsb += hd -> bctx . count ) < t ) msb ++ ; t = lsb ; lsb <<= 3 ; msb <<= 3 ; msb |= t >> 29 ; if ( hd -> bctx . count < 56 ) { hd -> bctx . buf [ hd -> bctx . count ++ ] = 0x80 ; while ( hd -> bctx . count < 56 ) hd -> bctx . buf [ hd -> bctx . count ++ ] = 0 ; } else { hd -> bctx . buf [ hd -> bctx . count ++ ] = 0x80 ; while ( hd -> bctx . count < 64 ) hd -> bctx . buf [ hd -> bctx . count ++ ] = 0 ; _gcry_md_block_write ( hd , NULL , 0 ) ; ; memset ( hd -> bctx . buf , 0 , 56 ) ; } buf_put_be32 ( hd -> bctx . buf + 56 , msb ) ; buf_put_be32 ( hd -> bctx . buf + 60 , lsb ) ; burn = transform ( hd , hd -> bctx . buf , 1 ) ; _gcry_burn_stack ( burn ) ; p = hd -> bctx . buf ; #define X ( a )                                                                    \
    do                                                                         \
    {                                                                          \
        buf_put_be32(p, hd->h##a);                                             \
        p += 4;                                                                \
    } while (0) X ( 0 ) ; X ( 1 ) ; X ( 2 ) ; X ( 3 ) ; X ( 4 ) ; X ( 5 ) ; X ( 6 ) ; X ( 7 ) ; #undef  X }
The routine finally terminates the computation and returns the
digest.
The routine finally terminates the computation and returns the digest .
/* flush */ /* multiply by 64 to make a byte count */ /* add the count */ /* multiply by 8 to make a bit count */ /* enough room */ /* pad */ /* pad */ /* need one extra block */ /* pad character */ /* flush */ /* fill next block with zeroes */ /* append the 64 bit count */