diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/auditor_signatures.c | 32 | ||||
-rw-r--r-- | src/util/crypto_helper_esign.c | 6 | ||||
-rw-r--r-- | src/util/crypto_helper_rsa.c | 6 | ||||
-rw-r--r-- | src/util/exchange_signatures.c | 12 | ||||
-rw-r--r-- | src/util/offline_signatures.c | 108 | ||||
-rw-r--r-- | src/util/secmod_signatures.c | 16 | ||||
-rw-r--r-- | src/util/taler-exchange-secmod-eddsa.c | 96 | ||||
-rw-r--r-- | src/util/taler-exchange-secmod-eddsa.h | 2 | ||||
-rw-r--r-- | src/util/taler-exchange-secmod-rsa.c | 109 | ||||
-rw-r--r-- | src/util/taler-exchange-secmod-rsa.h | 2 | ||||
-rw-r--r-- | src/util/test_helper_eddsa.c | 8 | ||||
-rw-r--r-- | src/util/test_helper_rsa.c | 42 | ||||
-rw-r--r-- | src/util/wallet_signatures.c | 20 |
13 files changed, 228 insertions, 231 deletions
diff --git a/src/util/auditor_signatures.c b/src/util/auditor_signatures.c index 6ca1b046d..7b53c21c1 100644 --- a/src/util/auditor_signatures.c +++ b/src/util/auditor_signatures.c @@ -28,10 +28,10 @@ TALER_auditor_denom_validity_sign ( const char *auditor_url, const struct TALER_DenominationHash *h_denom_pub, const struct TALER_MasterPublicKeyP *master_pub, - struct GNUNET_TIME_Absolute stamp_start, - struct GNUNET_TIME_Absolute stamp_expire_withdraw, - struct GNUNET_TIME_Absolute stamp_expire_deposit, - struct GNUNET_TIME_Absolute stamp_expire_legal, + struct GNUNET_TIME_Timestamp stamp_start, + struct GNUNET_TIME_Timestamp stamp_expire_withdraw, + struct GNUNET_TIME_Timestamp stamp_expire_deposit, + struct GNUNET_TIME_Timestamp stamp_expire_legal, const struct TALER_Amount *coin_value, const struct TALER_Amount *fee_withdraw, const struct TALER_Amount *fee_deposit, @@ -43,10 +43,10 @@ TALER_auditor_denom_validity_sign ( struct TALER_ExchangeKeyValidityPS kv = { .purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS), .purpose.size = htonl (sizeof (kv)), - .start = GNUNET_TIME_absolute_hton (stamp_start), - .expire_withdraw = GNUNET_TIME_absolute_hton (stamp_expire_withdraw), - .expire_deposit = GNUNET_TIME_absolute_hton (stamp_expire_deposit), - .expire_legal = GNUNET_TIME_absolute_hton (stamp_expire_legal), + .start = GNUNET_TIME_timestamp_hton (stamp_start), + .expire_withdraw = GNUNET_TIME_timestamp_hton (stamp_expire_withdraw), + .expire_deposit = GNUNET_TIME_timestamp_hton (stamp_expire_deposit), + .expire_legal = GNUNET_TIME_timestamp_hton (stamp_expire_legal), .denom_hash = *h_denom_pub, .master = *master_pub, }; @@ -75,10 +75,10 @@ TALER_auditor_denom_validity_verify ( const char *auditor_url, const struct TALER_DenominationHash *h_denom_pub, const struct TALER_MasterPublicKeyP *master_pub, - struct GNUNET_TIME_Absolute stamp_start, - struct GNUNET_TIME_Absolute stamp_expire_withdraw, - struct GNUNET_TIME_Absolute stamp_expire_deposit, - struct GNUNET_TIME_Absolute stamp_expire_legal, + struct GNUNET_TIME_Timestamp stamp_start, + struct GNUNET_TIME_Timestamp stamp_expire_withdraw, + struct GNUNET_TIME_Timestamp stamp_expire_deposit, + struct GNUNET_TIME_Timestamp stamp_expire_legal, const struct TALER_Amount *coin_value, const struct TALER_Amount *fee_withdraw, const struct TALER_Amount *fee_deposit, @@ -90,10 +90,10 @@ TALER_auditor_denom_validity_verify ( struct TALER_ExchangeKeyValidityPS kv = { .purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS), .purpose.size = htonl (sizeof (kv)), - .start = GNUNET_TIME_absolute_hton (stamp_start), - .expire_withdraw = GNUNET_TIME_absolute_hton (stamp_expire_withdraw), - .expire_deposit = GNUNET_TIME_absolute_hton (stamp_expire_deposit), - .expire_legal = GNUNET_TIME_absolute_hton (stamp_expire_legal), + .start = GNUNET_TIME_timestamp_hton (stamp_start), + .expire_withdraw = GNUNET_TIME_timestamp_hton (stamp_expire_withdraw), + .expire_deposit = GNUNET_TIME_timestamp_hton (stamp_expire_deposit), + .expire_legal = GNUNET_TIME_timestamp_hton (stamp_expire_legal), .denom_hash = *h_denom_pub, .master = *master_pub, }; diff --git a/src/util/crypto_helper_esign.c b/src/util/crypto_helper_esign.c index 702ea74df..5a9ad74e2 100644 --- a/src/util/crypto_helper_esign.c +++ b/src/util/crypto_helper_esign.c @@ -182,7 +182,7 @@ handle_mt_avail (struct TALER_CRYPTO_ExchangeSignHelper *esh, if (GNUNET_OK != TALER_exchange_secmod_eddsa_verify ( &kan->exchange_pub, - GNUNET_TIME_absolute_ntoh (kan->anchor_time), + GNUNET_TIME_timestamp_ntoh (kan->anchor_time), GNUNET_TIME_relative_ntoh (kan->duration), &kan->secm_pub, &kan->secm_sig)) @@ -191,7 +191,7 @@ handle_mt_avail (struct TALER_CRYPTO_ExchangeSignHelper *esh, return GNUNET_SYSERR; } esh->ekc (esh->ekc_cls, - GNUNET_TIME_absolute_ntoh (kan->anchor_time), + GNUNET_TIME_timestamp_ntoh (kan->anchor_time), GNUNET_TIME_relative_ntoh (kan->duration), &kan->exchange_pub, &kan->secm_pub, @@ -220,7 +220,7 @@ handle_mt_purge (struct TALER_CRYPTO_ExchangeSignHelper *esh, return GNUNET_SYSERR; } esh->ekc (esh->ekc_cls, - GNUNET_TIME_UNIT_ZERO_ABS, + GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_ZERO, &pn->exchange_pub, NULL, diff --git a/src/util/crypto_helper_rsa.c b/src/util/crypto_helper_rsa.c index 3138ebf3e..fbfc97702 100644 --- a/src/util/crypto_helper_rsa.c +++ b/src/util/crypto_helper_rsa.c @@ -225,7 +225,7 @@ handle_mt_avail (struct TALER_CRYPTO_RsaDenominationHelper *dh, TALER_exchange_secmod_rsa_verify ( &h_rsa, section_name, - GNUNET_TIME_absolute_ntoh (kan->anchor_time), + GNUNET_TIME_timestamp_ntoh (kan->anchor_time), GNUNET_TIME_relative_ntoh (kan->duration_withdraw), &kan->secm_pub, &kan->secm_sig)) @@ -236,7 +236,7 @@ handle_mt_avail (struct TALER_CRYPTO_RsaDenominationHelper *dh, } dh->dkc (dh->dkc_cls, section_name, - GNUNET_TIME_absolute_ntoh (kan->anchor_time), + GNUNET_TIME_timestamp_ntoh (kan->anchor_time), GNUNET_TIME_relative_ntoh (kan->duration_withdraw), &h_rsa, &denom_pub, @@ -272,7 +272,7 @@ handle_mt_purge (struct TALER_CRYPTO_RsaDenominationHelper *dh, GNUNET_h2s (&pn->h_rsa.hash)); dh->dkc (dh->dkc_cls, NULL, - GNUNET_TIME_UNIT_ZERO_ABS, + GNUNET_TIME_UNIT_ZERO_TS, GNUNET_TIME_UNIT_ZERO, &pn->h_rsa, NULL, diff --git a/src/util/exchange_signatures.c b/src/util/exchange_signatures.c index 2e71a33c1..b923c29de 100644 --- a/src/util/exchange_signatures.c +++ b/src/util/exchange_signatures.c @@ -28,9 +28,9 @@ TALER_exchange_deposit_confirm_verify ( const struct TALER_PrivateContractHash *h_contract_terms, const struct TALER_MerchantWireHash *h_wire, const struct TALER_ExtensionContractHash *h_extensions, - struct GNUNET_TIME_Absolute exchange_timestamp, - struct GNUNET_TIME_Absolute wire_deadline, - struct GNUNET_TIME_Absolute refund_deadline, + struct GNUNET_TIME_Timestamp exchange_timestamp, + struct GNUNET_TIME_Timestamp wire_deadline, + struct GNUNET_TIME_Timestamp refund_deadline, const struct TALER_Amount *amount_without_fee, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_MerchantPublicKeyP *merchant_pub, @@ -42,9 +42,9 @@ TALER_exchange_deposit_confirm_verify ( .purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS)), .h_contract_terms = *h_contract_terms, .h_wire = *h_wire, - .exchange_timestamp = GNUNET_TIME_absolute_hton (exchange_timestamp), - .wire_deadline = GNUNET_TIME_absolute_hton (wire_deadline), - .refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline), + .exchange_timestamp = GNUNET_TIME_timestamp_hton (exchange_timestamp), + .wire_deadline = GNUNET_TIME_timestamp_hton (wire_deadline), + .refund_deadline = GNUNET_TIME_timestamp_hton (refund_deadline), .coin_pub = *coin_pub, .merchant_pub = *merchant_pub }; diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c index fe502c659..cd9dceca5 100644 --- a/src/util/offline_signatures.c +++ b/src/util/offline_signatures.c @@ -27,14 +27,14 @@ void TALER_exchange_offline_auditor_add_sign ( const struct TALER_AuditorPublicKeyP *auditor_pub, const char *auditor_url, - struct GNUNET_TIME_Absolute start_date, + struct GNUNET_TIME_Timestamp start_date, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { struct TALER_MasterAddAuditorPS kv = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_AUDITOR), .purpose.size = htonl (sizeof (kv)), - .start_date = GNUNET_TIME_absolute_hton (start_date), + .start_date = GNUNET_TIME_timestamp_hton (start_date), .auditor_pub = *auditor_pub, }; @@ -51,7 +51,7 @@ enum GNUNET_GenericReturnValue TALER_exchange_offline_auditor_add_verify ( const struct TALER_AuditorPublicKeyP *auditor_pub, const char *auditor_url, - struct GNUNET_TIME_Absolute start_date, + struct GNUNET_TIME_Timestamp start_date, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig) { @@ -59,7 +59,7 @@ TALER_exchange_offline_auditor_add_verify ( .purpose.purpose = htonl ( TALER_SIGNATURE_MASTER_ADD_AUDITOR), .purpose.size = htonl (sizeof (aa)), - .start_date = GNUNET_TIME_absolute_hton (start_date), + .start_date = GNUNET_TIME_timestamp_hton (start_date), .auditor_pub = *auditor_pub }; @@ -76,14 +76,14 @@ TALER_exchange_offline_auditor_add_verify ( void TALER_exchange_offline_auditor_del_sign ( const struct TALER_AuditorPublicKeyP *auditor_pub, - struct GNUNET_TIME_Absolute end_date, + struct GNUNET_TIME_Timestamp end_date, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { struct TALER_MasterDelAuditorPS kv = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DEL_AUDITOR), .purpose.size = htonl (sizeof (kv)), - .end_date = GNUNET_TIME_absolute_hton (end_date), + .end_date = GNUNET_TIME_timestamp_hton (end_date), .auditor_pub = *auditor_pub, }; @@ -96,7 +96,7 @@ TALER_exchange_offline_auditor_del_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_auditor_del_verify ( const struct TALER_AuditorPublicKeyP *auditor_pub, - struct GNUNET_TIME_Absolute end_date, + struct GNUNET_TIME_Timestamp end_date, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig) { @@ -104,7 +104,7 @@ TALER_exchange_offline_auditor_del_verify ( .purpose.purpose = htonl ( TALER_SIGNATURE_MASTER_DEL_AUDITOR), .purpose.size = htonl (sizeof (da)), - .end_date = GNUNET_TIME_absolute_hton (end_date), + .end_date = GNUNET_TIME_timestamp_hton (end_date), .auditor_pub = *auditor_pub }; @@ -197,9 +197,9 @@ TALER_exchange_offline_signkey_revoke_verify ( void TALER_exchange_offline_signkey_validity_sign ( const struct TALER_ExchangePublicKeyP *exchange_pub, - struct GNUNET_TIME_Absolute start_sign, - struct GNUNET_TIME_Absolute end_sign, - struct GNUNET_TIME_Absolute end_legal, + struct GNUNET_TIME_Timestamp start_sign, + struct GNUNET_TIME_Timestamp end_sign, + struct GNUNET_TIME_Timestamp end_legal, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { @@ -207,9 +207,9 @@ TALER_exchange_offline_signkey_validity_sign ( .purpose.purpose = htonl ( TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY), .purpose.size = htonl (sizeof (skv)), - .start = GNUNET_TIME_absolute_hton (start_sign), - .expire = GNUNET_TIME_absolute_hton (end_sign), - .end = GNUNET_TIME_absolute_hton (end_legal), + .start = GNUNET_TIME_timestamp_hton (start_sign), + .expire = GNUNET_TIME_timestamp_hton (end_sign), + .end = GNUNET_TIME_timestamp_hton (end_legal), .signkey_pub = *exchange_pub }; @@ -222,9 +222,9 @@ TALER_exchange_offline_signkey_validity_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_signkey_validity_verify ( const struct TALER_ExchangePublicKeyP *exchange_pub, - struct GNUNET_TIME_Absolute start_sign, - struct GNUNET_TIME_Absolute end_sign, - struct GNUNET_TIME_Absolute end_legal, + struct GNUNET_TIME_Timestamp start_sign, + struct GNUNET_TIME_Timestamp end_sign, + struct GNUNET_TIME_Timestamp end_legal, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig) { @@ -232,9 +232,9 @@ TALER_exchange_offline_signkey_validity_verify ( .purpose.purpose = htonl ( TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY), .purpose.size = htonl (sizeof (skv)), - .start = GNUNET_TIME_absolute_hton (start_sign), - .expire = GNUNET_TIME_absolute_hton (end_sign), - .end = GNUNET_TIME_absolute_hton (end_legal), + .start = GNUNET_TIME_timestamp_hton (start_sign), + .expire = GNUNET_TIME_timestamp_hton (end_sign), + .end = GNUNET_TIME_timestamp_hton (end_legal), .signkey_pub = *exchange_pub }; @@ -250,10 +250,10 @@ TALER_exchange_offline_signkey_validity_verify ( void TALER_exchange_offline_denom_validity_sign ( const struct TALER_DenominationHash *h_denom_pub, - struct GNUNET_TIME_Absolute stamp_start, - struct GNUNET_TIME_Absolute stamp_expire_withdraw, - struct GNUNET_TIME_Absolute stamp_expire_deposit, - struct GNUNET_TIME_Absolute stamp_expire_legal, + struct GNUNET_TIME_Timestamp stamp_start, + struct GNUNET_TIME_Timestamp stamp_expire_withdraw, + struct GNUNET_TIME_Timestamp stamp_expire_deposit, + struct GNUNET_TIME_Timestamp stamp_expire_legal, const struct TALER_Amount *coin_value, const struct TALER_Amount *fee_withdraw, const struct TALER_Amount *fee_deposit, @@ -267,10 +267,10 @@ TALER_exchange_offline_denom_validity_sign ( = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY), .purpose.size = htonl (sizeof (issue)), - .start = GNUNET_TIME_absolute_hton (stamp_start), - .expire_withdraw = GNUNET_TIME_absolute_hton (stamp_expire_withdraw), - .expire_deposit = GNUNET_TIME_absolute_hton (stamp_expire_deposit), - .expire_legal = GNUNET_TIME_absolute_hton (stamp_expire_legal), + .start = GNUNET_TIME_timestamp_hton (stamp_start), + .expire_withdraw = GNUNET_TIME_timestamp_hton (stamp_expire_withdraw), + .expire_deposit = GNUNET_TIME_timestamp_hton (stamp_expire_deposit), + .expire_legal = GNUNET_TIME_timestamp_hton (stamp_expire_legal), .denom_hash = *h_denom_pub }; @@ -295,10 +295,10 @@ TALER_exchange_offline_denom_validity_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_denom_validity_verify ( const struct TALER_DenominationHash *h_denom_pub, - struct GNUNET_TIME_Absolute stamp_start, - struct GNUNET_TIME_Absolute stamp_expire_withdraw, - struct GNUNET_TIME_Absolute stamp_expire_deposit, - struct GNUNET_TIME_Absolute stamp_expire_legal, + struct GNUNET_TIME_Timestamp stamp_start, + struct GNUNET_TIME_Timestamp stamp_expire_withdraw, + struct GNUNET_TIME_Timestamp stamp_expire_deposit, + struct GNUNET_TIME_Timestamp stamp_expire_legal, const struct TALER_Amount *coin_value, const struct TALER_Amount *fee_withdraw, const struct TALER_Amount *fee_deposit, @@ -312,10 +312,10 @@ TALER_exchange_offline_denom_validity_verify ( TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY), .purpose.size = htonl (sizeof (dkv)), .master = *master_pub, - .start = GNUNET_TIME_absolute_hton (stamp_start), - .expire_withdraw = GNUNET_TIME_absolute_hton (stamp_expire_withdraw), - .expire_deposit = GNUNET_TIME_absolute_hton (stamp_expire_deposit), - .expire_legal = GNUNET_TIME_absolute_hton (stamp_expire_legal), + .start = GNUNET_TIME_timestamp_hton (stamp_start), + .expire_withdraw = GNUNET_TIME_timestamp_hton (stamp_expire_withdraw), + .expire_deposit = GNUNET_TIME_timestamp_hton (stamp_expire_deposit), + .expire_legal = GNUNET_TIME_timestamp_hton (stamp_expire_legal), .denom_hash = *h_denom_pub }; @@ -341,18 +341,16 @@ TALER_exchange_offline_denom_validity_verify ( void TALER_exchange_offline_wire_add_sign ( const char *payto_uri, - struct GNUNET_TIME_Absolute now, + struct GNUNET_TIME_Timestamp now, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { struct TALER_MasterAddWirePS kv = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_WIRE), .purpose.size = htonl (sizeof (kv)), - .start_date = GNUNET_TIME_absolute_hton (now), + .start_date = GNUNET_TIME_timestamp_hton (now), }; - GNUNET_assert (GNUNET_OK == - GNUNET_TIME_round_abs (&now)); TALER_payto_hash (payto_uri, &kv.h_payto); GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, @@ -364,14 +362,14 @@ TALER_exchange_offline_wire_add_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_wire_add_verify ( const char *payto_uri, - struct GNUNET_TIME_Absolute sign_time, + struct GNUNET_TIME_Timestamp sign_time, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig) { struct TALER_MasterAddWirePS aw = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_WIRE), .purpose.size = htonl (sizeof (aw)), - .start_date = GNUNET_TIME_absolute_hton (sign_time), + .start_date = GNUNET_TIME_timestamp_hton (sign_time), }; TALER_payto_hash (payto_uri, @@ -388,18 +386,16 @@ TALER_exchange_offline_wire_add_verify ( void TALER_exchange_offline_wire_del_sign ( const char *payto_uri, - struct GNUNET_TIME_Absolute now, + struct GNUNET_TIME_Timestamp now, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { struct TALER_MasterDelWirePS kv = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DEL_WIRE), .purpose.size = htonl (sizeof (kv)), - .end_date = GNUNET_TIME_absolute_hton (now), + .end_date = GNUNET_TIME_timestamp_hton (now), }; - GNUNET_assert (GNUNET_OK == - GNUNET_TIME_round_abs (&now)); TALER_payto_hash (payto_uri, &kv.h_payto); GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, @@ -411,7 +407,7 @@ TALER_exchange_offline_wire_del_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_wire_del_verify ( const char *payto_uri, - struct GNUNET_TIME_Absolute sign_time, + struct GNUNET_TIME_Timestamp sign_time, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig) { @@ -419,7 +415,7 @@ TALER_exchange_offline_wire_del_verify ( .purpose.purpose = htonl ( TALER_SIGNATURE_MASTER_DEL_WIRE), .purpose.size = htonl (sizeof (aw)), - .end_date = GNUNET_TIME_absolute_hton (sign_time), + .end_date = GNUNET_TIME_timestamp_hton (sign_time), }; TALER_payto_hash (payto_uri, @@ -435,8 +431,8 @@ TALER_exchange_offline_wire_del_verify ( void TALER_exchange_offline_wire_fee_sign ( const char *payment_method, - struct GNUNET_TIME_Absolute start_time, - struct GNUNET_TIME_Absolute end_time, + struct GNUNET_TIME_Timestamp start_time, + struct GNUNET_TIME_Timestamp end_time, const struct TALER_Amount *wire_fee, const struct TALER_Amount *closing_fee, const struct TALER_MasterPrivateKeyP *master_priv, @@ -445,8 +441,8 @@ TALER_exchange_offline_wire_fee_sign ( struct TALER_MasterWireFeePS kv = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES), .purpose.size = htonl (sizeof (kv)), - .start_date = GNUNET_TIME_absolute_hton (start_time), - .end_date = GNUNET_TIME_absolute_hton (end_time), + .start_date = GNUNET_TIME_timestamp_hton (start_time), + .end_date = GNUNET_TIME_timestamp_hton (end_time), }; GNUNET_CRYPTO_hash (payment_method, @@ -465,8 +461,8 @@ TALER_exchange_offline_wire_fee_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_wire_fee_verify ( const char *payment_method, - struct GNUNET_TIME_Absolute start_time, - struct GNUNET_TIME_Absolute end_time, + struct GNUNET_TIME_Timestamp start_time, + struct GNUNET_TIME_Timestamp end_time, const struct TALER_Amount *wire_fee, const struct TALER_Amount *closing_fee, const struct TALER_MasterPublicKeyP *master_pub, @@ -475,8 +471,8 @@ TALER_exchange_offline_wire_fee_verify ( struct TALER_MasterWireFeePS wf = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES), .purpose.size = htonl (sizeof (wf)), - .start_date = GNUNET_TIME_absolute_hton (start_time), - .end_date = GNUNET_TIME_absolute_hton (end_time) + .start_date = GNUNET_TIME_timestamp_hton (start_time), + .end_date = GNUNET_TIME_timestamp_hton (end_time) }; GNUNET_CRYPTO_hash (payment_method, diff --git a/src/util/secmod_signatures.c b/src/util/secmod_signatures.c index 077ce229a..9cb15bcf5 100644 --- a/src/util/secmod_signatures.c +++ b/src/util/secmod_signatures.c @@ -26,7 +26,7 @@ void TALER_exchange_secmod_eddsa_sign ( const struct TALER_ExchangePublicKeyP *exchange_pub, - struct GNUNET_TIME_Absolute start_sign, + struct GNUNET_TIME_Timestamp start_sign, struct GNUNET_TIME_Relative duration, const struct TALER_SecurityModulePrivateKeyP *secm_priv, struct TALER_SecurityModuleSignatureP *secm_sig) @@ -35,7 +35,7 @@ TALER_exchange_secmod_eddsa_sign ( .purpose.purpose = htonl (TALER_SIGNATURE_SM_SIGNING_KEY), .purpose.size = htonl (sizeof (ska)), .exchange_pub = *exchange_pub, - .anchor_time = GNUNET_TIME_absolute_hton (start_sign), + .anchor_time = GNUNET_TIME_timestamp_hton (start_sign), .duration = GNUNET_TIME_relative_hton (duration) }; @@ -48,7 +48,7 @@ TALER_exchange_secmod_eddsa_sign ( enum GNUNET_GenericReturnValue TALER_exchange_secmod_eddsa_verify ( const struct TALER_ExchangePublicKeyP *exchange_pub, - struct GNUNET_TIME_Absolute start_sign, + struct GNUNET_TIME_Timestamp start_sign, struct GNUNET_TIME_Relative duration, const struct TALER_SecurityModulePublicKeyP *secm_pub, const struct TALER_SecurityModuleSignatureP *secm_sig) @@ -57,7 +57,7 @@ TALER_exchange_secmod_eddsa_verify ( .purpose.purpose = htonl (TALER_SIGNATURE_SM_SIGNING_KEY), .purpose.size = htonl (sizeof (ska)), .exchange_pub = *exchange_pub, - .anchor_time = GNUNET_TIME_absolute_hton (start_sign), + .anchor_time = GNUNET_TIME_timestamp_hton (start_sign), .duration = GNUNET_TIME_relative_hton (duration) }; @@ -73,7 +73,7 @@ void TALER_exchange_secmod_rsa_sign ( const struct TALER_RsaPubHashP *h_rsa, const char *section_name, - struct GNUNET_TIME_Absolute start_sign, + struct GNUNET_TIME_Timestamp start_sign, struct GNUNET_TIME_Relative duration, const struct TALER_SecurityModulePrivateKeyP *secm_priv, struct TALER_SecurityModuleSignatureP *secm_sig) @@ -82,7 +82,7 @@ TALER_exchange_secmod_rsa_sign ( .purpose.purpose = htonl (TALER_SIGNATURE_SM_RSA_DENOMINATION_KEY), .purpose.size = htonl (sizeof (dka)), .h_rsa = *h_rsa, - .anchor_time = GNUNET_TIME_absolute_hton (start_sign), + .anchor_time = GNUNET_TIME_timestamp_hton (start_sign), .duration_withdraw = GNUNET_TIME_relative_hton (duration) }; @@ -100,7 +100,7 @@ enum GNUNET_GenericReturnValue TALER_exchange_secmod_rsa_verify ( const struct TALER_RsaPubHashP *h_rsa, const char *section_name, - struct GNUNET_TIME_Absolute start_sign, + struct GNUNET_TIME_Timestamp start_sign, struct GNUNET_TIME_Relative duration, const struct TALER_SecurityModulePublicKeyP *secm_pub, const struct TALER_SecurityModuleSignatureP *secm_sig) @@ -109,7 +109,7 @@ TALER_exchange_secmod_rsa_verify ( .purpose.purpose = htonl (TALER_SIGNATURE_SM_RSA_DENOMINATION_KEY), .purpose.size = htonl (sizeof (dka)), .h_rsa = *h_rsa, - .anchor_time = GNUNET_TIME_absolute_hton (start_sign), + .anchor_time = GNUNET_TIME_timestamp_hton (start_sign), .duration_withdraw = GNUNET_TIME_relative_hton (duration) }; diff --git a/src/util/taler-exchange-secmod-eddsa.c b/src/util/taler-exchange-secmod-eddsa.c index 3fe9b284e..02b36fb9a 100644 --- a/src/util/taler-exchange-secmod-eddsa.c +++ b/src/util/taler-exchange-secmod-eddsa.c @@ -78,7 +78,7 @@ struct Key /** * Time at which this key is supposed to become valid. */ - struct GNUNET_TIME_Absolute anchor; + struct GNUNET_TIME_Timestamp anchor; /** * Generation when this key was created or revoked. @@ -124,13 +124,13 @@ static int global_ret; * Time when the key update is executed. * Either the actual current time, or a pretended time. */ -static struct GNUNET_TIME_Absolute now; +static struct GNUNET_TIME_Timestamp now; /** * The time for the key update, as passed by the user * on the command line. */ -static struct GNUNET_TIME_Absolute now_tmp; +static struct GNUNET_TIME_Timestamp now_tmp; /** * Where do we store the keys? @@ -179,7 +179,7 @@ notify_client_key_add (struct TES_Client *client, struct TALER_CRYPTO_EddsaKeyAvailableNotification an = { .header.size = htons (sizeof (an)), .header.type = htons (TALER_HELPER_EDDSA_MT_AVAIL), - .anchor_time = GNUNET_TIME_absolute_hton (key->anchor), + .anchor_time = GNUNET_TIME_timestamp_hton (key->anchor), .duration = GNUNET_TIME_relative_hton (duration), .exchange_pub = key->exchange_pub, .secm_pub = TES_smpub @@ -274,7 +274,7 @@ handle_sign_request (struct TES_Client *client, key = keys_head; while ( (NULL != key) && (GNUNET_TIME_absolute_is_past ( - GNUNET_TIME_absolute_add (key->anchor, + GNUNET_TIME_absolute_add (key->anchor.abs_time, duration))) ) { struct Key *nxt = key->next; @@ -284,9 +284,9 @@ handle_sign_request (struct TES_Client *client, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Deleting past key %s (expired %s ago)\n", TALER_B2S (&nxt->exchange_pub), - GNUNET_STRINGS_relative_time_to_string ( + GNUNET_TIME_relative2s ( GNUNET_TIME_absolute_get_duration ( - GNUNET_TIME_absolute_add (key->anchor, + GNUNET_TIME_absolute_add (key->anchor.abs_time, duration)), GNUNET_YES)); GNUNET_CONTAINER_DLL_remove (keys_head, @@ -364,7 +364,7 @@ setup_key (struct Key *key, GNUNET_asprintf (&key->filename, "%s/%llu", keydir, - (unsigned long long) (key->anchor.abs_value_us + (unsigned long long) (key->anchor.abs_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us)); if (GNUNET_OK != GNUNET_DISK_fn_write (key->filename, @@ -638,23 +638,21 @@ static enum GNUNET_GenericReturnValue create_key (void) { struct Key *key; - struct GNUNET_TIME_Absolute anchor; - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp anchor; - now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); - if (NULL == keys_tail) + anchor = GNUNET_TIME_timestamp_get (); + if (NULL != keys_tail) { - anchor = now; - } - else - { - anchor = GNUNET_TIME_absolute_add (keys_tail->anchor, - GNUNET_TIME_relative_subtract ( - duration, - overlap_duration)); - if (now.abs_value_us > anchor.abs_value_us) - anchor = now; + struct GNUNET_TIME_Absolute abs; + + abs = GNUNET_TIME_absolute_add (keys_tail->anchor.abs_time, + GNUNET_TIME_relative_subtract ( + duration, + overlap_duration)); + if (GNUNET_TIME_absolute_cmp (anchor.abs_time, + <, + abs)) + anchor = GNUNET_TIME_absolute_to_timestamp (abs); } key = GNUNET_new (struct Key); key->anchor = anchor; @@ -689,11 +687,11 @@ key_action_time (void) if (NULL == nxt) return GNUNET_TIME_UNIT_ZERO_ABS; return GNUNET_TIME_absolute_min ( - GNUNET_TIME_absolute_add (nxt->anchor, + GNUNET_TIME_absolute_add (nxt->anchor.abs_time, duration), GNUNET_TIME_absolute_subtract ( GNUNET_TIME_absolute_subtract ( - GNUNET_TIME_absolute_add (keys_tail->anchor, + GNUNET_TIME_absolute_add (keys_tail->anchor.abs_time, duration), lookahead_sign), overlap_duration)); @@ -719,7 +717,7 @@ update_keys (void *cls) GNUNET_TIME_absolute_is_past ( GNUNET_TIME_absolute_subtract ( GNUNET_TIME_absolute_subtract ( - GNUNET_TIME_absolute_add (keys_tail->anchor, + GNUNET_TIME_absolute_add (keys_tail->anchor.abs_time, duration), lookahead_sign), overlap_duration)) ) @@ -743,7 +741,7 @@ update_keys (void *cls) /* purge expired keys */ while ( (NULL != nxt) && GNUNET_TIME_absolute_is_past ( - GNUNET_TIME_absolute_add (nxt->anchor, + GNUNET_TIME_absolute_add (nxt->anchor.abs_time, duration))) { if (! wake) @@ -754,9 +752,9 @@ update_keys (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Purging past key %s (expired %s ago)\n", TALER_B2S (&nxt->exchange_pub), - GNUNET_STRINGS_relative_time_to_string ( + GNUNET_TIME_relative2s ( GNUNET_TIME_absolute_get_duration ( - GNUNET_TIME_absolute_add (nxt->anchor, + GNUNET_TIME_absolute_add (nxt->anchor.abs_time, duration)), GNUNET_YES)); purge_key (nxt); @@ -788,7 +786,7 @@ parse_key (const char *filename, char *anchor_s; char dummy; unsigned long long anchor_ll; - struct GNUNET_TIME_Absolute anchor; + struct GNUNET_TIME_Timestamp anchor; anchor_s = strrchr (filename, '/'); @@ -810,8 +808,10 @@ parse_key (const char *filename, filename); return GNUNET_SYSERR; } - anchor.abs_value_us = anchor_ll * GNUNET_TIME_UNIT_SECONDS.rel_value_us; - if (anchor_ll != anchor.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us) + anchor.abs_time.abs_value_us = anchor_ll + * GNUNET_TIME_UNIT_SECONDS.rel_value_us; + if (anchor_ll != anchor.abs_time.abs_value_us + / GNUNET_TIME_UNIT_SECONDS.rel_value_us) { /* Integer overflow. Bad, invalid filename. */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -850,7 +850,7 @@ parse_key (const char *filename, NULL != pos; pos = pos->next) { - if (pos->anchor.abs_value_us > anchor.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (pos->anchor, >, anchor)) break; before = pos; } @@ -1012,8 +1012,6 @@ load_durations (const struct GNUNET_CONFIGURATION_Handle *cfg) "DURATION"); return GNUNET_SYSERR; } - GNUNET_TIME_round_rel (&overlap_duration); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "taler-exchange-secmod-eddsa", @@ -1025,7 +1023,6 @@ load_durations (const struct GNUNET_CONFIGURATION_Handle *cfg) "LOOKAHEAD_SIGN"); return GNUNET_SYSERR; } - GNUNET_TIME_round_rel (&lookahead_sign); return GNUNET_OK; } @@ -1071,7 +1068,7 @@ run (void *cls, (void) cls; (void) args; (void) cfgfile; - if (now.abs_value_us != now_tmp.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (now, !=, now_tmp)) { /* The user gave "--now", use it! */ now = now_tmp; @@ -1079,9 +1076,8 @@ run (void *cls, else { /* get current time again, we may be timetraveling! */ - now = GNUNET_TIME_absolute_get (); + now = GNUNET_TIME_timestamp_get (); } - GNUNET_TIME_round_abs (&now); if (GNUNET_OK != load_durations (cfg)) { @@ -1114,12 +1110,13 @@ run (void *cls, &import_key, NULL); if ( (NULL != keys_head) && - (GNUNET_TIME_absolute_is_future (keys_head->anchor)) ) + (GNUNET_TIME_absolute_is_future (keys_head->anchor.abs_time)) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Existing anchor is in %s the future. Refusing to start\n", - GNUNET_STRINGS_relative_time_to_string ( - GNUNET_TIME_absolute_get_remaining (keys_head->anchor), + GNUNET_TIME_relative2s ( + GNUNET_TIME_absolute_get_remaining ( + keys_head->anchor.abs_time), GNUNET_YES)); global_ret = EXIT_FAILURE; GNUNET_SCHEDULER_shutdown (); @@ -1148,11 +1145,11 @@ main (int argc, struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_timetravel ('T', "timetravel"), - GNUNET_GETOPT_option_absolute_time ('t', - "time", - "TIMESTAMP", - "pretend it is a different time for the update", - &now_tmp), + GNUNET_GETOPT_option_timestamp ('t', + "time", + "TIMESTAMP", + "pretend it is a different time for the update", + &now_tmp), GNUNET_GETOPT_OPTION_END }; enum GNUNET_GenericReturnValue ret; @@ -1164,8 +1161,9 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ TALER_OS_init (); - now = now_tmp = GNUNET_TIME_absolute_get (); - ret = GNUNET_PROGRAM_run (argc, argv, + now_tmp = now = GNUNET_TIME_timestamp_get (); + ret = GNUNET_PROGRAM_run (argc, + argv, "taler-exchange-secmod-eddsa", "Handle private EDDSA key operations for a Taler exchange", options, diff --git a/src/util/taler-exchange-secmod-eddsa.h b/src/util/taler-exchange-secmod-eddsa.h index 39054c414..c05d90a6c 100644 --- a/src/util/taler-exchange-secmod-eddsa.h +++ b/src/util/taler-exchange-secmod-eddsa.h @@ -54,7 +54,7 @@ struct TALER_CRYPTO_EddsaKeyAvailableNotification /** * When does the key become available? */ - struct GNUNET_TIME_AbsoluteNBO anchor_time; + struct GNUNET_TIME_TimestampNBO anchor_time; /** * How long is the key available after @e anchor_time? diff --git a/src/util/taler-exchange-secmod-rsa.c b/src/util/taler-exchange-secmod-rsa.c index e121e9ab6..e40c8e39f 100644 --- a/src/util/taler-exchange-secmod-rsa.c +++ b/src/util/taler-exchange-secmod-rsa.c @@ -98,7 +98,7 @@ struct DenominationKey /** * Time at which this key is supposed to become valid. */ - struct GNUNET_TIME_Absolute anchor; + struct GNUNET_TIME_Timestamp anchor; /** * Generation when this key was created or revoked. @@ -173,13 +173,13 @@ static int global_ret; * Time when the key update is executed. * Either the actual current time, or a pretended time. */ -static struct GNUNET_TIME_Absolute now; +static struct GNUNET_TIME_Timestamp now; /** * The time for the key update, as passed by the user * on the command line. */ -static struct GNUNET_TIME_Absolute now_tmp; +static struct GNUNET_TIME_Timestamp now_tmp; /** * Where do we store the keys? @@ -257,7 +257,7 @@ generate_response (struct DenominationKey *dk) an->header.type = htons (TALER_HELPER_RSA_MT_AVAIL); an->pub_size = htons ((uint16_t) buf_len); an->section_name_len = htons ((uint16_t) nlen); - an->anchor_time = GNUNET_TIME_absolute_hton (dk->anchor); + an->anchor_time = GNUNET_TIME_timestamp_hton (dk->anchor); an->duration_withdraw = GNUNET_TIME_relative_hton (denom->duration_withdraw); TALER_exchange_secmod_rsa_sign (&dk->h_rsa, denom->section, @@ -315,8 +315,7 @@ handle_sign_request (struct TES_Client *client, return TES_transmit (client->csock, &sf.header); } - if (0 != - GNUNET_TIME_absolute_get_remaining (dk->anchor).rel_value_us) + if (GNUNET_TIME_absolute_is_future (dk->anchor.abs_time)) { /* it is too early */ struct TALER_CRYPTO_SignFailure sf = { @@ -383,14 +382,14 @@ handle_sign_request (struct TES_Client *client, GNUNET_free (buf); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Sending RSA signature after %s\n", - GNUNET_STRINGS_relative_time_to_string ( + GNUNET_TIME_relative2s ( GNUNET_TIME_absolute_get_duration (now), GNUNET_YES)); ret = TES_transmit (client->csock, &sr->header); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Sent RSA signature after %s\n", - GNUNET_STRINGS_relative_time_to_string ( + GNUNET_TIME_relative2s ( GNUNET_TIME_absolute_get_duration (now), GNUNET_YES)); GNUNET_free (sr); @@ -439,7 +438,7 @@ setup_key (struct DenominationKey *dk, "%s/%s/%llu", keydir, denom->section, - (unsigned long long) (dk->anchor.abs_value_us + (unsigned long long) (dk->anchor.abs_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us)); if (GNUNET_OK != GNUNET_DISK_fn_write (dk->filename, @@ -459,7 +458,7 @@ setup_key (struct DenominationKey *dk, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setup fresh private key %s at %s in `%s' (generation #%llu)\n", GNUNET_h2s (&dk->h_rsa.hash), - GNUNET_STRINGS_absolute_time_to_string (dk->anchor), + GNUNET_TIME_timestamp2s (dk->anchor), dk->filename, (unsigned long long) key_gen); dk->denom_priv = priv; @@ -785,23 +784,22 @@ rsa_update_client_keys (struct TES_Client *client) */ static enum GNUNET_GenericReturnValue create_key (struct Denomination *denom, - struct GNUNET_TIME_Absolute now) + struct GNUNET_TIME_Timestamp now) { struct DenominationKey *dk; - struct GNUNET_TIME_Absolute anchor; + struct GNUNET_TIME_Timestamp anchor; - if (NULL == denom->keys_tail) - { - anchor = now; - } - else + anchor = now; + if (NULL != denom->keys_tail) { - anchor = GNUNET_TIME_absolute_add (denom->keys_tail->anchor, - GNUNET_TIME_relative_subtract ( - denom->duration_withdraw, - overlap_duration)); - if (now.abs_value_us > anchor.abs_value_us) - anchor = now; + struct GNUNET_TIME_Absolute abs; + + abs = GNUNET_TIME_absolute_add (denom->keys_tail->anchor.abs_time, + GNUNET_TIME_relative_subtract ( + denom->duration_withdraw, + overlap_duration)); + if (GNUNET_TIME_absolute_cmp (now.abs_time, <, abs)) + anchor = GNUNET_TIME_absolute_to_timestamp (abs); } dk = GNUNET_new (struct DenominationKey); dk->denom = denom; @@ -839,14 +837,14 @@ denomination_action_time (const struct Denomination *denom) return GNUNET_TIME_UNIT_ZERO_ABS; tt = GNUNET_TIME_absolute_subtract ( GNUNET_TIME_absolute_subtract ( - GNUNET_TIME_absolute_add (tail->anchor, + GNUNET_TIME_absolute_add (tail->anchor.abs_time, denom->duration_withdraw), lookahead_sign), overlap_duration); if (head->rc > 0) return tt; /* head expiration does not count due to rc > 0 */ return GNUNET_TIME_absolute_min ( - GNUNET_TIME_absolute_add (head->anchor, + GNUNET_TIME_absolute_add (head->anchor.abs_time, denom->duration_withdraw), tt); } @@ -864,7 +862,7 @@ denomination_action_time (const struct Denomination *denom) */ static enum GNUNET_GenericReturnValue update_keys (struct Denomination *denom, - struct GNUNET_TIME_Absolute now, + struct GNUNET_TIME_Timestamp now, bool *wake) { /* create new denomination keys */ @@ -873,11 +871,11 @@ update_keys (struct Denomination *denom, "Updating keys of denomination `%s', last key %s valid for another %s\n", denom->section, GNUNET_h2s (&denom->keys_tail->h_rsa.hash), - GNUNET_STRINGS_relative_time_to_string ( + GNUNET_TIME_relative2s ( GNUNET_TIME_absolute_get_remaining ( GNUNET_TIME_absolute_subtract ( GNUNET_TIME_absolute_add ( - denom->keys_tail->anchor, + denom->keys_tail->anchor.abs_time, denom->duration_withdraw), overlap_duration)), GNUNET_YES)); @@ -885,7 +883,7 @@ update_keys (struct Denomination *denom, GNUNET_TIME_absolute_is_past ( GNUNET_TIME_absolute_subtract ( GNUNET_TIME_absolute_subtract ( - GNUNET_TIME_absolute_add (denom->keys_tail->anchor, + GNUNET_TIME_absolute_add (denom->keys_tail->anchor.abs_time, denom->duration_withdraw), lookahead_sign), overlap_duration)) ) @@ -908,7 +906,7 @@ update_keys (struct Denomination *denom, /* remove expired denomination keys */ while ( (NULL != denom->keys_head) && GNUNET_TIME_absolute_is_past - (GNUNET_TIME_absolute_add (denom->keys_head->anchor, + (GNUNET_TIME_absolute_add (denom->keys_head->anchor.abs_time, denom->duration_withdraw)) ) { struct DenominationKey *key = denom->keys_head; @@ -951,7 +949,7 @@ update_keys (struct Denomination *denom, NULL != pos; pos = pos->next) { - if (denomination_action_time (pos).abs_value_us >= at.abs_value_us) + if (GNUNET_TIME_absolute_cmp (denomination_action_time (pos), >=, at)) break; before = pos; } @@ -974,12 +972,13 @@ update_denominations (void *cls) { struct Denomination *denom; struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp t; bool wake = false; (void) cls; keygen_task = NULL; now = GNUNET_TIME_absolute_get (); - (void) GNUNET_TIME_round_abs (&now); + t = GNUNET_TIME_absolute_to_timestamp (now); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating denominations ...\n"); GNUNET_assert (0 == pthread_mutex_lock (&keys_lock)); @@ -987,7 +986,7 @@ update_denominations (void *cls) denom = denom_head; if (GNUNET_OK != update_keys (denom, - now, + t, &wake)) return; } while (denom != denom_head); @@ -1020,7 +1019,7 @@ parse_key (struct Denomination *denom, char *anchor_s; char dummy; unsigned long long anchor_ll; - struct GNUNET_TIME_Absolute anchor; + struct GNUNET_TIME_Timestamp anchor; anchor_s = strrchr (filename, '/'); @@ -1042,8 +1041,10 @@ parse_key (struct Denomination *denom, filename); return; } - anchor.abs_value_us = anchor_ll * GNUNET_TIME_UNIT_SECONDS.rel_value_us; - if (anchor_ll != anchor.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us) + anchor.abs_time.abs_value_us + = anchor_ll * GNUNET_TIME_UNIT_SECONDS.rel_value_us; + if (anchor_ll != anchor.abs_time.abs_value_us + / GNUNET_TIME_UNIT_SECONDS.rel_value_us) { /* Integer overflow. Bad, invalid filename. */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -1105,7 +1106,7 @@ parse_key (struct Denomination *denom, NULL != pos; pos = pos->next) { - if (pos->anchor.abs_value_us > anchor.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (pos->anchor, >, anchor)) break; before = pos; } @@ -1267,9 +1268,9 @@ parse_denomination_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, "DURATION_WITHDRAW"); return GNUNET_SYSERR; } - GNUNET_TIME_round_rel (&denom->duration_withdraw); - if (overlap_duration.rel_value_us >= - denom->duration_withdraw.rel_value_us) + if (GNUNET_TIME_relative_cmp (overlap_duration, + >=, + denom->duration_withdraw)) { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "taler-exchange-secmod-rsa", @@ -1317,7 +1318,7 @@ struct LoadContext /** * Current time to use. */ - struct GNUNET_TIME_Absolute now; + struct GNUNET_TIME_Timestamp t; /** * Status, to be set to #GNUNET_SYSERR on failure @@ -1379,7 +1380,7 @@ load_denominations (void *cls, denom_tail, denom); update_keys (denom, - ctx->now, + ctx->t, &wake); } @@ -1404,8 +1405,6 @@ load_durations (const struct GNUNET_CONFIGURATION_Handle *cfg) "OVERLAP_DURATION"); return GNUNET_SYSERR; } - GNUNET_TIME_round_rel (&overlap_duration); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "taler-exchange-secmod-rsa", @@ -1417,7 +1416,6 @@ load_durations (const struct GNUNET_CONFIGURATION_Handle *cfg) "LOOKAHEAD_SIGN"); return GNUNET_SYSERR; } - GNUNET_TIME_round_rel (&lookahead_sign); return GNUNET_OK; } @@ -1459,10 +1457,11 @@ run (void *cls, .updater = rsa_update_client_keys, .init = rsa_client_init }; + (void) cls; (void) args; (void) cfgfile; - if (now.abs_value_us != now_tmp.abs_value_us) + if (GNUNET_TIME_timestamp_cmp (now, !=, now_tmp)) { /* The user gave "--now", use it! */ now = now_tmp; @@ -1470,9 +1469,8 @@ run (void *cls, else { /* get current time again, we may be timetraveling! */ - now = GNUNET_TIME_absolute_get (); + now = GNUNET_TIME_timestamp_get (); } - GNUNET_TIME_round_abs (&now); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "taler-exchange-secmod-rsa", @@ -1505,10 +1503,9 @@ run (void *cls, struct LoadContext lc = { .cfg = cfg, .ret = GNUNET_OK, - .now = now + .t = now }; - (void) GNUNET_TIME_round_abs (&lc.now); GNUNET_assert (0 == pthread_mutex_lock (&keys_lock)); GNUNET_CONFIGURATION_iterate_sections (cfg, &load_denominations, @@ -1552,11 +1549,11 @@ main (int argc, struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_timetravel ('T', "timetravel"), - GNUNET_GETOPT_option_absolute_time ('t', - "time", - "TIMESTAMP", - "pretend it is a different time for the update", - &now_tmp), + GNUNET_GETOPT_option_timestamp ('t', + "time", + "TIMESTAMP", + "pretend it is a different time for the update", + &now_tmp), GNUNET_GETOPT_OPTION_END }; enum GNUNET_GenericReturnValue ret; @@ -1568,7 +1565,7 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ TALER_OS_init (); - now = now_tmp = GNUNET_TIME_absolute_get (); + now_tmp = now = GNUNET_TIME_timestamp_get (); ret = GNUNET_PROGRAM_run (argc, argv, "taler-exchange-secmod-rsa", "Handle private RSA key operations for a Taler exchange", diff --git a/src/util/taler-exchange-secmod-rsa.h b/src/util/taler-exchange-secmod-rsa.h index b0fdfbd96..61fa58811 100644 --- a/src/util/taler-exchange-secmod-rsa.h +++ b/src/util/taler-exchange-secmod-rsa.h @@ -59,7 +59,7 @@ struct TALER_CRYPTO_RsaKeyAvailableNotification /** * When does the key become available? */ - struct GNUNET_TIME_AbsoluteNBO anchor_time; + struct GNUNET_TIME_TimestampNBO anchor_time; /** * How long is the key available after @e anchor_time? diff --git a/src/util/test_helper_eddsa.c b/src/util/test_helper_eddsa.c index 471441c68..da1c51b46 100644 --- a/src/util/test_helper_eddsa.c +++ b/src/util/test_helper_eddsa.c @@ -65,7 +65,7 @@ struct KeyData /** * Validity start point. */ - struct GNUNET_TIME_Absolute start_time; + struct GNUNET_TIME_Timestamp start_time; /** * Key expires for signing at @e start_time plus this value. @@ -112,7 +112,7 @@ static struct KeyData keys[MAX_KEYS]; */ static void key_cb (void *cls, - struct GNUNET_TIME_Absolute start_time, + struct GNUNET_TIME_Timestamp start_time, struct GNUNET_TIME_Relative validity_duration, const struct TALER_ExchangePublicKeyP *exchange_pub, const struct TALER_SecurityModulePublicKeyP *sm_pub, @@ -207,7 +207,7 @@ test_revocation (struct TALER_CRYPTO_ExchangeSignHelper *esh) TALER_CRYPTO_helper_esign_poll (esh); if ( (! keys[j].revoked) || (GNUNET_TIME_absolute_is_past ( - GNUNET_TIME_absolute_add (keys[j].start_time, + GNUNET_TIME_absolute_add (keys[j].start_time.abs_time, keys[j].validity_duration))) ) { break; @@ -217,7 +217,7 @@ test_revocation (struct TALER_CRYPTO_ExchangeSignHelper *esh) } if ( (keys[j].revoked) && (! GNUNET_TIME_absolute_is_past ( - GNUNET_TIME_absolute_add (keys[j].start_time, + GNUNET_TIME_absolute_add (keys[j].start_time.abs_time, keys[j].validity_duration))) ) { fprintf (stderr, diff --git a/src/util/test_helper_rsa.c b/src/util/test_helper_rsa.c index bafa45ba8..ac4ae1dc0 100644 --- a/src/util/test_helper_rsa.c +++ b/src/util/test_helper_rsa.c @@ -64,7 +64,7 @@ struct KeyData /** * Validity start point. */ - struct GNUNET_TIME_Absolute start_time; + struct GNUNET_TIME_Timestamp start_time; /** * Key expires for signing at @e start_time plus this value. @@ -137,7 +137,7 @@ free_keys (void) static void key_cb (void *cls, const char *section_name, - struct GNUNET_TIME_Absolute start_time, + struct GNUNET_TIME_Timestamp start_time, struct GNUNET_TIME_Relative validity_duration, const struct TALER_RsaPubHashP *h_rsa, const struct TALER_DenominationPublicKey *denom_pub, @@ -297,15 +297,19 @@ test_signing (struct TALER_CRYPTO_RsaDenominationHelper *dh) switch (ec) { case TALER_EC_NONE: - if (GNUNET_TIME_absolute_get_remaining (keys[i].start_time).rel_value_us > - GNUNET_TIME_UNIT_SECONDS.rel_value_us) + if (GNUNET_TIME_relative_cmp (GNUNET_TIME_absolute_get_remaining ( + keys[i].start_time.abs_time), + >, + GNUNET_TIME_UNIT_SECONDS)) { /* key worked too early */ GNUNET_break (0); return 4; } - if (GNUNET_TIME_absolute_get_duration (keys[i].start_time).rel_value_us > - keys[i].validity_duration.rel_value_us) + if (GNUNET_TIME_relative_cmp (GNUNET_TIME_absolute_get_duration ( + keys[i].start_time.abs_time), + >, + keys[i].validity_duration)) { /* key worked too later */ GNUNET_break (0); @@ -344,12 +348,14 @@ test_signing (struct TALER_CRYPTO_RsaDenominationHelper *dh) case TALER_EC_EXCHANGE_DENOMINATION_HELPER_TOO_EARLY: /* This 'failure' is expected, we're testing also for the error handling! */ - if ( (0 == - GNUNET_TIME_absolute_get_remaining ( - keys[i].start_time).rel_value_us) && - (GNUNET_TIME_absolute_get_duration ( - keys[i].start_time).rel_value_us < - keys[i].validity_duration.rel_value_us) ) + if ( (GNUNET_TIME_relative_is_zero ( + GNUNET_TIME_absolute_get_remaining ( + keys[i].start_time.abs_time))) && + (GNUNET_TIME_relative_cmp ( + GNUNET_TIME_absolute_get_duration ( + keys[i].start_time.abs_time), + <, + keys[i].validity_duration)) ) { /* key should have worked! */ GNUNET_break (0); @@ -422,11 +428,15 @@ perf_signing (struct TALER_CRYPTO_RsaDenominationHelper *dh, { if (! keys[i].valid) continue; - if (GNUNET_TIME_absolute_get_remaining (keys[i].start_time).rel_value_us > - GNUNET_TIME_UNIT_SECONDS.rel_value_us) + if (GNUNET_TIME_relative_cmp (GNUNET_TIME_absolute_get_remaining ( + keys[i].start_time.abs_time), + >, + GNUNET_TIME_UNIT_SECONDS)) continue; - if (GNUNET_TIME_absolute_get_duration (keys[i].start_time).rel_value_us > - keys[i].validity_duration.rel_value_us) + if (GNUNET_TIME_relative_cmp (GNUNET_TIME_absolute_get_duration ( + keys[i].start_time.abs_time), + >, + keys[i].validity_duration)) continue; { struct TALER_CoinPubHash c_hash; diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c index 8700d4a80..b895de14b 100644 --- a/src/util/wallet_signatures.c +++ b/src/util/wallet_signatures.c @@ -31,9 +31,9 @@ TALER_wallet_deposit_sign ( const struct TALER_PrivateContractHash *h_contract_terms, const struct TALER_ExtensionContractHash *h_extensions, const struct TALER_DenominationHash *h_denom_pub, - struct GNUNET_TIME_Absolute wallet_timestamp, + struct GNUNET_TIME_Timestamp wallet_timestamp, const struct TALER_MerchantPublicKeyP *merchant_pub, - struct GNUNET_TIME_Absolute refund_deadline, + struct GNUNET_TIME_Timestamp refund_deadline, const struct TALER_CoinSpendPrivateKeyP *coin_priv, struct TALER_CoinSpendSignatureP *coin_sig) { @@ -43,17 +43,13 @@ TALER_wallet_deposit_sign ( .h_contract_terms = *h_contract_terms, .h_wire = *h_wire, .h_denom_pub = *h_denom_pub, - .wallet_timestamp = GNUNET_TIME_absolute_hton (wallet_timestamp), - .refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline), + .wallet_timestamp = GNUNET_TIME_timestamp_hton (wallet_timestamp), + .refund_deadline = GNUNET_TIME_timestamp_hton (refund_deadline), .merchant = *merchant_pub }; if (NULL != h_extensions) dr.h_extensions = *h_extensions; - GNUNET_assert (GNUNET_OK == - GNUNET_TIME_round_abs (&wallet_timestamp)); - GNUNET_assert (GNUNET_OK == - GNUNET_TIME_round_abs (&refund_deadline)); TALER_amount_hton (&dr.amount_with_fee, amount); TALER_amount_hton (&dr.deposit_fee, @@ -72,9 +68,9 @@ TALER_wallet_deposit_verify ( const struct TALER_PrivateContractHash *h_contract_terms, const struct TALER_ExtensionContractHash *h_extensions, const struct TALER_DenominationHash *h_denom_pub, - struct GNUNET_TIME_Absolute wallet_timestamp, + struct GNUNET_TIME_Timestamp wallet_timestamp, const struct TALER_MerchantPublicKeyP *merchant_pub, - struct GNUNET_TIME_Absolute refund_deadline, + struct GNUNET_TIME_Timestamp refund_deadline, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendSignatureP *coin_sig) { @@ -84,8 +80,8 @@ TALER_wallet_deposit_verify ( .h_contract_terms = *h_contract_terms, .h_wire = *h_wire, .h_denom_pub = *h_denom_pub, - .wallet_timestamp = GNUNET_TIME_absolute_hton (wallet_timestamp), - .refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline), + .wallet_timestamp = GNUNET_TIME_timestamp_hton (wallet_timestamp), + .refund_deadline = GNUNET_TIME_timestamp_hton (refund_deadline), .merchant = *merchant_pub }; |