25#include "gnunet_error_codes.h"
279 printf (
"%s Intermediate result: %s.%s <- %s.%s\n",
290 unsigned int d_count,
292 unsigned int c_count,
301 for (i = 0; i < c_count; i++)
304 printf (
"%s\n",
line);
310 printf (
"Received NULL\n");
319 unsigned int d_count,
321 unsigned int c_count,
333 printf (
"Delegation Chain:\n");
334 for (i = 0; i < d_count; i++)
339 if (0 !=
dc[i].subject_attribute_len)
341 printf (
"(%d) %s.%s <- %s.%s\n",
344 dc[i].issuer_attribute,
346 dc[i].subject_attribute);
350 printf (
"(%d) %s.%s <- %s\n",
353 dc[i].issuer_attribute,
359 printf (
"\nDelegate(s):\n");
360 for (i = 0; i < c_count; i++)
364 printf (
"%s.%s <- %s\n", iss_key, dele[i].issuer_attribute, sub_key);
368 printf (
"Successful.\n");
393 _ (
"Ego `%s' not known to identity service\n"),
408 _ (
"Issuer public key `%s' is not well-formed\n"),
458 "Storing record with relative expiration time of %s\n",
468 "Storing record with absolute expiration time of %s\n",
482 fprintf (stderr,
"Error occurred during lookup, shutting down.\n");
495 printf (
"Adding successful.\n");
506 const char *rec_name,
550 char *subject_pubkey_str;
551 char *zone_pubkey_str;
559 _ (
"Failed to connect to namestore\n"));
567 _ (
"Ego does not exist!\n"));
583 "%s is not a valid credential\n",
import);
598 if (strcmp (zone_pubkey_str, subject_pubkey_str) != 0)
601 "Import signed delegate does not match this ego's public key.\n")
624 fputs (
"Value for unknown record type not well-formed.\n", stderr);
629 "Value for record type `%s' not well-formed.\n",
635 "Value `%s' invalid for record type `%s'\n",
646 fprintf (stderr,
"Missing option -e for operation 'create'\n");
652 fprintf (stderr,
"Invalid time format `%s'\n",
expiration);
677 char *subject_pubkey_str;
678 char *subject_attr = NULL;
686 fprintf (stderr,
"Please specify a TTL\n");
694 "%s is not a valid ttl! Only absolute times are accepted!\n",
704 subject_pubkey_str = token;
706 token = strtok (NULL,
" ");
709 subject_attr = token;
715 if (NULL == subject_pubkey_str)
718 "Subject pubkey not given\n");
727 "Subject public key `%s' is not well-formed\n",
741 printf (
"%s\n",
res);
774 fprintf (stderr,
"Missing option '-ego'\n");
780 fprintf (stderr,
"Missing option '-attribute' for issuer attribute\n");
786 fprintf (stderr,
"Missing option -subject for operation 'create'.'\n");
804 fprintf (stderr,
"'import' required\n");
821 fprintf (stderr,
"ego required\n");
827 fprintf (stderr,
"Subject public key needed\n");
852 fprintf (stderr,
_ (
"Issuer public key not well-formed\n"));
861 fprintf (stderr,
_ (
"Failed to connect to ABD\n"));
867 fprintf (stderr,
_ (
"You must provide issuer the attribute\n"));
874 fprintf (stderr,
_ (
"ego required\n"));
884 fprintf (stderr,
_ (
"Subject public key needed\n"));
892 _ (
"Subject public key `%s' is not well-formed\n"),
902 fprintf (stderr,
_ (
"Issuer public key not well-formed\n"));
911 _ (
"Issuer public key `%s' is not well-formed\n"),
920 fprintf (stderr,
_ (
"Failed to connect to ABD\n"));
926 fprintf (stderr,
_ (
"You must provide issuer and subject attributes\n"));
936 char *tok = strtok (tmp,
",");
941 fprintf (stderr,
"Invalid subject credentials\n");
946 while (NULL != (tok = strtok (NULL,
",")))
951 tok = strtok (tmp,
",");
952 for (i = 0; i < count; i++)
959 tok = strtok (NULL,
",");
974 for (i = 0; i < count; i++)
987 "Please specify name to lookup, subject key and issuer key!\n"));
1008 "verify credential against attribute"),
1015 "The public key of the subject to lookup the"
1016 "credential for, or for issuer side storage: subject and its attributes")
1023 gettext_noop (
"The private, signed delegate presented by the subject"),
1030 "The public key of the authority to verify the credential against"),
1041 gettext_noop (
"The issuer attribute to verify against or to issue"),
1047 "The time to live for the credential."
1048 "e.g. 5m, 6h, \"1990-12-30 12:00:00\""),
1057 "Create and issue a credential issuer side."),
1060 "createSubjectSide",
1062 "Issue a credential subject side."),
1067 gettext_noop (
"Create, sign and return a credential subject side."),
1074 "Import signed credentials that should be issued to a zone/ego"),
1084 "Indicates that the collect/verify process is done via forward search."),
1090 "Indicates that the collect/verify process is done via forward search."),
1103 _ (
"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.
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)
static struct GNUNET_ABD_Request * collect_request
Handle to collect request.
static int create_ss
Create mode.
static struct GNUNET_CRYPTO_PrivateKey zone_pkey
Private key for the our zone.
static const char * record_label
Record label for storing delegations.
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)
struct GNUNET_CRYPTO_PublicKey issuer_pkey
Issuer key.
static int collect
Collect mode.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int sign_ss
Create mode.
static int parse_expiration(const char *expirationstring, int *etime_is_rel_, uint64_t *etime_)
Parse expiration time.
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.
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 add_continuation(void *cls, enum GNUNET_ErrorCode ec)
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 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.
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 void get_existing_record(void *cls, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
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)
struct GNUNET_CRYPTO_PublicKey subject_pkey
Subject key.
static uint64_t etime
Expiration string converted to numeric value.
static gnutls_certificate_credentials_t cred
The credential.
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 char * expirationstring
Optional expiration string -E.
static unsigned int rd_count
Number of records for currently parsed set.
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
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;.
GNUNET_ABD_AlgoDirectionFlags
struct GNUNET_ABD_Handle * GNUNET_ABD_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the ABD service.
struct GNUNET_ABD_Delegate * GNUNET_ABD_delegate_issue(const struct GNUNET_CRYPTO_PrivateKey *issuer, struct GNUNET_CRYPTO_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_verify(struct GNUNET_ABD_Handle *handle, const struct GNUNET_CRYPTO_PublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_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.
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.
struct GNUNET_ABD_Request * GNUNET_ABD_collect(struct GNUNET_ABD_Handle *handle, const struct GNUNET_CRYPTO_PublicKey *issuer_key, const char *issuer_attribute, const struct GNUNET_CRYPTO_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_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.
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).
@ 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.
const struct GNUNET_CRYPTO_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
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.
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_PublicKey *pk)
Get the identifier (public key) of an ego.
#define GNUNET_log(kind,...)
char * GNUNET_CRYPTO_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_public_key_from_string(const char *str, struct GNUNET_CRYPTO_PublicKey *key)
Parses a (Base32) string representation of the public key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ 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.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_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.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_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.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
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_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
#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.
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE
For ABD reverse lookups.
#define GNUNET_GNSRECORD_TYPE_DELEGATE
For ABD policies.
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_NONE
No error (success).
const char * issuer_attribute
The issuer attribute.
struct GNUNET_CRYPTO_PublicKey subject_key
Public key of the subject this attribute was delegated to.
const char * issuer_attribute
The attribute.
const char * subject_attribute
The attribute.
struct GNUNET_CRYPTO_PublicKey issuer_key
The issuer of the delegation.
Connection to the ABD service.
Handle to a verify request.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
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.
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.