示例#1
0
文件: makepkg.c 项目: Arikado/SCEkrit
static void calculate_hashes(void)
{
	calculate_hash(pkg + 0x2c0, 0x40, pkg + 0x80 + 3*0x30);
	calculate_hash(pkg + 0x300, 0x40, pkg + 0x80 + 3*0x30 + 8*0x10);
	calculate_hash(pkg + 0x340, pkg_files_size,
			pkg + 0x80 + 3*0x30 + 16*0x10);
}
示例#2
0
void calculate_salt(void)
{
    uint32_t random_value = 0;
    calculate_hash(pass_code, 8, var_Hkey.index); // Calculates sha256 of the keys pressed in var_W*10 msec interval and stores it in var_Hkey

    random_value = random_lcg();

    calculate_hash(&random_value, 1, var_R.index);

    xor_func(var_R.index, var_Hkey.index, 8);

    calculate_hash(var_R.index, 8, var_T.index);

    xor_func(var_Salt.index, var_T.index, 8);

    if (enter_button_status == THIRD_TIME_PRESSED)
    {
        save_salt_to_mcu();
    }
    else
    {
        Start_W_timer();
    }

}
示例#3
0
int main(int argc, char *argv[])
{
    banner();
    if (argc < 2)
    {
        int i=0;
        char *func[] =
        {
"VirtualAlloc",   /* kernel32.dll */
"LoadLibraryA",
"DnsQuery_A",    /* dnsapi.dll */
0x0
        };
       printf("HASH\t\t\tFUNCTION\n----\t\t\t--------\n");
        while ( *func )
        {
              printf("0x%X\t\t%s\n", calculate_hash(*func), *func);
              i++;
              *func = func[i];

        }
    }
    else
    {
       char *manfunc[] = {argv[1]};
       printf("HASH\t\t\tFUNCTION\n----\t\t\t--------\n");
       printf("0x%X\t\t%s\n", calculate_hash(*manfunc), *manfunc);
    }

    return 0;
}
示例#4
0
文件: hash.c 项目: k-akashi/hogelan
int
insert_hash (struct hash * hash, void * data, void * key)
{
	int hash_value;
	struct hashnode * node, * ptr, * prev;
	
	if ((hash_value = calculate_hash (key)) < 0) 
		return -1;

	prev = &hash->table[hash_value];
	pthread_mutex_lock (&hash->mutex[hash_value]);

	for (ptr = prev->next; ptr != NULL; ptr = ptr->next) {
		if (compare_key (key, ptr->key) == 0) {
			pthread_mutex_unlock (&hash->mutex[hash_value]);
			return -1;
		}
		prev = ptr;
	}
	
	node = (struct hashnode *) malloc (sizeof (struct hashnode));
	memset (node, 0, sizeof (struct hashnode));
	node->next = NULL;
	node->data = data;
	memcpy (node->key, key, HASH_KEY_LEN);
	prev->next = node;

	pthread_mutex_unlock (&hash->mutex[hash_value]);

	return 1;
}
示例#5
0
文件: hash.c 项目: k-akashi/hogelan
void *
delete_hash (struct hash * hash, void * key)
{
	int hash_value;
	void * data;
	struct hashnode * ptr, * prev;

	if ((hash_value = calculate_hash (key)) < 0) 
		return NULL;

	prev = &hash->table[hash_value];
	
	pthread_mutex_lock (&hash->mutex[hash_value]);	

	for (ptr = prev->next; ptr != NULL; ptr = ptr->next) {
		if (compare_key (key, ptr->key) == 0)
			break;
		prev = ptr;
	}

	if (ptr == NULL) {
		pthread_mutex_unlock (&hash->mutex[hash_value]);	
		return NULL;
	}		

	prev->next = ptr->next;
	data = ptr->data;
	free (ptr);

	pthread_mutex_unlock (&hash->mutex[hash_value]);	

	return data;
}
示例#6
0
Person::Person(BIGNUM *_p, BIGNUM *_g, BIGNUM *_B) {
  p = BN_dup(_p);
  g = BN_dup(_g);
  B = BN_dup(_B);
  set_keys();
  calculate_hash();
}
示例#7
0
/**
 * fit_image_process_hash - Process a single subnode of the images/ node
 *
 * Check each subnode and process accordingly. For hash nodes we generate
 * a hash of the supplised data and store it in the node.
 *
 * @fit:	pointer to the FIT format image header
 * @image_name:	name of image being processes (used to display errors)
 * @noffset:	subnode offset
 * @data:	data to process
 * @size:	size of data in bytes
 * @return 0 if ok, -1 on error
 */
