From c07ae5c8d29202466f066e4dcddbfd091513db7c Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Thu, 5 Nov 2020 21:20:38 +0100 Subject: additional abstraction for identity keys Signed-off-by: TheJackiMonster --- src/include/gnunet_identity_service.h | 215 ++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) (limited to 'src/include/gnunet_identity_service.h') diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 17714fec4..8084a3a98 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h @@ -137,6 +137,33 @@ struct GNUNET_IDENTITY_PublicKey }; +/** + * An identity signature as per LSD0001. + */ +struct GNUNET_IDENTITY_Signature +{ + /** + * Type of signature. + * Defined by the GNS zone type value. + * In NBO. + */ + uint32_t type; + + union + { + /** + * An ECDSA signature + */ + struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature; + + /** + * AN EdDSA signature + */ + struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; + }; +}; + + /** * Handle for an operation with the identity service. */ @@ -378,6 +405,194 @@ ssize_t GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); +/** + * Get the compacted length of a #GNUNET_IDENTITY_Signature. + * Compacted means that it returns the minimum number of bytes this + * signature is long, as opposed to the union structure inside + * #GNUNET_IDENTITY_Signature. + * Useful for compact serializations. + * + * @param sig the signature. + * @return -1 on error, else the compacted length of the signature. + */ +ssize_t +GNUNET_IDENTITY_signature_get_length (const struct GNUNET_IDENTITY_Signature *sig); + + +/** + * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer. + * The buffer has to contain at least the compacted length of + * a #GNUNET_IDENTITY_PublicKey bytes. + * If the buffer is too small, the function returns -1 as error. + * If the buffer does not contain a valid key, it returns -2 as error. + * + * @param key the key + * @param buffer the buffer + * @param len the length of buffer + * @return -1 or -2 on error, else the amount of bytes read from the buffer + */ +ssize_t +GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, + const void* buffer, + size_t len); + + +/** + * Writes a #GNUNET_IDENTITY_PublicKey to a compact buffer. + * The buffer requires space for at least the compacted length of + * a #GNUNET_IDENTITY_PublicKey in bytes. + * If the buffer is too small, the function returns -1 as error. + * If the key is not valid, it returns -2 as error. + * + * @param key the key + * @param buffer the buffer + * @param len the length of buffer + * @return -1 or -2 on error, else the amount of bytes written to the buffer + */ +ssize_t +GNUNET_IDENTITY_write_key_to_buffer (const struct GNUNET_IDENTITY_PublicKey *key, + void* buffer, + size_t len); + + +/** + * @brief Sign a given block. + * + * The @a purpose data is the beginning of the data of which the signature is + * to be created. The `size` field in @a purpose must correctly indicate the + * number of bytes of the data structure, including its header. If possible, + * use #GNUNET_IDENTITY_private_key_sign() instead of this function. + * + * @param priv private key to use for the signing + * @param purpose what to sign (size, purpose) + * @param[out] sig where to write the signature + * @return #GNUNET_SYSERR on error, #GNUNET_OK on success + */ +int +GNUNET_IDENTITY_private_key_sign_ (const struct GNUNET_IDENTITY_PrivateKey *priv, + const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, + struct GNUNET_IDENTITY_Signature *sig); + + +/** + * @brief Sign a given block with #GNUNET_IDENTITY_PrivateKey. + * + * The @a ps data must be a fixed-size struct for which the signature is to be + * created. The `size` field in @a ps->purpose must correctly indicate the + * number of bytes of the data structure, including its header. + * + * @param priv private key to use for the signing + * @param ps packed struct with what to sign, MUST begin with a purpose + * @param[out] sig where to write the signature + */ +#define GNUNET_IDENTITY_private_key_sign(priv,ps,sig) do { \ + /* check size is set correctly */ \ + GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \ + /* check 'ps' begins with the purpose */ \ + GNUNET_static_assert (((void*) (ps)) == \ + ((void*) &(ps)->purpose)); \ + GNUNET_assert (GNUNET_OK == \ + GNUNET_IDENTITY_private_key_sign_ (priv, \ + &(ps)->purpose, \ + sig)); \ +} while (0) + + +/** + * @brief Verify a given signature. + * + * The @a validate data is the beginning of the data of which the signature + * is to be verified. The `size` field in @a validate must correctly indicate + * the number of bytes of the data structure, including its header. If @a + * purpose does not match the purpose given in @a validate (the latter must be + * in big endian), signature verification fails. If possible, + * use #GNUNET_IDENTITY_public_key_verify() instead of this function (only if @a validate + * is not fixed-size, you must use this function directly). + * + * @param purpose what is the purpose that the signature should have? + * @param validate block to validate (size, purpose, data) + * @param sig signature that is being validated + * @param pub public key of the signer + * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid + */ +int +GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, + const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, + const struct GNUNET_IDENTITY_Signature *sig, + const struct GNUNET_IDENTITY_PublicKey *pub); + + +/** + * @brief Verify a given signature with #GNUNET_IDENTITY_PublicKey. + * + * The @a ps data must be a fixed-size struct for which the signature is to be + * created. The `size` field in @a ps->purpose must correctly indicate the + * number of bytes of the data structure, including its header. + * + * @param purp purpose of the signature, must match 'ps->purpose.purpose' + * (except in host byte order) + * @param ps packed struct with what to sign, MUST begin with a purpose + * @param sig where to read the signature from + * @param pub public key to use for the verifying + */ +#define GNUNET_IDENTITY_public_key_verify(purp,ps,sig,pub) ({ \ + /* check size is set correctly */ \ + GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ + /* check 'ps' begins with the purpose */ \ + GNUNET_static_assert (((void*) (ps)) == \ + ((void*) &(ps)->purpose)); \ + GNUNET_IDENTITY_public_key_verify_(purp, \ + &(ps)->purpose, \ + sig, \ + pub); \ + }) + + +/** + * Encrypt a block with #GNUNET_IDENTITY_PublicKey and derives a + * #GNUNET_CRYPTO_EcdhePublicKey which is required for decryption + * using ecdh to derive a symmetric key. + * + * @param block the block to encrypt + * @param size the size of the @a block + * @param pub public key to use for ecdh + * @param ecc where to write the ecc public key + * @param result the output parameter in which to store the encrypted result + * can be the same or overlap with @c block + * @returns the size of the encrypted block, -1 for errors. + * Due to the use of CFB and therefore an effective stream cipher, + * this size should be the same as @c len. + */ +ssize_t +GNUNET_IDENTITY_public_key_encrypt(const void *block, + size_t size, + const struct GNUNET_IDENTITY_PublicKey *pub, + struct GNUNET_CRYPTO_EcdhePublicKey *ecc, + void *result); + + +/** + * Decrypt a given block with #GNUNET_IDENTITY_PrivateKey and a given + * #GNUNET_CRYPTO_EcdhePublicKey using ecdh to derive a symmetric key. + * + * @param block the data to decrypt, encoded as returned by encrypt + * @param size the size of the @a block to decrypt + * @param priv private key to use for ecdh + * @param ecc the ecc public key + * @param result address to store the result at + * can be the same or overlap with @c block + * @return -1 on failure, size of decrypted block on success. + * Due to the use of CFB and therefore an effective stream cipher, + * this size should be the same as @c size. + */ +ssize_t +GNUNET_IDENTITY_private_key_decrypt(const void *block, + size_t size, + const struct GNUNET_IDENTITY_PrivateKey *priv, + const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, + void *result); + + /** * Creates a (Base32) string representation of the public key. * The resulting string encodes a compacted representation of the key. -- cgit v1.2.3 From 4d10374ff7762d64c387b70edf9f31397eab4123 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Fri, 6 Nov 2020 10:31:35 +0100 Subject: added compact reading and writing for signatures Signed-off-by: TheJackiMonster --- po/POTFILES.in | 1 + src/identity/identity_api.c | 64 +++++++++++++++++++++++++++-------- src/include/gnunet_identity_service.h | 60 +++++++++++++++++++++++++------- 3 files changed, 98 insertions(+), 27 deletions(-) (limited to 'src/include/gnunet_identity_service.h') diff --git a/po/POTFILES.in b/po/POTFILES.in index 6aab56d14..1f577e139 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -523,5 +523,6 @@ src/vpn/vpn_api.c src/zonemaster/gnunet-service-zonemaster-monitor.c src/zonemaster/gnunet-service-zonemaster.c src/fs/fs_api.h +src/include/gnunet_identity_service.h src/testbed/testbed_api.h src/testbed/testbed_api_operations.h diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index a277d8877..45c18b95c 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c @@ -990,6 +990,40 @@ GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key) } +ssize_t +GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, + const void* buffer, + size_t len) +{ + if (len < sizeof (key->type)) + return -1; + GNUNET_memcpy(&(key->type), buffer, sizeof (key->type)); + const ssize_t length = GNUNET_IDENTITY_key_get_length(key); + if (len < length) + return -1; + if (length < 0) + return -2; + GNUNET_memcpy(&(key->ecdsa_key), buffer + sizeof (key->type), length - sizeof (key->type)); + return length; +} + + +ssize_t +GNUNET_IDENTITY_write_key_to_buffer (const struct GNUNET_IDENTITY_PublicKey *key, + void* buffer, + size_t len) +{ + const ssize_t length = GNUNET_IDENTITY_key_get_length(key); + if (len < length) + return -1; + if (length < 0) + return -2; + GNUNET_memcpy(buffer, &(key->type), sizeof (key->type)); + GNUNET_memcpy(buffer + sizeof (key->type), &(key->ecdsa_key), length - sizeof (key->type)); + return length; +} + + ssize_t GNUNET_IDENTITY_signature_get_length (const struct GNUNET_IDENTITY_Signature *sig) { @@ -1009,35 +1043,35 @@ GNUNET_IDENTITY_signature_get_length (const struct GNUNET_IDENTITY_Signature *si ssize_t -GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, - const void* buffer, - size_t len) +GNUNET_IDENTITY_read_signature_from_buffer (struct GNUNET_IDENTITY_Signature *sig, + const void* buffer, + size_t len) { - if (len < sizeof (key->type)) - return -1; - GNUNET_memcpy(&(key->type), buffer, sizeof (key->type)); - const ssize_t length = GNUNET_IDENTITY_key_get_length(key); + if (len < sizeof (sig->type)) + return -1; + GNUNET_memcpy(&(sig->type), buffer, sizeof (sig->type)); + const ssize_t length = GNUNET_IDENTITY_signature_get_length(sig); if (len < length) return -1; if (length < 0) - return -2; - GNUNET_memcpy(&(key->ecdsa_key), buffer + sizeof (key->type), length - sizeof (key->type)); + return -2; + GNUNET_memcpy(&(sig->ecdsa_signature), buffer + sizeof (sig->type), length - sizeof (sig->type)); return length; } ssize_t -GNUNET_IDENTITY_write_key_to_buffer (const struct GNUNET_IDENTITY_PublicKey *key, - void* buffer, - size_t len) +GNUNET_IDENTITY_write_signature_to_buffer (const struct GNUNET_IDENTITY_Signature *sig, + void* buffer, + size_t len) { - const ssize_t length = GNUNET_IDENTITY_key_get_length(key); + const ssize_t length = GNUNET_IDENTITY_signature_get_length(sig); if (len < length) return -1; if (length < 0) return -2; - GNUNET_memcpy(buffer, &(key->type), sizeof (key->type)); - GNUNET_memcpy(buffer + sizeof (key->type), &(key->ecdsa_key), length - sizeof (key->type)); + GNUNET_memcpy(buffer, &(sig->type), sizeof (sig->type)); + GNUNET_memcpy(buffer + sizeof (sig->type), &(sig->ecdsa_signature), length - sizeof (sig->type)); return length; } diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 8084a3a98..64799f195 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h @@ -405,6 +405,42 @@ ssize_t GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); +/** + * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer. + * The buffer has to contain at least the compacted length of + * a #GNUNET_IDENTITY_PublicKey in bytes. + * If the buffer is too small, the function returns -1 as error. + * If the buffer does not contain a valid key, it returns -2 as error. + * + * @param key the key + * @param buffer the buffer + * @param len the length of buffer + * @return -1 or -2 on error, else the amount of bytes read from the buffer + */ +ssize_t +GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, + const void* buffer, + size_t len); + + +/** + * Writes a #GNUNET_IDENTITY_PublicKey to a compact buffer. + * The buffer requires space for at least the compacted length of + * a #GNUNET_IDENTITY_PublicKey in bytes. + * If the buffer is too small, the function returns -1 as error. + * If the key is not valid, it returns -2 as error. + * + * @param key the key + * @param buffer the buffer + * @param len the length of buffer + * @return -1 or -2 on error, else the amount of bytes written to the buffer + */ +ssize_t +GNUNET_IDENTITY_write_key_to_buffer (const struct GNUNET_IDENTITY_PublicKey *key, + void* buffer, + size_t len); + + /** * Get the compacted length of a #GNUNET_IDENTITY_Signature. * Compacted means that it returns the minimum number of bytes this @@ -420,39 +456,39 @@ GNUNET_IDENTITY_signature_get_length (const struct GNUNET_IDENTITY_Signature *si /** - * Reads a #GNUNET_IDENTITY_PublicKey from a compact buffer. + * Reads a #GNUNET_IDENTITY_Signature from a compact buffer. * The buffer has to contain at least the compacted length of - * a #GNUNET_IDENTITY_PublicKey bytes. + * a #GNUNET_IDENTITY_Signature in bytes. * If the buffer is too small, the function returns -1 as error. * If the buffer does not contain a valid key, it returns -2 as error. * - * @param key the key + * @param sig the signature * @param buffer the buffer * @param len the length of buffer * @return -1 or -2 on error, else the amount of bytes read from the buffer */ ssize_t -GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, - const void* buffer, - size_t len); +GNUNET_IDENTITY_read_signature_from_buffer (struct GNUNET_IDENTITY_Signature *sig, + const void* buffer, + size_t len); /** - * Writes a #GNUNET_IDENTITY_PublicKey to a compact buffer. + * Writes a #GNUNET_IDENTITY_Signature to a compact buffer. * The buffer requires space for at least the compacted length of - * a #GNUNET_IDENTITY_PublicKey in bytes. + * a #GNUNET_IDENTITY_Signature in bytes. * If the buffer is too small, the function returns -1 as error. * If the key is not valid, it returns -2 as error. * - * @param key the key + * @param sig the signature * @param buffer the buffer * @param len the length of buffer * @return -1 or -2 on error, else the amount of bytes written to the buffer */ ssize_t -GNUNET_IDENTITY_write_key_to_buffer (const struct GNUNET_IDENTITY_PublicKey *key, - void* buffer, - size_t len); +GNUNET_IDENTITY_write_signature_to_buffer (const struct GNUNET_IDENTITY_Signature *sig, + void* buffer, + size_t len); /** -- cgit v1.2.3 From ca808598b9c28e1bb089d2d8cb7ec9332f2c0137 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Sun, 8 Nov 2020 01:57:15 +0100 Subject: fixed signature asserts Signed-off-by: TheJackiMonster --- src/include/gnunet_crypto_lib.h | 6 +++--- src/include/gnunet_identity_service.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/include/gnunet_identity_service.h') diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 03fb16a43..2bbf2b1e7 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h @@ -1700,7 +1700,7 @@ GNUNET_CRYPTO_eddsa_sign_ ( */ #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \ /* check size is set correctly */ \ - GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*ps)); \ + GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \ /* check 'ps' begins with the purpose */ \ GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ @@ -1747,7 +1747,7 @@ GNUNET_CRYPTO_ecdsa_sign_ ( */ #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \ /* check size is set correctly */ \ - GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \ + GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ /* check 'ps' begins with the purpose */ \ GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ @@ -1853,7 +1853,7 @@ GNUNET_CRYPTO_ecdsa_verify_ ( */ #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \ /* check size is set correctly */ \ - GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \ + GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ /* check 'ps' begins with the purpose */ \ GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 64799f195..66761e526 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h @@ -523,7 +523,7 @@ GNUNET_IDENTITY_private_key_sign_ (const struct GNUNET_IDENTITY_PrivateKey *priv */ #define GNUNET_IDENTITY_private_key_sign(priv,ps,sig) do { \ /* check size is set correctly */ \ - GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \ + GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ /* check 'ps' begins with the purpose */ \ GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ -- cgit v1.2.3 From 5306c3356854b535fe09654b270f06615bf94e94 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 10 Nov 2020 09:01:17 +0900 Subject: -fix signatures in revocation --- po/POTFILES.in | 102 ++++++++--------- src/identity/identity_api.c | 190 ++++++++++++++++++-------------- src/include/gnunet_identity_service.h | 89 ++++++++------- src/include/gnunet_revocation_service.h | 7 +- src/revocation/revocation_api.c | 57 +++++----- 5 files changed, 238 insertions(+), 207 deletions(-) (limited to 'src/include/gnunet_identity_service.h') diff --git a/po/POTFILES.in b/po/POTFILES.in index 1f577e139..35bd71771 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -10,21 +10,13 @@ src/arm/arm_monitor_api.c src/arm/gnunet-arm.c src/arm/gnunet-service-arm.c src/arm/mockup-service.c -src/ats-tests/ats-testing-experiment.c -src/ats-tests/ats-testing-log.c -src/ats-tests/ats-testing-preferences.c -src/ats-tests/ats-testing-traffic.c -src/ats-tests/ats-testing.c -src/ats-tests/gnunet-ats-sim.c -src/ats-tests/gnunet-solver-eval.c -src/ats-tool/gnunet-ats.c src/ats/ats_api_connectivity.c src/ats/ats_api_performance.c src/ats/ats_api_scanner.c src/ats/ats_api_scheduling.c src/ats/gnunet-ats-solver-eval.c -src/ats/gnunet-service-ats.c src/ats/gnunet-service-ats_addresses.c +src/ats/gnunet-service-ats.c src/ats/gnunet-service-ats_connectivity.c src/ats/gnunet-service-ats_normalization.c src/ats/gnunet-service-ats_performance.c @@ -33,6 +25,14 @@ src/ats/gnunet-service-ats_preferences.c src/ats/gnunet-service-ats_reservations.c src/ats/gnunet-service-ats_scheduling.c src/ats/plugin_ats_proportional.c +src/ats-tests/ats-testing.c +src/ats-tests/ats-testing-experiment.c +src/ats-tests/ats-testing-log.c +src/ats-tests/ats-testing-preferences.c +src/ats-tests/ats-testing-traffic.c +src/ats-tests/gnunet-ats-sim.c +src/ats-tests/gnunet-solver-eval.c +src/ats-tool/gnunet-ats.c src/auction/gnunet-auction-create.c src/auction/gnunet-auction-info.c src/auction/gnunet-auction-join.c @@ -50,8 +50,8 @@ src/cadet/cadet_api_list_peers.c src/cadet/cadet_api_list_tunnels.c src/cadet/cadet_test_lib.c src/cadet/desirability_table.c -src/cadet/gnunet-cadet-profiler.c src/cadet/gnunet-cadet.c +src/cadet/gnunet-cadet-profiler.c src/cadet/gnunet-service-cadet.c src/cadet/gnunet-service-cadet_channel.c src/cadet/gnunet-service-cadet_connection.c @@ -67,15 +67,15 @@ src/consensus/gnunet-service-consensus.c src/consensus/plugin_block_consensus.c src/conversation/conversation_api.c src/conversation/conversation_api_call.c -src/conversation/gnunet-conversation-test.c src/conversation/gnunet-conversation.c -src/conversation/gnunet-helper-audio-playback-gst.c +src/conversation/gnunet-conversation-test.c +src/conversation/gnunet_gst.c +src/conversation/gnunet_gst_test.c src/conversation/gnunet-helper-audio-playback.c -src/conversation/gnunet-helper-audio-record-gst.c +src/conversation/gnunet-helper-audio-playback-gst.c src/conversation/gnunet-helper-audio-record.c +src/conversation/gnunet-helper-audio-record-gst.c src/conversation/gnunet-service-conversation.c -src/conversation/gnunet_gst.c -src/conversation/gnunet_gst_test.c src/conversation/microphone.c src/conversation/plugin_gnsrecord_conversation.c src/conversation/speaker.c @@ -105,6 +105,7 @@ src/dht/dht_api.c src/dht/dht_test_lib.c src/dht/gnunet-dht-get.c src/dht/gnunet-dht-monitor.c +src/dht/gnunet_dht_profiler.c src/dht/gnunet-dht-put.c src/dht/gnunet-service-dht.c src/dht/gnunet-service-dht_clients.c @@ -113,7 +114,6 @@ src/dht/gnunet-service-dht_hello.c src/dht/gnunet-service-dht_neighbours.c src/dht/gnunet-service-dht_nse.c src/dht/gnunet-service-dht_routing.c -src/dht/gnunet_dht_profiler.c src/dht/plugin_block_dht.c src/dns/dns_api.c src/dns/gnunet-dns-monitor.c @@ -148,8 +148,8 @@ src/fs/gnunet-auto-share.c src/fs/gnunet-daemon-fsprofiler.c src/fs/gnunet-directory.c src/fs/gnunet-download.c -src/fs/gnunet-fs-profiler.c src/fs/gnunet-fs.c +src/fs/gnunet-fs-profiler.c src/fs/gnunet-helper-fs-publish.c src/fs/gnunet-publish.c src/fs/gnunet-search.c @@ -169,9 +169,9 @@ src/gns/gns_tld_api.c src/gns/gnunet-bcd.c src/gns/gnunet-dns2gns.c src/gns/gnunet-gns-benchmark.c +src/gns/gnunet-gns.c src/gns/gnunet-gns-import.c src/gns/gnunet-gns-proxy.c -src/gns/gnunet-gns.c src/gns/gnunet-service-gns.c src/gns/gnunet-service-gns_interceptor.c src/gns/gnunet-service-gns_resolver.c @@ -189,8 +189,8 @@ src/gnsrecord/json_gnsrecord.c src/gnsrecord/plugin_gnsrecord_dns.c src/hello/address.c src/hello/gnunet-hello.c -src/hello/hello-ng.c src/hello/hello.c +src/hello/hello-ng.c src/hostlist/gnunet-daemon-hostlist.c src/hostlist/gnunet-daemon-hostlist_client.c src/hostlist/gnunet-daemon-hostlist_server.c @@ -214,8 +214,8 @@ src/namecache/namecache_api.c src/namecache/plugin_namecache_flat.c src/namecache/plugin_namecache_postgres.c src/namecache/plugin_namecache_sqlite.c -src/namestore/gnunet-namestore-fcfsd.c src/namestore/gnunet-namestore.c +src/namestore/gnunet-namestore-fcfsd.c src/namestore/gnunet-service-namestore.c src/namestore/gnunet-zoneimport.c src/namestore/namestore_api.c @@ -241,17 +241,17 @@ src/nat/gnunet-service-nat_mini.c src/nat/gnunet-service-nat_stun.c src/nat/nat_api.c src/nat/nat_api_stun.c -src/nse/gnunet-nse-profiler.c src/nse/gnunet-nse.c +src/nse/gnunet-nse-profiler.c src/nse/gnunet-service-nse.c src/nse/nse_api.c src/nt/nt.c -src/peerinfo-tool/gnunet-peerinfo.c -src/peerinfo-tool/gnunet-peerinfo_plugins.c -src/peerinfo-tool/plugin_rest_peerinfo.c src/peerinfo/gnunet-service-peerinfo.c src/peerinfo/peerinfo_api.c src/peerinfo/peerinfo_api_notify.c +src/peerinfo-tool/gnunet-peerinfo.c +src/peerinfo-tool/gnunet-peerinfo_plugins.c +src/peerinfo-tool/plugin_rest_peerinfo.c src/peerstore/gnunet-peerstore.c src/peerstore/gnunet-service-peerstore.c src/peerstore/peerstore_api.c @@ -297,27 +297,27 @@ src/rest/gnunet-rest-server.c src/rest/plugin_rest_config.c src/rest/plugin_rest_copying.c src/rest/rest.c -src/revocation/gnunet-revocation-tvg.c src/revocation/gnunet-revocation.c +src/revocation/gnunet-revocation-tvg.c src/revocation/gnunet-service-revocation.c src/revocation/plugin_block_revocation.c src/revocation/revocation_api.c -src/rps/gnunet-rps-profiler.c src/rps/gnunet-rps.c +src/rps/gnunet-rps-profiler.c src/rps/gnunet-service-rps.c src/rps/gnunet-service-rps_custommap.c src/rps/gnunet-service-rps_sampler.c src/rps/gnunet-service-rps_sampler_elem.c src/rps/gnunet-service-rps_view.c +src/rps/rps_api.c src/rps/rps-sampler_client.c src/rps/rps-sampler_common.c src/rps/rps-test_util.c -src/rps/rps_api.c src/scalarproduct/gnunet-scalarproduct.c -src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c -src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c src/scalarproduct/gnunet-service-scalarproduct_alice.c src/scalarproduct/gnunet-service-scalarproduct_bob.c +src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c +src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c src/scalarproduct/scalarproduct_api.c src/secretsharing/gnunet-secretsharing-profiler.c src/secretsharing/gnunet-service-secretsharing.c @@ -331,12 +331,12 @@ src/set/gnunet-set-ibf-profiler.c src/set/gnunet-set-profiler.c src/set/ibf.c src/set/ibf_sim.c -src/set/plugin_block_set_test.c -src/set/set_api.c src/seti/gnunet-service-seti.c src/seti/gnunet-seti-profiler.c src/seti/plugin_block_seti_test.c src/seti/seti_api.c +src/set/plugin_block_set_test.c +src/set/set_api.c src/setu/gnunet-service-setu.c src/setu/gnunet-service-setu_strata_estimator.c src/setu/gnunet-setu-ibf-profiler.c @@ -355,16 +355,15 @@ src/statistics/gnunet-statistics.c src/statistics/statistics_api.c src/template/gnunet-service-template.c src/template/gnunet-template.c -src/testbed-logger/gnunet-service-testbed-logger.c -src/testbed-logger/testbed_logger_api.c src/testbed/generate-underlay-topology.c src/testbed/gnunet-daemon-latency-logger.c src/testbed/gnunet-daemon-testbed-blacklist.c src/testbed/gnunet-daemon-testbed-underlay.c src/testbed/gnunet-helper-testbed.c +src/testbed/gnunet_mpi_test.c src/testbed/gnunet-service-test-barriers.c -src/testbed/gnunet-service-testbed.c src/testbed/gnunet-service-testbed_barriers.c +src/testbed/gnunet-service-testbed.c src/testbed/gnunet-service-testbed_cache.c src/testbed/gnunet-service-testbed_connectionpool.c src/testbed/gnunet-service-testbed_cpustatus.c @@ -372,19 +371,20 @@ src/testbed/gnunet-service-testbed_links.c src/testbed/gnunet-service-testbed_meminfo.c src/testbed/gnunet-service-testbed_oc.c src/testbed/gnunet-service-testbed_peers.c -src/testbed/gnunet-testbed-profiler.c -src/testbed/gnunet_mpi_test.c src/testbed/gnunet_testbed_mpi_spawn.c -src/testbed/testbed_api.c +src/testbed/gnunet-testbed-profiler.c +src/testbed-logger/gnunet-service-testbed-logger.c +src/testbed-logger/testbed_logger_api.c src/testbed/testbed_api_barriers.c +src/testbed/testbed_api.c src/testbed/testbed_api_hosts.c src/testbed/testbed_api_operations.c src/testbed/testbed_api_peers.c src/testbed/testbed_api_sd.c src/testbed/testbed_api_services.c src/testbed/testbed_api_statistics.c -src/testbed/testbed_api_test.c src/testbed/testbed_api_testbed.c +src/testbed/testbed_api_test.c src/testbed/testbed_api_topology.c src/testbed/testbed_api_underlay.c src/testing/gnunet-testing.c @@ -396,40 +396,34 @@ src/transport/gnunet-communicator-tcp.c src/transport/gnunet-communicator-udp.c src/transport/gnunet-communicator-unix.c src/transport/gnunet-helper-transport-bluetooth.c -src/transport/gnunet-helper-transport-wlan-dummy.c src/transport/gnunet-helper-transport-wlan.c +src/transport/gnunet-helper-transport-wlan-dummy.c src/transport/gnunet-service-tng.c -src/transport/gnunet-service-transport.c src/transport/gnunet-service-transport_ats.c +src/transport/gnunet-service-transport.c src/transport/gnunet-service-transport_hello.c src/transport/gnunet-service-transport_manipulation.c src/transport/gnunet-service-transport_neighbours.c src/transport/gnunet-service-transport_plugins.c src/transport/gnunet-service-transport_validation.c +src/transport/gnunet-transport.c src/transport/gnunet-transport-profiler.c src/transport/gnunet-transport-wlan-receiver.c src/transport/gnunet-transport-wlan-sender.c -src/transport/gnunet-transport.c src/transport/plugin_transport_http_client.c src/transport/plugin_transport_http_common.c src/transport/plugin_transport_http_server.c src/transport/plugin_transport_smtp.c src/transport/plugin_transport_tcp.c src/transport/plugin_transport_template.c -src/transport/plugin_transport_udp.c src/transport/plugin_transport_udp_broadcasting.c +src/transport/plugin_transport_udp.c src/transport/plugin_transport_unix.c src/transport/plugin_transport_wlan.c src/transport/tcp_connection_legacy.c src/transport/tcp_server_legacy.c src/transport/tcp_server_mst_legacy.c src/transport/tcp_service_legacy.c -src/transport/transport-testing-filenames.c -src/transport/transport-testing-loggers.c -src/transport/transport-testing-main.c -src/transport/transport-testing-send.c -src/transport/transport-testing.c -src/transport/transport-testing2.c src/transport/transport_api2_application.c src/transport/transport_api2_communication.c src/transport/transport_api2_core.c @@ -442,6 +436,12 @@ src/transport/transport_api_manipulation.c src/transport/transport_api_monitor_peers.c src/transport/transport_api_monitor_plugins.c src/transport/transport_api_offer_hello.c +src/transport/transport-testing2.c +src/transport/transport-testing.c +src/transport/transport-testing-filenames.c +src/transport/transport-testing-loggers.c +src/transport/transport-testing-main.c +src/transport/transport-testing-send.c src/util/bandwidth.c src/util/benchmark.c src/util/bio.c @@ -456,8 +456,8 @@ src/util/consttime_memcmp.c src/util/container_bloomfilter.c src/util/container_heap.c src/util/container_meta_data.c -src/util/container_multihashmap.c src/util/container_multihashmap32.c +src/util/container_multihashmap.c src/util/container_multipeermap.c src/util/container_multishortmap.c src/util/container_multiuuidmap.c @@ -481,8 +481,8 @@ src/util/dnsparser.c src/util/dnsstub.c src/util/getopt.c src/util/getopt_helpers.c -src/util/gnunet-config-diff.c src/util/gnunet-config.c +src/util/gnunet-config-diff.c src/util/gnunet-crypto-tvg.c src/util/gnunet-ecc.c src/util/gnunet-qr.c @@ -520,8 +520,8 @@ src/vpn/gnunet-helper-vpn.c src/vpn/gnunet-service-vpn.c src/vpn/gnunet-vpn.c src/vpn/vpn_api.c -src/zonemaster/gnunet-service-zonemaster-monitor.c src/zonemaster/gnunet-service-zonemaster.c +src/zonemaster/gnunet-service-zonemaster-monitor.c src/fs/fs_api.h src/include/gnunet_identity_service.h src/testbed/testbed_api.h diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 6f7c5d860..f40472240 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c @@ -953,6 +953,7 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) GNUNET_free (h); } + ssize_t private_key_get_length (const struct GNUNET_IDENTITY_PrivateKey *key) { @@ -971,7 +972,6 @@ private_key_get_length (const struct GNUNET_IDENTITY_PrivateKey *key) } - ssize_t GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key) { @@ -992,106 +992,116 @@ GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key) ssize_t GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, - const void* buffer, - size_t len) + const void*buffer, + size_t len) { if (len < sizeof (key->type)) return -1; - GNUNET_memcpy(&(key->type), buffer, sizeof (key->type)); - const ssize_t length = GNUNET_IDENTITY_key_get_length(key); + GNUNET_memcpy (&(key->type), buffer, sizeof (key->type)); + const ssize_t length = GNUNET_IDENTITY_key_get_length (key); if (len < length) - return -1; + return -1; if (length < 0) return -2; - GNUNET_memcpy(&(key->ecdsa_key), buffer + sizeof (key->type), length - sizeof (key->type)); + GNUNET_memcpy (&(key->ecdsa_key), buffer + sizeof (key->type), length + - sizeof (key->type)); return length; } ssize_t -GNUNET_IDENTITY_write_key_to_buffer (const struct GNUNET_IDENTITY_PublicKey *key, - void* buffer, - size_t len) +GNUNET_IDENTITY_write_key_to_buffer (const struct + GNUNET_IDENTITY_PublicKey *key, + void*buffer, + size_t len) { - const ssize_t length = GNUNET_IDENTITY_key_get_length(key); + const ssize_t length = GNUNET_IDENTITY_key_get_length (key); if (len < length) - return -1; + return -1; if (length < 0) - return -2; - GNUNET_memcpy(buffer, &(key->type), sizeof (key->type)); - GNUNET_memcpy(buffer + sizeof (key->type), &(key->ecdsa_key), length - sizeof (key->type)); + return -2; + GNUNET_memcpy (buffer, key, length); return length; } ssize_t -GNUNET_IDENTITY_signature_get_length (const struct GNUNET_IDENTITY_Signature *sig) +GNUNET_IDENTITY_signature_get_length (const struct + GNUNET_IDENTITY_Signature *sig) { switch (ntohl (sig->type)) { case GNUNET_IDENTITY_TYPE_ECDSA: - return sizeof (sig->type) + sizeof (sig->ecdsa_signature); - break; + return sizeof (sig->type) + sizeof (sig->ecdsa_signature); + break; case GNUNET_IDENTITY_TYPE_EDDSA: - return sizeof (sig->type) + sizeof (sig->eddsa_signature); - break; + return sizeof (sig->type) + sizeof (sig->eddsa_signature); + break; default: - GNUNET_break (0); + GNUNET_break (0); } return -1; } ssize_t -GNUNET_IDENTITY_read_signature_from_buffer (struct GNUNET_IDENTITY_Signature *sig, - const void* buffer, - size_t len) +GNUNET_IDENTITY_read_signature_from_buffer (struct + GNUNET_IDENTITY_Signature *sig, + const void*buffer, + size_t len) { if (len < sizeof (sig->type)) - return -1; - GNUNET_memcpy(&(sig->type), buffer, sizeof (sig->type)); - const ssize_t length = GNUNET_IDENTITY_signature_get_length(sig); + return -1; + GNUNET_memcpy (&(sig->type), buffer, sizeof (sig->type)); + const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig); if (len < length) - return -1; + return -1; if (length < 0) - return -2; - GNUNET_memcpy(&(sig->ecdsa_signature), buffer + sizeof (sig->type), length - sizeof (sig->type)); + return -2; + GNUNET_memcpy (&(sig->ecdsa_signature), buffer + sizeof (sig->type), length + - sizeof (sig->type)); return length; } ssize_t -GNUNET_IDENTITY_write_signature_to_buffer (const struct GNUNET_IDENTITY_Signature *sig, - void* buffer, - size_t len) +GNUNET_IDENTITY_write_signature_to_buffer (const struct + GNUNET_IDENTITY_Signature *sig, + void*buffer, + size_t len) { - const ssize_t length = GNUNET_IDENTITY_signature_get_length(sig); + const ssize_t length = GNUNET_IDENTITY_signature_get_length (sig); if (len < length) - return -1; + return -1; if (length < 0) - return -2; - GNUNET_memcpy(buffer, &(sig->type), sizeof (sig->type)); - GNUNET_memcpy(buffer + sizeof (sig->type), &(sig->ecdsa_signature), length - sizeof (sig->type)); + return -2; + GNUNET_memcpy (buffer, &(sig->type), sizeof (sig->type)); + GNUNET_memcpy (buffer + sizeof (sig->type), &(sig->ecdsa_signature), length + - sizeof (sig->type)); return length; } int -GNUNET_IDENTITY_private_key_sign_ (const struct GNUNET_IDENTITY_PrivateKey *priv, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_IDENTITY_Signature *sig) +GNUNET_IDENTITY_private_key_sign_ (const struct + GNUNET_IDENTITY_PrivateKey *priv, + const struct + GNUNET_CRYPTO_EccSignaturePurpose *purpose, + struct GNUNET_IDENTITY_Signature *sig) { sig->type = priv->type; switch (ntohl (priv->type)) { case GNUNET_IDENTITY_TYPE_ECDSA: - return GNUNET_CRYPTO_ecdsa_sign_ (& (priv->ecdsa_key), purpose, & (sig->ecdsa_signature)); - break; + return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose, + &(sig->ecdsa_signature)); + break; case GNUNET_IDENTITY_TYPE_EDDSA: - return GNUNET_CRYPTO_eddsa_sign_ (& (priv->eddsa_key), purpose, & (sig->eddsa_signature)); - break; + return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose, + &(sig->eddsa_signature)); + break; default: - GNUNET_break (0); + GNUNET_break (0); } return GNUNET_SYSERR; @@ -1100,22 +1110,27 @@ GNUNET_IDENTITY_private_key_sign_ (const struct GNUNET_IDENTITY_PrivateKey *priv int GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, - const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct GNUNET_IDENTITY_Signature *sig, - const struct GNUNET_IDENTITY_PublicKey *pub) + const struct + GNUNET_CRYPTO_EccSignaturePurpose *validate, + const struct GNUNET_IDENTITY_Signature *sig, + const struct GNUNET_IDENTITY_PublicKey *pub) { /* check type matching of 'sig' and 'pub' */ GNUNET_assert (ntohl (pub->type) == ntohl (sig->type)); switch (ntohl (pub->type)) { case GNUNET_IDENTITY_TYPE_ECDSA: - return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate, & (sig->ecdsa_signature), & (pub->ecdsa_key)); - break; + return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate, + &(sig->ecdsa_signature), + &(pub->ecdsa_key)); + break; case GNUNET_IDENTITY_TYPE_EDDSA: - return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate, & (sig->eddsa_signature), & (pub->eddsa_key)); - break; + return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate, + &(sig->eddsa_signature), + &(pub->eddsa_key)); + break; default: - GNUNET_break (0); + GNUNET_break (0); } return GNUNET_SYSERR; @@ -1123,56 +1138,64 @@ GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, ssize_t -GNUNET_IDENTITY_public_key_encrypt(const void *block, - size_t size, - const struct GNUNET_IDENTITY_PublicKey *pub, - struct GNUNET_CRYPTO_EcdhePublicKey *ecc, - void *result) +GNUNET_IDENTITY_public_key_encrypt (const void *block, + size_t size, + const struct GNUNET_IDENTITY_PublicKey *pub, + struct GNUNET_CRYPTO_EcdhePublicKey *ecc, + void *result) { struct GNUNET_CRYPTO_EcdhePrivateKey pk; - GNUNET_CRYPTO_ecdhe_key_create(&pk); + GNUNET_CRYPTO_ecdhe_key_create (&pk); struct GNUNET_HashCode hash; switch (ntohl (pub->type)) { case GNUNET_IDENTITY_TYPE_ECDSA: - if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_ecdsa(&pk, &(pub->ecdsa_key), &hash)) + if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_ecdsa (&pk, &(pub->ecdsa_key), + &hash)) return -1; break; case GNUNET_IDENTITY_TYPE_EDDSA: - if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_eddsa(&pk, &(pub->eddsa_key), &hash)) + if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdh_eddsa (&pk, &(pub->eddsa_key), + &hash)) return -1; break; default: return -1; } - GNUNET_CRYPTO_ecdhe_key_get_public(&pk, ecc); - GNUNET_CRYPTO_ecdhe_key_clear(&pk); + GNUNET_CRYPTO_ecdhe_key_get_public (&pk, ecc); + GNUNET_CRYPTO_ecdhe_key_clear (&pk); struct GNUNET_CRYPTO_SymmetricSessionKey key; struct GNUNET_CRYPTO_SymmetricInitializationVector iv; - GNUNET_CRYPTO_hash_to_aes_key(&hash, &key, &iv); - GNUNET_CRYPTO_zero_keys(&hash, sizeof(hash)); - const ssize_t encrypted = GNUNET_CRYPTO_symmetric_encrypt(block, size, &key, &iv, result); - GNUNET_CRYPTO_zero_keys(&key, sizeof(key)); - GNUNET_CRYPTO_zero_keys(&iv, sizeof(iv)); + GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv); + GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash)); + const ssize_t encrypted = GNUNET_CRYPTO_symmetric_encrypt (block, size, &key, + &iv, result); + GNUNET_CRYPTO_zero_keys (&key, sizeof(key)); + GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv)); return encrypted; } ssize_t -GNUNET_IDENTITY_private_key_decrypt(const void *block, - size_t size, - const struct GNUNET_IDENTITY_PrivateKey *priv, - const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, - void *result) { +GNUNET_IDENTITY_private_key_decrypt (const void *block, + size_t size, + const struct + GNUNET_IDENTITY_PrivateKey *priv, + const struct + GNUNET_CRYPTO_EcdhePublicKey *ecc, + void *result) +{ struct GNUNET_HashCode hash; switch (ntohl (priv->type)) { case GNUNET_IDENTITY_TYPE_ECDSA: - if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_ecdh(&(priv->ecdsa_key), ecc, &hash)) + if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_ecdh (&(priv->ecdsa_key), ecc, + &hash)) return -1; break; case GNUNET_IDENTITY_TYPE_EDDSA: - if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_ecdh(&(priv->eddsa_key), ecc, &hash)) + if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_ecdh (&(priv->eddsa_key), ecc, + &hash)) return -1; break; default: @@ -1180,11 +1203,12 @@ GNUNET_IDENTITY_private_key_decrypt(const void *block, } struct GNUNET_CRYPTO_SymmetricSessionKey key; struct GNUNET_CRYPTO_SymmetricInitializationVector iv; - GNUNET_CRYPTO_hash_to_aes_key(&hash, &key, &iv); - GNUNET_CRYPTO_zero_keys(&hash, sizeof(hash)); - const ssize_t decrypted = GNUNET_CRYPTO_symmetric_decrypt(block, size, &key, &iv, result); - GNUNET_CRYPTO_zero_keys(&key, sizeof(key)); - GNUNET_CRYPTO_zero_keys(&iv, sizeof(iv)); + GNUNET_CRYPTO_hash_to_aes_key (&hash, &key, &iv); + GNUNET_CRYPTO_zero_keys (&hash, sizeof(hash)); + const ssize_t decrypted = GNUNET_CRYPTO_symmetric_decrypt (block, size, &key, + &iv, result); + GNUNET_CRYPTO_zero_keys (&key, sizeof(key)); + GNUNET_CRYPTO_zero_keys (&iv, sizeof(iv)); return decrypted; } @@ -1222,7 +1246,7 @@ GNUNET_IDENTITY_public_key_from_string (const char *str, if (GNUNET_OK != ret) return GNUNET_SYSERR; ktype = ntohl (key->type); - return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; //FIXME other keys, cleaner way? + return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; // FIXME other keys, cleaner way? } @@ -1240,7 +1264,7 @@ GNUNET_IDENTITY_private_key_from_string (const char *str, if (GNUNET_OK != ret) return GNUNET_SYSERR; ktype = ntohl (key->type); - return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; //FIXME other keys, cleaner way? + return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; // FIXME other keys, cleaner way? } diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 66761e526..0174e52aa 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h @@ -151,9 +151,9 @@ struct GNUNET_IDENTITY_Signature union { - /** - * An ECDSA signature - */ + /** + * An ECDSA signature + */ struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature; /** @@ -419,8 +419,8 @@ GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key); */ ssize_t GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, - const void* buffer, - size_t len); + const void*buffer, + size_t len); /** @@ -436,9 +436,10 @@ GNUNET_IDENTITY_read_key_from_buffer (struct GNUNET_IDENTITY_PublicKey *key, * @return -1 or -2 on error, else the amount of bytes written to the buffer */ ssize_t -GNUNET_IDENTITY_write_key_to_buffer (const struct GNUNET_IDENTITY_PublicKey *key, - void* buffer, - size_t len); +GNUNET_IDENTITY_write_key_to_buffer (const struct + GNUNET_IDENTITY_PublicKey *key, + void*buffer, + size_t len); /** @@ -452,7 +453,8 @@ GNUNET_IDENTITY_write_key_to_buffer (const struct GNUNET_IDENTITY_PublicKey *key * @return -1 on error, else the compacted length of the signature. */ ssize_t -GNUNET_IDENTITY_signature_get_length (const struct GNUNET_IDENTITY_Signature *sig); +GNUNET_IDENTITY_signature_get_length (const struct + GNUNET_IDENTITY_Signature *sig); /** @@ -468,9 +470,10 @@ GNUNET_IDENTITY_signature_get_length (const struct GNUNET_IDENTITY_Signature *si * @return -1 or -2 on error, else the amount of bytes read from the buffer */ ssize_t -GNUNET_IDENTITY_read_signature_from_buffer (struct GNUNET_IDENTITY_Signature *sig, - const void* buffer, - size_t len); +GNUNET_IDENTITY_read_signature_from_buffer (struct + GNUNET_IDENTITY_Signature *sig, + const void*buffer, + size_t len); /** @@ -486,9 +489,10 @@ GNUNET_IDENTITY_read_signature_from_buffer (struct GNUNET_IDENTITY_Signature *si * @return -1 or -2 on error, else the amount of bytes written to the buffer */ ssize_t -GNUNET_IDENTITY_write_signature_to_buffer (const struct GNUNET_IDENTITY_Signature *sig, - void* buffer, - size_t len); +GNUNET_IDENTITY_write_signature_to_buffer (const struct + GNUNET_IDENTITY_Signature *sig, + void*buffer, + size_t len); /** @@ -505,9 +509,11 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct GNUNET_IDENTITY_Signatur * @return #GNUNET_SYSERR on error, #GNUNET_OK on success */ int -GNUNET_IDENTITY_private_key_sign_ (const struct GNUNET_IDENTITY_PrivateKey *priv, - const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_IDENTITY_Signature *sig); +GNUNET_IDENTITY_private_key_sign_ (const struct + GNUNET_IDENTITY_PrivateKey *priv, + const struct + GNUNET_CRYPTO_EccSignaturePurpose *purpose, + struct GNUNET_IDENTITY_Signature *sig); /** @@ -528,9 +534,9 @@ GNUNET_IDENTITY_private_key_sign_ (const struct GNUNET_IDENTITY_PrivateKey *priv GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ GNUNET_assert (GNUNET_OK == \ - GNUNET_IDENTITY_private_key_sign_ (priv, \ - &(ps)->purpose, \ - sig)); \ + GNUNET_IDENTITY_private_key_sign_ (priv, \ + &(ps)->purpose, \ + sig)); \ } while (0) @@ -553,9 +559,11 @@ GNUNET_IDENTITY_private_key_sign_ (const struct GNUNET_IDENTITY_PrivateKey *priv */ int GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, - const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct GNUNET_IDENTITY_Signature *sig, - const struct GNUNET_IDENTITY_PublicKey *pub); + const struct + GNUNET_CRYPTO_EccSignaturePurpose *validate, + const struct GNUNET_IDENTITY_Signature *sig, + const struct + GNUNET_IDENTITY_PublicKey *pub); /** @@ -577,10 +585,10 @@ GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, /* check 'ps' begins with the purpose */ \ GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ - GNUNET_IDENTITY_public_key_verify_(purp, \ - &(ps)->purpose, \ - sig, \ - pub); \ + GNUNET_IDENTITY_public_key_verify_ (purp, \ + &(ps)->purpose, \ + sig, \ + pub); \ }) @@ -600,11 +608,11 @@ GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, * this size should be the same as @c len. */ ssize_t -GNUNET_IDENTITY_public_key_encrypt(const void *block, - size_t size, - const struct GNUNET_IDENTITY_PublicKey *pub, - struct GNUNET_CRYPTO_EcdhePublicKey *ecc, - void *result); +GNUNET_IDENTITY_public_key_encrypt (const void *block, + size_t size, + const struct GNUNET_IDENTITY_PublicKey *pub, + struct GNUNET_CRYPTO_EcdhePublicKey *ecc, + void *result); /** @@ -622,11 +630,13 @@ GNUNET_IDENTITY_public_key_encrypt(const void *block, * this size should be the same as @c size. */ ssize_t -GNUNET_IDENTITY_private_key_decrypt(const void *block, - size_t size, - const struct GNUNET_IDENTITY_PrivateKey *priv, - const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, - void *result); +GNUNET_IDENTITY_private_key_decrypt (const void *block, + size_t size, + const struct + GNUNET_IDENTITY_PrivateKey *priv, + const struct + GNUNET_CRYPTO_EcdhePublicKey *ecc, + void *result); /** @@ -689,7 +699,8 @@ GNUNET_IDENTITY_private_key_from_string (const char*str, * @return GNUNET_SYSERR on error. */ enum GNUNET_GenericReturnValue -GNUNET_IDENTITY_key_get_public (const struct GNUNET_IDENTITY_PrivateKey *privkey, +GNUNET_IDENTITY_key_get_public (const struct + GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key); diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h index 3ad8f864b..d56116914 100644 --- a/src/include/gnunet_revocation_service.h +++ b/src/include/gnunet_revocation_service.h @@ -102,15 +102,12 @@ struct GNUNET_REVOCATION_SignaturePurposePS */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - /** - * The revoked public key - */ - struct GNUNET_IDENTITY_PublicKey key; - /** * The timestamp of the revocation */ struct GNUNET_TIME_AbsoluteNBO timestamp; + + /** Followed by the zone public key type and key **/ }; GNUNET_NETWORK_STRUCT_END diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index ee0150064..44c42ae49 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c @@ -426,7 +426,7 @@ enum GNUNET_GenericReturnValue check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, const struct GNUNET_IDENTITY_PublicKey *key) { - struct GNUNET_REVOCATION_SignaturePurposePS spurp; + struct GNUNET_REVOCATION_SignaturePurposePS *spurp; struct GNUNET_IDENTITY_Signature *sig; const struct GNUNET_IDENTITY_PublicKey *pk; size_t ksize; @@ -434,19 +434,20 @@ check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; ksize = GNUNET_IDENTITY_key_get_length (pk); - spurp.key = *pk; - spurp.timestamp = pow->timestamp; - spurp.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); - spurp.purpose.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) - + GNUNET_IDENTITY_key_get_length (pk) - + sizeof (struct GNUNET_TIME_AbsoluteNBO)); + spurp = GNUNET_malloc (sizeof (*spurp) + ksize); + spurp->timestamp = pow->timestamp; + spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); + spurp->purpose.size = htonl (sizeof(*spurp) + ksize); + GNUNET_IDENTITY_write_key_to_buffer (pk, + (char*) &spurp[1], + ksize); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expected signature payload len: %u\n", - ntohl (spurp.purpose.size)); - sig = (struct GNUNET_CRYPTO_EcdsaSignature *) ((char*)&pow[1] + ksize); + ntohl (spurp->purpose.size)); + sig = (struct GNUNET_IDENTITY_Signature *) ((char*)&pow[1] + ksize); if (GNUNET_OK != GNUNET_IDENTITY_public_key_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, - &spurp.purpose, + &spurp->purpose, sig, key)) { @@ -572,7 +573,7 @@ sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_REVOCATION_PowP *pow) { struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_get (); - struct GNUNET_REVOCATION_SignaturePurposePS rp; + struct GNUNET_REVOCATION_SignaturePurposePS *rp; const struct GNUNET_IDENTITY_PublicKey *pk; size_t ksize; char *sig; @@ -586,18 +587,19 @@ sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; ksize = GNUNET_IDENTITY_key_get_length (pk); pow->timestamp = GNUNET_TIME_absolute_hton (ts); - rp.timestamp = pow->timestamp; - rp.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); - rp.purpose.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) - + ksize - + sizeof (struct GNUNET_TIME_AbsoluteNBO)); + rp = GNUNET_malloc (sizeof (*rp) + ksize); + rp->timestamp = pow->timestamp; + rp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); + rp->purpose.size = htonl (sizeof(*rp) + ksize); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Signature payload len: %u\n", - ntohl (rp.purpose.size)); - rp.key = *pk; + ntohl (rp->purpose.size)); + GNUNET_IDENTITY_write_key_to_buffer (pk, + ((char*)&rp[1]), + ksize); sig = ((char*)&pow[1]) + ksize; int result = GNUNET_IDENTITY_private_key_sign_ (key, - &rp.purpose, + &rp->purpose, (void*) sig); if (result == GNUNET_SYSERR) return GNUNET_NO; else return result; @@ -762,20 +764,17 @@ size_t GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow) { size_t size; + size_t ksize; const struct GNUNET_IDENTITY_PublicKey *pk; + const struct GNUNET_IDENTITY_Signature *sig; size = sizeof (struct GNUNET_REVOCATION_PowP); pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; - size += GNUNET_IDENTITY_key_get_length (pk); - - switch (ntohl (pk->type)) - { - case GNUNET_IDENTITY_TYPE_ECDSA: - return size + sizeof (struct GNUNET_CRYPTO_EcdsaSignature); - default: - return 0; - } - return 0; + ksize = GNUNET_IDENTITY_key_get_length (pk); + size += ksize; + sig = (struct GNUNET_IDENTITY_Signature *) ((char*)&pow[1] + ksize); + size += GNUNET_IDENTITY_signature_get_length (sig); + return size; } -- cgit v1.2.3 From 82b5c638583860897fac1cab3dc1ebd2bed10949 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 10 Nov 2020 19:44:32 +0900 Subject: -minor API change --- src/fs/gnunet-publish.c | 9 +++--- src/identity/identity_api.c | 20 ++++++------- src/include/gnunet_identity_service.h | 46 ++++++++++++++--------------- src/pt/test_gns_vpn.c | 2 +- src/reclaim/oidc_helper.c | 47 ++++++++++++++++++------------ src/revocation/revocation_api.c | 30 ++++++++++--------- src/testbed/test_testbed_api_template.conf | 2 +- 7 files changed, 83 insertions(+), 73 deletions(-) (limited to 'src/include/gnunet_identity_service.h') diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 518192283..dea467669 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -591,13 +591,12 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result) GNUNET_SCHEDULER_shutdown (); return; } - if (NULL == namespace) - priv = NULL; - else + priv = NULL; + if (NULL != namespace) { pk = GNUNET_IDENTITY_ego_get_private_key (namespace); - if (GNUNET_IDENTITY_TYPE_ECDSA == ntohl (pk->type)) - priv = &pk->ecdsa_key; + GNUNET_assert (GNUNET_IDENTITY_TYPE_ECDSA == ntohl (pk->type)); + priv = &pk->ecdsa_key; } pc = GNUNET_FS_publish_start (ctx, fi, diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index f40472240..d44e8da96 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c @@ -1083,11 +1083,11 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct int -GNUNET_IDENTITY_private_key_sign_ (const struct - GNUNET_IDENTITY_PrivateKey *priv, - const struct - GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_IDENTITY_Signature *sig) +GNUNET_IDENTITY_sign_ (const struct + GNUNET_IDENTITY_PrivateKey *priv, + const struct + GNUNET_CRYPTO_EccSignaturePurpose *purpose, + struct GNUNET_IDENTITY_Signature *sig) { sig->type = priv->type; switch (ntohl (priv->type)) @@ -1109,11 +1109,11 @@ GNUNET_IDENTITY_private_key_sign_ (const struct int -GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, - const struct - GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct GNUNET_IDENTITY_Signature *sig, - const struct GNUNET_IDENTITY_PublicKey *pub) +GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, + const struct + GNUNET_CRYPTO_EccSignaturePurpose *validate, + const struct GNUNET_IDENTITY_Signature *sig, + const struct GNUNET_IDENTITY_PublicKey *pub) { /* check type matching of 'sig' and 'pub' */ GNUNET_assert (ntohl (pub->type) == ntohl (sig->type)); diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index 0174e52aa..e59cf65af 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h @@ -501,7 +501,7 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct * The @a purpose data is the beginning of the data of which the signature is * to be created. The `size` field in @a purpose must correctly indicate the * number of bytes of the data structure, including its header. If possible, - * use #GNUNET_IDENTITY_private_key_sign() instead of this function. + * use #GNUNET_IDENTITY_sign() instead of this function. * * @param priv private key to use for the signing * @param purpose what to sign (size, purpose) @@ -509,7 +509,7 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct * @return #GNUNET_SYSERR on error, #GNUNET_OK on success */ int -GNUNET_IDENTITY_private_key_sign_ (const struct +GNUNET_IDENTITY_sign_ (const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, @@ -527,7 +527,7 @@ GNUNET_IDENTITY_private_key_sign_ (const struct * @param ps packed struct with what to sign, MUST begin with a purpose * @param[out] sig where to write the signature */ -#define GNUNET_IDENTITY_private_key_sign(priv,ps,sig) do { \ +#define GNUNET_IDENTITY_sign(priv,ps,sig) do { \ /* check size is set correctly */ \ GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ /* check 'ps' begins with the purpose */ \ @@ -548,7 +548,7 @@ GNUNET_IDENTITY_private_key_sign_ (const struct * the number of bytes of the data structure, including its header. If @a * purpose does not match the purpose given in @a validate (the latter must be * in big endian), signature verification fails. If possible, - * use #GNUNET_IDENTITY_public_key_verify() instead of this function (only if @a validate + * use #GNUNET_IDENTITY_signature_verify() instead of this function (only if @a validate * is not fixed-size, you must use this function directly). * * @param purpose what is the purpose that the signature should have? @@ -558,12 +558,12 @@ GNUNET_IDENTITY_private_key_sign_ (const struct * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid */ int -GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, - const struct - GNUNET_CRYPTO_EccSignaturePurpose *validate, - const struct GNUNET_IDENTITY_Signature *sig, - const struct - GNUNET_IDENTITY_PublicKey *pub); +GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, + const struct + GNUNET_CRYPTO_EccSignaturePurpose *validate, + const struct GNUNET_IDENTITY_Signature *sig, + const struct + GNUNET_IDENTITY_PublicKey *pub); /** @@ -579,7 +579,7 @@ GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, * @param sig where to read the signature from * @param pub public key to use for the verifying */ -#define GNUNET_IDENTITY_public_key_verify(purp,ps,sig,pub) ({ \ +#define GNUNET_IDENTITY_signature_verify(purp,ps,sig,pub) ({ \ /* check size is set correctly */ \ GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \ /* check 'ps' begins with the purpose */ \ @@ -608,11 +608,11 @@ GNUNET_IDENTITY_public_key_verify_ (uint32_t purpose, * this size should be the same as @c len. */ ssize_t -GNUNET_IDENTITY_public_key_encrypt (const void *block, - size_t size, - const struct GNUNET_IDENTITY_PublicKey *pub, - struct GNUNET_CRYPTO_EcdhePublicKey *ecc, - void *result); +GNUNET_IDENTITY_encrypt (const void *block, + size_t size, + const struct GNUNET_IDENTITY_PublicKey *pub, + struct GNUNET_CRYPTO_EcdhePublicKey *ecc, + void *result); /** @@ -630,13 +630,13 @@ GNUNET_IDENTITY_public_key_encrypt (const void *block, * this size should be the same as @c size. */ ssize_t -GNUNET_IDENTITY_private_key_decrypt (const void *block, - size_t size, - const struct - GNUNET_IDENTITY_PrivateKey *priv, - const struct - GNUNET_CRYPTO_EcdhePublicKey *ecc, - void *result); +GNUNET_IDENTITY_decrypt (const void *block, + size_t size, + const struct + GNUNET_IDENTITY_PrivateKey *priv, + const struct + GNUNET_CRYPTO_EcdhePublicKey *ecc, + void *result); /** diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c index cf0455477..7b4abaec2 100644 --- a/src/pt/test_gns_vpn.c +++ b/src/pt/test_gns_vpn.c @@ -560,7 +560,7 @@ identity_cb (void *cls, void **ctx, const char *name) { - const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key; + const struct GNUNET_IDENTITY_PrivateKey *zone_key; struct GNUNET_GNSRECORD_Data rd; char *rd_string; char *peername; diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c index 0caa46b90..c6d56e02d 100644 --- a/src/reclaim/oidc_helper.c +++ b/src/reclaim/oidc_helper.c @@ -154,10 +154,12 @@ fix_base64 (char *str) replace_char (str, '/', '_'); } + static json_t* -generate_userinfo_json(const struct GNUNET_IDENTITY_PublicKey *sub_key, - const struct GNUNET_RECLAIM_AttributeList *attrs, - const struct GNUNET_RECLAIM_PresentationList *presentations) +generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, + const struct GNUNET_RECLAIM_AttributeList *attrs, + const struct + GNUNET_RECLAIM_PresentationList *presentations) { struct GNUNET_RECLAIM_AttributeListEntry *le; struct GNUNET_RECLAIM_PresentationListEntry *ple; @@ -206,7 +208,8 @@ generate_userinfo_json(const struct GNUNET_IDENTITY_PublicKey *sub_key, ple->presentation->data, ple->presentation->data_size); json_object_set_new (aggr_sources_jwt, - GNUNET_RECLAIM_presentation_number_to_typename (ple->presentation->type), + GNUNET_RECLAIM_presentation_number_to_typename ( + ple->presentation->type), json_string (pres_val_str) ); json_object_set_new (aggr_sources, source_name, aggr_sources_jwt); GNUNET_free (pres_val_str); @@ -286,6 +289,7 @@ generate_userinfo_json(const struct GNUNET_IDENTITY_PublicKey *sub_key, return body; } + /** * Generate userinfo JSON as string * @@ -297,12 +301,13 @@ generate_userinfo_json(const struct GNUNET_IDENTITY_PublicKey *sub_key, char * OIDC_generate_userinfo (const struct GNUNET_IDENTITY_PublicKey *sub_key, const struct GNUNET_RECLAIM_AttributeList *attrs, - const struct GNUNET_RECLAIM_PresentationList *presentations) + const struct + GNUNET_RECLAIM_PresentationList *presentations) { char *body_str; - json_t* body = generate_userinfo_json (sub_key, - attrs, - presentations); + json_t*body = generate_userinfo_json (sub_key, + attrs, + presentations); body_str = json_dumps (body, JSON_INDENT (0) | JSON_COMPACT); json_decref (body); return body_str; @@ -324,7 +329,8 @@ char * OIDC_generate_id_token (const struct GNUNET_IDENTITY_PublicKey *aud_key, const struct GNUNET_IDENTITY_PublicKey *sub_key, const struct GNUNET_RECLAIM_AttributeList *attrs, - const struct GNUNET_RECLAIM_PresentationList *presentations, + const struct + GNUNET_RECLAIM_PresentationList *presentations, const struct GNUNET_TIME_Relative *expiration_time, const char *nonce, const char *secret_key) @@ -441,7 +447,8 @@ char * OIDC_build_authz_code (const struct GNUNET_IDENTITY_PrivateKey *issuer, const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_RECLAIM_AttributeList *attrs, - const struct GNUNET_RECLAIM_PresentationList *presentations, + const struct + GNUNET_RECLAIM_PresentationList *presentations, const char *nonce_str, const char *code_challenge) { @@ -544,10 +551,10 @@ OIDC_build_authz_code (const struct GNUNET_IDENTITY_PrivateKey *issuer, buf_ptr += payload_len; // Sign and store signature if (GNUNET_SYSERR == - GNUNET_IDENTITY_private_key_sign_ (issuer, - purpose, - (struct GNUNET_IDENTITY_Signature *) - buf_ptr)) + GNUNET_IDENTITY_sign_ (issuer, + purpose, + (struct GNUNET_IDENTITY_Signature *) + buf_ptr)) { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable to sign code\n"); @@ -684,10 +691,11 @@ OIDC_parse_authz_code (const struct GNUNET_IDENTITY_PublicKey *audience, return GNUNET_SYSERR; } if (GNUNET_OK != - GNUNET_IDENTITY_public_key_verify_ (GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN, - purpose, - signature, - &(ticket->identity))) + GNUNET_IDENTITY_signature_verify_ ( + GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN, + purpose, + signature, + &(ticket->identity))) { GNUNET_free (code_payload); if (NULL != *nonce_str) @@ -840,7 +848,8 @@ OIDC_check_scopes_for_claim_request (const char*scopes, } } - } else if (0 == strcmp (attr, scope_variable)) + } + else if (0 == strcmp (attr, scope_variable)) { /** attribute matches requested scope **/ GNUNET_free (scope_variables); diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index 44c42ae49..791c3d008 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c @@ -444,12 +444,12 @@ check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expected signature payload len: %u\n", ntohl (spurp->purpose.size)); - sig = (struct GNUNET_IDENTITY_Signature *) ((char*)&pow[1] + ksize); + sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize); if (GNUNET_OK != - GNUNET_IDENTITY_public_key_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, - &spurp->purpose, - sig, - key)) + GNUNET_IDENTITY_signature_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, + &spurp->purpose, + sig, + key)) { return GNUNET_SYSERR; } @@ -570,7 +570,7 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow, enum GNUNET_GenericReturnValue sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, - struct GNUNET_REVOCATION_PowP *pow) + struct GNUNET_REVOCATION_PowP *pow) { struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_get (); struct GNUNET_REVOCATION_SignaturePurposePS *rp; @@ -595,14 +595,16 @@ sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, "Signature payload len: %u\n", ntohl (rp->purpose.size)); GNUNET_IDENTITY_write_key_to_buffer (pk, - ((char*)&rp[1]), + ((char*) &rp[1]), ksize); - sig = ((char*)&pow[1]) + ksize; - int result = GNUNET_IDENTITY_private_key_sign_ (key, - &rp->purpose, - (void*) sig); - if (result == GNUNET_SYSERR) return GNUNET_NO; - else return result; + sig = ((char*) &pow[1]) + ksize; + int result = GNUNET_IDENTITY_sign_ (key, + &rp->purpose, + (void*) sig); + if (result == GNUNET_SYSERR) + return GNUNET_NO; + else + return result; } @@ -772,7 +774,7 @@ GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow) pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; ksize = GNUNET_IDENTITY_key_get_length (pk); size += ksize; - sig = (struct GNUNET_IDENTITY_Signature *) ((char*)&pow[1] + ksize); + sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize); size += GNUNET_IDENTITY_signature_get_length (sig); return size; } diff --git a/src/testbed/test_testbed_api_template.conf b/src/testbed/test_testbed_api_template.conf index 255c1b766..ae0368a8b 100644 --- a/src/testbed/test_testbed_api_template.conf +++ b/src/testbed/test_testbed_api_template.conf @@ -32,7 +32,7 @@ WAN_QUOTA_IN = 3932160 USE_EPHEMERAL_KEYS = NO IMMEDIATE_START = YES -[transport-udp] +[transport-tcp] TIMEOUT = 300 s [PATHS] -- cgit v1.2.3 From 37e6d57460f3f4aecd7abbd74e107ff70edc8859 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 10 Nov 2020 20:00:34 +0900 Subject: -fix --- src/include/gnunet_identity_service.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/include/gnunet_identity_service.h') diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index e59cf65af..a75e573d6 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h @@ -510,10 +510,10 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct */ int GNUNET_IDENTITY_sign_ (const struct - GNUNET_IDENTITY_PrivateKey *priv, - const struct - GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_IDENTITY_Signature *sig); + GNUNET_IDENTITY_PrivateKey *priv, + const struct + GNUNET_CRYPTO_EccSignaturePurpose *purpose, + struct GNUNET_IDENTITY_Signature *sig); /** @@ -534,9 +534,9 @@ GNUNET_IDENTITY_sign_ (const struct GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ GNUNET_assert (GNUNET_OK == \ - GNUNET_IDENTITY_private_key_sign_ (priv, \ - &(ps)->purpose, \ - sig)); \ + GNUNET_IDENTITY_sign_ (priv, \ + &(ps)->purpose, \ + sig)); \ } while (0) -- cgit v1.2.3 From 63fe195e40e55f13ab29e3ba578e97017fc4cc48 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 10 Nov 2020 20:06:32 +0900 Subject: -fix --- src/include/gnunet_identity_service.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/include/gnunet_identity_service.h') diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index a75e573d6..2974568db 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h @@ -585,10 +585,10 @@ GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, /* check 'ps' begins with the purpose */ \ GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ - GNUNET_IDENTITY_public_key_verify_ (purp, \ - &(ps)->purpose, \ - sig, \ - pub); \ + GNUNET_IDENTITY_signature_verify_ (purp, \ + &(ps)->purpose, \ + sig, \ + pub); \ }) -- cgit v1.2.3