Add a return value to hasher_t.allocate_hash()
This commit is contained in:
@@ -1490,12 +1490,13 @@ end:
|
||||
}
|
||||
/* create certificate hash */
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
||||
if (hasher == NULL)
|
||||
if (!hasher ||
|
||||
!hasher->allocate_hash(hasher, this->encoding, &this->encoding_hash))
|
||||
{
|
||||
DESTROY_IF(hasher);
|
||||
DBG1(DBG_ASN, " unable to create hash of certificate, SHA1 not supported");
|
||||
return FALSE;
|
||||
}
|
||||
hasher->allocate_hash(hasher, this->encoding, &this->encoding_hash);
|
||||
hasher->destroy(hasher);
|
||||
}
|
||||
return success;
|
||||
@@ -2344,11 +2345,12 @@ static bool generate(private_x509_cert_t *cert, certificate_t *sign_cert,
|
||||
asn1_bitstring("c", cert->signature));
|
||||
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
||||
if (!hasher)
|
||||
if (!hasher ||
|
||||
!hasher->allocate_hash(hasher, cert->encoding, &cert->encoding_hash))
|
||||
{
|
||||
DESTROY_IF(hasher);
|
||||
return FALSE;
|
||||
}
|
||||
hasher->allocate_hash(hasher, cert->encoding, &cert->encoding_hash);
|
||||
hasher->destroy(hasher);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -159,22 +159,24 @@ static chunk_t build_requestList(private_x509_ocsp_request_t *this)
|
||||
enumerator_t *enumerator;
|
||||
|
||||
issuer = cert->get_subject(cert);
|
||||
hasher->allocate_hash(hasher, issuer->get_encoding(issuer),
|
||||
&issuerNameHash);
|
||||
hasher->destroy(hasher);
|
||||
|
||||
enumerator = this->candidates->create_enumerator(this->candidates);
|
||||
while (enumerator->enumerate(enumerator, &x509))
|
||||
if (hasher->allocate_hash(hasher, issuer->get_encoding(issuer),
|
||||
&issuerNameHash))
|
||||
{
|
||||
chunk_t request, serialNumber;
|
||||
enumerator = this->candidates->create_enumerator(
|
||||
this->candidates);
|
||||
while (enumerator->enumerate(enumerator, &x509))
|
||||
{
|
||||
chunk_t request, serialNumber;
|
||||
|
||||
serialNumber = x509->get_serial(x509);
|
||||
request = build_Request(this, issuerNameHash, issuerKeyHash,
|
||||
serialNumber);
|
||||
list = chunk_cat("mm", list, request);
|
||||
serialNumber = x509->get_serial(x509);
|
||||
request = build_Request(this, issuerNameHash,
|
||||
issuerKeyHash, serialNumber);
|
||||
list = chunk_cat("mm", list, request);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
chunk_free(&issuerNameHash);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
chunk_free(&issuerNameHash);
|
||||
hasher->destroy(hasher);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -201,19 +201,22 @@ METHOD(ocsp_response_t, get_status, cert_validation_t,
|
||||
/* check issuerNameHash, if available */
|
||||
else if (response->issuerNameHash.ptr)
|
||||
{
|
||||
id = issuercert->get_subject(issuercert);
|
||||
hasher = lib->crypto->create_hasher(lib->crypto,
|
||||
hasher_algorithm_from_oid(response->hashAlgorithm));
|
||||
if (!hasher)
|
||||
if (!hasher ||
|
||||
!hasher->allocate_hash(hasher, id->get_encoding(id), &hash))
|
||||
{
|
||||
DESTROY_IF(hasher);
|
||||
continue;
|
||||
}
|
||||
id = issuercert->get_subject(issuercert);
|
||||
hasher->allocate_hash(hasher, id->get_encoding(id), &hash);
|
||||
hasher->destroy(hasher);
|
||||
if (!chunk_equals(hash, response->issuerNameHash))
|
||||
{
|
||||
free(hash.ptr);
|
||||
continue;
|
||||
}
|
||||
free(hash.ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user