static int fit_image_process_hash(void *fit, const char *image_name,
		int noffset, const void *data, size_t size)
{
	uint8_t value[FIT_MAX_HASH_LEN];
	const char *node_name;
	int value_len;
	char *algo;
	int ret;

	node_name = fit_get_name(fit, noffset, NULL);

	if (fit_image_hash_get_algo(fit, noffset, &algo)) {
		printf("Can't get hash algo property for '%s' hash node in '%s' image node\n",
		       node_name, image_name);
		return -ENOENT;
	}

	if (calculate_hash(data, size, algo, value, &value_len)) {
		printf("Unsupported hash algorithm (%s) for '%s' hash node in '%s' image node\n",
		       algo, node_name, image_name);
		return -EPROTONOSUPPORT;
	}

	ret = fit_set_hash_value(fit, noffset, value, value_len);
	if (ret) {
		printf("Can't set hash value for '%s' hash node in '%s' image node\n",
		       node_name, image_name);
		return ret;
	}

	return 0;
}
示例#8
0
void *
search_hash( struct hash *hash, void *key ) {
  assert( hash != NULL );
  assert( key != NULL );

  int hash_value;
  if ( ( hash_value = calculate_hash( key, hash->keylen ) ) < 0 ) {
    return NULL;
  }

  struct hashnode *ptr = &hash->table[ hash_value ];

  pthread_mutex_lock( &hash->mutex[ hash_value ] );

  for ( ptr = ptr->next; ptr != NULL; ptr = ptr->next ) {
    if ( compare_key( key, ptr->key, hash->keylen ) == 0 ) {
      pthread_mutex_unlock( &hash->mutex[ hash_value ] );
      return ptr->data;
    }
  }

  pthread_mutex_unlock( &hash->mutex[ hash_value ] );

  return NULL;
}
示例#9
0
int static_hash_table_get(static_hash_table* h_table, char* key, int* success_indicator) {
	if (key == NULL) {
		*success_indicator = -1;
		return -1;
	}

	int hash = calculate_hash(key, h_table->capacity);
	if (hash == -1) {
		*success_indicator = -1;
		return -1;
	}
	
	bucket* current_bucket = h_table->store[hash];
	while (current_bucket != NULL) {
		if (strcmp(current_bucket->key, key) == 0) {
			*success_indicator = 0;
			return current_bucket->value;
		}
	
		current_bucket = current_bucket->next_bucket;
	}

	*success_indicator = -1;
	return -1;
}
示例#10
0
int
read_file(char *filename, long Q, int R, long RM, int zero_value, int chunk_num)
{
    FILE *input;
    char *source = NULL;
    char *temp = NULL;
    char *packet = NULL;
    int copy_len = 0;
    int rc; 
	int j = 0;

    // read the file
    input = fopen(filename, "r");
    //check((input != NULL), "Can't find the file.");

    source = (char *) malloc(SIZE);
    //check((source != NULL), "Can't alloc merrory.");

    temp = (char *) malloc(SIZE);
    //check((temp != NULL), "Can't alloc merrory.");

    packet = (char *) malloc(SIZE);
    //check((packet != NULL), "Can't alloc merrory.");

    while (fgets(source, SIZE, input) != NULL) {
        // First: delete the '\n'
        int len = strlen(source);
        strncpy(temp, source, len - 1); 
        temp[len - 1] = '\0';

        // Second: copy and calculate the hash value    
        // 30000 is the lagest pack playload. 
        memcpy(packet + copy_len, temp, strlen(temp));
		copy_len += strlen(temp);
		packet[copy_len] = '\0';

        if (copy_len >= chunk_num) {
            //calculate the hash
            rc = calculate_hash(packet, copy_len, Q, R, RM, 
                        zero_value, chunk_num);
            //check(rc == 0, "calculate hash maybe error.");
        	copy_len = 0;
        }   
	}

    fclose(input);
    free(source);
    free(temp);
    free(packet);
    return 0;

      error:
    fclose(input);
    free(source);
    free(temp);
    free(packet);
    return -1;
}
示例#11
0
文件: main.c 项目: Azii/Uni
int bitcoin_parallel(const unsigned int processcount) {
	printf("\n\nStarting bitcoin_parallel\n");
	// Start, end time
	unsigned long start,end;
	// Set start time
	start = current_time_millis();

	// TODO: Create a Blockheader object and fill it with the initial data using the getWork Method
	Blockheader * blockheader = malloc(sizeof(Blockheader));
	getWork(blockheader);
	// TODO: Split the calculation of the hashes into several segments based on the processcount
	int segment_size = ceil((double) MAX_HASHES / processcount);
	unsigned long starting_nonce = toulong(blockheader->nonce);
	//printf("starting_nonce am anfang: %ld\n", starting_nonce);
	
	// TODO: Spawn a process for each segment
	int pos = 0;
	int * child_pids = malloc(sizeof(int) * processcount);
	for (int i = 0; i < processcount; i++)
	{
		child_pids[i] = 0;
	}
	
	for (; pos < processcount; pos++)
	{
		child_pids[pos] = fork();
		if (child_pids[pos] < 0)
		{
			printf("failed forking");
			return EXIT_FAILURE;
		}
		if (child_pids[pos] == 0)
		{
			break;
		}
	}
	
	if (pos < processcount)
	{
		starting_nonce += pos * segment_size;
		char * n = to_reversed_char_arr(starting_nonce);
		memcpy(&(blockheader->nonce), n, sizeof(char) * 4);
		calculate_hash(blockheader, segment_size);
		return EXIT_SUCCESS;
	}
	
	int status;
	for (int i = 0; i < processcount; i++)
	{
		wait(&status);
	}
	
	end = current_time_millis();
	printf("Calculation finished after %.3fs\n", (double) (end - start) / 1000);

	return EXIT_SUCCESS;
}
示例#12
0
文件: hashmap.c 项目: marekw2143/MM3
void add_cell(Node *cell)
{
    #ifdef PRINT_CALL_MAP
        std::cout<<"P";
    #endif
    int key = calculate_hash((size_t)(cell->offset + _buffers->data));
    Entry *en = _entries[key];

    while(en->next)
        en = en->next;

    _lasts[key]->next = CreateEntry(cell);
//    en->next = CreateEntry(cell);
}
示例#13
0
static const struct hash_table_entry *fetch_entry(struct metadata_table *table,
		long long cstart)
{
	struct hash_table_entry **hash_table = table->hash_table;
	const int hash = calculate_hash(cstart);
	struct hash_table_entry *entry = hash_table[hash];
	while (entry && entry->cstart != cstart) {
		entry = entry->next;
	}
	if (!entry) {
		entry = load_entry(table->pdata, cstart);
		hash_table[hash] = entry;
	}
	return entry;
}
示例#14
0
文件: hashmap.c 项目: marekw2143/MM3
Node *find_cell(size_t address)
{
    #ifdef PRINT_CALL_MAP
        std::cout<<"F";
    #endif
    int key = calculate_hash(address);
    Entry *en = _entries[key];

    while( en && (en->addr != address))
        en = en->next;

    if(en)
        return en->cell;
    return NULL;
}
示例#15
0
static int fit_image_check_hash(const void *fit, int noffset, const void *data,
				size_t size, char **err_msgp)
{
	uint8_t value[FIT_MAX_HASH_LEN];
	int value_len;
	char *algo;
	uint8_t *fit_value;
	int fit_value_len;
	int ignore;

	*err_msgp = NULL;

	if (fit_image_hash_get_algo(fit, noffset, &algo)) {
		*err_msgp = "Can't get hash algo property";
		return -1;
	}
	printf("%s", algo);

	if (IMAGE_ENABLE_IGNORE) {
		fit_image_hash_get_ignore(fit, noffset, &ignore);
		if (ignore) {
			printf("-skipped ");
			return 0;
		}
	}

	if (fit_image_hash_get_value(fit, noffset, &fit_value,
				     &fit_value_len)) {
		*err_msgp = "Can't get hash value property";
		return -1;
	}

	if (calculate_hash(data, size, algo, value, &value_len)) {
		*err_msgp = "Unsupported hash algorithm";
		return -1;
	}

	if (value_len != fit_value_len) {
		*err_msgp = "Bad hash value len";
		return -1;
	} else if (memcmp(value, fit_value, value_len) != 0) {
		*err_msgp = "Bad hash value";
		return -1;
	}

	return 0;
}
示例#16
0
int authenticate_user(const char *user, char *passwd)
{
	hash_digest_t passwd_sig, match_against;
	int i;

	calculate_hash(passwd, passwd_sig);

	memset(match_against, 0 , sizeof(match_against));

#if CONFIG_LIBAUTH_DEFAULT_USER
	if (!strncmp(user, CONFIG_LIBAUTH_DEFAULT_USERNAME, strlen(user))) {
		if (string_to_digest(libs_common_libauth_passwd_data_start,
				     libs_common_libauth_passwd_data_size,
				     (u8 *)&match_against,
				     sizeof(match_against)) != VMM_OK)
			return VMM_EFAIL;

		for (i = 0; i < HASH_LEN; i++) {
			if (match_against[i] != passwd_sig[i]) {
				return VMM_EFAIL;
			}
		}

		return VMM_OK;
	}
#endif

	if (get_user_hash(user,
		(u8 *)&match_against, sizeof(match_against)) == VMM_OK) {
		for (i = 0; i < HASH_LEN; i++) {
			if (match_against[i] != passwd_sig[i]) {
				return VMM_EFAIL;
			}
		}

		return VMM_OK;
	}

	return VMM_EFAIL;
}
示例#17
0
bool static_hash_table_remove(static_hash_table* h_table, char* key) {
	if (h_table == NULL || h_table->store == NULL || key == NULL) {
		return false;
	}

	int hash = calculate_hash(key, h_table->capacity);
	if (hash < 0) {
		return false;
	}

	bucket* current_bucket = h_table->store[hash];
	while (current_bucket != NULL) {
		if (strcmp(current_bucket->key, key) == 0) {
			if (current_bucket->prev_bucket != NULL) {
				current_bucket->prev_bucket->next_bucket = current_bucket->next_bucket;
				if (current_bucket->next_bucket != NULL) {
					current_bucket->next_bucket->prev_bucket = current_bucket->prev_bucket;
				}
			} else {
				if (current_bucket->next_bucket != NULL) {
					current_bucket->next_bucket->prev_bucket = NULL;
					h_table->store[hash] = current_bucket->next_bucket;
				} else {
					h_table->store[hash] = NULL;
				}
			}
				
			if (key != current_bucket->key) {
				free(current_bucket->key);
			}

			free(current_bucket);
			return true;
		}

		current_bucket = current_bucket->next_bucket; 
	}

	return false;
}
示例#18
0
void CertificateCache::insert(const Certificate& certificate)
{
    const HashedId8 id = calculate_hash(certificate);

    // this may drop expired entries and extend some's lifetime
    std::list<Certificate> certs = lookup(id, certificate.subject_info.subject_type);

    // TODO: implement equality comparison for Certificate
    if (certs.size()) {
        const auto binary_insert = convert_for_signing(certificate);
        for (auto& cert : certs) {
            const auto binary_found = convert_for_signing(cert);
            if (binary_insert == binary_found) {
                return;
            }
        }
    }

    Clock::duration lifetime = Clock::duration::zero();
    if (certificate.subject_info.subject_type == SubjectType::Authorization_Ticket) {
        // section 7.1 in ETSI TS 103 097 v1.2.1
        // there must be a CAM with the authorization ticket every one second
        // we choose two seconds here to account for one missed message
        lifetime = std::chrono::seconds(2);
    } else if (certificate.subject_info.subject_type == SubjectType::Authorization_Authority) {
        // section 7.1 in ETSI TS 103 097 v1.2.1
        // chains are only sent upon request, there will probably only be a few authoritation authorities in use
        // one hour is an arbitrarily choosen cache period for now
        lifetime = std::chrono::seconds(3600);
    }

    if (lifetime > Clock::duration::zero()) {
        CachedCertificate entry;
        entry.certificate = certificate;
        map_type::iterator stored = m_certificates.emplace(id, entry);
        heap_type::handle_type& handle = stored->second.handle;
        handle = m_expiries.push(Expiry { m_runtime.now() + lifetime, stored });
    }
}
示例#19
0
void *
delete_hash( struct hash *hash, void *key ) {
  assert( hash != NULL );
  assert( key != NULL );

  int hash_value = -1;
  if ( ( hash_value = calculate_hash( key, hash->keylen ) ) < 0 ) {
    return NULL;
  }

  struct hashnode *prev = &hash->table[ hash_value ];

  pthread_mutex_lock( &hash->mutex[ hash_value ] );

  struct hashnode *ptr = NULL;
  for ( ptr = prev->next; ptr != NULL; ptr = ptr->next ) {
    if ( compare_key( key, ptr->key, hash->keylen ) == 0 ) {
      break;
    }
    prev = ptr;
  }

  if ( ptr == NULL ) {
    pthread_mutex_unlock( &hash->mutex[ hash_value ] );
    return NULL;
  }

  prev->next = ptr->next;
  void *data = ptr->data;
  free( ptr->key );
  free( ptr );

  hash->count--;

  pthread_mutex_unlock( &hash->mutex[ hash_value ] );

  return data;
}
示例#20
0
文件: main.c 项目: Azii/Uni
int bitcoin_loop(const unsigned int processcount) {
	printf("\n\nStarting bitcoin_loop\n");
	// Start, end time
	unsigned long start,end;
	// Set start time
	start = current_time_millis();
	
	Blockheader * blockheader = malloc(sizeof(Blockheader));
	getWork(blockheader);
	// TODO: Split the calculation of the hashes into several segments based on the processcount
	int segment_size = ceil((double)MAX_HASHES / processcount);
	
	for (int i = 0; i < processcount; i++)
	{
		calculate_hash(blockheader, segment_size);
		//printf("nonce after run #%i: %ld\n", i, toulong(blockheader->nonce));
	}

	end = current_time_millis();
	printf("Calculation finished after %.3fs\n", (double) (end - start) / 1000);
	free(blockheader);
	return EXIT_SUCCESS;
}
示例#21
0
int
insert_hash( struct hash *hash, void *data, void *key ) {
  assert( hash != NULL );
  assert( data != NULL );
  assert( key != NULL );

  int hash_value = -1;
  if ( ( hash_value = calculate_hash( key, hash->keylen ) ) < 0 ) {
    return -1;
  }

  struct hashnode *prev = &hash->table[ hash_value ];
  pthread_mutex_lock( &hash->mutex[ hash_value ] );

  for ( struct hashnode *ptr = prev->next; ptr != NULL; ptr = ptr->next ) {
    if ( compare_key( key, ptr->key, hash->keylen ) == 0 ) {
      pthread_mutex_unlock( &hash->mutex[ hash_value ] );
      return -1;
    }
    prev = ptr;
  }

  struct hashnode *node = ( struct hashnode * ) malloc( sizeof( struct hashnode ) );
  memset( node, 0, sizeof( struct hashnode ) );
  node->next = NULL;
  node->data = data;
  node->key = ( uint8_t * ) malloc( ( size_t ) hash->keylen );
  memcpy( node->key, key, ( size_t ) hash->keylen );
  prev->next = node;

  hash->count++;

  pthread_mutex_unlock( &hash->mutex[ hash_value ] );

  return 1;
}
示例#22
0
static_hash_table* static_hash_table_put(static_hash_table* h_table, char* key, int value) {
	if (h_table == NULL || h_table->store == NULL || key == NULL) {
		return NULL;
	}

	//printf("static_hash_table_put:: query to put (%s, %d)\n", key, value);

	char* key_to_put = strdup(key);

	int hash = calculate_hash(key_to_put, h_table->capacity);
	if (hash == -1) {
		return NULL;
	}

	bucket* current_bucket = h_table->store[hash];
	bucket* prev_bucket;

	if (current_bucket == NULL) {
		//printf("static_hash_table_put:: h_table->store[%d] == NULL\n", hash);
		//printf("static_hash_table_put:: let's change it\n");
		h_table->store[hash] = (bucket*)malloc(sizeof(bucket));
		if (h_table->store[hash] == NULL) {
			abort_prg("static_hash_table_put:: malloc error");
		}
	
		h_table->store[hash]->key = key_to_put;
		h_table->store[hash]->value = value;
		h_table->store[hash]->next_bucket = NULL;
		h_table->store[hash]->prev_bucket = NULL;
		//printf("static_hash_table_put:: successfully put (%s, %d)\n", h_table->store[hash]->key, h_table->store[hash]->value);
	
		return h_table;
	} 

	//printf("static_hash_table_put:: h_table->store[%d] != NULL\n", hash);
	//printf("static_hash_table_put:: let's search element (%s, ?)\n", key_to_put);
	while (current_bucket != NULL) {
		if ( strcmp(current_bucket->key, key_to_put) == 0 ) {
			//printf("static_hash_table_put:: found! (%s, %d)\n", current_bucket->key, current_bucket->value);
			current_bucket->value = value;
			//printf("static_hash_table_put:: successfully changed: now record is (%s, %d)\n", current_bucket->key, current_bucket->value);

			return h_table;
		}

		prev_bucket = current_bucket;
		current_bucket = current_bucket->next_bucket;
	}

	//printf("static_hash_table_put:: element not found! creating new one: (%s, %d)\n", key_to_put, value);
	bucket* new_bucket = (bucket*)malloc(sizeof(bucket));
	if (new_bucket == NULL) {
		abort_prg("static_hash_table_put:: malloc error");
	}

	new_bucket->key = key_to_put;
	new_bucket->value = value;
	new_bucket->next_bucket = NULL;
	new_bucket->prev_bucket = prev_bucket;

	prev_bucket->next_bucket = new_bucket;
	
	//printf("static_hash_table_put:: element created and put successfully: (%s, %d)\n", new_bucket->key, new_bucket->value); 
	
	return h_table;
}
示例#23
0
void Person::set_recipient_pub(BIGNUM *_B) {
  B = BN_dup(_B);
  calculate_hash();
}
示例#24
0
static int
p12_store(hx509_context context,
	  hx509_certs certs, void *data, int flags, hx509_lock lock)
{
    struct ks_pkcs12 *p12 = data;
    PKCS12_PFX pfx;
    PKCS12_AuthenticatedSafe as;
    PKCS12_OctetString asdata;
    size_t size;
    int ret;

    memset(&as, 0, sizeof(as));
    memset(&pfx, 0, sizeof(pfx));

    ret = hx509_certs_iter_f(context, p12->certs, store_func, &as);
    if (ret)
	goto out;

    ASN1_MALLOC_ENCODE(PKCS12_AuthenticatedSafe, asdata.data, asdata.length,
		       &as, &size, ret);
    free_PKCS12_AuthenticatedSafe(&as);
    if (ret)
	return ret;

    ret = der_parse_hex_heim_integer("03", &pfx.version);
    if (ret) {
	free(asdata.data);
	goto out;
    }

    pfx.authSafe.content = calloc(1, sizeof(*pfx.authSafe.content));

    ASN1_MALLOC_ENCODE(PKCS12_OctetString,
		       pfx.authSafe.content->data,
		       pfx.authSafe.content->length,
		       &asdata, &size, ret);
    free(asdata.data);
    if (ret)
	goto out;

    ret = der_copy_oid(&asn1_oid_id_pkcs7_data, &pfx.authSafe.contentType);
    if (ret)
	goto out;

    ASN1_MALLOC_ENCODE(PKCS12_PFX, asdata.data, asdata.length,
		       &pfx, &size, ret);
    if (ret)
	goto out;

#if 0
    const struct _hx509_password *pw;

    pw = _hx509_lock_get_passwords(lock);
    if (pw != NULL) {
	pfx.macData = calloc(1, sizeof(*pfx.macData));
	if (pfx.macData == NULL) {
	    ret = ENOMEM;
	    hx509_set_error_string(context, 0, ret, "malloc out of memory");
	    return ret;
	}
	if (pfx.macData == NULL) {
	    free(asdata.data);
	    goto out;
	}
    }
    ret = calculate_hash(&aspath, pw, pfx.macData);
#endif

    rk_dumpdata(p12->fn, asdata.data, asdata.length);
    free(asdata.data);

out:
    free_PKCS12_AuthenticatedSafe(&as);
    free_PKCS12_PFX(&pfx);

    return ret;
}
示例#25
0
int fit_list_images(void *fit, int images_offset) {
	int node;
	int count;

	const char *description;

	for(count = 0,node = fdt_first_subnode(fit, images_offset); node >= 0; node = fdt_next_subnode(fit, node), count++) {
		
		printf("\n  === Image (%d) - %s ===\n", count, fdt_get_name(fit, node, NULL));

		description = fdt_getprop(fit, node, "description", NULL);
		if(!description) {
			description = "Unavailable";
		}

		const char *type = fdt_getprop(fit, node, "type", NULL);
		const char *compression = fdt_getprop(fit, node, "compression", NULL);
		int data_len = 0;
		const void *data = fdt_getprop(fit, node, "data", &data_len);
		char *length = "Unavailable";
		char len_buf[32];
		if(data) {
			snprintf(len_buf, 32, "%d", data_len);
			length = len_buf;
		}

		const char *arch = fdt_getprop(fit, node, "arch", NULL);
		const char *os = fdt_getprop(fit, node, "os", NULL);
		
		const fdt32_t *load_addr = fdt_getprop(fit, node, "load", NULL);
		int32_t load = 0;
		if(load_addr) {
			load = fdt32_to_cpu(*load_addr);
		}

		const fdt32_t *entry_addr = fdt_getprop(fit, node, "entry", NULL);
		int32_t entry = 0;
		if(entry_addr) {
			entry = fdt32_to_cpu(*entry_addr);
		}
   
		printf("  Description   : %s\n", description);
		printf("  Type          : %s\n", type);
		printf("  Compression   : %s\n", compression);
		printf("  Length (bytes): %s\n", length);
		if(arch) {
		printf("  Architecture  : %s\n", arch);
		}
		if(os) {
			printf("  OS            : %s\n", os);
		}
		if(load_addr) {
			printf("  Load Address  : 0x%08x\n", load);
		}

		if(entry_addr) {
			printf("  Entry Address : 0x%08x\n", entry);
		}

		// Check all hashes.
		int hash_node;
		int hash_count = 0;
		for(hash_count = 0, hash_node = fdt_first_subnode(fit, node); 
			hash_node >= 0; hash_node = fdt_next_subnode(fit, hash_node), hash_count++) {
			
			printf("  === Hash %d ===\n", hash_count);
	
			const char *algo = fdt_getprop(fit, hash_node, "algo", NULL);
			int val_len;
			const unsigned char *value = fdt_getprop(fit, hash_node, "value", &val_len);

			char digest[20*2+2];
			char val[8];
			int i;

			strcpy(digest, "");

			for(i = 0; i < val_len; i++) {
				sprintf(val, "%02x", value[i]);
				strcat(digest, val);
			}

			digest[2*val_len] = '\0';

			printf("    Algorithm   : %s\n", algo);
			printf("    Digest      : %s\n", digest);

			calculate_hash(data, data_len, algo, digest, &i);

			char *verify = "FAILED";

			if(!memcmp(value, digest, val_len)) {
				verify = "OK";
			}

			printf("    Verify      : %s\n", verify);
		}
	}
}