aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/reclaim_api.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-19 23:53:02 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-20 17:59:02 +0200
commita57d476abbe857365aff157f389cc1188b5dd090 (patch)
treee8f7163ef7e6f5426748fed8d2eaa5183038a5d6 /src/reclaim/reclaim_api.c
parente75869506cc08e08056168383bd4ab02e1f007de (diff)
downloadgnunet-a57d476abbe857365aff157f389cc1188b5dd090.tar.gz
gnunet-a57d476abbe857365aff157f389cc1188b5dd090.zip
reclaim: Attestations now called credentials. Credentials are presented to third parties as presentations.
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r--src/reclaim/reclaim_api.c58
1 files changed, 48 insertions, 10 deletions
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index 2cfcbad09..1e0251519 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -92,6 +92,11 @@ struct GNUNET_RECLAIM_Operation
92 GNUNET_RECLAIM_TicketCallback tr_cb; 92 GNUNET_RECLAIM_TicketCallback tr_cb;
93 93
94 /** 94 /**
95 * Ticket issue result callback
96 */
97 GNUNET_RECLAIM_IssueTicketCallback ti_cb;
98
99 /**
95 * Envelope with the message for this queue entry. 100 * Envelope with the message for this queue entry.
96 */ 101 */
97 struct GNUNET_MQ_Envelope *env; 102 struct GNUNET_MQ_Envelope *env;
@@ -866,6 +871,30 @@ handle_credential_result (void *cls, const struct
866 GNUNET_assert (0); 871 GNUNET_assert (0);
867} 872}
868 873
874/**
875 * Handle an incoming message of type
876 * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
877 *
878 * @param cls
879 * @param msg the message we received
880 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
881 */
882static int
883check_ticket_result (void *cls, const struct TicketResultMessage *msg)
884{
885 size_t msg_len;
886 size_t pres_len;
887
888 msg_len = ntohs (msg->header.size);
889 pres_len = ntohs (msg->presentations_len);
890 if (msg_len != sizeof(struct TicketResultMessage) + pres_len)
891 {
892 GNUNET_break (0);
893 return GNUNET_SYSERR;
894 }
895 return GNUNET_OK;
896}
897
869 898
870/** 899/**
871 * Handle an incoming message of type 900 * Handle an incoming message of type
@@ -880,8 +909,10 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
880 struct GNUNET_RECLAIM_Handle *handle = cls; 909 struct GNUNET_RECLAIM_Handle *handle = cls;
881 struct GNUNET_RECLAIM_Operation *op; 910 struct GNUNET_RECLAIM_Operation *op;
882 struct GNUNET_RECLAIM_TicketIterator *it; 911 struct GNUNET_RECLAIM_TicketIterator *it;
912 struct GNUNET_RECLAIM_PresentationList *pres;
883 uint32_t r_id = ntohl (msg->id); 913 uint32_t r_id = ntohl (msg->id);
884 static const struct GNUNET_RECLAIM_Ticket ticket; 914 static const struct GNUNET_RECLAIM_Ticket ticket;
915 uint32_t pres_len = ntohs (msg->presentations_len);
885 916
886 for (op = handle->op_head; NULL != op; op = op->next) 917 for (op = handle->op_head; NULL != op; op = op->next)
887 if (op->r_id == r_id) 918 if (op->r_id == r_id)
@@ -893,18 +924,25 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
893 return; 924 return;
894 if (NULL != op) 925 if (NULL != op)
895 { 926 {
927 if (0 < pres_len)
928 pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*)&msg[1],
929 pres_len);
896 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op); 930 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
897 if (0 == 931 if (0 ==
898 memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket))) 932 memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
899 { 933 {
900 if (NULL != op->tr_cb) 934 if (NULL != op->ti_cb)
901 op->tr_cb (op->cls, NULL); 935 op->ti_cb (op->cls, NULL, NULL);
902 } 936 }
903 else 937 else
904 { 938 {
905 if (NULL != op->tr_cb) 939 if (NULL != op->ti_cb)
906 op->tr_cb (op->cls, &msg->ticket); 940 op->ti_cb (op->cls,
941 &msg->ticket,
942 (0 < pres_len) ? pres : NULL);
907 } 943 }
944 if (0 < pres_len)
945 GNUNET_RECLAIM_presentation_list_destroy (pres);
908 free_op (op); 946 free_op (op);
909 return; 947 return;
910 } 948 }
@@ -989,10 +1027,10 @@ reconnect (struct GNUNET_RECLAIM_Handle *h)
989 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT, 1027 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT,
990 struct CredentialResultMessage, 1028 struct CredentialResultMessage,
991 h), 1029 h),
992 GNUNET_MQ_hd_fixed_size (ticket_result, 1030 GNUNET_MQ_hd_var_size (ticket_result,
993 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, 1031 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
994 struct TicketResultMessage, 1032 struct TicketResultMessage,
995 h), 1033 h),
996 GNUNET_MQ_hd_var_size (consume_ticket_result, 1034 GNUNET_MQ_hd_var_size (consume_ticket_result,
997 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, 1035 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT,
998 struct ConsumeTicketResultMessage, 1036 struct ConsumeTicketResultMessage,
@@ -1506,7 +1544,7 @@ GNUNET_RECLAIM_ticket_issue (
1506 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 1544 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1507 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 1545 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1508 const struct GNUNET_RECLAIM_AttributeList *attrs, 1546 const struct GNUNET_RECLAIM_AttributeList *attrs,
1509 GNUNET_RECLAIM_TicketCallback cb, 1547 GNUNET_RECLAIM_IssueTicketCallback cb,
1510 void *cb_cls) 1548 void *cb_cls)
1511{ 1549{
1512 struct GNUNET_RECLAIM_Operation *op; 1550 struct GNUNET_RECLAIM_Operation *op;
@@ -1516,7 +1554,7 @@ GNUNET_RECLAIM_ticket_issue (
1516 fprintf (stderr, "Issuing ticket\n"); 1554 fprintf (stderr, "Issuing ticket\n");
1517 op = GNUNET_new (struct GNUNET_RECLAIM_Operation); 1555 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1518 op->h = h; 1556 op->h = h;
1519 op->tr_cb = cb; 1557 op->ti_cb = cb;
1520 op->cls = cb_cls; 1558 op->cls = cb_cls;
1521 op->r_id = h->r_id_gen++; 1559 op->r_id = h->r_id_gen++;
1522 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op); 1560 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);