Add a return value to hasher_t.allocate_hash()
This commit is contained in:
@@ -203,18 +203,15 @@ METHOD(hasher_t, get_hash, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(hasher_t, allocate_hash, void,
|
||||
METHOD(hasher_t, allocate_hash, bool,
|
||||
private_pkcs11_hasher_t *this, chunk_t chunk, chunk_t *hash)
|
||||
{
|
||||
if (hash)
|
||||
{
|
||||
*hash = chunk_alloc(this->size);
|
||||
get_hash(this, chunk, hash->ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
get_hash(this, chunk, NULL);
|
||||
return get_hash(this, chunk, hash->ptr);
|
||||
}
|
||||
return get_hash(this, chunk, NULL);
|
||||
}
|
||||
|
||||
METHOD(hasher_t, destroy, void,
|
||||
|
||||
@@ -266,13 +266,15 @@ METHOD(private_key_t, sign, bool,
|
||||
}
|
||||
if (hash_alg != HASH_UNKNOWN)
|
||||
{
|
||||
hasher_t *hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
|
||||
if (!hasher)
|
||||
hasher_t *hasher;
|
||||
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
|
||||
if (!hasher || !hasher->allocate_hash(hasher, data, &hash))
|
||||
{
|
||||
DESTROY_IF(hasher);
|
||||
this->lib->f->C_CloseSession(session);
|
||||
return FALSE;
|
||||
}
|
||||
hasher->allocate_hash(hasher, data, &hash);
|
||||
hasher->destroy(hasher);
|
||||
data = hash;
|
||||
}
|
||||
|
||||
@@ -235,13 +235,15 @@ METHOD(public_key_t, verify, bool,
|
||||
}
|
||||
if (hash_alg != HASH_UNKNOWN)
|
||||
{
|
||||
hasher_t *hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
|
||||
if (!hasher)
|
||||
hasher_t *hasher;
|
||||
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, hash_alg);
|
||||
if (!hasher || !hasher->allocate_hash(hasher, data, &hash))
|
||||
{
|
||||
DESTROY_IF(hasher);
|
||||
this->lib->f->C_CloseSession(session);
|
||||
return FALSE;
|
||||
}
|
||||
hasher->allocate_hash(hasher, data, &hash);
|
||||
hasher->destroy(hasher);
|
||||
data = hash;
|
||||
}
|
||||
@@ -374,12 +376,12 @@ static bool fingerprint_ecdsa(private_pkcs11_public_key_t *this,
|
||||
return FALSE;
|
||||
}
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
||||
if (!hasher)
|
||||
if (!hasher || !hasher->allocate_hash(hasher, asn1, fp))
|
||||
{
|
||||
DESTROY_IF(hasher);
|
||||
chunk_clear(&asn1);
|
||||
return FALSE;
|
||||
}
|
||||
hasher->allocate_hash(hasher, asn1, fp);
|
||||
hasher->destroy(hasher);
|
||||
chunk_clear(&asn1);
|
||||
lib->encoding->cache(lib->encoding, type, this, *fp);
|
||||
|
||||
Reference in New Issue
Block a user