38 #include "gnunet_signatures.h"
226 "Hashing over %.*s\n",
262 "Address hash is %s\n",
323 while (NULL != (a =
builder->a_head))
366 if (block_size <
sizeof (*
bh))
372 block +=
sizeof (*bh);
373 block_size -=
sizeof (*bh);
374 while (block_size > 0)
376 const void *
end = memchr (block,
395 block_size -= (
end - block);
427 if (0 != strncasecmp (url,
429 strlen (
"gnunet://hello/")))
431 url += strlen (
"gnunet://hello/");
432 s1 = strchr (url,
'/');
438 s2 = strchr (s1 + 1,
'/');
444 q = strchr (url,
'?');
446 q = url + strlen (url);
466 unsigned long long sec;
469 if ( (0 == sscanf (s2 + 1,
493 eq = strchr (
q,
'=');
501 amp = strchr (eq,
'&');
507 if ( (NULL == addr) ||
508 (0 == strlen (addr)) )
561 if (
builder->a_length > UINT16_MAX)
575 msg->url_counter = htons ((uint16_t)
builder->a_length);
593 if (
builder->a_length > UINT16_MAX)
624 blen -
sizeof (*block));
628 msg->url_counter = htons ((uint16_t)
builder->a_length);
642 const char *sep =
"?";
654 "gnunet://hello/%s/%s/%llu",
669 eou = strstr (a->uri,
677 pfx_len = eou - a->uri;
680 a->uri_len - 4 - pfx_len,
705 size_t needed =
sizeof (
bh);
714 needed += a->uri_len;
716 if ( (NULL == block) ||
717 (needed < *block_size) )
719 *block_size = needed;
732 pos = block +
sizeof (
bh);
742 *block_size = needed;
751 size_t alen = strlen (
address) + 1;
760 "Invalid address `%s'\n",
770 if ( (! isalpha ((
unsigned char) *
p)) &&
788 a->
uri = (
const char *) &a[1];
852 uint16_t
len = ntohs (hello->
size);
867 len -=
sizeof (*msg);
868 *block_size =
len +
sizeof (*bh);
873 bh->expiration_time =
msg->expiration_time;
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
#define GNUNET_SIGNATURE_PURPOSE_HELLO
Signature by which a peer affirms its address.
static int ret
Return value of the commandline.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int end
Set if we are to shutdown all services (including ARM).
static struct Experiment * e
static char * address
GNS address for this phone.
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
static struct GNUNET_TRANSPORT_Blacklist * bh
The blacklist handle we obtain from transport when we register ourselves for access control.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_block(const void *block, size_t block_size)
Parse block into builder.
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of 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_MessageHeader * GNUNET_HELLO_builder_to_dht_hello_msg(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Generate DHT HELLO message (without peer ID) from a builder.
void GNUNET_HELLO_builder_iterate(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_PeerIdentity *pid, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a builder.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Remove individual address from the builder.
#define GNUNET_HELLO_ADDRESS_EXPIRATION
For how long are HELLO signatures valid?
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_msg(const struct GNUNET_MessageHeader *msg)
Parse msg into builder.
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to 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)
Generate DHT block from a builder.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new(const struct GNUNET_PeerIdentity *pid)
Allocate builder.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_url(const char *url)
Parse GNUnet HELLO url into builder.
void(* GNUNET_HELLO_UriCallback)(void *cls, const char *uri)
Callback function used to extract URIs from a 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.
struct GNUNET_MQ_Envelope * GNUNET_HELLO_builder_to_env(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
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,...)
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
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.
#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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#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_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.
#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_urldecode(const char *data, size_t 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_urlencode(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.
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.
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".
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 (!...
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.
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.