[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 162/171: -start jwt
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 162/171: -start jwt |
Date: |
Thu, 04 Jan 2018 16:11:10 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 24a0b84d503375bf66b5df932cd18631cc88cf8d
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Mon Dec 4 17:39:36 2017 +0100
-start jwt
---
src/identity-attribute/Makefile.am | 3 ++-
.../jwt.c | 30 ++++++++++++++--------
src/include/gnunet_identity_attribute_lib.h | 14 ++++++++++
3 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/src/identity-attribute/Makefile.am
b/src/identity-attribute/Makefile.am
index 583545344..b84ad3492 100644
--- a/src/identity-attribute/Makefile.am
+++ b/src/identity-attribute/Makefile.am
@@ -20,7 +20,8 @@ lib_LTLIBRARIES = \
libgnunetidentityattribute.la
libgnunetidentityattribute_la_SOURCES = \
- identity_attribute.c
+ identity_attribute.c \
+ jwt.c
libgnunetidentityattribute_la_LIBADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
diff --git a/src/identity-provider/jwt.c b/src/identity-attribute/jwt.c
similarity index 81%
rename from src/identity-provider/jwt.c
rename to src/identity-attribute/jwt.c
index c8bc67806..935e0a79d 100644
--- a/src/identity-provider/jwt.c
+++ b/src/identity-attribute/jwt.c
@@ -26,7 +26,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_signatures.h"
-#include "identity_attribute.h"
+#include "gnunet_identity_attribute_lib.h"
#include <jansson.h>
@@ -55,18 +55,20 @@ create_jwt_header(void)
}
/**
- * Create a JWT from a ticket and attributes
+ * Create a JWT from attributes
*
- * @param ticket the ticket
+ * @param sub_key the public of the subject
* @param attrs the attribute list
+ * @param priv_key the key used to sign the JWT
* @return a new base64-encoded JWT string.
*/
char*
-jwt_create (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
- const struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key)
+GNUNET_IDENTITY_ATTRIBUTE_jwt_create_from_list (const struct
GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
+ const struct
GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
+ const struct
GNUNET_CRYPTO_EcdsaPrivateKey *priv_key)
{
- struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *le;
+ struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le;
+ struct GNUNET_CRYPTO_EcdsaPublicKey iss_key;
struct GNUNET_CRYPTO_EcdsaSignature signature;
struct GNUNET_CRYPTO_EccSignaturePurpose *purpose;
char* audience;
@@ -79,12 +81,14 @@ jwt_create (const struct GNUNET_IDENTITY_PROVIDER_Ticket
*ticket,
char* body_base64;
char* signature_target;
char* signature_base64;
+ char* attr_val_str;
json_t* body;
+ GNUNET_CRYPTO_ecdsa_key_get_public (priv_key, &iss_key);
/* TODO maybe we should use a local identity here */
- issuer = GNUNET_STRINGS_data_to_string_alloc (&ticket->identity,
+ issuer = GNUNET_STRINGS_data_to_string_alloc (&iss_key,
sizeof (struct
GNUNET_CRYPTO_EcdsaPublicKey));
- audience = GNUNET_STRINGS_data_to_string_alloc (&ticket->audience,
+ audience = GNUNET_STRINGS_data_to_string_alloc (sub_key,
sizeof (struct
GNUNET_CRYPTO_EcdsaPublicKey));
header = create_jwt_header ();
body = json_object ();
@@ -103,9 +107,13 @@ jwt_create (const struct GNUNET_IDENTITY_PROVIDER_Ticket
*ticket,
* calls the Attribute plugins to create a
* json representation for its value
*/
+ attr_val_str = GNUNET_IDENTITY_ATTRIBUTE_value_to_string (le->claim->type,
+ le->claim->data,
+
le->claim->data_size);
json_object_set_new (body,
- le->attribute->name,
- json_string (le->attribute->data));
+ le->claim->name,
+ json_string (attr_val_str));
+ GNUNET_free (attr_val_str);
}
body_str = json_dumps (body, JSON_INDENT(0));
json_decref (body);
diff --git a/src/include/gnunet_identity_attribute_lib.h
b/src/include/gnunet_identity_attribute_lib.h
index a43b509da..4c765515b 100644
--- a/src/include/gnunet_identity_attribute_lib.h
+++ b/src/include/gnunet_identity_attribute_lib.h
@@ -260,6 +260,20 @@ GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type,
const char*
GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type);
+
+/**
+ * Create a JWT from attributes
+ *
+ * @param sub_key the public of the subject
+ * @param attrs the attribute list
+ * @param priv_key the key used to sign the JWT
+ * @return a new base64-encoded JWT string.
+ */
+char*
+GNUNET_IDENTITY_ATTRIBUTE_jwt_create_from_list (const struct
GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
+ const struct
GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
+ const struct
GNUNET_CRYPTO_EcdsaPrivateKey *priv_key);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] 159/171: Merge remote-tracking branch 'origin/master' into identity_abe, (continued)
- [GNUnet-SVN] [gnunet] 159/171: Merge remote-tracking branch 'origin/master' into identity_abe, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 164/171: Merge remote-tracking branch 'origin/master' into identity_abe, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 166/171: -move idp experimental, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 168/171: -move abe functionality out of util; prepare for release, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 156/171: -add stats, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 126/171: -remove deprecated, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 154/171: -fixes, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 152/171: -add docker entrypoint, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 129/171: -fix, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 161/171: -fix, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 162/171: -start jwt,
gnunet <=
- [GNUnet-SVN] [gnunet] 118/171: -minor fixed, start consume, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 141/171: -add attribute store API, fixes, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 139/171: -add ticket listing for rest, bugfixes, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 147/171: -add consume rest api, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 167/171: -merge, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 145/171: -bugfixes, fix memleaks, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 143/171: -improve revocation handling, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 160/171: -fix makefile, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 146/171: -add tests, gnunet, 2018/01/04
- [GNUnet-SVN] [gnunet] 158/171: -refactored, gnunet, 2018/01/04