botan: Remove unnecessary nested blocks and simplify keyid allocation
This commit is contained in:
@@ -159,25 +159,15 @@ bool botan_get_fingerprint(botan_pubkey_t pubkey, void *cache,
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case KEYID_PUBKEY_SHA1:
|
case KEYID_PUBKEY_SHA1:
|
||||||
{
|
|
||||||
/* subjectPublicKey -> use botan_pubkey_fingerprint() */
|
/* subjectPublicKey -> use botan_pubkey_fingerprint() */
|
||||||
fp->len = 0;
|
*fp = chunk_alloc(HASH_SIZE_SHA1);
|
||||||
if (botan_pubkey_fingerprint(pubkey, "SHA-1", NULL, &fp->len)
|
|
||||||
!= BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*fp = chunk_alloc(fp->len);
|
|
||||||
if (botan_pubkey_fingerprint(pubkey, "SHA-1", fp->ptr, &fp->len))
|
if (botan_pubkey_fingerprint(pubkey, "SHA-1", fp->ptr, &fp->len))
|
||||||
{
|
{
|
||||||
chunk_free(fp);
|
chunk_free(fp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case KEYID_PUBKEY_INFO_SHA1:
|
case KEYID_PUBKEY_INFO_SHA1:
|
||||||
{
|
|
||||||
/* subjectPublicKeyInfo -> use botan_pubkey_export(), then hash */
|
/* subjectPublicKeyInfo -> use botan_pubkey_export(), then hash */
|
||||||
if (!botan_get_encoding(pubkey, PUBKEY_SPKI_ASN1_DER, &key))
|
if (!botan_get_encoding(pubkey, PUBKEY_SPKI_ASN1_DER, &key))
|
||||||
{
|
{
|
||||||
@@ -196,7 +186,6 @@ bool botan_get_fingerprint(botan_pubkey_t pubkey, void *cache,
|
|||||||
hasher->destroy(hasher);
|
hasher->destroy(hasher);
|
||||||
chunk_free(&key);
|
chunk_free(&key);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user