exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit de5c05229fbe3d690c38e1af1be95c6367265031
parent 314116595e3b1b43dfba23839313dc1590b67b20
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Sat, 18 Jul 2026 11:51:35 +0200

fix htonl/htons confusion

Diffstat:
Msrc/bank-lib/bank_api_registration.c | 20++++++++++----------
Msrc/include/taler/taler_bank_service.h | 21+--------------------
Msrc/include/taler/taler_crypto_lib.h | 30++++++++++++++++++++++++++----
Msrc/util/wallet_signatures.c | 66++++++++++++++++++------------------------------------------------
4 files changed, 55 insertions(+), 82 deletions(-)

diff --git a/src/bank-lib/bank_api_registration.c b/src/bank-lib/bank_api_registration.c @@ -286,7 +286,7 @@ TALER_BANK_registration ( const char *base_url, const struct TALER_FullPayto *credit_account, const struct TALER_Amount *credit_amount, - enum TALER_BANK_RegistrationType type, + enum TALER_BankRegistrationType type, const union TALER_AccountPublicKeyP *account_pub, const struct TALER_PreparedTransferAuthorizationPrivateKeyP * authorization_priv, @@ -301,15 +301,15 @@ TALER_BANK_registration ( json_t *reg_obj; CURL *eh; - TALER_wallet_prepared_transfer_registration_sign (*credit_account, - credit_amount, - type == - TALER_BANK_REGISTRATION_TYPE_RESERVE, - recurrent, - - account_pub, - authorization_priv, - &authorization_sig); + TALER_wallet_prepared_transfer_registration_sign ( + *credit_account, + credit_amount, + type == + TALER_BANK_REGISTRATION_TYPE_RESERVE, + recurrent, + account_pub, + authorization_priv, + &authorization_sig); GNUNET_CRYPTO_eddsa_key_get_public (&authorization_priv->eddsa_priv, &authorization_pub.eddsa_pub); diff --git a/src/include/taler/taler_bank_service.h b/src/include/taler/taler_bank_service.h @@ -1062,25 +1062,6 @@ enum TALER_BANK_SubjectFormat /** - * Transfer type requested at registration. - */ -enum TALER_BANK_RegistrationType -{ - - /** - * Standard reserve withdrawal. - */ - TALER_BANK_REGISTRATION_TYPE_RESERVE, - - /** - * KYC authentication transfer. - */ - TALER_BANK_REGISTRATION_TYPE_KYC - -}; - - -/** * @brief A /registration Handle */ struct TALER_BANK_RegistrationHandle; @@ -1283,7 +1264,7 @@ TALER_BANK_registration ( const char *base_url, const struct TALER_FullPayto *credit_account, const struct TALER_Amount *credit_amount, - enum TALER_BANK_RegistrationType type, + enum TALER_BankRegistrationType type, const union TALER_AccountPublicKeyP *account_pub, const struct TALER_PreparedTransferAuthorizationPrivateKeyP * authorization_priv, diff --git a/src/include/taler/taler_crypto_lib.h b/src/include/taler/taler_crypto_lib.h @@ -4936,12 +4936,35 @@ TALER_wallet_order_unclaim_verify ( const struct GNUNET_CRYPTO_EddsaSignature *nsig); +/** + * Transfer type requested at registration. + */ +enum TALER_BankRegistrationType +{ + + /** + * Invalid / uninitialized registration type. + */ + TALER_BANK_REGISTRATION_TYPE_INVALID = 0, + + /** + * Standard reserve withdrawal. + */ + TALER_BANK_REGISTRATION_TYPE_RESERVE = 1, + + /** + * KYC authentication transfer. + */ + TALER_BANK_REGISTRATION_TYPE_KYC = 2 + +}; + + void TALER_wallet_prepared_transfer_registration_sign ( const struct TALER_FullPayto credit_account, const struct TALER_Amount *credit_amount, - // enum TALER_BANK_RegistrationType type, TODO solve the include cycle - bool is_reserve, + enum TALER_BankRegistrationType type, bool recurrent, const union TALER_AccountPublicKeyP *account_pub, const struct TALER_PreparedTransferAuthorizationPrivateKeyP *auth_priv, @@ -4952,8 +4975,7 @@ enum GNUNET_GenericReturnValue TALER_wallet_prepared_transfer_registration_verify ( const struct TALER_FullPayto credit_account, const struct TALER_Amount *credit_amount, - // enum TALER_BANK_RegistrationType type, TODO solve the include cycle - bool is_reserve, + enum TALER_BankRegistrationType type, bool recurrent, const union TALER_AccountPublicKeyP *account_pub, const struct TALER_PreparedTransferAuthorizationPublicKeyP *auth_pub, diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c @@ -2206,20 +2206,25 @@ struct TALER_PreparedTransferRegisterPS * Purpose is #TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER */ struct GNUNET_CRYPTO_SignaturePurpose purpose; + struct TALER_FullPaytoHashP credit_account; struct TALER_AmountNBO credit_amount; + /** - * 1: reserve, 2: kyc - */ + * NBO of `enum TALER_BankRegistrationType`; 1: reserve, 2: kyc + */ uint32_t type; + /** - * 1: one-time, 2: recurrent - */ + * In NBO, 0: reserved, 1: one-time, 2: recurrent + */ uint16_t recurrent; + /** - * 1: EdDSA - */ + * Currently always 1: EdDSA + */ uint16_t alg; + union TALER_AccountPublicKeyP account_pub; }; @@ -2231,8 +2236,7 @@ void TALER_wallet_prepared_transfer_registration_sign ( const struct TALER_FullPayto credit_account, const struct TALER_Amount *credit_amount, - // enum TALER_BANK_RegistrationType type, TODO solve the include cycle - bool is_reserve, + enum TALER_BankRegistrationType type, bool recurrent, const union TALER_AccountPublicKeyP *account_pub, const struct TALER_PreparedTransferAuthorizationPrivateKeyP *auth_priv, @@ -2242,7 +2246,9 @@ TALER_wallet_prepared_transfer_registration_sign ( .purpose.size = htonl (sizeof (rcp)), .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER) , + .type = htonl ((uint32_t) type), .alg = htons (1), + .recurrent = htons (recurrent ? 2 : 1), .account_pub = *account_pub }; @@ -2250,25 +2256,6 @@ TALER_wallet_prepared_transfer_registration_sign ( &rcp.credit_account); TALER_amount_hton (&rcp.credit_amount, credit_amount); - - if (is_reserve) - { - rcp.type = htonl (1); - } - else - { - rcp.type = htonl (2); - } - - if (recurrent) - { - rcp.recurrent = htons (2); - } - else - { - rcp.recurrent = htons (1); - } - GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign_ ( &auth_priv->eddsa_priv, @@ -2281,8 +2268,7 @@ enum GNUNET_GenericReturnValue TALER_wallet_prepared_transfer_registration_verify ( const struct TALER_FullPayto credit_account, const struct TALER_Amount *credit_amount, - // enum TALER_BANK_RegistrationType type, TODO solve the include cycle - bool is_reserve, + enum TALER_BankRegistrationType type, bool recurrent, const union TALER_AccountPublicKeyP *account_pub, const struct TALER_PreparedTransferAuthorizationPublicKeyP *auth_pub, @@ -2292,7 +2278,9 @@ TALER_wallet_prepared_transfer_registration_verify ( .purpose.size = htonl (sizeof (rcp)), .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER) , - .alg = htonl (1), + .type = htonl ((uint32_t) type), + .alg = htons (1), + .recurrent = htons (recurrent ? 2 : 1), .account_pub = *account_pub }; @@ -2301,24 +2289,6 @@ TALER_wallet_prepared_transfer_registration_verify ( TALER_amount_hton (&rcp.credit_amount, credit_amount); - if (is_reserve) - { - rcp.type = htonl (1); - } - else - { - rcp.type = htonl (2); - } - - if (recurrent) - { - rcp.recurrent = htonl (1); - } - else - { - rcp.recurrent = htonl (2); - } - return GNUNET_CRYPTO_eddsa_verify_ ( TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER, &rcp.purpose,