diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-09 11:59:33 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-09 11:59:33 +0000 |
commit | 0070016a317fecd96bd3dde6ff5670c9a8b81d00 (patch) | |
tree | 2dd6829ab88c37f1d92c67eab5b7f48002e8cd57 /src/util | |
parent | 6a69a20d6847a6a359e3b8eb289bf351fed0651a (diff) | |
download | gnunet-0070016a317fecd96bd3dde6ff5670c9a8b81d00.tar.gz gnunet-0070016a317fecd96bd3dde6ff5670c9a8b81d00.zip |
add GNUNET_CRYPTO_rsa_public_key_hash
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/crypto_rsa.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index d7bcd1175..66082fc9d 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -299,7 +299,7 @@ GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_rsa_PublicKey *key) | |||
299 | */ | 299 | */ |
300 | size_t | 300 | size_t |
301 | GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_rsa_PublicKey *key, | 301 | GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_rsa_PublicKey *key, |
302 | char **buffer) | 302 | char **buffer) |
303 | { | 303 | { |
304 | size_t n; | 304 | size_t n; |
305 | char *b; | 305 | char *b; |
@@ -320,6 +320,28 @@ GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_rsa_PublicKey *k | |||
320 | 320 | ||
321 | 321 | ||
322 | /** | 322 | /** |
323 | * Compute hash over the public key. | ||
324 | * | ||
325 | * @param key public key to hash | ||
326 | * @param hc where to store the hash code | ||
327 | */ | ||
328 | void | ||
329 | GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_rsa_PublicKey *key, | ||
330 | struct GNUNET_HashCode *hc) | ||
331 | { | ||
332 | char *buf; | ||
333 | size_t buf_size; | ||
334 | |||
335 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (key, | ||
336 | &buf); | ||
337 | GNUNET_CRYPTO_hash (buf, | ||
338 | buf_size, | ||
339 | hc); | ||
340 | GNUNET_free (buf); | ||
341 | } | ||
342 | |||
343 | |||
344 | /** | ||
323 | * Decode the public key from the data-format back | 345 | * Decode the public key from the data-format back |
324 | * to the "normal", internal format. | 346 | * to the "normal", internal format. |
325 | * | 347 | * |
@@ -329,7 +351,7 @@ GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_rsa_PublicKey *k | |||
329 | */ | 351 | */ |
330 | struct GNUNET_CRYPTO_rsa_PublicKey * | 352 | struct GNUNET_CRYPTO_rsa_PublicKey * |
331 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, | 353 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, |
332 | size_t len) | 354 | size_t len) |
333 | { | 355 | { |
334 | struct GNUNET_CRYPTO_rsa_PublicKey *key; | 356 | struct GNUNET_CRYPTO_rsa_PublicKey *key; |
335 | gcry_mpi_t n; | 357 | gcry_mpi_t n; |