38#include "gnunet_signatures.h"
273 "Hashing over %.*s\n",
309 "Address hash is %s\n",
377 while (NULL != (a =
builder->a_head))
420 if (block_size <
sizeof (*bh))
426 block +=
sizeof (*bh);
427 block_size -=
sizeof (*bh);
428 while (block_size > 0)
430 const void *
end = memchr (block,
449 block_size -= (
end - block);
504 if (0 != strncasecmp (url,
506 strlen (
"gnunet://hello/")))
508 url += strlen (
"gnunet://hello/");
509 s1 = strchr (url,
'/');
515 s2 = strchr (s1 + 1,
'/');
521 q = strchr (url,
'?');
523 q = url + strlen (url);
543 unsigned long long sec;
546 if ( (0 == sscanf (s2 + 1,
570 eq = strchr (
q,
'=');
578 amp = strchr (eq,
'&');
584 if ( (NULL == addr) ||
585 (0 == strlen (addr)) )
639 if (
builder->a_length > UINT16_MAX)
654 msg->url_counter = htons ((uint16_t)
builder->a_length);
674 if (
builder->a_length > UINT16_MAX)
707 blen -
sizeof (*block));
711 msg->url_counter = htons ((uint16_t)
builder->a_length);
725 const char *sep =
"?";
737 "gnunet://hello/%s/%s/%llu",
752 eou = strstr (a->uri,
760 pfx_len = eou - a->uri;
789 size_t needed =
sizeof (bh);
798 needed += a->uri_len;
800 if ( (NULL == block) ||
801 (needed < *block_size) )
803 *block_size = needed;
819 pos = block +
sizeof (bh);
829 *block_size = needed;
838 size_t alen = strlen (
address) + 1;
842 if (NULL == (e = strstr (
address,
847 "Invalid address `%s'\n",
857 if ( (! isalpha ((
unsigned char) *
p)) &&
875 a->
uri = (
const char *) &a[1];
939 uint16_t len = ntohs (hello->
size);
949 if (len <
sizeof (*
msg))
954 len -=
sizeof (*msg);
955 *block_size = len +
sizeof (*bh);
1024 size_t *result_size)
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int ret
Final status code.
static int end
Set if we are to shutdown all services (including ARM).
static char * address
GNS address for this phone.
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int result
Global testing status.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static struct GNUNET_FS_UnindexContext * uc
static struct GNUNET_OS_Process * p
Helper process we started.
Helper library for handling HELLO URIs.
Constants for network protocols.
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
#define GNUNET_CRYPTO_eddsa_verify(purp, ps, sig, pub)
Verify EdDSA signature.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
void GNUNET_HELLO_sign_address(const char *address, enum GNUNET_NetworkType nt, struct GNUNET_TIME_Absolute mono_time, const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, void **result, size_t *result_size)
Build address record by signing raw information with private key.
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
const struct GNUNET_PeerIdentity * GNUNET_HELLO_builder_iterate(const struct GNUNET_HELLO_Builder *builder, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a builder.
enum GNUNET_GenericReturnValue GNUNET_HELLO_dht_msg_to_block(const struct GNUNET_MessageHeader *hello, const struct GNUNET_PeerIdentity *pid, void **block, size_t *block_size, struct GNUNET_TIME_Absolute *block_expiration)
Convert a DHT hello message to a HELLO block.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new(const struct GNUNET_PeerIdentity *pid)
Allocate builder.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_block(const void *block, size_t block_size)
Parse block into builder.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_msg(const struct GNUNET_MessageHeader *msg)
Parse msg into builder.
const struct GNUNET_PeerIdentity * GNUNET_HELLO_builder_get_id(const struct GNUNET_HELLO_Builder *builder)
Get the PeerIdentity for this builder.
struct GNUNET_TIME_Absolute GNUNET_HELLO_builder_get_expiration_time(const struct GNUNET_MessageHeader *msg)
Get the expiration time for this HELLO.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Remove individual address from the builder.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_block(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, void *block, size_t *block_size, struct GNUNET_TIME_Relative expiration_time)
Generate DHT block from a builder.
void(* GNUNET_HELLO_UriCallback)(void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
Callback function used to extract URIs from a builder.
#define GNUNET_HELLO_ADDRESS_EXPIRATION
For how long are HELLO signatures valid?
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_url(const char *url)
Parse GNUnet HELLO url into builder.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to the builder.
char * GNUNET_HELLO_builder_to_url(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Generate GNUnet HELLO URI from a builder.
char * GNUNET_HELLO_address_to_prefix(const char *address)
Given an address as a string, extract the prefix that identifies the communicator offering transmissi...
struct GNUNET_MessageHeader * GNUNET_HELLO_builder_to_dht_hello_msg(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative expiration_time)
Generate DHT HELLO message (without peer ID) from a builder.
struct GNUNET_MQ_Envelope * GNUNET_HELLO_builder_to_env(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative expiration_time)
Generate envelope with GNUnet HELLO message (including peer ID) from a builder.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
GNUNET_GenericReturnValue
Named constants for return values.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
#define GNUNET_PACKED
gcc-ism to get packed structs.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
#define GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO
HELLO advertising a neighbours addresses.
#define GNUNET_MESSAGE_TYPE_HELLO_URI
Latest HELLO messages used for communicating peer addresses.
size_t GNUNET_STRINGS_urlencode(size_t len, const char data[static len], char **out)
url/percent encode (RFC3986).
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
size_t GNUNET_STRINGS_urldecode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_s(uint64_t s_after_epoch)
Convert seconds after the UNIX epoch to absolute time.
struct GNUNET_TIME_Timestamp GNUNET_TIME_relative_to_timestamp(struct GNUNET_TIME_Relative rel)
Convert relative time to a timestamp in the future.
uint64_t GNUNET_TIME_timestamp_to_s(struct GNUNET_TIME_Timestamp ts)
Convert timestamp to number of seconds after the UNIX epoch.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
bool GNUNET_TIME_absolute_is_past(struct GNUNET_TIME_Absolute abs)
Test if abs is truly in the past (excluding now).
static void sign_hello(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_TIME_Timestamp et, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaSignature *sig)
Create HELLO signature.
static enum GNUNET_GenericReturnValue verify_hello(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_TIME_Absolute et, const struct GNUNET_CRYPTO_EddsaSignature *sig)
Verify HELLO signature.
static void hash_addresses(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
Compute hash over addresses in builder.
static unsigned int size
Size of the "table".
#define GNUNET_SIGNATURE_PURPOSE_HELLO
Signature by which a peer affirms its address.
#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS
Signature by a peer affirming that this is one of its addresses for the given time period.
Struct to wrap data to do the merge of to hello uris.
unsigned int merged
Did we found at least one address to merge.
struct GNUNET_HELLO_Builder * builder
The builder of the hello uri we merge with.
unsigned int found
Did we found the actual address to check.
const char * address_uri
The actual address to check, if it is allready in the hello uri we merge with.
struct Address * next
Kept in a DLL.
size_t uri_len
Length of uri including 0-terminator.
struct Address * prev
Kept in a DLL.
const char * uri
Actual URI, allocated at the end of this struct.
Message used when a DHT provides its HELLO to direct neighbours.
uint16_t reserved
Reserved.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
struct GNUNET_MessageHeader header
Type must be GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO.
struct GNUNET_CRYPTO_EddsaSignature sig
Signature over the block, of purpose GNUNET_SIGNATURE_PURPOSE_HELLO.
uint16_t url_counter
Number of URLs encoded after the end of the struct, in NBO.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Private ECC key encoded for transmission.
an ECC signature using EdDSA.
Context for building (or parsing) HELLO URIs.
struct GNUNET_PeerIdentity pid
Public key of the peer.
struct Address * a_tail
Tail of the addresses DLL.
struct Address * a_head
Head of the addresses DLL.
unsigned int a_length
Length of the a_head DLL.
The identity of the host (wraps the signing key of the peer).
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Rounded time for timestamps used by GNUnet, in seconds.
struct GNUNET_TIME_Absolute abs_time
The actual value.
Message signed as part of a HELLO block/URL.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_HELLO.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the signature expire?
struct GNUNET_HashCode h_addrs
Hash over all addresses.
Message used when gossiping HELLOs between peers.
uint16_t reserved
Reserved.
uint16_t url_counter
Number of URLs encoded after the end of the struct, in NBO.
struct GNUNET_MessageHeader header
Type must be GNUNET_MESSAGE_TYPE_HELLO_URI.
Binary block we sign when we sign an address.
struct GNUNET_HashCode addr_hash
Hash of the address.
struct GNUNET_TIME_AbsoluteNBO mono_time
When was the address generated.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Purpose must be GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS.