aboutsummaryrefslogtreecommitdiff
path: root/src/credential/credential_api.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-06 10:09:21 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-06 10:09:21 +0100
commit10b2bbf99b0dc611a735ad0a04d3ab5109a090f0 (patch)
treec7cd07943c91d5a995aaca588259069449cbd7b3 /src/credential/credential_api.c
parent8c1425aa729914e0b2695fcab1ce29ea0aebffbb (diff)
downloadgnunet-10b2bbf99b0dc611a735ad0a04d3ab5109a090f0.tar.gz
gnunet-10b2bbf99b0dc611a735ad0a04d3ab5109a090f0.zip
-add expiration to cred
Diffstat (limited to 'src/credential/credential_api.c')
-rw-r--r--src/credential/credential_api.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/credential/credential_api.c b/src/credential/credential_api.c
index 3be2d8bbb..eb7af5b53 100644
--- a/src/credential/credential_api.c
+++ b/src/credential/credential_api.c
@@ -425,35 +425,29 @@ struct GNUNET_CREDENTIAL_CredentialRecordData *
425GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle, 425GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
426 const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, 426 const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
427 struct GNUNET_CRYPTO_EcdsaPublicKey *subject, 427 struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
428 const char *attribute) 428 const char *attribute,
429 struct GNUNET_TIME_Absolute *expiration)
429{ 430{
430 struct GNUNET_CREDENTIAL_CredentialRecordData *crd; 431 struct GNUNET_CREDENTIAL_CredentialRecordData *crd;
431 struct GNUNET_CRYPTO_EccSignaturePurpose *purp;
432 432
433 crd = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (attribute) + 1); 433 crd = GNUNET_malloc (sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (attribute) + 1);
434 434
435 purp = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + 435 crd->purpose.size = htonl (strlen (attribute) + 1 +
436 strlen (attribute) + 1);
437 purp->size = htonl (strlen (attribute) + 1 +
438 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + 436 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) +
439 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)); 437 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
438 sizeof (uint64_t));
440 439
441 purp->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL); 440 crd->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL);
442 GNUNET_CRYPTO_ecdsa_key_get_public (issuer, 441 GNUNET_CRYPTO_ecdsa_key_get_public (issuer,
443 &crd->issuer_key); 442 &crd->issuer_key);
444 crd->subject_key = *subject; 443 crd->subject_key = *subject;
444 crd->expiration = GNUNET_htonll (expiration->abs_value_us);
445 GNUNET_memcpy (&crd[1], 445 GNUNET_memcpy (&crd[1],
446 attribute, 446 attribute,
447 strlen (attribute)); 447 strlen (attribute));
448 GNUNET_memcpy (&purp[1],
449 subject,
450 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
451 GNUNET_memcpy (&purp[1] + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
452 attribute,
453 strlen (attribute));
454 if (GNUNET_OK != 448 if (GNUNET_OK !=
455 GNUNET_CRYPTO_ecdsa_sign (issuer, 449 GNUNET_CRYPTO_ecdsa_sign (issuer,
456 purp, 450 &crd->purpose,
457 &crd->sig)) 451 &crd->sig))
458 { 452 {
459 GNUNET_break (0); 453 GNUNET_break (0);