/* Withdraw the array type of object from the file buffer */ fbuf_uint32_t fbuf_withdraw( void *dest, const fbuf_uint32_t elem_sz, const fbuf_uint32_t Nelem, filebuf_t *fbuf ) { #if ! defined( WORDS_BIGENDIAN ) void *buf; #endif fbuf_uint32_t total_bytesize; fbuf_uint32_t total_fbufunit; total_bytesize = elem_sz * Nelem; total_fbufunit = byte2fbufunit( total_bytesize ); if ( fbuf->ptr + total_fbufunit <= fbuf->end ) { #if ! defined( WORDS_BIGENDIAN ) # if ! defined( HAVE_ALLOCA ) buf = ( char * ) malloc( total_bytesize ); # else buf = ( char * ) alloca( total_bytesize ); # endif if ( buf == NULL ) return (fbuf_uint32_t) 0; memcpy( buf, fbuf->ptr, byte2char( total_bytesize ) ); byteswap( Nelem, elem_sz, buf ); memcpy( dest, buf, byte2char( total_bytesize ) ); # if ! defined( HAVE_ALLOCA ) free( buf ); # endif #else memcpy( dest, fbuf->ptr, byte2char( total_bytesize ) ); #endif fbuf->ptr += total_fbufunit; return Nelem; } else return (fbuf_uint32_t) 0; }
int main(int argc, char **argv) { int i, rc; char *result; print_header(); rc = parse_argv(argc, argv); if (rc) { fprintf(stderr, "\n"); print_help(argv[0]); return rc; } fprintf(stderr, "[i] %s\n", enable_feedback ? "Feedback mode enabled" : "Default ciphering mode"); // Decode ciphertext decode(&data, enable_feedback); fprintf(stderr, "[i] Using the following gamma sequence: "); for (i = 0; i < data.plain_len; i++) { if (i > 20) { fprintf(stderr, "..."); break; } fprintf(stderr, "%02X", data.gamma[i]); } fprintf(stderr, "\n\n"); // Print result byte2char(data.plaintext, &result, data.plain_len); printf("%s\n", result); // Free the memory free_crypto_data(&data); return 0; }