req/binject/ext/binject_c/checksum.c
void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
{
unsigned long i, j;
unsigned char finalcount[8];

    for (i = 0; i < 8; i++) {
        finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
         >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
    }
    SHA1Update(context, (unsigned char *)"\200", 1);
    while ((context->count[0] & 504) != 448) {
        SHA1Update(context, (unsigned char *)"\0", 1);
    }
    SHA1Update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
    for (i = 0; i < 20; i++) {
        digest[i] = (unsigned char)
         ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
    }
    /* Wipe variables */
    i = j = 0;
    memset(context->buffer, 0, 64);
    memset(context->state, 0, 20);
    memset(context->count, 0, 8);
    memset(&finalcount, 0, 8);
#ifdef SHA1HANDSOFF  /* make SHA1Transform overwrite it's own static vars */
    SHA1Transform(context->state, context->buffer);
#endif
}
/* Add padding and return the message digest. */
Add padding and return the message digest.
Add padding and return the message digest .
void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
{
unsigned long i, j;
unsigned char finalcount[8];
    for (i = 0; i < 8; i++) {
        finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
         >> ((3-(i & 3)) * 8) ) & 255);  
    }
    SHA1Update(context, (unsigned char *)"\200", 1);
    while ((context->count[0] & 504) != 448) {
        SHA1Update(context, (unsigned char *)"\0", 1);
    }
    SHA1Update(context, finalcount, 8);  
    for (i = 0; i < 20; i++) {
        digest[i] = (unsigned char)
         ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
    }
    i = j = 0;
    memset(context->buffer, 0, 64);
    memset(context->state, 0, 20);
    memset(context->count, 0, 8);
    memset(&finalcount, 0, 8);
#ifdef SHA1HANDSOFF  
    SHA1Transform(context->state, context->buffer);
#endif
}
void SHA1Final ( unsigned char digest [ 20 ] , SHA1_CTX * context ) { unsigned long i , j ; unsigned char finalcount [ 8 ] ; for ( i = 0 ; i < 8 ; i ++ ) { finalcount [ i ] = ( unsigned char ) ( ( context -> count [ ( i >= 4 ? 0 : 1 ) ] >> ( ( 3 - ( i & 3 ) ) * 8 ) ) & 255 ) ; } SHA1Update ( context , ( unsigned char * ) " \200 " , 1 ) ; while ( ( context -> count [ 0 ] & 504 ) != 448 ) { SHA1Update ( context , ( unsigned char * ) " \0 " , 1 ) ; } SHA1Update ( context , finalcount , 8 ) ; for ( i = 0 ; i < 20 ; i ++ ) { digest [ i ] = ( unsigned char ) ( ( context -> state [ i >> 2 ] >> ( ( 3 - ( i & 3 ) ) * 8 ) ) & 255 ) ; } i = j = 0 ; memset ( context -> buffer , 0 , 64 ) ; memset ( context -> state , 0 , 20 ) ; memset ( context -> count , 0 , 8 ) ; memset ( & finalcount , 0 , 8 ) ; #ifdef SHA1HANDSOFF SHA1Transform ( context -> state , context -> buffer ) ; #endif }
Add padding and return the message digest.
Add padding and return the message digest .
/* Endian independent */ /* Should cause a SHA1Transform() */ /* Wipe variables */ /* make SHA1Transform overwrite it's own static vars */