aboutsummaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/exchange_api_handle.c')
-rw-r--r--src/lib/exchange_api_handle.c275
1 files changed, 153 insertions, 122 deletions
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index d0c0c0bad..d0777dc01 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -61,8 +61,8 @@
61 * @param code what was the curl error code 61 * @param code what was the curl error code
62 */ 62 */
63#define CURL_STRERROR(type, function, code) \ 63#define CURL_STRERROR(type, function, code) \
64 GNUNET_log (type, "Curl function `%s' has failed at `%s:%d' with error: %s", \ 64 GNUNET_log (type, "Curl function `%s' has failed at `%s:%d' with error: %s", \
65 function, __FILE__, __LINE__, curl_easy_strerror (code)); 65 function, __FILE__, __LINE__, curl_easy_strerror (code));
66 66
67/** 67/**
68 * Stages of initialization for the `struct TALER_EXCHANGE_Handle` 68 * Stages of initialization for the `struct TALER_EXCHANGE_Handle`
@@ -281,7 +281,8 @@ TEAH_acc_confirmation_cb (void *cls,
281 if (MHD_HTTP_OK != http_status) 281 if (MHD_HTTP_OK != http_status)
282 { 282 {
283 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 283 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
284 _("Failed to submit deposit confirmation to auditor `%s' with HTTP status %d (EC: %d). This is acceptable if it does not happen often.\n"), 284 _ (
285 "Failed to submit deposit confirmation to auditor `%s' with HTTP status %d (EC: %d). This is acceptable if it does not happen often.\n"),
285 ale->auditor_url, 286 ale->auditor_url,
286 http_status, 287 http_status,
287 (int) ec); 288 (int) ec);
@@ -310,7 +311,8 @@ TEAH_get_auditors_for_dc (struct TALER_EXCHANGE_Handle *h,
310 if (NULL == h->auditors_head) 311 if (NULL == h->auditors_head)
311 { 312 {
312 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 313 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
313 _("No auditor available for exchange `%s'. Not submitting deposit confirmations.\n"), 314 _ (
315 "No auditor available for exchange `%s'. Not submitting deposit confirmations.\n"),
314 h->url); 316 h->url);
315 return; 317 return;
316 } 318 }
@@ -385,7 +387,7 @@ parse_json_signkey (struct TALER_EXCHANGE_SigningPublicKey *sign_key,
385 &sign_key->valid_until), 387 &sign_key->valid_until),
386 GNUNET_JSON_spec_absolute_time ("stamp_end", 388 GNUNET_JSON_spec_absolute_time ("stamp_end",
387 &sign_key->valid_legal), 389 &sign_key->valid_legal),
388 GNUNET_JSON_spec_end() 390 GNUNET_JSON_spec_end ()
389 }; 391 };
390 392
391 if (GNUNET_OK != 393 if (GNUNET_OK !=
@@ -400,17 +402,19 @@ parse_json_signkey (struct TALER_EXCHANGE_SigningPublicKey *sign_key,
400 if (! check_sigs) 402 if (! check_sigs)
401 return GNUNET_OK; 403 return GNUNET_OK;
402 sign_key_issue.signkey_pub = sign_key->key; 404 sign_key_issue.signkey_pub = sign_key->key;
403 sign_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); 405 sign_key_issue.purpose.purpose = htonl (
404 sign_key_issue.purpose.size = htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS)); 406 TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY);
407 sign_key_issue.purpose.size = htonl (sizeof (struct
408 TALER_ExchangeSigningKeyValidityPS));
405 sign_key_issue.master_public_key = *master_key; 409 sign_key_issue.master_public_key = *master_key;
406 sign_key_issue.start = GNUNET_TIME_absolute_hton (sign_key->valid_from); 410 sign_key_issue.start = GNUNET_TIME_absolute_hton (sign_key->valid_from);
407 sign_key_issue.expire = GNUNET_TIME_absolute_hton (sign_key->valid_until); 411 sign_key_issue.expire = GNUNET_TIME_absolute_hton (sign_key->valid_until);
408 sign_key_issue.end = GNUNET_TIME_absolute_hton (sign_key->valid_legal); 412 sign_key_issue.end = GNUNET_TIME_absolute_hton (sign_key->valid_legal);
409 if (GNUNET_OK != 413 if (GNUNET_OK !=
410 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY, 414 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY,
411 &sign_key_issue.purpose, 415 &sign_key_issue.purpose,
412 &sign_key_issue_sig.eddsa_signature, 416 &sign_key_issue_sig.eddsa_signature,
413 &master_key->eddsa_pub)) 417 &master_key->eddsa_pub))
414 { 418 {
415 GNUNET_break_op (0); 419 GNUNET_break_op (0);
416 return GNUNET_SYSERR; 420 return GNUNET_SYSERR;
@@ -462,7 +466,7 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key,
462 &denom_key->fee_refund), 466 &denom_key->fee_refund),
463 GNUNET_JSON_spec_rsa_public_key ("denom_pub", 467 GNUNET_JSON_spec_rsa_public_key ("denom_pub",
464 &denom_key->key.rsa_public_key), 468 &denom_key->key.rsa_public_key),
465 GNUNET_JSON_spec_end() 469 GNUNET_JSON_spec_end ()
466 }; 470 };
467 471
468 if (GNUNET_OK != 472 if (GNUNET_OK !=
@@ -488,9 +492,12 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key,
488 denom_key_issue.master = *master_key; 492 denom_key_issue.master = *master_key;
489 denom_key_issue.denom_hash = denom_key->h_key; 493 denom_key_issue.denom_hash = denom_key->h_key;
490 denom_key_issue.start = GNUNET_TIME_absolute_hton (denom_key->valid_from); 494 denom_key_issue.start = GNUNET_TIME_absolute_hton (denom_key->valid_from);
491 denom_key_issue.expire_withdraw = GNUNET_TIME_absolute_hton (denom_key->withdraw_valid_until); 495 denom_key_issue.expire_withdraw = GNUNET_TIME_absolute_hton (
492 denom_key_issue.expire_deposit = GNUNET_TIME_absolute_hton (denom_key->expire_deposit); 496 denom_key->withdraw_valid_until);
493 denom_key_issue.expire_legal = GNUNET_TIME_absolute_hton (denom_key->expire_legal); 497 denom_key_issue.expire_deposit = GNUNET_TIME_absolute_hton (
498 denom_key->expire_deposit);
499 denom_key_issue.expire_legal = GNUNET_TIME_absolute_hton (
500 denom_key->expire_legal);
494 TALER_amount_hton (&denom_key_issue.value, 501 TALER_amount_hton (&denom_key_issue.value,
495 &denom_key->value); 502 &denom_key->value);
496 TALER_amount_hton (&denom_key_issue.fee_withdraw, 503 TALER_amount_hton (&denom_key_issue.fee_withdraw,
@@ -502,16 +509,17 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key,
502 TALER_amount_hton (&denom_key_issue.fee_refund, 509 TALER_amount_hton (&denom_key_issue.fee_refund,
503 &denom_key->fee_refund); 510 &denom_key->fee_refund);
504 EXITIF (GNUNET_SYSERR == 511 EXITIF (GNUNET_SYSERR ==
505 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, 512 GNUNET_CRYPTO_eddsa_verify (
506 &denom_key_issue.purpose, 513 TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY,
507 &denom_key->master_sig.eddsa_signature, 514 &denom_key_issue.purpose,
508 &master_key->eddsa_pub)); 515 &denom_key->master_sig.eddsa_signature,
516 &master_key->eddsa_pub));
509 GNUNET_CRYPTO_hash_context_read (hash_context, 517 GNUNET_CRYPTO_hash_context_read (hash_context,
510 &denom_key_issue.denom_hash, 518 &denom_key_issue.denom_hash,
511 sizeof (struct GNUNET_HashCode)); 519 sizeof (struct GNUNET_HashCode));
512 return GNUNET_OK; 520 return GNUNET_OK;
513 521
514 EXITIF_exit: 522 EXITIF_exit:
515 GNUNET_JSON_parse_free (spec); 523 GNUNET_JSON_parse_free (spec);
516 return GNUNET_SYSERR; 524 return GNUNET_SYSERR;
517} 525}
@@ -547,7 +555,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
547 &auditor_url), 555 &auditor_url),
548 GNUNET_JSON_spec_json ("denomination_keys", 556 GNUNET_JSON_spec_json ("denomination_keys",
549 &keys), 557 &keys),
550 GNUNET_JSON_spec_end() 558 GNUNET_JSON_spec_end ()
551 }; 559 };
552 560
553 if (GNUNET_OK != 561 if (GNUNET_OK !=
@@ -567,7 +575,8 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
567 kv.master = key_data->master_pub; 575 kv.master = key_data->master_pub;
568 len = json_array_size (keys); 576 len = json_array_size (keys);
569 auditor->denom_keys = GNUNET_new_array (len, 577 auditor->denom_keys = GNUNET_new_array (len,
570 struct TALER_EXCHANGE_AuditorDenominationInfo); 578 struct
579 TALER_EXCHANGE_AuditorDenominationInfo);
571 i = 0; 580 i = 0;
572 off = 0; 581 off = 0;
573 json_array_foreach (keys, i, key) { 582 json_array_foreach (keys, i, key) {
@@ -580,7 +589,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
580 &auditor_sig), 589 &auditor_sig),
581 GNUNET_JSON_spec_fixed_auto ("denom_pub_h", 590 GNUNET_JSON_spec_fixed_auto ("denom_pub_h",
582 &denom_h), 591 &denom_h),
583 GNUNET_JSON_spec_end() 592 GNUNET_JSON_spec_end ()
584 }; 593 };
585 594
586 if (GNUNET_OK != 595 if (GNUNET_OK !=
@@ -593,7 +602,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
593 } 602 }
594 dk = NULL; 603 dk = NULL;
595 dk_off = UINT_MAX; 604 dk_off = UINT_MAX;
596 for (unsigned int j=0;j<key_data->num_denom_keys;j++) 605 for (unsigned int j = 0; j<key_data->num_denom_keys; j++)
597 { 606 {
598 if (0 == GNUNET_memcmp (&denom_h, 607 if (0 == GNUNET_memcmp (&denom_h,
599 &key_data->denom_keys[j].h_key)) 608 &key_data->denom_keys[j].h_key))
@@ -617,20 +626,20 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
617 TALER_amount_hton (&kv.value, 626 TALER_amount_hton (&kv.value,
618 &dk->value); 627 &dk->value);
619 TALER_amount_hton (&kv.fee_withdraw, 628 TALER_amount_hton (&kv.fee_withdraw,
620 &dk->fee_withdraw); 629 &dk->fee_withdraw);
621 TALER_amount_hton (&kv.fee_deposit, 630 TALER_amount_hton (&kv.fee_deposit,
622 &dk->fee_deposit); 631 &dk->fee_deposit);
623 TALER_amount_hton (&kv.fee_refresh, 632 TALER_amount_hton (&kv.fee_refresh,
624 &dk->fee_refresh); 633 &dk->fee_refresh);
625 TALER_amount_hton (&kv.fee_refund, 634 TALER_amount_hton (&kv.fee_refund,
626 &dk->fee_refund); 635 &dk->fee_refund);
627 kv.denom_hash = dk->h_key; 636 kv.denom_hash = dk->h_key;
628 637
629 if (GNUNET_OK != 638 if (GNUNET_OK !=
630 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS, 639 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS,
631 &kv.purpose, 640 &kv.purpose,
632 &auditor_sig.eddsa_sig, 641 &auditor_sig.eddsa_sig,
633 &auditor->auditor_pub.eddsa_pub)) 642 &auditor->auditor_pub.eddsa_pub))
634 { 643 {
635 GNUNET_break_op (0); 644 GNUNET_break_op (0);
636 GNUNET_JSON_parse_free (spec); 645 GNUNET_JSON_parse_free (spec);
@@ -658,26 +667,27 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
658static void 667static void
659auditor_version_cb 668auditor_version_cb
660 (void *cls, 669 (void *cls,
661 const struct TALER_AUDITOR_VersionInformation *vi, 670 const struct TALER_AUDITOR_VersionInformation *vi,
662 enum TALER_AUDITOR_VersionCompatibility compat) 671 enum TALER_AUDITOR_VersionCompatibility compat)
663{ 672{
664 struct TEAH_AuditorListEntry *ale = cls; 673 struct TEAH_AuditorListEntry *ale = cls;
665 674
666 if (0 != (TALER_AUDITOR_VC_INCOMPATIBLE & compat)) 675 if (0 != (TALER_AUDITOR_VC_INCOMPATIBLE & compat))
667 { 676 {
668 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 677 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
669 _("Auditor `%s' runs incompatible protocol version!\n"), 678 _ ("Auditor `%s' runs incompatible protocol version!\n"),
670 ale->auditor_url); 679 ale->auditor_url);
671 if (0 != (TALER_AUDITOR_VC_OLDER & compat)) 680 if (0 != (TALER_AUDITOR_VC_OLDER & compat))
672 { 681 {
673 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 682 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
674 _("Auditor `%s' runs outdated protocol version!\n"), 683 _ ("Auditor `%s' runs outdated protocol version!\n"),
675 ale->auditor_url); 684 ale->auditor_url);
676 } 685 }
677 if (0 != (TALER_AUDITOR_VC_NEWER & compat)) 686 if (0 != (TALER_AUDITOR_VC_NEWER & compat))
678 { 687 {
679 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 688 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
680 _("Auditor `%s' runs more recent incompatible version. We should upgrade!\n"), 689 _ (
690 "Auditor `%s' runs more recent incompatible version. We should upgrade!\n"),
681 ale->auditor_url); 691 ale->auditor_url);
682 } 692 }
683 return; 693 return;
@@ -698,7 +708,7 @@ update_auditors (struct TALER_EXCHANGE_Handle *exchange)
698 struct TALER_EXCHANGE_Keys *kd = &exchange->key_data; 708 struct TALER_EXCHANGE_Keys *kd = &exchange->key_data;
699 709
700 TALER_LOG_DEBUG ("Updating auditors\n"); 710 TALER_LOG_DEBUG ("Updating auditors\n");
701 for (unsigned int i=0;i<kd->num_auditors;i++) 711 for (unsigned int i = 0; i<kd->num_auditors; i++)
702 { 712 {
703 /* Compare auditor data from /keys with auditor data 713 /* Compare auditor data from /keys with auditor data
704 * from owned exchange structures. */ 714 * from owned exchange structures. */
@@ -752,8 +762,8 @@ TALER_denoms_cmp (struct TALER_EXCHANGE_DenomPublicKey *denom1,
752 762
753 /* First check if pub is the same. */ 763 /* First check if pub is the same. */
754 if (0 != GNUNET_CRYPTO_rsa_public_key_cmp 764 if (0 != GNUNET_CRYPTO_rsa_public_key_cmp
755 (denom1->key.rsa_public_key, 765 (denom1->key.rsa_public_key,
756 denom2->key.rsa_public_key)) 766 denom2->key.rsa_public_key))
757 return 1; 767 return 1;
758 768
759 tmp1 = denom1->key.rsa_public_key; 769 tmp1 = denom1->key.rsa_public_key;
@@ -815,7 +825,7 @@ decode_keys_json (const json_t *resp_obj,
815 &key_data->list_issue_date), 825 &key_data->list_issue_date),
816 GNUNET_JSON_spec_relative_time ("reserve_closing_delay", 826 GNUNET_JSON_spec_relative_time ("reserve_closing_delay",
817 &key_data->reserve_closing_delay), 827 &key_data->reserve_closing_delay),
818 GNUNET_JSON_spec_end() 828 GNUNET_JSON_spec_end ()
819 }; 829 };
820 830
821 if (JSON_OBJECT != json_typeof (resp_obj)) 831 if (JSON_OBJECT != json_typeof (resp_obj))
@@ -829,7 +839,7 @@ decode_keys_json (const json_t *resp_obj,
829 struct GNUNET_JSON_Specification spec[] = { 839 struct GNUNET_JSON_Specification spec[] = {
830 GNUNET_JSON_spec_string ("version", 840 GNUNET_JSON_spec_string ("version",
831 &ver), 841 &ver),
832 GNUNET_JSON_spec_end() 842 GNUNET_JSON_spec_end ()
833 }; 843 };
834 844
835 if (GNUNET_OK != 845 if (GNUNET_OK !=
@@ -882,11 +892,11 @@ decode_keys_json (const json_t *resp_obj,
882 unsigned int index; 892 unsigned int index;
883 893
884 EXITIF (NULL == (sign_keys_array = 894 EXITIF (NULL == (sign_keys_array =
885 json_object_get (resp_obj, 895 json_object_get (resp_obj,
886 "signkeys"))); 896 "signkeys")));
887 EXITIF (JSON_ARRAY != json_typeof (sign_keys_array)); 897 EXITIF (JSON_ARRAY != json_typeof (sign_keys_array));
888 EXITIF (0 == (key_data->num_sign_keys = 898 EXITIF (0 == (key_data->num_sign_keys =
889 json_array_size (sign_keys_array))); 899 json_array_size (sign_keys_array)));
890 key_data->sign_keys 900 key_data->sign_keys
891 = GNUNET_new_array (key_data->num_sign_keys, 901 = GNUNET_new_array (key_data->num_sign_keys,
892 struct TALER_EXCHANGE_SigningPublicKey); 902 struct TALER_EXCHANGE_SigningPublicKey);
@@ -908,8 +918,8 @@ decode_keys_json (const json_t *resp_obj,
908 unsigned int index; 918 unsigned int index;
909 919
910 EXITIF (NULL == (denom_keys_array = 920 EXITIF (NULL == (denom_keys_array =
911 json_object_get (resp_obj, 921 json_object_get (resp_obj,
912 "denoms"))); 922 "denoms")));
913 EXITIF (JSON_ARRAY != json_typeof (denom_keys_array)); 923 EXITIF (JSON_ARRAY != json_typeof (denom_keys_array));
914 924
915 index = 0; 925 index = 0;
@@ -924,7 +934,7 @@ decode_keys_json (const json_t *resp_obj,
924 &key_data->master_pub, 934 &key_data->master_pub,
925 hash_context)); 935 hash_context));
926 936
927 for (unsigned int j=0; 937 for (unsigned int j = 0;
928 j<key_data->num_denom_keys; 938 j<key_data->num_denom_keys;
929 j++) 939 j++)
930 { 940 {
@@ -965,8 +975,8 @@ decode_keys_json (const json_t *resp_obj,
965 unsigned int index; 975 unsigned int index;
966 976
967 EXITIF (NULL == (auditors_array = 977 EXITIF (NULL == (auditors_array =
968 json_object_get (resp_obj, 978 json_object_get (resp_obj,
969 "auditors"))); 979 "auditors")));
970 EXITIF (JSON_ARRAY != json_typeof (auditors_array)); 980 EXITIF (JSON_ARRAY != json_typeof (auditors_array));
971 981
972 /* Merge with the existing auditor information we have (/keys cherry picking) */ 982 /* Merge with the existing auditor information we have (/keys cherry picking) */
@@ -983,7 +993,7 @@ decode_keys_json (const json_t *resp_obj,
983 check_sig, 993 check_sig,
984 auditor_info, 994 auditor_info,
985 key_data)); 995 key_data));
986 for (unsigned int j=0;j<key_data->num_auditors;j++) 996 for (unsigned int j = 0; j<key_data->num_auditors; j++)
987 { 997 {
988 struct TALER_EXCHANGE_AuditorInformation *aix = &key_data->auditors[j]; 998 struct TALER_EXCHANGE_AuditorInformation *aix = &key_data->auditors[j];
989 999
@@ -998,9 +1008,10 @@ decode_keys_json (const json_t *resp_obj,
998 aix->num_denom_keys + ai.num_denom_keys); 1008 aix->num_denom_keys + ai.num_denom_keys);
999 memcpy (&aix->denom_keys[aix->num_denom_keys - ai.num_denom_keys], 1009 memcpy (&aix->denom_keys[aix->num_denom_keys - ai.num_denom_keys],
1000 ai.denom_keys, 1010 ai.denom_keys,
1001 ai.num_denom_keys * sizeof (struct TALER_EXCHANGE_AuditorDenominationInfo)); 1011 ai.num_denom_keys * sizeof (struct
1002 break; 1012 TALER_EXCHANGE_AuditorDenominationInfo));
1003 } 1013 break;
1014 }
1004 } 1015 }
1005 if (GNUNET_YES == found) 1016 if (GNUNET_YES == found)
1006 continue; /* we are done */ 1017 continue; /* we are done */
@@ -1025,8 +1036,8 @@ decode_keys_json (const json_t *resp_obj,
1025 &ks.hc); 1036 &ks.hc);
1026 hash_context = NULL; 1037 hash_context = NULL;
1027 EXITIF (GNUNET_OK != 1038 EXITIF (GNUNET_OK !=
1028 TALER_EXCHANGE_test_signing_key (key_data, 1039 TALER_EXCHANGE_test_signing_key (key_data,
1029 &pub)); 1040 &pub));
1030 EXITIF (GNUNET_OK != 1041 EXITIF (GNUNET_OK !=
1031 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_KEY_SET, 1042 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_KEY_SET,
1032 &ks.purpose, 1043 &ks.purpose,
@@ -1034,7 +1045,7 @@ decode_keys_json (const json_t *resp_obj,
1034 &pub.eddsa_pub)); 1045 &pub.eddsa_pub));
1035 } 1046 }
1036 return GNUNET_OK; 1047 return GNUNET_OK;
1037 EXITIF_exit: 1048 EXITIF_exit:
1038 1049
1039 *vc = TALER_EXCHANGE_VC_PROTOCOL_ERROR; 1050 *vc = TALER_EXCHANGE_VC_PROTOCOL_ERROR;
1040 if (NULL != hash_context) 1051 if (NULL != hash_context)
@@ -1054,13 +1065,14 @@ free_key_data (struct TALER_EXCHANGE_Keys *key_data)
1054 GNUNET_array_grow (key_data->sign_keys, 1065 GNUNET_array_grow (key_data->sign_keys,
1055 key_data->num_sign_keys, 1066 key_data->num_sign_keys,
1056 0); 1067 0);
1057 for (unsigned int i=0;i<key_data->num_denom_keys;i++) 1068 for (unsigned int i = 0; i<key_data->num_denom_keys; i++)
1058 GNUNET_CRYPTO_rsa_public_key_free (key_data->denom_keys[i].key.rsa_public_key); 1069 GNUNET_CRYPTO_rsa_public_key_free (
1070 key_data->denom_keys[i].key.rsa_public_key);
1059 1071
1060 GNUNET_array_grow (key_data->denom_keys, 1072 GNUNET_array_grow (key_data->denom_keys,
1061 key_data->denom_keys_size, 1073 key_data->denom_keys_size,
1062 0); 1074 0);
1063 for (unsigned int i=0;i<key_data->num_auditors;i++) 1075 for (unsigned int i = 0; i<key_data->num_auditors; i++)
1064 { 1076 {
1065 GNUNET_array_grow (key_data->auditors[i].denom_keys, 1077 GNUNET_array_grow (key_data->auditors[i].denom_keys,
1066 key_data->auditors[i].num_denom_keys, 1078 key_data->auditors[i].num_denom_keys,
@@ -1157,7 +1169,8 @@ TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange,
1157 TEAH_handle_reset (exchange); 1169 TEAH_handle_reset (exchange);
1158 } 1170 }
1159 if ( (GNUNET_NO == force_download) && 1171 if ( (GNUNET_NO == force_download) &&
1160 (0 < GNUNET_TIME_absolute_get_remaining (exchange->key_data_expiration).rel_value_us) ) 1172 (0 < GNUNET_TIME_absolute_get_remaining (
1173 exchange->key_data_expiration).rel_value_us) )
1161 return exchange->key_data_expiration; 1174 return exchange->key_data_expiration;
1162 if (NULL == exchange->retry_task) 1175 if (NULL == exchange->retry_task)
1163 exchange->retry_task = GNUNET_SCHEDULER_add_now (&request_keys, 1176 exchange->retry_task = GNUNET_SCHEDULER_add_now (&request_keys,
@@ -1223,19 +1236,22 @@ keys_completed_cb (void *cls,
1223 /* First make a shallow copy, we then need another pass for the RSA key... */ 1236 /* First make a shallow copy, we then need another pass for the RSA key... */
1224 memcpy (kd.denom_keys, 1237 memcpy (kd.denom_keys,
1225 kd_old.denom_keys, 1238 kd_old.denom_keys,
1226 kd_old.num_denom_keys * sizeof (struct TALER_EXCHANGE_DenomPublicKey)); 1239 kd_old.num_denom_keys * sizeof (struct
1240 TALER_EXCHANGE_DenomPublicKey));
1227 1241
1228 for (unsigned int i=0;i<kd_old.num_denom_keys;i++) 1242 for (unsigned int i = 0; i<kd_old.num_denom_keys; i++)
1229 kd.denom_keys[i].key.rsa_public_key 1243 kd.denom_keys[i].key.rsa_public_key
1230 = GNUNET_CRYPTO_rsa_public_key_dup (kd_old.denom_keys[i].key.rsa_public_key); 1244 = GNUNET_CRYPTO_rsa_public_key_dup (
1245 kd_old.denom_keys[i].key.rsa_public_key);
1231 1246
1232 kd.num_auditors = kd_old.num_auditors; 1247 kd.num_auditors = kd_old.num_auditors;
1233 kd.auditors = GNUNET_new_array (kd.num_auditors, 1248 kd.auditors = GNUNET_new_array (kd.num_auditors,
1234 struct TALER_EXCHANGE_AuditorInformation); 1249 struct TALER_EXCHANGE_AuditorInformation);
1235 /* Now the necessary deep copy... */ 1250 /* Now the necessary deep copy... */
1236 for (unsigned int i=0;i<kd_old.num_auditors;i++) 1251 for (unsigned int i = 0; i<kd_old.num_auditors; i++)
1237 { 1252 {
1238 const struct TALER_EXCHANGE_AuditorInformation *aold = &kd_old.auditors[i]; 1253 const struct TALER_EXCHANGE_AuditorInformation *aold =
1254 &kd_old.auditors[i];
1239 struct TALER_EXCHANGE_AuditorInformation *anew = &kd.auditors[i]; 1255 struct TALER_EXCHANGE_AuditorInformation *anew = &kd.auditors[i];
1240 1256
1241 anew->auditor_pub = aold->auditor_pub; 1257 anew->auditor_pub = aold->auditor_pub;
@@ -1246,7 +1262,8 @@ keys_completed_cb (void *cls,
1246 aold->num_denom_keys); 1262 aold->num_denom_keys);
1247 memcpy (anew->denom_keys, 1263 memcpy (anew->denom_keys,
1248 aold->denom_keys, 1264 aold->denom_keys,
1249 aold->num_denom_keys * sizeof (struct TALER_EXCHANGE_AuditorDenominationInfo)); 1265 aold->num_denom_keys * sizeof (struct
1266 TALER_EXCHANGE_AuditorDenominationInfo));
1250 } 1267 }
1251 1268
1252 /* Old auditors got just copied into new ones. */ 1269 /* Old auditors got just copied into new ones. */
@@ -1258,7 +1275,7 @@ keys_completed_cb (void *cls,
1258 { 1275 {
1259 TALER_LOG_ERROR ("Could not decode /keys response\n"); 1276 TALER_LOG_ERROR ("Could not decode /keys response\n");
1260 response_code = 0; 1277 response_code = 0;
1261 for (unsigned int i=0;i<kd.num_auditors;i++) 1278 for (unsigned int i = 0; i<kd.num_auditors; i++)
1262 { 1279 {
1263 struct TALER_EXCHANGE_AuditorInformation *anew = &kd.auditors[i]; 1280 struct TALER_EXCHANGE_AuditorInformation *anew = &kd.auditors[i];
1264 1281
@@ -1270,7 +1287,7 @@ keys_completed_cb (void *cls,
1270 GNUNET_free (kd.auditors); 1287 GNUNET_free (kd.auditors);
1271 kd.auditors = NULL; 1288 kd.auditors = NULL;
1272 kd.num_auditors = 0; 1289 kd.num_auditors = 0;
1273 for (unsigned int i=0;i<kd_old.num_denom_keys;i++) 1290 for (unsigned int i = 0; i<kd_old.num_denom_keys; i++)
1274 GNUNET_CRYPTO_rsa_public_key_free (kd.denom_keys[i].key.rsa_public_key); 1291 GNUNET_CRYPTO_rsa_public_key_free (kd.denom_keys[i].key.rsa_public_key);
1275 GNUNET_array_grow (kd.denom_keys, 1292 GNUNET_array_grow (kd.denom_keys,
1276 kd.denom_keys_size, 1293 kd.denom_keys_size,
@@ -1375,10 +1392,10 @@ TEAH_handle_is_ready (struct TALER_EXCHANGE_Handle *h)
1375 */ 1392 */
1376char * 1393char *
1377TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h, 1394TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h,
1378 const char *path) 1395 const char *path)
1379{ 1396{
1380 return TEAH_path_to_url2 (h->url, 1397 return TEAH_path_to_url2 (h->url,
1381 path); 1398 path);
1382} 1399}
1383 1400
1384 1401
@@ -1391,7 +1408,7 @@ TEAH_path_to_url (struct TALER_EXCHANGE_Handle *h,
1391 */ 1408 */
1392char * 1409char *
1393TEAH_path_to_url2 (const char *base_url, 1410TEAH_path_to_url2 (const char *base_url,
1394 const char *path) 1411 const char *path)
1395{ 1412{
1396 char *url; 1413 char *url;
1397 1414
@@ -1515,14 +1532,14 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
1515 struct GNUNET_TIME_Absolute expire; 1532 struct GNUNET_TIME_Absolute expire;
1516 struct GNUNET_JSON_Specification spec[] = { 1533 struct GNUNET_JSON_Specification spec[] = {
1517 GNUNET_JSON_spec_uint32 ("version", 1534 GNUNET_JSON_spec_uint32 ("version",
1518 &version), 1535 &version),
1519 GNUNET_JSON_spec_json ("keys", 1536 GNUNET_JSON_spec_json ("keys",
1520 &keys), 1537 &keys),
1521 GNUNET_JSON_spec_string ("url", 1538 GNUNET_JSON_spec_string ("url",
1522 &url), 1539 &url),
1523 GNUNET_JSON_spec_absolute_time ("expire", 1540 GNUNET_JSON_spec_absolute_time ("expire",
1524 &expire), 1541 &expire),
1525 GNUNET_JSON_spec_end() 1542 GNUNET_JSON_spec_end ()
1526 }; 1543 };
1527 struct TALER_EXCHANGE_Keys key_data; 1544 struct TALER_EXCHANGE_Keys key_data;
1528 1545
@@ -1539,23 +1556,23 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
1539 if (0 != version) 1556 if (0 != version)
1540 return; /* unsupported version */ 1557 return; /* unsupported version */
1541 if (0 != strcmp (url, 1558 if (0 != strcmp (url,
1542 exchange->url)) 1559 exchange->url))
1543 { 1560 {
1544 GNUNET_break (0); 1561 GNUNET_break (0);
1545 return; 1562 return;
1546 } 1563 }
1547 memset (&key_data, 1564 memset (&key_data,
1548 0, 1565 0,
1549 sizeof (struct TALER_EXCHANGE_Keys)); 1566 sizeof (struct TALER_EXCHANGE_Keys));
1550 if (GNUNET_OK != 1567 if (GNUNET_OK !=
1551 decode_keys_json (keys, 1568 decode_keys_json (keys,
1552 GNUNET_NO, 1569 GNUNET_NO,
1553 &key_data, 1570 &key_data,
1554 &vc)) 1571 &vc))
1555 { 1572 {
1556 GNUNET_break (0); 1573 GNUNET_break (0);
1557 return; 1574 return;
1558 } 1575 }
1559 /* decode successful, initialize with the result */ 1576 /* decode successful, initialize with the result */
1560 GNUNET_assert (NULL == exchange->key_data_raw); 1577 GNUNET_assert (NULL == exchange->key_data_raw);
1561 exchange->key_data_raw = json_deep_copy (keys); 1578 exchange->key_data_raw = json_deep_copy (keys);
@@ -1566,7 +1583,7 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
1566 /* notify application about the key information */ 1583 /* notify application about the key information */
1567 exchange->cert_cb (exchange->cert_cb_cls, 1584 exchange->cert_cb (exchange->cert_cb_cls,
1568 &exchange->key_data, 1585 &exchange->key_data,
1569 vc); 1586 vc);
1570} 1587}
1571 1588
1572 1589
@@ -1599,7 +1616,7 @@ TALER_EXCHANGE_serialize_data
1599 GNUNET_break (0); 1616 GNUNET_break (0);
1600 return NULL; 1617 return NULL;
1601 } 1618 }
1602 for (unsigned int i=0;i<kd->num_sign_keys;i++) 1619 for (unsigned int i = 0; i<kd->num_sign_keys; i++)
1603 { 1620 {
1604 const struct TALER_EXCHANGE_SigningPublicKey *sk = &kd->sign_keys[i]; 1621 const struct TALER_EXCHANGE_SigningPublicKey *sk = &kd->sign_keys[i];
1605 json_t *signkey; 1622 json_t *signkey;
@@ -1609,19 +1626,19 @@ TALER_EXCHANGE_serialize_data
1609 signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}", 1626 signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}",
1610 "key", 1627 "key",
1611 GNUNET_JSON_from_data_auto 1628 GNUNET_JSON_from_data_auto
1612 (&sk->key), 1629 (&sk->key),
1613 "master_sig", 1630 "master_sig",
1614 GNUNET_JSON_from_data_auto 1631 GNUNET_JSON_from_data_auto
1615 (&sk->master_sig), 1632 (&sk->master_sig),
1616 "stamp_start", 1633 "stamp_start",
1617 GNUNET_JSON_from_time_abs 1634 GNUNET_JSON_from_time_abs
1618 (sk->valid_from), 1635 (sk->valid_from),
1619 "stamp_expire", 1636 "stamp_expire",
1620 GNUNET_JSON_from_time_abs 1637 GNUNET_JSON_from_time_abs
1621 (sk->valid_until), 1638 (sk->valid_until),
1622 "stamp_end", 1639 "stamp_end",
1623 GNUNET_JSON_from_time_abs 1640 GNUNET_JSON_from_time_abs
1624 (sk->valid_legal)); 1641 (sk->valid_legal));
1625 if (NULL == signkey) 1642 if (NULL == signkey)
1626 { 1643 {
1627 GNUNET_break (0); 1644 GNUNET_break (0);
@@ -1643,7 +1660,7 @@ TALER_EXCHANGE_serialize_data
1643 json_decref (signkeys); 1660 json_decref (signkeys);
1644 return NULL; 1661 return NULL;
1645 } 1662 }
1646 for (unsigned int i=0;i<kd->num_denom_keys;i++) 1663 for (unsigned int i = 0; i<kd->num_denom_keys; i++)
1647 { 1664 {
1648 const struct TALER_EXCHANGE_DenomPublicKey *dk = &kd->denom_keys[i]; 1665 const struct TALER_EXCHANGE_DenomPublicKey *dk = &kd->denom_keys[i];
1649 json_t *denom; 1666 json_t *denom;
@@ -1676,14 +1693,15 @@ TALER_EXCHANGE_serialize_data
1676 GNUNET_JSON_from_data_auto (&dk->master_sig), 1693 GNUNET_JSON_from_data_auto (&dk->master_sig),
1677 /* #10 */ 1694 /* #10 */
1678 "denom_pub", 1695 "denom_pub",
1679 GNUNET_JSON_from_rsa_public_key (dk->key.rsa_public_key)); 1696 GNUNET_JSON_from_rsa_public_key (
1697 dk->key.rsa_public_key));
1680 if (NULL == denom) 1698 if (NULL == denom)
1681 { 1699 {
1682 GNUNET_break (0); 1700 GNUNET_break (0);
1683 continue; 1701 continue;
1684 } 1702 }
1685 if (0 != json_array_append_new (denoms, 1703 if (0 != json_array_append_new (denoms,
1686 denom)) 1704 denom))
1687 { 1705 {
1688 GNUNET_break (0); 1706 GNUNET_break (0);
1689 json_decref (denom); 1707 json_decref (denom);
@@ -1700,7 +1718,7 @@ TALER_EXCHANGE_serialize_data
1700 json_decref (signkeys); 1718 json_decref (signkeys);
1701 return NULL; 1719 return NULL;
1702 } 1720 }
1703 for (unsigned int i=0;i<kd->num_auditors;i++) 1721 for (unsigned int i = 0; i<kd->num_auditors; i++)
1704 { 1722 {
1705 const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i]; 1723 const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i];
1706 json_t *a; 1724 json_t *a;
@@ -1715,10 +1733,12 @@ TALER_EXCHANGE_serialize_data
1715 json_decref (auditors); 1733 json_decref (auditors);
1716 return NULL; 1734 return NULL;
1717 } 1735 }
1718 for (unsigned int j=0;j<ai->num_denom_keys;j++) 1736 for (unsigned int j = 0; j<ai->num_denom_keys; j++)
1719 { 1737 {
1720 const struct TALER_EXCHANGE_AuditorDenominationInfo *adi = &ai->denom_keys[j]; 1738 const struct TALER_EXCHANGE_AuditorDenominationInfo *adi =
1721 const struct TALER_EXCHANGE_DenomPublicKey *dk = &kd->denom_keys[adi->denom_key_offset]; 1739 &ai->denom_keys[j];
1740 const struct TALER_EXCHANGE_DenomPublicKey *dk =
1741 &kd->denom_keys[adi->denom_key_offset];
1722 json_t *k; 1742 json_t *k;
1723 1743
1724 if (now.abs_value_us > dk->expire_deposit.abs_value_us) 1744 if (now.abs_value_us > dk->expire_deposit.abs_value_us)
@@ -1832,10 +1852,10 @@ TALER_EXCHANGE_serialize_data
1832struct TALER_EXCHANGE_Handle * 1852struct TALER_EXCHANGE_Handle *
1833TALER_EXCHANGE_connect 1853TALER_EXCHANGE_connect
1834 (struct GNUNET_CURL_Context *ctx, 1854 (struct GNUNET_CURL_Context *ctx,
1835 const char *url, 1855 const char *url,
1836 TALER_EXCHANGE_CertificationCallback cert_cb, 1856 TALER_EXCHANGE_CertificationCallback cert_cb,
1837 void *cert_cb_cls, 1857 void *cert_cb_cls,
1838 ...) 1858 ...)
1839{ 1859{
1840 struct TALER_EXCHANGE_Handle *exchange; 1860 struct TALER_EXCHANGE_Handle *exchange;
1841 va_list ap; 1861 va_list ap;
@@ -1845,8 +1865,8 @@ TALER_EXCHANGE_connect
1845 url); 1865 url);
1846 /* Disable 100 continue processing */ 1866 /* Disable 100 continue processing */
1847 GNUNET_break (GNUNET_OK == 1867 GNUNET_break (GNUNET_OK ==
1848 GNUNET_CURL_append_header (ctx, 1868 GNUNET_CURL_append_header (ctx,
1849 "Expect:")); 1869 "Expect:"));
1850 exchange = GNUNET_new (struct TALER_EXCHANGE_Handle); 1870 exchange = GNUNET_new (struct TALER_EXCHANGE_Handle);
1851 exchange->ctx = ctx; 1871 exchange->ctx = ctx;
1852 exchange->url = GNUNET_strdup (url); 1872 exchange->url = GNUNET_strdup (url);
@@ -1856,20 +1876,21 @@ TALER_EXCHANGE_connect
1856 exchange); 1876 exchange);
1857 va_start (ap, cert_cb_cls); 1877 va_start (ap, cert_cb_cls);
1858 while (TALER_EXCHANGE_OPTION_END != 1878 while (TALER_EXCHANGE_OPTION_END !=
1859 (opt = va_arg (ap, int))) 1879 (opt = va_arg (ap, int)))
1860 { 1880 {
1861 switch (opt) { 1881 switch (opt)
1882 {
1862 case TALER_EXCHANGE_OPTION_END: 1883 case TALER_EXCHANGE_OPTION_END:
1863 GNUNET_assert (0); 1884 GNUNET_assert (0);
1864 break; 1885 break;
1865 case TALER_EXCHANGE_OPTION_DATA: 1886 case TALER_EXCHANGE_OPTION_DATA:
1866 { 1887 {
1867 const json_t *data = va_arg (ap, const json_t *); 1888 const json_t *data = va_arg (ap, const json_t *);
1868 1889
1869 deserialize_data (exchange, 1890 deserialize_data (exchange,
1870 data); 1891 data);
1871 break; 1892 break;
1872 } 1893 }
1873 default: 1894 default:
1874 GNUNET_assert (0); 1895 GNUNET_assert (0);
1875 break; 1896 break;
@@ -1902,10 +1923,13 @@ request_keys (void *cls)
1902 if (GNUNET_YES == TEAH_handle_is_ready (exchange)) 1923 if (GNUNET_YES == TEAH_handle_is_ready (exchange))
1903 { 1924 {
1904 TALER_LOG_DEBUG ("Last DK issue date (before GETting /keys): %s\n", 1925 TALER_LOG_DEBUG ("Last DK issue date (before GETting /keys): %s\n",
1905 GNUNET_STRINGS_absolute_time_to_string (exchange->key_data.last_denom_issue_date)); 1926 GNUNET_STRINGS_absolute_time_to_string (
1927 exchange->key_data.last_denom_issue_date));
1906 sprintf (&url[strlen (url)], 1928 sprintf (&url[strlen (url)],
1907 "last_issue_date=%llu&", 1929 "last_issue_date=%llu&",
1908 (unsigned long long) exchange->key_data.last_denom_issue_date.abs_value_us / 1000000LLU); 1930 (unsigned long
1931 long) exchange->key_data.last_denom_issue_date.abs_value_us
1932 / 1000000LLU);
1909 } 1933 }
1910 1934
1911 if (GNUNET_YES == exchange->with_now) 1935 if (GNUNET_YES == exchange->with_now)
@@ -1969,7 +1993,8 @@ TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle *exchange)
1969 { 1993 {
1970 GNUNET_assert (aie->ale == ale); 1994 GNUNET_assert (aie->ale == ale);
1971 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1995 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1972 _("Not sending deposit confirmation to auditor `%s' due to exchange disconnect\n"), 1996 _ (
1997 "Not sending deposit confirmation to auditor `%s' due to exchange disconnect\n"),
1973 ale->auditor_url); 1998 ale->auditor_url);
1974 TALER_AUDITOR_deposit_confirmation_cancel (aie->dch); 1999 TALER_AUDITOR_deposit_confirmation_cancel (aie->dch);
1975 GNUNET_CONTAINER_DLL_remove (ale->ai_head, 2000 GNUNET_CONTAINER_DLL_remove (ale->ai_head,
@@ -2017,9 +2042,10 @@ TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle *exchange)
2017 */ 2042 */
2018const struct TALER_EXCHANGE_SigningPublicKey * 2043const struct TALER_EXCHANGE_SigningPublicKey *
2019TALER_EXCHANGE_get_signing_key_details (const struct TALER_EXCHANGE_Keys *keys, 2044TALER_EXCHANGE_get_signing_key_details (const struct TALER_EXCHANGE_Keys *keys,
2020 const struct TALER_ExchangePublicKeyP *pub) 2045 const struct
2046 TALER_ExchangePublicKeyP *pub)
2021{ 2047{
2022 for (unsigned int i=0;i<keys->num_sign_keys;i++) 2048 for (unsigned int i = 0; i<keys->num_sign_keys; i++)
2023 { 2049 {
2024 struct TALER_EXCHANGE_SigningPublicKey *spk = &keys->sign_keys[i]; 2050 struct TALER_EXCHANGE_SigningPublicKey *spk = &keys->sign_keys[i];
2025 2051
@@ -2047,9 +2073,11 @@ TALER_EXCHANGE_test_signing_key (const struct TALER_EXCHANGE_Keys *keys,
2047 2073
2048 /* we will check using a tolerance of 1h for the time */ 2074 /* we will check using a tolerance of 1h for the time */
2049 now = GNUNET_TIME_absolute_get (); 2075 now = GNUNET_TIME_absolute_get ();
2050 for (unsigned int i=0;i<keys->num_sign_keys;i++) 2076 for (unsigned int i = 0; i<keys->num_sign_keys; i++)
2051 if ( (keys->sign_keys[i].valid_from.abs_value_us <= now.abs_value_us + 60 * 60 * 1000LL * 1000LL) && 2077 if ( (keys->sign_keys[i].valid_from.abs_value_us <= now.abs_value_us + 60
2052 (keys->sign_keys[i].valid_until.abs_value_us > now.abs_value_us - 60 * 60 * 1000LL * 1000LL) && 2078 * 60 * 1000LL * 1000LL) &&
2079 (keys->sign_keys[i].valid_until.abs_value_us > now.abs_value_us - 60
2080 * 60 * 1000LL * 1000LL) &&
2053 (0 == GNUNET_memcmp (pub, 2081 (0 == GNUNET_memcmp (pub,
2054 &keys->sign_keys[i].key)) ) 2082 &keys->sign_keys[i].key)) )
2055 return GNUNET_OK; 2083 return GNUNET_OK;
@@ -2080,11 +2108,13 @@ TALER_EXCHANGE_get_base_url (const struct TALER_EXCHANGE_Handle *exchange)
2080 */ 2108 */
2081const struct TALER_EXCHANGE_DenomPublicKey * 2109const struct TALER_EXCHANGE_DenomPublicKey *
2082TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys, 2110TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys,
2083 const struct TALER_DenominationPublicKey *pk) 2111 const struct
2112 TALER_DenominationPublicKey *pk)
2084{ 2113{
2085 for (unsigned int i=0;i<keys->num_denom_keys;i++) 2114 for (unsigned int i = 0; i<keys->num_denom_keys; i++)
2086 if (0 == GNUNET_CRYPTO_rsa_public_key_cmp (pk->rsa_public_key, 2115 if (0 == GNUNET_CRYPTO_rsa_public_key_cmp (pk->rsa_public_key,
2087 keys->denom_keys[i].key.rsa_public_key)) 2116 keys->denom_keys[i].key.
2117 rsa_public_key))
2088 return &keys->denom_keys[i]; 2118 return &keys->denom_keys[i];
2089 return NULL; 2119 return NULL;
2090} 2120}
@@ -2098,10 +2128,11 @@ TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys,
2098 * @return details about the given denomination key 2128 * @return details about the given denomination key
2099 */ 2129 */
2100const struct TALER_EXCHANGE_DenomPublicKey * 2130const struct TALER_EXCHANGE_DenomPublicKey *
2101TALER_EXCHANGE_get_denomination_key_by_hash (const struct TALER_EXCHANGE_Keys *keys, 2131TALER_EXCHANGE_get_denomination_key_by_hash (const struct
2132 TALER_EXCHANGE_Keys *keys,
2102 const struct GNUNET_HashCode *hc) 2133 const struct GNUNET_HashCode *hc)
2103{ 2134{
2104 for (unsigned int i=0;i<keys->num_denom_keys;i++) 2135 for (unsigned int i = 0; i<keys->num_denom_keys; i++)
2105 if (0 == GNUNET_memcmp (hc, 2136 if (0 == GNUNET_memcmp (hc,
2106 &keys->denom_keys[i].h_key)) 2137 &keys->denom_keys[i].h_key))
2107 return &keys->denom_keys[i]; 2138 return &keys->denom_keys[i];