int sha_main(void *p) { struct thread_data *arg = (struct thread_data*)p; int argc = arg->argc; char **argv = arg->argv; FILE *fin; SHA_INFO sha_info; if (argc < 2) { fin = stdin; sha_stream(&sha_info, fin); sha_print(&sha_info); } else { while (--argc) { fin = fopen(*(++argv), "rb"); if (fin == NULL) { printf("error opening %s for reading\n", *argv); } else { sha_stream(&sha_info, fin); sha_print(&sha_info); fclose(fin); } } } return(0); }
VOID NextBitLoc( ULONG *resx, ULONG *resy, UWORD width, UWORD height ) { ULONG x, y, hash; SHA_INFO sha = {0}; y = counter / width; x = counter % width; // First iteration sha_init(&sha); sha_update( &sha, key, SHA_DIGESTSIZE ); sha_update( &sha, (UBYTE *)&x, sizeof(x) ); sha_final( &sha ); D(sha_print( &sha )); hash = (sha.digest[0] & 0x7fffffff); // Lose the sign y = (y+hash) % height; // Second iteration sha_init(&sha); sha_update( &sha, key, SHA_DIGESTSIZE ); sha_update( &sha, (UBYTE *)&y, sizeof(y) ); sha_final( &sha ); D(sha_print( &sha )); hash = (sha.digest[0] & 0x7fffffff); // Lose the sign x = (x+hash) % width; // Third iteration sha_init(&sha); sha_update( &sha, key, SHA_DIGESTSIZE ); sha_update( &sha, (UBYTE *)&x, sizeof(x) ); sha_final( &sha ); D(sha_print( &sha )); hash = (sha.digest[0] & 0x7fffffff); // Lose the sign y = (y+hash) % height; *resx = x; *resy = y; ++counter; }
int main(int argc, char **argv) { FILE *fin; SHA_INFO sha_info; if (argc < 2) { fin = stdin; sha_stream(&sha_info, fin); sha_print(&sha_info); } else { while (--argc) { int len = strlen(*(++argv)); sha_string(&sha_info, *(argv), len); sha_print(&sha_info); } } return(0); }
PERROR MakeKeyMaterial( FRAME *frame, UBYTE *passphrase, struct PPTBase *PPTBase ) { ROWPTR cp, tmprow; WORD row; struct ExecBase *SysBase = PPTBase->lb_Sys; SHA_INFO sha = {0}; PERROR res = PERR_OK; sha_init( &sha ); InitProgress(frame,"Building key...", 0, frame->pix->height ); /* * First, use the passphrase for the key. */ if( strlen(passphrase) > 0 ) sha_update( &sha, passphrase, strlen(passphrase) ); if( tmprow = AllocVec( frame->pix->bytes_per_row, 0L ) ) { for( row = 0; row < frame->pix->height; row++ ) { WORD col; cp = GetPixelRow( frame, row ); if( Progress( frame, row ) ) { res = PERR_BREAK; break; } for( col = 0; col < frame->pix->bytes_per_row; col++ ) { /* Use only significant bytes */ tmprow[col] = cp[col] & 0xFE; } sha_update( &sha, tmprow, frame->pix->bytes_per_row ); } // Use the passphrase again (why?) if( strlen(passphrase) > 0 ) sha_update( &sha, passphrase, strlen(passphrase) ); FinishProgress( frame ); sha_final( &sha ); memcpy( key, &sha.digest[0], SHA_DIGESTSIZE ); D(sha_print( &sha ) ); FreeVec( tmprow ); } else { SetErrorCode( frame, PERR_OUTOFMEMORY ); res = PERR_OUTOFMEMORY; } return res; }
void compute_digest(int index){ SHA_INFO sha_info; sha_stream(&sha_info, Tdata[index].data,Tdata[index].size); if (PRINT) { sha_print(&sha_info); } }
int main_sha () { // FILE *fin; SHA_INFO sha_info; if (filein_sha == NULL) { printf("error opening filein_sha for reading (sha)\n"); } else { sha_stream(&sha_info, filein_sha); pthread_mutex_lock(&mutex_print); sha_print(&sha_info); pthread_mutex_unlock(&mutex_print); fclose(filein_sha); } return(0); }