diff options
author | Christian Blättler <blatc2@bfh.ch> | 2024-04-18 16:15:47 +0200 |
---|---|---|
committer | Christian Blättler <blatc2@bfh.ch> | 2024-04-19 10:52:58 +0200 |
commit | 2c961a557b9b59963a0456fc2713eea361b8e653 (patch) | |
tree | d277765b58ad15db99008765936627c91371c2d7 | |
parent | aa7793b28368c406b2b9043d33f9af203c0f513f (diff) |
check hash before inserting
-rw-r--r-- | src/backenddb/pg_insert_token_family_key.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/backenddb/pg_insert_token_family_key.c b/src/backenddb/pg_insert_token_family_key.c index 849bdc13..b13c8079 100644 --- a/src/backenddb/pg_insert_token_family_key.c +++ b/src/backenddb/pg_insert_token_family_key.c @@ -37,15 +37,20 @@ TMH_PG_insert_token_family_key (void *cls, { struct PostgresClosure *pg = cls; const char *cipher = NULL; - // struct GNUNET_HashCode pub_hash; + struct GNUNET_HashCode pub_hash; switch (pub->public_key.cipher) { case GNUNET_CRYPTO_BSA_RSA: cipher = "rsa"; + GNUNET_CRYPTO_rsa_public_key_hash (pub->public_key.details.rsa_public_key, + &pub_hash); break; case GNUNET_CRYPTO_BSA_CS: cipher = "cs"; + GNUNET_CRYPTO_hash (&pub->public_key.details.cs_public_key, + sizeof (pub->public_key.details.cs_public_key), + &pub_hash); break; case GNUNET_CRYPTO_BSA_INVALID: /* case listed to make compilers happy */ @@ -64,13 +69,10 @@ TMH_PG_insert_token_family_key (void *cls, }; GNUNET_assert (pub->public_key.cipher == priv->private_key.cipher); - // TODO: Ensure pub->public_key.pub_key_hash matches the actual public key - // GNUNET_CRYPTO_hash (res, - // len, - // &bpk->pub_key_hash); - // GNUNET_assert (0 == - // GNUNET_memcmp (&pub_hash, - // &pub->public_key.)); + + GNUNET_assert (0 == + GNUNET_memcmp (&pub_hash, + &pub->public_key.pub_key_hash)); GNUNET_assert (! GNUNET_TIME_absolute_is_zero ( valid_after.abs_time)); GNUNET_assert (! GNUNET_TIME_absolute_is_zero ( |