mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
GNUTLS: Cleanup fingerprint generation
Removes intermediate buffer, properly check return values
This commit is contained in:
parent
a888b33274
commit
292cefd2b5
1 changed files with 2 additions and 5 deletions
|
@ -608,7 +608,6 @@ static int
|
||||||
make_certfp(gnutls_x509_crt_t cert, uint8_t certfp[RB_SSL_CERTFP_LEN], int method)
|
make_certfp(gnutls_x509_crt_t cert, uint8_t certfp[RB_SSL_CERTFP_LEN], int method)
|
||||||
{
|
{
|
||||||
gnutls_digest_algorithm_t algo;
|
gnutls_digest_algorithm_t algo;
|
||||||
uint8_t digest[RB_SSL_CERTFP_LEN * 2];
|
|
||||||
size_t digest_size;
|
size_t digest_size;
|
||||||
bool spki = false;
|
bool spki = false;
|
||||||
int len;
|
int len;
|
||||||
|
@ -637,7 +636,7 @@ make_certfp(gnutls_x509_crt_t cert, uint8_t certfp[RB_SSL_CERTFP_LEN], int metho
|
||||||
|
|
||||||
if (!spki)
|
if (!spki)
|
||||||
{
|
{
|
||||||
if (gnutls_x509_crt_get_fingerprint(cert, algo, digest, &digest_size) < 0)
|
if (gnutls_x509_crt_get_fingerprint(cert, algo, certfp, &digest_size) != 0)
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -667,7 +666,7 @@ make_certfp(gnutls_x509_crt_t cert, uint8_t certfp[RB_SSL_CERTFP_LEN], int metho
|
||||||
|
|
||||||
if (der_pubkey)
|
if (der_pubkey)
|
||||||
{
|
{
|
||||||
if (gnutls_hash_fast(algo, der_pubkey, der_pubkey_len, digest) != 0)
|
if (gnutls_hash_fast(algo, der_pubkey, der_pubkey_len, certfp) != 0)
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
rb_free(der_pubkey);
|
rb_free(der_pubkey);
|
||||||
|
@ -678,8 +677,6 @@ make_certfp(gnutls_x509_crt_t cert, uint8_t certfp[RB_SSL_CERTFP_LEN], int metho
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len)
|
|
||||||
memcpy(certfp, digest, len);
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue