278 printf (
"%s Intermediate result: %s.%s <- %s.%s\n",
289 unsigned int d_count,
291 unsigned int c_count,
300 for (i = 0; i < c_count; i++)
303 printf (
"%s\n",
line);
309 printf (
"Received NULL\n");
318 unsigned int d_count,
320 unsigned int c_count,
332 printf (
"Delegation Chain:\n");
333 for (i = 0; i < d_count; i++)
338 if (0 !=
dc[i].subject_attribute_len)
340 printf (
"(%d) %s.%s <- %s.%s\n",
343 dc[i].issuer_attribute,
345 dc[i].subject_attribute);
349 printf (
"(%d) %s.%s <- %s\n",
352 dc[i].issuer_attribute,
358 printf (
"\nDelegate(s):\n");
359 for (i = 0; i < c_count; i++)
363 printf (
"%s.%s <- %s\n", iss_key, dele[i].issuer_attribute, sub_key);
367 printf (
"Successful.\n");
392 _ (
"Ego `%s' not known to identity service\n"),
407 _ (
"Issuer public key `%s' is not well-formed\n"),
457 "Storing record with relative expiration time of %s\n",
467 "Storing record with absolute expiration time of %s\n",
481 fprintf (stderr,
"Error occurred during lookup, shutting down.\n");
494 printf (
"Adding successful.\n");
496 fprintf (stderr,
"Error occurred during adding, shutting down.\n");
505 const char *rec_name,
549 char *subject_pubkey_str;
550 char *zone_pubkey_str;
558 _ (
"Failed to connect to namestore\n"));
566 _(
"Ego does not exist!\n"));
582 "%s is not a valid credential\n",
import);
597 if (strcmp (zone_pubkey_str, subject_pubkey_str) != 0)
600 "Import signed delegate does not match this ego's public key.\n");
622 fputs (
"Value for unknown record type not well-formed.\n", stderr);
627 "Value for record type `%s' not well-formed.\n",
633 "Value `%s' invalid for record type `%s'\n",
644 fprintf (stderr,
"Missing option -e for operation 'create'\n");
650 fprintf (stderr,
"Invalid time format `%s'\n",
expiration);
681 fprintf (stderr,
"Please specify a TTL\n");
689 "%s is not a valid ttl! Only absolute times are accepted!\n",
696 char *subject_pubkey_str;
697 char *subject_attr = NULL;
702 subject_pubkey_str = token;
704 token = strtok (NULL,
" ");
707 subject_attr = token;
713 if (NULL == subject_pubkey_str)
716 "Subject pubkey not given\n");
725 "Subject public key `%s' is not well-formed\n",
739 printf (
"%s\n",
res);
772 fprintf (stderr,
"Missing option '-ego'\n");
778 fprintf (stderr,
"Missing option '-attribute' for issuer attribute\n");
784 fprintf (stderr,
"Missing option -subject for operation 'create'.'\n");
802 fprintf (stderr,
"'import' required\n");
819 fprintf (stderr,
"ego required\n");
825 fprintf (stderr,
"Subject public key needed\n");
850 fprintf (stderr,
_ (
"Issuer public key not well-formed\n"));
859 fprintf (stderr,
_ (
"Failed to connect to ABD\n"));
865 fprintf (stderr,
_ (
"You must provide issuer the attribute\n"));
872 fprintf (stderr,
_ (
"ego required\n"));
882 fprintf (stderr,
_ (
"Subject public key needed\n"));
890 _ (
"Subject public key `%s' is not well-formed\n"),
900 fprintf (stderr,
_ (
"Issuer public key not well-formed\n"));
909 _ (
"Issuer public key `%s' is not well-formed\n"),
918 fprintf (stderr,
_ (
"Failed to connect to ABD\n"));
924 fprintf (stderr,
_ (
"You must provide issuer and subject attributes\n"));
931 char *tok = strtok (tmp,
",");
934 fprintf (stderr,
"Invalid subject credentials\n");
941 while (NULL != (tok = strtok (NULL,
",")))
948 tok = strtok (tmp,
",");
949 for (i = 0; i < count; i++)
956 tok = strtok (NULL,
",");
971 for (i = 0; i < count; i++)
983 "Please specify name to lookup, subject key and issuer key!\n"));
998 main (
int argc,
char *
const *argv)
1004 "verify credential against attribute"),
1011 "The public key of the subject to lookup the"
1012 "credential for, or for issuer side storage: subject and its attributes"),
1018 gettext_noop (
"The private, signed delegate presented by the subject"),
1025 "The public key of the authority to verify the credential against"),
1036 gettext_noop (
"The issuer attribute to verify against or to issue"),
1042 "The time to live for the credential."
1043 "e.g. 5m, 6h, \"1990-12-30 12:00:00\""),
1052 "Create and issue a credential issuer side."),
1055 "createSubjectSide",
1057 "Issue a credential subject side."),
1062 gettext_noop (
"Create, sign and return a credential subject side."),
1069 "Import signed credentials that should be issued to a zone/ego"),
1079 "Indicates that the collect/verify process is done via forward search."),
1085 "Indicates that the collect/verify process is done via forward search."),
1098 _ (
"GNUnet abd resolver tool"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
int GNUNET_ABD_delegate_serialize(struct GNUNET_ABD_Delegate *dele, char **data)
API to serialize and deserialize delegation chains and abds.
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
For ABD reverse lookups.
#define GNUNET_GNSRECORD_TYPE_DELEGATE
For ABD policies.
char * GNUNET_ABD_delegate_to_string(const struct GNUNET_ABD_Delegate *cred)
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_from_string(const char *s)
Delegate helper functions.
#define gettext_noop(String)
static void handle_verify_result(void *cls, unsigned int d_count, struct GNUNET_ABD_Delegation *dc, unsigned int c_count, struct GNUNET_ABD_Delegate *dele)
struct GNUNET_IDENTITY_PublicKey subject_pkey
Subject key.
static struct GNUNET_ABD_Request * collect_request
Handle to collect request.
static int create_ss
Create mode.
static char * record_label
Record label for storing delegations.
static struct GNUNET_IDENTITY_PrivateKey zone_pkey
Private key for the our zone.
static char * issuer_attr
Issuer attribute.
static char * expiration
Credential TTL.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the 'add' operation.
static int is_private
Is record private.
static int create_is
Create mode.
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Callback invoked from identity service with ego information.
static char * subject_delegate
Subject delegate string.
static void do_timeout(void *cls)
Task run on timeout.
static char * issuer_key
Issuer pubkey string.
static void sign_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego)
static int collect
Collect mode.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int sign_ss
Create mode.
static int ret
Return value of the commandline.
static void store_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego)
static void * data
Value in binary format.
static void do_shutdown(void *cls)
Task run on shutdown.
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
struct GNUNET_IDENTITY_PublicKey issuer_pkey
Issuer key.
static int backward
Search direction: backward.
static void handle_collect_result(void *cls, unsigned int d_count, struct GNUNET_ABD_Delegation *dc, unsigned int c_count, struct GNUNET_ABD_Delegate *dele)
static char * ego_name
ego
static struct GNUNET_SCHEDULER_Task * tt
Task scheduled to handle timeout.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
static int verify
Verify mode.
static void get_existing_record(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
static int forward
Search direction: forward.
static int etime_is_rel
Is expiration time relative or absolute time?
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
static int parse_expiration(const char *expirationstring, int *etime_is_rel, uint64_t *etime)
Parse expiration time.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
static void error_cb(void *cls)
Function called if lookup fails.
static struct GNUNET_ABD_Handle * abd
Handle to Credential service.
static void add_continuation(void *cls, int32_t success, const char *emsg)
int main(int argc, char *const *argv)
The main function for gnunet-gns.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static char * subject
Subject pubkey string.
static struct GNUNET_ABD_Request * verify_request
Handle to verify request.
enum GNUNET_ABD_AlgoDirectionFlags direction
API enum, filled and passed for collect/verify.
static char * typestring
Type of the record to add/remove, NULL to remove all.
static void handle_intermediate_result(void *cls, struct GNUNET_ABD_Delegation *dd, bool is_bw)
static uint64_t etime
Expiration string converted to numeric value.
static int prefix
If printing the value of PREFIX has been requested.
static char * line
Desired phone line (string to be converted to a hash).
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static struct GNUNET_FS_DownloadContext * dc
static const struct GNUNET_IDENTITY_PrivateKey * zone_key
Private key of the zone.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static char * expirationstring
Desired expiration time.
API to the Credential service.
API that can be used to manipulate GNS record data.
API that can be used to store naming information on a GNUnet node;.
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_issue(const struct GNUNET_IDENTITY_PrivateKey *issuer, struct GNUNET_IDENTITY_PublicKey *subject, const char *iss_attr, const char *sub_attr, struct GNUNET_TIME_Absolute *expiration)
Issue an attribute to a subject.
struct GNUNET_ABD_Request * GNUNET_ABD_collect(struct GNUNET_ABD_Handle *handle, const struct GNUNET_IDENTITY_PublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_IDENTITY_PrivateKey *subject_key, enum GNUNET_ABD_AlgoDirectionFlags direction, GNUNET_ABD_CredentialResultProcessor proc, void *proc_cls, GNUNET_ABD_IntermediateResultProcessor proc2, void *proc2_cls)
Performs attribute collection.
GNUNET_ABD_AlgoDirectionFlags
struct GNUNET_ABD_Request * GNUNET_ABD_verify(struct GNUNET_ABD_Handle *handle, const struct GNUNET_IDENTITY_PublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_IDENTITY_PublicKey *subject_key, uint32_t delegate_count, const struct GNUNET_ABD_Delegate *delegates, enum GNUNET_ABD_AlgoDirectionFlags direction, GNUNET_ABD_CredentialResultProcessor proc, void *proc_cls, GNUNET_ABD_IntermediateResultProcessor proc2, void *proc2_cls)
Performs attribute verification.
struct GNUNET_ABD_Handle * GNUNET_ABD_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the ABD service.
void GNUNET_ABD_disconnect(struct GNUNET_ABD_Handle *handle)
Shutdown connection with the ABD service.
void GNUNET_ABD_request_cancel(struct GNUNET_ABD_Request *lr)
Cancel pending verify request.
@ GNUNET_ABD_FLAG_BACKWARD
@ GNUNET_ABD_FLAG_FORWARD
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of the value s of a record of type type to the respective binary repre...
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_public_key_from_string(const char *str, struct GNUNET_IDENTITY_PublicKey *key)
Parses a (Base32) string representation of the public key.
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_IDENTITY_PublicKey *pk)
Get the identifier (public key) of an ego.
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
struct GNUNET_IDENTITY_EgoLookup * GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_IDENTITY_EgoCallback cb, void *cb_cls)
Lookup an ego by name.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
const char * issuer_attribute
The issuer attribute.
struct GNUNET_IDENTITY_PublicKey subject_key
Public key of the subject this credential was issued to.
struct GNUNET_TIME_Absolute expiration
Expiration of this credential.
struct GNUNET_IDENTITY_PublicKey issuer_key
The issuer of the delegation.
const char * issuer_attribute
The attribute.
const char * subject_attribute
The attribute.
struct GNUNET_IDENTITY_PublicKey subject_key
Public key of the subject this attribute was delegated to.
Connection to the ABD service.
Handle to a verify request.
Definition of a command line option.
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Entry in list of pending tasks.
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.