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-18 16:15:47 +0200 |
commit | 0d296088b75a30dbe70552db48643ced38a9659f (patch) | |
tree | f039e8f52f2ef82931ecf329f8baf2604d4daf34 /src | |
parent | 4ff7bb2573714f37d7519ab38a143bf3241e766a (diff) |
check hash before inserting
Diffstat (limited to 'src')
-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 ( |