diff options
author | szengel <szengel@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-07-04 15:46:47 +0000 |
---|---|---|
committer | szengel <szengel@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-07-04 15:46:47 +0000 |
commit | 799429793ffaf088a164e9c4d5f34b228ce98093 (patch) | |
tree | 960400a3d5fd9d11ee320111caddba8a0a192d5a /src/regex/regex.c | |
parent | c643a7e1cbaf5d7d5c87f68c300baa0b92d18be0 (diff) |
regex: actually checking the proof, fixes
git-svn-id: https://gnunet.org/svn/gnunet@22482 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/regex/regex.c')
-rw-r--r-- | src/regex/regex.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/regex/regex.c b/src/regex/regex.c index a1619ef28b..1290569ccd 100644 --- a/src/regex/regex.c +++ b/src/regex/regex.c @@ -287,7 +287,8 @@ state_compare (const void *a, const void *b) * Get all edges leaving state 's'. * * @param s state. - * @param edges all edges leaving 's'. + * @param edges all edges leaving 's', expected to be allocated and have enough + * space for s->transitions_count elements. * * @return number of edges. */ @@ -2471,7 +2472,7 @@ GNUNET_REGEX_get_canonical_regex (struct GNUNET_REGEX_Automaton *a) /** * Get the first key for the given 'input_string'. This hashes the first x bits - * of the 'input_strings'. + * of the 'input_string'. * * @param input_string string. * @param string_len length of the 'input_string'. @@ -2480,9 +2481,9 @@ GNUNET_REGEX_get_canonical_regex (struct GNUNET_REGEX_Automaton *a) * @return number of bits of 'input_string' that have been consumed * to construct the key */ -unsigned int -GNUNET_REGEX_get_first_key (const char *input_string, unsigned int string_len, - struct GNUNET_HashCode *key) +size_t +GNUNET_REGEX_get_first_key (const char *input_string, size_t string_len, + struct GNUNET_HashCode * key) { unsigned int size; @@ -2503,15 +2504,17 @@ GNUNET_REGEX_get_first_key (const char *input_string, unsigned int string_len, /** * Check if the given 'proof' matches the given 'key'. * - * @param proof partial regex - * @param key hash + * @param proof partial regex of a state. + * @param key hash of a state. * - * @return GNUNET_OK if the proof is valid for the given key + * @return GNUNET_OK if the proof is valid for the given key. */ int GNUNET_REGEX_check_proof (const char *proof, const struct GNUNET_HashCode *key) { - return GNUNET_OK; + struct GNUNET_HashCode key_check; + GNUNET_CRYPTO_hash (proof, strlen (proof), &key_check); + return (0 == GNUNET_CRYPTO_hash_cmp (key, &key_check)) ? GNUNET_OK : GNUNET_NO; } |