summaryrefslogtreecommitdiff
path: root/src/credential/credential_api.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-02 17:29:08 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-02 17:29:08 +0100
commit646723dd495657a184d1f7e439f4958a72bee1df (patch)
tree77df41a043da4fd8cf1ad5449d11362c427df619 /src/credential/credential_api.c
parent59f9630b8be3dcde087a4ef6956217704d0dacb4 (diff)
downloadgnunet-646723dd495657a184d1f7e439f4958a72bee1df.tar.gz
gnunet-646723dd495657a184d1f7e439f4958a72bee1df.zip
- add verify and issue to cli
Diffstat (limited to 'src/credential/credential_api.c')
-rw-r--r--src/credential/credential_api.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c
index 8ff66c574..8d3c96ca8 100644
--- a/src/credential/credential_api.c
+++ b/src/credential/credential_api.c
@@ -28,6 +28,7 @@
28#include "gnunet_arm_service.h" 28#include "gnunet_arm_service.h"
29#include "gnunet_hello_lib.h" 29#include "gnunet_hello_lib.h"
30#include "gnunet_protocols.h" 30#include "gnunet_protocols.h"
31#include "gnunet_signatures.h"
31#include "credential.h" 32#include "credential.h"
32#include "gnunet_credential_service.h" 33#include "gnunet_credential_service.h"
33#include "gnunet_identity_service.h" 34#include "gnunet_identity_service.h"
@@ -406,5 +407,49 @@ GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
406 return vr; 407 return vr;
407} 408}
408 409
410/**
411 * Issue an attribute to a subject
412 *
413 * @param handle handle to the Credential service
414 * @param issuer the ego that should be used to issue the attribute
415 * @param subject the subject of the attribute
416 * @param attribute the name of the attribute
417 * @return handle to the queued request
418 */
419struct GNUNET_CREDENTIAL_CredentialRecordData *
420GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
421 const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
422 struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
423 const char *attribute)
424{
425 struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
426
427 crd = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (attribute) + 1);
428
429 crd->purpose.size = htonl (strlen (attribute) + 1 +
430 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
431 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
432 sizeof (struct GNUNET_TIME_AbsoluteNBO));
433 crd->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
434 GNUNET_CRYPTO_ecdsa_key_get_public (issuer,
435 &crd->issuer_key);
436
437 GNUNET_memcpy (&crd[1],
438 attribute,
439 strlen (attribute));
440 if (GNUNET_OK !=
441 GNUNET_CRYPTO_ecdsa_sign (issuer,
442 &crd->purpose,
443 &crd->sig))
444 {
445 GNUNET_break (0);
446 GNUNET_free (crd);
447 return NULL;
448 }
449 return crd;
450}
451
452
453
409 454
410/* end of credential_api.c */ 455/* end of credential_api.c */