/* This file is part of GNUnet. Copyright (C) 2012-2013 GNUnet e.V. GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . SPDX-License-Identifier: AGPL3.0-or-later */ /** * @file gnunet-credential.c * @brief command line tool to access command line Credential service * @author Martin Schanzenbach */ #include "platform.h" #include #include #include #include "credential_misc.h" #include "credential_serialization.h" /** * Configuration we are using. */ static const struct GNUNET_CONFIGURATION_Handle *cfg; /** * EgoLookup */ static struct GNUNET_IDENTITY_EgoLookup *el; /** * Handle to Credential service. */ static struct GNUNET_CREDENTIAL_Handle *credential; /** * Desired timeout for the lookup (default is no timeout). */ static struct GNUNET_TIME_Relative timeout; /** * Handle to verify request */ static struct GNUNET_CREDENTIAL_Request *verify_request; /** * Handle to collect request */ static struct GNUNET_CREDENTIAL_Request *collect_request; /** * Task scheduled to handle timeout. */ static struct GNUNET_SCHEDULER_Task *tt; /** * Subject pubkey string */ static char *subject_key; /** * Subject credential string */ static char *subject_credential; /** * Credential TTL */ static char *expiration; /** * Subject key */ struct GNUNET_CRYPTO_EcdsaPublicKey subject_pkey; /** * Issuer key */ struct GNUNET_CRYPTO_EcdsaPublicKey issuer_pkey; /** * Issuer pubkey string */ static char *issuer_key; /** * ego */ static char *ego_name; /** * Issuer attribute */ static char *issuer_attr; /** * Verify mode */ static int verify; /** * Issue mode */ static int create_cred; /** * Collect mode */ static int collect; /** * Task run on shutdown. Cleans up everything. * * @param cls unused */ static void do_shutdown (void *cls) { if (NULL != verify_request) { GNUNET_CREDENTIAL_request_cancel (verify_request); verify_request = NULL; } if (NULL != credential) { GNUNET_CREDENTIAL_disconnect (credential); credential = NULL; } if (NULL != tt) { GNUNET_SCHEDULER_cancel (tt); tt = NULL; } } /** * Task run on timeout. Triggers shutdown. * * @param cls unused */ static void do_timeout (void *cls) { tt = NULL; GNUNET_SCHEDULER_shutdown (); } static void handle_collect_result (void *cls, unsigned int d_count, struct GNUNET_CREDENTIAL_Delegation *dc, unsigned int c_count, struct GNUNET_CREDENTIAL_Credential *cred) { int i; char* line; verify_request = NULL; if (NULL != cred) { for (i=0;iissuer_attribute); tok = strtok(NULL, ","); GNUNET_free (cred); } verify_request = GNUNET_CREDENTIAL_verify(credential, &issuer_pkey, issuer_attr, //TODO argument &subject_pkey, count, credentials, &handle_verify_result, NULL); for (i=0;i