コード例 #1
0
/**
 * \ingroup Core_Signature
 *
 * Verify a subkey signature.
 *
 * \param key The public key whose subkey was signed.
 * \param subkey The subkey of the public key that was signed.
 * \param sig The signature.
 * \param signer The public key of the signer.
 * \param raw_packet The raw signature packet.
 * \return 1 if OK; else 0
 */
unsigned
pgp_check_subkey_sig(const pgp_pubkey_t *key,
			   const pgp_pubkey_t *subkey,
			   const pgp_sig_t *sig,
			   const pgp_pubkey_t *signer,
			   const uint8_t *raw_packet)
{
	pgp_hash_t	hash;
	unsigned	ret;

	init_key_sig(&hash, sig, key);
	hash_add_key(&hash, subkey);
	ret = finalise_sig(&hash, sig, signer, raw_packet);
	return ret;
}
コード例 #2
0
ファイル: quickhash.c プロジェクト: Jan-E/quickhash
/**
 * Adds a new element to the hash with a value index
 *
 * Parameters:
 * - hash: A valid quickhash
 * - key: The key
 * - value_idx: The index for the associated value into the value store.
 *
 * Returns:
 * - 1 if the element was added or 0 if the element couldn't be added
 */
int qhi_hash_add_with_index(qhi *hash, qhv key, uint32_t value_index)
{
	uint32_t idx;
	qhl     *list;

	// obtain the hashed key, and the bucket list for the hashed key
	idx = qhi_set_hash(hash, key);
	list = &(hash->bucket_list[idx]);

	// check if we already have the key in the list if requested
	if (hash->options->check_for_dupes && find_bucket_from_list(hash, list, key, NULL)) {
		return 0;
	}

	return qhi_add_entry_to_list(hash, list, hash_add_key(hash, key), value_index);
}
コード例 #3
0
ファイル: quickhash.c プロジェクト: Jan-E/quickhash
/**
 * Adds a new element, or updates the value if the key already is part of the hash
 *
 * Parameters:
 * - hash: A valid quickhash
 * - key: The key
 * - value: The value
 *
 * Returns:
 * - 1 if the element is part of the hash and was updated, 2 if the element was
 *   added or 0 if an error occurred.
 */
int qhi_hash_set(qhi *hash, qhv key, qhv value)
{
	uint32_t idx;
	qhl     *list;
	qhb     *bucket;

	// obtain the hashed key, and the bucket list for the hashed key
	idx = qhi_set_hash(hash, key);
	list = &(hash->bucket_list[idx]);

	// check if we already have the key in the list if requested
	if (find_bucket_from_list(hash, list, key, &bucket)) {
		// update
		return qhi_update_value_in_bucket(hash, bucket, value);
	} else {
		// add
		return qhi_add_entry_to_list(hash, list, hash_add_key(hash, key), hash_add_value(hash, value)) ? 2 : 0;
	}
	return 0;
}
コード例 #4
0
ファイル: quickhash.c プロジェクト: Jan-E/quickhash
/**
 * Adds a new element to the hash
 *
 * Parameters:
 * - hash: A valid quickhash
 * - key: The key
 *
 * Returns:
 * - 1 if the element was added or 0 if the element couldn't be added
 */
int qhi_set_add(qhi *hash, qhv key)
{
	uint32_t idx;
	qhl     *list;
	qhb  *bucket;

	// obtain the hashed key, and the bucket list for the hashed key
	idx = qhi_set_hash(hash, key);
	list = &(hash->bucket_list[idx]);

	// check if we already have the key in the list if requested
	if (hash->options->check_for_dupes && find_bucket_from_list(hash, list, key, NULL)) {
		return 0;
	}

	// create new bucket
	bucket = qhb_create(hash);
	if (!bucket) {
		return 0;
	}
	bucket->key = hash_add_key(hash, key);
	bucket->next = NULL;

	// add bucket to list
	if (list->head == NULL) {
		// first bucket in list
		list->head = bucket;
		list->tail = bucket;
	} else {
		// following bucked in a list
		list->tail->next = bucket;
		list->tail = bucket;
#if DEBUG
		hash->collisions++;
#endif
	}
	hash->element_count++;
	list->size++;
	return 1;
}