src/lib/sha1.c
static void SHA1PadMessage(SHA1Context *context)
{
    /*
     *  Check to see if the current message block is too small to hold
     *  the initial padding bits and length.  If so, we will pad the
     *  block, process it, and then continue padding into a second
     *  block.
     */
    if (context->Message_Block_Index > 55) {
        context->Message_Block[context->Message_Block_Index++] = 0x80;
        while(context->Message_Block_Index < 64) {
            context->Message_Block[context->Message_Block_Index++] = 0;
        }

        SHA1ProcessMessageBlock(context);

        while(context->Message_Block_Index < 56) {
            context->Message_Block[context->Message_Block_Index++] = 0;
        }
    } else {
        context->Message_Block[context->Message_Block_Index++] = 0x80;
        while(context->Message_Block_Index < 56) {

            context->Message_Block[context->Message_Block_Index++] = 0;
        }
    }

    /*
     *  Store the message length as the last 8 octets
     */
    context->Message_Block[56] = context->Length_High >> 24;
    context->Message_Block[57] = context->Length_High >> 16;
    context->Message_Block[58] = context->Length_High >> 8;
    context->Message_Block[59] = context->Length_High;
    context->Message_Block[60] = context->Length_Low >> 24;
    context->Message_Block[61] = context->Length_Low >> 16;
    context->Message_Block[62] = context->Length_Low >> 8;
    context->Message_Block[63] = context->Length_Low;

    SHA1ProcessMessageBlock(context);
}
/*
 *  SHA1PadMessage
 *

 *  Description:
 *      According to the standard, the message must be padded to an even
 *      512 bits.  The first padding bit must be a '1'.  The last 64
 *      bits represent the length of the original message.  All bits in
 *      between should be 0.  This function will pad the message
 *      according to those rules by filling the Message_Block array
 *      accordingly.  It will also call the ProcessMessageBlock function
 *      provided appropriately.  When it returns, it can be assumed that
 *      the message digest has been computed.
 *
 *  Parameters:
 *      context: [in/out]
 *          The context to pad
 *      ProcessMessageBlock: [in]
 *          The appropriate SHA*ProcessMessageBlock function
 *  Returns:
 *      Nothing.
 *
 */
SHA1PadMessage
Description:
According to the standard, the message must be padded to an even
512 bits.  The first padding bit must be a '1'.  The last 64
bits represent the length of the original message.  All bits in
between should be 0.  This function will pad the message
according to those rules by filling the Message_Block array
accordingly.  It will also call the ProcessMessageBlock function
provided appropriately.  When it returns, it can be assumed that
the message digest has been computed.

[in/out]
The context to pad
ProcessMessageBlock: [in]
The appropriate SHA*ProcessMessageBlock function
Returns:
Nothing.
SHA1PadMessage Description : According to the standard the message must be padded to an even 512 bits . The first padding bit must be a ' 1 ' . The last 64 bits represent the length of the original message . All bits in between should be 0 . This function will pad the message according to those rules by filling the Message_Block array accordingly . It will also call the ProcessMessageBlock function provided appropriately . When it returns it can be assumed that the message digest has been computed . [ in / out ] The context to pad ProcessMessageBlock : [ in ] The appropriate SHA * ProcessMessageBlock function Returns : Nothing .
static void SHA1PadMessage(SHA1Context *context)
{
    if (context->Message_Block_Index > 55) {
        context->Message_Block[context->Message_Block_Index++] = 0x80;
        while(context->Message_Block_Index < 64) {
            context->Message_Block[context->Message_Block_Index++] = 0;
        }
        SHA1ProcessMessageBlock(context);
        while(context->Message_Block_Index < 56) {
            context->Message_Block[context->Message_Block_Index++] = 0;
        }
    } else {
        context->Message_Block[context->Message_Block_Index++] = 0x80;
        while(context->Message_Block_Index < 56) {
            context->Message_Block[context->Message_Block_Index++] = 0;
        }
    }
    context->Message_Block[56] = context->Length_High >> 24;
    context->Message_Block[57] = context->Length_High >> 16;
    context->Message_Block[58] = context->Length_High >> 8;
    context->Message_Block[59] = context->Length_High;
    context->Message_Block[60] = context->Length_Low >> 24;
    context->Message_Block[61] = context->Length_Low >> 16;
    context->Message_Block[62] = context->Length_Low >> 8;
    context->Message_Block[63] = context->Length_Low;
    SHA1ProcessMessageBlock(context);
}
static void SHA1PadMessage ( SHA1Context * context ) { if ( context -> Message_Block_Index > 55 ) { context -> Message_Block [ context -> Message_Block_Index ++ ] = 0x80 ; while ( context -> Message_Block_Index < 64 ) { context -> Message_Block [ context -> Message_Block_Index ++ ] = 0 ; } SHA1ProcessMessageBlock ( context ) ; while ( context -> Message_Block_Index < 56 ) { context -> Message_Block [ context -> Message_Block_Index ++ ] = 0 ; } } else { context -> Message_Block [ context -> Message_Block_Index ++ ] = 0x80 ; while ( context -> Message_Block_Index < 56 ) { context -> Message_Block [ context -> Message_Block_Index ++ ] = 0 ; } } context -> Message_Block [ 56 ] = context -> Length_High >> 24 ; context -> Message_Block [ 57 ] = context -> Length_High >> 16 ; context -> Message_Block [ 58 ] = context -> Length_High >> 8 ; context -> Message_Block [ 59 ] = context -> Length_High ; context -> Message_Block [ 60 ] = context -> Length_Low >> 24 ; context -> Message_Block [ 61 ] = context -> Length_Low >> 16 ; context -> Message_Block [ 62 ] = context -> Length_Low >> 8 ; context -> Message_Block [ 63 ] = context -> Length_Low ; SHA1ProcessMessageBlock ( context ) ; }
SHA1PadMessage
  Description:
      According to the standard, the message must be padded to an even
      512 bits.
SHA1PadMessage Description : According to the standard the message must be padded to an even 512 bits .
/*
     *  Check to see if the current message block is too small to hold
     *  the initial padding bits and length.  If so, we will pad the
     *  block, process it, and then continue padding into a second
     *  block.
     */ /*
     *  Store the message length as the last 8 octets
     */