diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/taler_crypto_lib.h | 304 | ||||
-rw-r--r-- | src/include/taler_mint_service.h | 22 | ||||
-rw-r--r-- | src/include/taler_signatures.h | 31 | ||||
-rw-r--r-- | src/lib/mint_api.c | 64 | ||||
-rw-r--r-- | src/mint/key_io.c | 10 | ||||
-rw-r--r-- | src/mint/key_io.h | 6 | ||||
-rw-r--r-- | src/mint/plugin_mintdb_common.c | 4 | ||||
-rw-r--r-- | src/mint/plugin_mintdb_postgres.c | 129 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_db.c | 132 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_db.h | 22 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_deposit.c | 6 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_keystate.c | 18 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_keystate.h | 4 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 101 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.c | 43 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.h | 10 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_withdraw.c | 27 | ||||
-rw-r--r-- | src/mint/taler-mint-keycheck.c | 10 | ||||
-rw-r--r-- | src/mint/taler-mint-keyup.c | 51 | ||||
-rw-r--r-- | src/mint/taler_mintdb_plugin.h | 180 | ||||
-rw-r--r-- | src/mint/test_mint_common.c | 25 | ||||
-rw-r--r-- | src/mint/test_mint_db.c | 47 | ||||
-rw-r--r-- | src/util/crypto.c | 15 |
23 files changed, 794 insertions, 467 deletions
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index db663612c..0c0ad8865 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -28,6 +28,296 @@ /* ****************** Coin crypto primitives ************* */ /** + * Type of public keys for Taler reserves. + */ +struct TALER_ReservePublicKey +{ + /** + * Taler uses EdDSA for reserves. + */ + struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; +}; + + +/** + * Type of private keys for Taler reserves. + */ +struct TALER_ReservePrivateKey +{ + /** + * Taler uses EdDSA for reserves. + */ + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; +}; + + +/** + * Type of signatures used with Taler reserves. + */ +struct TALER_ReserveSignature +{ + /** + * Taler uses EdDSA for reserves. + */ + struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; +}; + + +/** + * Type of public keys to for merchant authorizations. + * Merchants can issue refunds using the corresponding + * private key. + */ +struct TALER_MerchantPublicKey +{ + /** + * Taler uses EdDSA for merchants. + */ + struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; +}; + + +/** + * Type of private keys for merchant authorizations. + * Merchants can issue refunds using the corresponding + * private key. + */ +struct TALER_MerchantPrivateKey +{ + /** + * Taler uses EdDSA for merchants. + */ + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; +}; + + +/** + * Type of public keys used by clients to sign + * messages during a melting session. + */ +struct TALER_SessionPublicKey +{ + /** + * Taler uses EdDSA for melting session keys. + */ + struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; +}; + + +/** + * Type of public keys used by clients to sign + * messages during a melting session. + */ +struct TALER_SessionPrivateKey +{ + /** + * Taler uses EdDSA for melting session keys. + */ + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; +}; + + +/** + * Type of transfer public keys used during refresh + * operations. + */ +struct TALER_TransferPublicKey +{ + /** + * Taler uses ECDSA for transfer keys. + * FIXME: should this not be ECDHE? + */ + struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_pub; +}; + + +/** + * Type of transfer public keys used during refresh + * operations. + */ +struct TALER_TransferPrivateKey +{ + /** + * Taler uses ECDSA for melting session keys. + * FIXME: should this not be ECDHE? + */ + struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_priv; +}; + + +/** + * Type of signatures used by clients to sign + * messages during a melting session. + */ +struct TALER_SessionSignature +{ + /** + * Taler uses EdDSA for melting session keys. + */ + struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; +}; + + +/** + * Type of online public keys used by the mint to sign + * messages. + */ +struct TALER_MintPublicKey +{ + /** + * Taler uses EdDSA for online mint message signing. + */ + struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; +}; + + +/** + * Type of online public keys used by the mint to + * sign messages. + */ +struct TALER_MintPrivateKey +{ + /** + * Taler uses EdDSA for online signatures sessions. + */ + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; +}; + + +/** + * Type of signatures used by the mint to sign messages online. + */ +struct TALER_MintSignature +{ + /** + * Taler uses EdDSA for online signatures sessions. + */ + struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; +}; + + +/** + * Type of the offline master public key used by the mint. + */ +struct TALER_MasterPublicKey +{ + /** + * Taler uses EdDSA for the long-term offline master key. + */ + struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; +}; + + +/** + * Type of the offline master public keys used by the mint. + */ +struct TALER_MasterPrivateKey +{ + /** + * Taler uses EdDSA for the long-term offline master key. + */ + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; +}; + + +/** + * Type of signatures by the offline master public key used by the mint. + */ +struct TALER_MasterSignature +{ + /** + * Taler uses EdDSA for the long-term offline master key. + */ + struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; +}; + + + +/** + * Type of public keys for Taler coins. + */ +struct TALER_CoinSpendPublicKey +{ + /** + * Taler uses ECDSA for coins. + */ + struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_pub; +}; + + +/** + * Type of private keys for Taler coins. + */ +struct TALER_CoinSpendPrivateKey +{ + /** + * Taler uses ECDSA for coins. + */ + struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_priv; +}; + + +/** + * Type of signatures made with Taler coins. + */ +struct TALER_CoinSpendSignature +{ + /** + * Taler uses ECDSA for coins. + */ + struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature; +}; + + +/** + * Type of blinding keys for Taler. + */ +struct TALER_DenominationBlindingKey +{ + /** + * Taler uses RSA for blinding. + */ + struct GNUNET_CRYPTO_rsa_BlindingKey *rsa_blinding_key; +}; + + +/** + * Type of (unblinded) coin signatures for Taler. + */ +struct TALER_DenominationSignature +{ + /** + * Taler uses RSA for blinding. + */ + struct GNUNET_CRYPTO_rsa_Signature *rsa_signature; +}; + + +/** + * Type of public signing keys for verifying blindly signed coins. + */ +struct TALER_DenominationPublicKey +{ + /** + * Taler uses RSA for signing coins. + */ + struct GNUNET_CRYPTO_rsa_PublicKey *rsa_public_key; +}; + + +/** + * Type of private signing keys for blind signing of coins. + */ +struct TALER_DenominationPrivateKey +{ + /** + * Taler uses RSA for signing coins. + */ + struct GNUNET_CRYPTO_rsa_PrivateKey *rsa_private_key; +}; + + +/** * Public information about a coin (including the public key * of the coin, the denomination key and the signature with * the denomination key). @@ -37,19 +327,19 @@ struct TALER_CoinPublicInfo /** * The coin's public key. */ - struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; + struct TALER_CoinSpendPublicKey coin_pub; /** * Public key representing the denomination of the coin * that is being deposited. */ - struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub; + struct TALER_DenominationPublicKey denom_pub; /** * (Unblinded) signature over @e coin_pub with @e denom_pub, * which demonstrates that the coin is valid. */ - struct GNUNET_CRYPTO_rsa_Signature *denom_sig; + struct TALER_DenominationSignature denom_sig; }; @@ -126,7 +416,7 @@ struct TALER_RefreshLinkEncrypted /** * Encrypted private key of the coin. */ - char coin_priv_enc[sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)]; + char coin_priv_enc[sizeof (struct TALER_CoinSpendPrivateKey)]; }; @@ -140,12 +430,12 @@ struct TALER_RefreshLinkDecrypted /** * Private key of the coin. */ - struct GNUNET_CRYPTO_EcdsaPrivateKey coin_priv; + struct TALER_CoinSpendPrivateKey coin_priv; /** - * Blinding key with @e blinding_key_enc_size bytes. + * Blinding key. */ - struct GNUNET_CRYPTO_rsa_BlindingKey *blinding_key; + struct TALER_DenominationBlindingKey blinding_key; }; diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index f300a5cfb..30aaad38e 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014 Christian Grothoff (and other contributing authors) + Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors) TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -42,7 +42,7 @@ struct TALER_MINT_SigningPublicKey /** * The signing public key */ - struct GNUNET_CRYPTO_EddsaPublicKey key; + struct TALER_MintPublicKey key; /** * Validity start time @@ -64,7 +64,7 @@ struct TALER_MINT_DenomPublicKey /** * The public key */ - struct GNUNET_CRYPTO_rsa_PublicKey *key; + struct TALER_DenominationPublicKey key; /** * Timestamp indicating when the denomination key becomes valid @@ -132,7 +132,7 @@ TALER_MINT_cleanup (struct TALER_MINT_Context *ctx); * @param hostname the hostname of the mint * @param port the point where the mint's HTTP service is running. If port is * given as 0, ports 80 or 443 are chosen depending on @a url. - * @param mint_key the public key of the mint. This is used to verify the + * @param master_key the public master key of the mint. This is used to verify the * responses of the mint. * @return the mint handle; NULL upon error */ @@ -140,7 +140,7 @@ struct TALER_MINT_Handle * TALER_MINT_connect (struct TALER_MINT_Context *ctx, const char *hostname, uint16_t port, - struct GNUNET_CRYPTO_EddsaPublicKey *mint_key); + const struct TALER_MasterPublicKey *master_key); /** * Disconnect from the mint @@ -282,15 +282,15 @@ struct TALER_MINT_DepositHandle * TALER_MINT_deposit_submit_json_ (struct TALER_MINT_Handle *mint, TALER_MINT_DepositResultCallback *cb, void *cls, - struct GNUNET_CRYPTO_EddsaPublicKey *coin_pub, - struct TALER_BLIND_SigningPublicKey *denom_pub, + const struct TALER_CoinPublicKey *coin_pub, + const struct TALER_BLIND_SigningPublicKey *denom_pub, struct TALER_BLIND_Signature *ubsig, uint64_t transaction_id, struct TALER_Amount *amount, - struct GNUNET_CRYPTO_EddsaPublicKey *merchant_pub, - struct GNUNET_HashCode *h_contract, - struct GNUNET_HashCode *h_wire, - struct GNUNET_CRYPTO_EddsaSignature *csig, + const struct TALER_MerchantPublicKey *merchant_pub, + const struct GNUNET_HashCode *h_contract, + const struct GNUNET_HashCode *h_wire, + const struct TALER_CoinSignature *csig, json_t *wire_obj); #endif diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 4566764d0..51134bf26 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014 Christian Grothoff (and other contributing authors) + Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors) TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -28,7 +28,6 @@ #ifndef TALER_SIGNATURES_H #define TALER_SIGNATURES_H -#include <gnunet/gnunet_util_lib.h> #include "taler_util.h" /** @@ -129,7 +128,7 @@ struct TALER_WithdrawRequest * Reserve public key (which reserve to withdraw from). This is * the public key which must match the signature. */ - struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub; + struct TALER_ReservePublicKey reserve_pub; /** * Value of the coin being minted (matching the denomination key) @@ -189,7 +188,7 @@ struct TALER_DepositRequest /** * The coin's public key. */ - struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; + struct TALER_CoinSpendPublicKey coin_pub; }; @@ -232,12 +231,12 @@ struct TALER_DepositConfirmation /** * The coin's public key. */ - struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; + struct TALER_CoinSpendPublicKey coin_pub; /** * The Merchant's public key. */ - struct GNUNET_CRYPTO_EddsaPublicKey merchant; + struct TALER_MerchantPublicKey merchant; }; @@ -274,7 +273,7 @@ struct RefreshMeltCoinSignature /** * The coin's public key. */ - struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; + struct TALER_CoinSpendPublicKey coin_pub; }; @@ -298,7 +297,7 @@ struct RefreshMeltSessionSignature * Public key of the refresh session for which * @e melt_client_signature must be a valid signature. */ - struct GNUNET_CRYPTO_EddsaPublicKey session_key; + struct TALER_SessionPublicKey session_key; /** * What is the total value of the coins created during the @@ -348,10 +347,12 @@ struct RefreshMeltConfirmSignRequestBody */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + // FIXME: We probably need more info in here... + /** - * FIXME. + * Public key the client uses for this session. */ - struct GNUNET_CRYPTO_EddsaPublicKey session_pub; + struct TALER_SessionPublicKey session_pub; }; @@ -365,7 +366,7 @@ struct TALER_MINT_SignKeyIssue /** * Signature over the signing key (by the master key of the mint). */ - struct GNUNET_CRYPTO_EddsaSignature signature; + struct TALER_MasterSignature signature; /** * Purpose is #TALER_SIGNATURE_MASTER_SIGNKEY. @@ -376,7 +377,7 @@ struct TALER_MINT_SignKeyIssue * Master public key of the mint corresponding to @e signature. * This is the long-term offline master key of the mint. */ - struct GNUNET_CRYPTO_EddsaPublicKey master_pub; + struct TALER_MasterPublicKey master_pub; /** * When does this signing key begin to be valid? @@ -395,7 +396,7 @@ struct TALER_MINT_SignKeyIssue * The public online signing key that the mint will use * between @e start and @e expire. */ - struct GNUNET_CRYPTO_EddsaPublicKey signkey_pub; + struct TALER_MintPublicKey signkey_pub; }; @@ -409,7 +410,7 @@ struct TALER_MINT_DenomKeyIssue * Signature over this struct to affirm the validity * of the key. */ - struct GNUNET_CRYPTO_EddsaSignature signature; + struct TALER_MasterSignature signature; /** * Purpose ist #TALER_SIGNATURE_MASTER_DENOM. @@ -420,7 +421,7 @@ struct TALER_MINT_DenomKeyIssue * The long-term offline master key of the mint that was * used to create @e signature. */ - struct GNUNET_CRYPTO_EddsaPublicKey master; + struct TALER_MasterPublicKey master; /** * Start time of the validity period for this key. diff --git a/src/lib/mint_api.c b/src/lib/mint_api.c index eb2697a2e..305fc95d9 100644 --- a/src/lib/mint_api.c +++ b/src/lib/mint_api.c @@ -179,9 +179,11 @@ struct TALER_MINT_KeysGetHandle char *url; TALER_MINT_KeysGetCallback cb; - void *cls; + + void *cb_cls; TALER_MINT_ContinuationCallback cont_cb; + void *cont_cls; }; @@ -202,7 +204,8 @@ struct TALER_MINT_DepositHandle char *url; TALER_MINT_DepositResultCallback cb; - void *cls; + + void *cb_cls; char *json_enc; @@ -219,7 +222,8 @@ struct TALER_MINT_DepositHandle * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ static int -parse_timestamp (struct GNUNET_TIME_Absolute *abs, const char *tstamp_enc) +parse_timestamp (struct GNUNET_TIME_Absolute *abs, + const char *tstamp_enc) { unsigned long tstamp; @@ -242,7 +246,7 @@ parse_timestamp (struct GNUNET_TIME_Absolute *abs, const char *tstamp_enc) static int parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key, json_t *sign_key_obj, - struct GNUNET_CRYPTO_EddsaPublicKey *master_key) + struct TALER_MasterPublicKey *master_key) { json_t *valid_from_obj; json_t *valid_until_obj; @@ -281,7 +285,7 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key, EXITIF (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_public_key_from_string (key_enc, 52, - &sign_key_issue.signkey_pub)); + &sign_key_issue.signkey_pub.eddsa_pub)); sign_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNKEY); sign_key_issue.purpose.size = htonl (sizeof (sign_key_issue) @@ -293,7 +297,7 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key, GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNKEY, &sign_key_issue.purpose, &sig, - master_key)); + &master_key->eddsa_pub)); sign_key = GNUNET_new (struct TALER_MINT_SigningPublicKey); sign_key->valid_from = valid_from; sign_key->valid_until = valid_until; @@ -337,7 +341,7 @@ parse_json_amount (json_t *amount_obj, struct TALER_Amount *amt) static int parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key, json_t *denom_key_obj, - struct GNUNET_CRYPTO_EddsaPublicKey *master_key) + struct TALER_MasterPublicKey *master_key) { json_t *obj; const char *sig_enc; @@ -424,9 +428,9 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key, GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOM, &denom_key_issue.purpose, &sig, - master_key)); + &master_key->eddsa_pub)); denom_key = GNUNET_new (struct TALER_MINT_DenomPublicKey); - denom_key->key = pk; + denom_key->key.rsa_public_key = pk; denom_key->valid_from = valid_from; denom_key->withdraw_valid_until = withdraw_valid_until; denom_key->deposit_valid_until = deposit_valid_until; @@ -451,7 +455,7 @@ parse_response_keys_get (const char *in, size_t size, { json_t *resp_obj; struct TALER_MINT_DenomPublicKey **denom_keys; - struct GNUNET_CRYPTO_EddsaPublicKey master_key; + struct TALER_MasterPublicKey master_key; struct GNUNET_TIME_Absolute list_issue_date; struct TALER_MINT_SigningPublicKey **sign_keys; unsigned int n_denom_keys; @@ -487,7 +491,7 @@ parse_response_keys_get (const char *in, size_t size, EXITIF (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (master_key_enc, 52, - &master_key)); + &master_key.eddsa_pub)); } { /* parse the issue date of the response */ @@ -664,7 +668,8 @@ request_failed (struct TALER_MINT_Handle *mint, long resp_code) { struct TALER_MINT_DepositHandle *dh = mint->req.deposit; TALER_MINT_DepositResultCallback cb = dh->cb; - void *cls = dh->cls; + void *cls = dh->cb_cls; + GNUNET_assert (NULL != dh); cleanup_deposit (dh); mint_disconnect (mint); @@ -705,7 +710,7 @@ request_succeeded (struct TALER_MINT_Handle *mint, long resp_code) parse_response_keys_get (mint->buf, mint->buf_size, &sign_keys, &n_sign_keys, &denom_keys, &n_denom_keys)) - gh->cb (gh->cls, sign_keys, denom_keys); + gh->cb (gh->cb_cls, sign_keys, denom_keys); else emsg = GNUNET_strdup ("Error parsing response"); } @@ -727,7 +732,7 @@ request_succeeded (struct TALER_MINT_Handle *mint, long resp_code) GNUNET_assert (NULL != dh); obj = NULL; cb = dh->cb; - cls = dh->cls; + cls = dh->cb_cls; status = 0; if (200 == resp_code) { @@ -903,15 +908,15 @@ download (char *bufptr, size_t size, size_t nitems, void *cls) * @param ctx the context * @param hostname the hostname of the mint * @param port the point where the mint's HTTP service is running. - * @param mint_key the public key of the mint. This is used to verify the - * responses of the mint. + * @param mint_key the offline master public key of the mint. + * This is used to verify the responses of the mint. * @return the mint handle; NULL upon error */ struct TALER_MINT_Handle * TALER_MINT_connect (struct TALER_MINT_Context *ctx, const char *hostname, uint16_t port, - struct GNUNET_CRYPTO_EddsaPublicKey *mint_key) + const struct TALER_MasterPublicKey *mint_key) { struct TALER_MINT_Handle *mint; @@ -952,15 +957,17 @@ TALER_MINT_disconnect (struct TALER_MINT_Handle *mint) * * @param mint handle to the mint * @param cb the callback to call with each retrieved denomination key - * @param cls closure for the above callback + * @param cb_cls closure for the above callback * @param cont_cb the callback to call after completing this asynchronous call * @param cont_cls the closure for the continuation callback * @return a handle to this asynchronous call; NULL upon eror */ struct TALER_MINT_KeysGetHandle * TALER_MINT_keys_get (struct TALER_MINT_Handle *mint, - TALER_MINT_KeysGetCallback cb, void *cls, - TALER_MINT_ContinuationCallback cont_cb, void *cont_cls) + TALER_MINT_KeysGetCallback cb, + void *cb_cls, + TALER_MINT_ContinuationCallback cont_cb, + void *cont_cls) { struct TALER_MINT_KeysGetHandle *gh; @@ -970,12 +977,17 @@ TALER_MINT_keys_get (struct TALER_MINT_Handle *mint, mint->req_type = REQUEST_TYPE_KEYSGET; mint->req.keys_get = gh; gh->cb = cb; - gh->cls = cls; + gh->cb_cls = cb_cls; gh->cont_cb = cont_cb; gh->cont_cls = cont_cls; - GNUNET_asprintf (&gh->url, "http://%s:%hu/keys", mint->hostname, mint->port); + GNUNET_asprintf (&gh->url, + "http://%s:%hu/keys", + mint->hostname, + mint->port); GNUNET_assert (CURLE_OK == - curl_easy_setopt (mint->curl, CURLOPT_URL, gh->url)); + curl_easy_setopt (mint->curl, + CURLOPT_URL, + gh->url)); if (GNUNET_NO == mint->connected) mint_connect (mint); perform_now (mint->ctx); @@ -1005,7 +1017,7 @@ TALER_MINT_keys_get_cancel (struct TALER_MINT_KeysGetHandle *get) * * @param mint the mint handle * @param cb the callback to call when a reply for this request is available - * @param cls closure for the above callback + * @param cb_cls closure for the above callback * @param deposit_obj the deposit permission received from the customer along * with the wireformat JSON object * @return a handle for this request; NULL if the JSON object could not be @@ -1015,7 +1027,7 @@ TALER_MINT_keys_get_cancel (struct TALER_MINT_KeysGetHandle *get) struct TALER_MINT_DepositHandle * TALER_MINT_deposit_submit_json (struct TALER_MINT_Handle *mint, TALER_MINT_DepositResultCallback cb, - void *cls, + void *cb_cls, json_t *deposit_obj) { struct TALER_MINT_DepositHandle *dh; @@ -1026,7 +1038,7 @@ TALER_MINT_deposit_submit_json (struct TALER_MINT_Handle *mint, mint->req_type = REQUEST_TYPE_DEPOSIT; mint->req.deposit = dh; dh->cb = cb; - dh->cls = cls; + dh->cb_cls = cb_cls; GNUNET_asprintf (&dh->url, "http://%s:%hu/deposit", mint->hostname, mint->port); GNUNET_assert (NULL != (dh->json_enc = json_dumps (deposit_obj, JSON_COMPACT))); GNUNET_assert (CURLE_OK == diff --git a/src/mint/key_io.c b/src/mint/key_io.c index d267ce2a2..182d6f3de 100644 --- a/src/mint/key_io.c +++ b/src/mint/key_io.c @@ -164,8 +164,9 @@ TALER_MINT_read_denom_key (const char *filename, GNUNET_free (data); return GNUNET_SYSERR; } - dki->denom_priv = priv; - dki->denom_pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); + dki->denom_priv.rsa_private_key = priv; + dki->denom_pub.rsa_public_key + = GNUNET_CRYPTO_rsa_private_key_get_public (priv); memcpy (&dki->issue, data, offset); @@ -193,8 +194,9 @@ TALER_MINT_write_denom_key (const char *filename, int ret; fh = NULL; - priv_enc_size = GNUNET_CRYPTO_rsa_private_key_encode (dki->denom_priv, - &priv_enc); + priv_enc_size + = GNUNET_CRYPTO_rsa_private_key_encode (dki->denom_priv.rsa_private_key, + &priv_enc); ret = GNUNET_SYSERR; if (NULL == (fh = GNUNET_DISK_file_open (filename, diff --git a/src/mint/key_io.h b/src/mint/key_io.h index b204629a2..6c6722a8a 100644 --- a/src/mint/key_io.h +++ b/src/mint/key_io.h @@ -52,7 +52,7 @@ struct TALER_MINT_SignKeyIssuePriv /** * Private key part of the mint's signing key. */ - struct GNUNET_CRYPTO_EddsaPrivateKey signkey_priv; + struct TALER_MintPrivateKey signkey_priv; /** * Public information about a mint signing key. @@ -75,13 +75,13 @@ struct TALER_MINT_DenomKeyIssuePriv * key is not available (this is the case after the key has expired * for signing coins, but is still valid for depositing coins). */ - struct GNUNET_CRYPTO_rsa_PrivateKey *denom_priv; + struct TALER_DenominationPrivateKey denom_priv; /** * Decoded denomination public key (the hash of it is in * @e issue, but we sometimes need the full public key as well). */ - struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub; + struct TALER_DenominationPublicKey denom_pub; /** * Signed public information about a denomination key. diff --git a/src/mint/plugin_mintdb_common.c b/src/mint/plugin_mintdb_common.c index 34aefb872..6e52a3bc4 100644 --- a/src/mint/plugin_mintdb_common.c +++ b/src/mint/plugin_mintdb_common.c @@ -46,8 +46,8 @@ common_free_reserve_history (void *cls, break; case TALER_MINT_DB_RO_WITHDRAW_COIN: cbc = rh->details.withdraw; - GNUNET_CRYPTO_rsa_signature_free (cbc->sig); - GNUNET_CRYPTO_rsa_public_key_free (cbc->denom_pub); + GNUNET_CRYPTO_rsa_signature_free (cbc->sig.rsa_signature); + GNUNET_CRYPTO_rsa_public_key_free (cbc->denom_pub.rsa_public_key); GNUNET_free (cbc); break; } diff --git a/src/mint/plugin_mintdb_postgres.c b/src/mint/plugin_mintdb_postgres.c index 1d7a965cf..1c0388427 100644 --- a/src/mint/plugin_mintdb_postgres.c +++ b/src/mint/plugin_mintdb_postgres.c @@ -758,15 +758,10 @@ postgres_reserve_get (void *cls, PGresult *result; uint64_t expiration_date_nbo; struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR(reserve->pub), + TALER_DB_QUERY_PARAM_PTR(&reserve->pub), TALER_DB_QUERY_PARAM_END }; - if (NULL == reserve->pub) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } result = TALER_DB_exec_prepared (session->conn, "get_reserve", params); @@ -821,11 +816,11 @@ postgres_reserves_update (void *cls, struct GNUNET_TIME_AbsoluteNBO expiry_nbo; int ret; - if ((NULL == reserve) || (NULL == reserve->pub)) + if (NULL == reserve) return GNUNET_SYSERR; ret = GNUNET_OK; struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (reserve->pub), + TALER_DB_QUERY_PARAM_PTR (&reserve->pub), TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value), TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction), TALER_DB_QUERY_PARAM_PTR (&expiry_nbo), @@ -901,7 +896,7 @@ postgres_reserves_in_insert (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reserve does not exist; creating a new one\n"); struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (reserve->pub), + TALER_DB_QUERY_PARAM_PTR (&reserve->pub), TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value), TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction), TALER_DB_QUERY_PARAM_PTR_SIZED (balance_nbo.currency, @@ -923,7 +918,7 @@ postgres_reserves_in_insert (void *cls, result = NULL; /* create new incoming transaction */ struct TALER_DB_QueryParam params[] = { - TALER_DB_QUERY_PARAM_PTR (reserve->pub), + TALER_DB_QUERY_PARAM_PTR (&reserve->pub), TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value), TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction), TALER_DB_QUERY_PARAM_PTR_SIZED (&balance_nbo.currency, @@ -1053,8 +1048,8 @@ postgres_get_collectable_blindcoin (void *cls, GNUNET_break (0); goto cleanup; } - collectable->denom_pub = denom_pub; - collectable->sig = denom_sig; + collectable->denom_pub.rsa_public_key = denom_pub; + collectable->sig.rsa_signature = denom_sig; ret = GNUNET_YES; cleanup: @@ -1103,10 +1098,10 @@ postgres_insert_collectable_blindcoin (void *cls, ret = GNUNET_SYSERR; denom_pub_enc_size = - GNUNET_CRYPTO_rsa_public_key_encode (collectable->denom_pub, + GNUNET_CRYPTO_rsa_public_key_encode (collectable->denom_pub.rsa_public_key, &denom_pub_enc); denom_sig_enc_size = - GNUNET_CRYPTO_rsa_signature_encode (collectable->sig, + GNUNET_CRYPTO_rsa_signature_encode (collectable->sig.rsa_signature, &denom_sig_enc); struct TALER_DB_QueryParam params[] = { TALER_DB_QUERY_PARAM_PTR (h_blind), @@ -1127,8 +1122,7 @@ postgres_insert_collectable_blindcoin (void *cls, QUERY_ERR (result); goto rollback; } - reserve.pub = (struct GNUNET_CRYPTO_EddsaPublicKey *) - &collectable->reserve_pub; + reserve.pub = collectable->reserve_pub; if (GNUNET_OK != postgres_reserve_get (cls, session, &reserve)) @@ -1172,7 +1166,7 @@ postgres_insert_collectable_blindcoin (void *cls, static struct ReserveHistory * postgres_get_reserve_history (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub) + const struct TALER_ReservePublicKey *reserve_pub) { PGresult *result; struct ReserveHistory *rh; @@ -1219,7 +1213,7 @@ postgres_get_reserve_history (void *cls, GNUNET_break (0); goto cleanup; } - (void) memcpy (&bt->reserve_pub, reserve_pub, sizeof (bt->reserve_pub)); + bt->reserve_pub = *reserve_pub; if (NULL != rh_head) { rh_head->next = GNUNET_new (struct ReserveHistory); @@ -1238,7 +1232,7 @@ postgres_get_reserve_history (void *cls, result = NULL; { struct GNUNET_HashCode blind_ev; - struct GNUNET_CRYPTO_EddsaSignature reserve_sig; + struct TALER_ReserveSignature reserve_sig; struct CollectableBlindcoin *cbc; char *denom_pub_enc; char *denom_sig_enc; @@ -1280,20 +1274,23 @@ postgres_get_reserve_history (void *cls, goto cleanup; } cbc = GNUNET_new (struct CollectableBlindcoin); - cbc->sig = GNUNET_CRYPTO_rsa_signature_decode (denom_sig_enc, - denom_sig_enc_size); + cbc->sig.rsa_signature + = GNUNET_CRYPTO_rsa_signature_decode (denom_sig_enc, + denom_sig_enc_size); GNUNET_free (denom_sig_enc); denom_sig_enc = NULL; - cbc->denom_pub = GNUNET_CRYPTO_rsa_public_key_decode (denom_pub_enc, - denom_pub_enc_size); + cbc->denom_pub.rsa_public_key + = GNUNET_CRYPTO_rsa_public_key_decode (denom_pub_enc, + denom_pub_enc_size); GNUNET_free (denom_pub_enc); denom_pub_enc = NULL; - if ((NULL == cbc->sig) || (NULL == cbc->denom_pub)) + if ( (NULL == cbc->sig.rsa_signature) || + (NULL == cbc->denom_pub.rsa_public_key) ) { - if (NULL != cbc->sig) - GNUNET_CRYPTO_rsa_signature_free (cbc->sig); - if (NULL != cbc->denom_pub) - GNUNET_CRYPTO_rsa_public_key_free (cbc->denom_pub); + if (NULL != cbc->sig.rsa_signature) + GNUNET_CRYPTO_rsa_signature_free (cbc->sig.rsa_signature); + if (NULL != cbc->denom_pub.rsa_public_key) + GNUNET_CRYPTO_rsa_public_key_free (cbc->denom_pub.rsa_public_key); GNUNET_free (cbc); GNUNET_break (0); goto cleanup; @@ -1394,10 +1391,10 @@ postgres_insert_deposit (void *cls, ret = GNUNET_SYSERR; denom_pub_enc_size = - GNUNET_CRYPTO_rsa_public_key_encode (deposit->coin.denom_pub, + GNUNET_CRYPTO_rsa_public_key_encode (deposit->coin.denom_pub.rsa_public_key, &denom_pub_enc); denom_sig_enc_size = - GNUNET_CRYPTO_rsa_signature_encode (deposit->coin.denom_sig, + GNUNET_CRYPTO_rsa_signature_encode (deposit->coin.denom_sig.rsa_signature, &denom_sig_enc); json_wire_enc = json_dumps (deposit->wire, JSON_COMPACT); TALER_amount_hton (&amount_nbo, @@ -1450,7 +1447,7 @@ postgres_insert_deposit (void *cls, static int postgres_get_refresh_session (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, struct RefreshSession *refresh_session) { // FIXME: check logic! @@ -1526,7 +1523,7 @@ postgres_get_refresh_session (void *cls, static int postgres_create_refresh_session (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + const struct TALER_SessionPublicKey *session_pub, const struct RefreshSession *refresh_session) { // FIXME: actually store session data! @@ -1570,7 +1567,7 @@ postgres_create_refresh_session (void *cls, static int postgres_insert_refresh_melt (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session, + const struct TALER_SessionPublicKey *refresh_session, uint16_t oldcoin_index, const struct RefreshMelt *melt) { @@ -1580,7 +1577,7 @@ postgres_insert_refresh_melt (void *cls, size_t buf_size; PGresult *result; - buf_size = GNUNET_CRYPTO_rsa_public_key_encode (melt->coin.denom_pub, + buf_size = GNUNET_CRYPTO_rsa_public_key_encode (melt->coin.denom_pub.rsa_public_key, &buf); { struct TALER_DB_QueryParam params[] = { @@ -1620,7 +1617,7 @@ postgres_insert_refresh_melt (void *cls, static int postgres_get_refresh_melt (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session, + const struct TALER_SessionPublicKey *refresh_session, uint16_t oldcoin_index, struct RefreshMelt *melt) { @@ -1645,9 +1642,9 @@ postgres_get_refresh_melt (void *cls, static int postgres_insert_refresh_order (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + const struct TALER_SessionPublicKey *session_pub, uint16_t num_newcoins, - struct GNUNET_CRYPTO_rsa_PublicKey *const*denom_pubs) + const struct TALER_DenominationPublicKey *denom_pubs) { // FIXME: check logic: was written for just one COIN! uint16_t newcoin_index_nbo = htons (num_newcoins); @@ -1655,7 +1652,7 @@ postgres_insert_refresh_order (void *cls, size_t buf_size; PGresult *result; - buf_size = GNUNET_CRYPTO_rsa_public_key_encode (*denom_pubs, + buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pubs->rsa_public_key, &buf); { @@ -1701,9 +1698,9 @@ postgres_insert_refresh_order (void *cls, static int postgres_get_refresh_order (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + const struct TALER_SessionPublicKey *session_pub, uint16_t num_newcoins, - struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs) + struct TALER_DenominationPublicKey *denom_pubs) { // FIXME: check logic -- was written for just one coin! char *buf; @@ -1744,7 +1741,9 @@ postgres_get_refresh_order (void *cls, return GNUNET_SYSERR; } PQclear (result); - denom_pubs[0] = GNUNET_CRYPTO_rsa_public_key_decode (buf, buf_size); + denom_pubs->rsa_public_key + = GNUNET_CRYPTO_rsa_public_key_decode (buf, + buf_size); GNUNET_free (buf); return GNUNET_OK; } @@ -1767,7 +1766,7 @@ postgres_get_refresh_order (void *cls, static int postgres_insert_refresh_commit_coins (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int i, unsigned int num_newcoins, const struct RefreshCommitCoin *commit_coins) @@ -1780,9 +1779,9 @@ postgres_insert_refresh_commit_coins (void *cls, TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coins->coin_ev, commit_coins->coin_ev_size), TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo), TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo), - TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coins->refresh_link->coin_priv_enc, - commit_coins->refresh_link->blinding_key_enc_size + - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)), + TALER_DB_QUERY_PARAM_PTR_SIZED (commit_coins->refresh_link->coin_priv_enc, + commit_coins->refresh_link->blinding_key_enc_size + + sizeof (struct TALER_CoinSpendPrivateKey)), TALER_DB_QUERY_PARAM_END }; @@ -1825,7 +1824,7 @@ postgres_insert_refresh_commit_coins (void *cls, static int postgres_get_refresh_commit_coins (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int cnc_index, unsigned int newcoin_index, struct RefreshCommitCoin *cc) @@ -1873,7 +1872,7 @@ postgres_get_refresh_commit_coins (void *cls, return GNUNET_SYSERR; } PQclear (result); - if (rl_buf_size < sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)) + if (rl_buf_size < sizeof (struct TALER_CoinSpendPrivateKey)) { GNUNET_free (c_buf); GNUNET_free (rl_buf); @@ -1896,7 +1895,7 @@ postgres_get_refresh_commit_coins (void *cls, * @param cls the `struct PostgresClosure` with the plugin-specific state * @param session database connection to use * @param refresh_session_pub public key of the refresh session this - * commitment belongs with + * commitment belongs with -- FIXME: should not be needed! * @param i set index (1st dimension) * @param j coin index (2nd dimension), corresponds to melted (old) coins * @param commit_link link information to store @@ -1905,7 +1904,7 @@ postgres_get_refresh_commit_coins (void *cls, static int postgres_insert_refresh_commit_links (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int i, unsigned int j, const struct RefreshCommitLink *commit_link) @@ -1950,7 +1949,7 @@ postgres_insert_refresh_commit_links (void *cls, * @param cls the `struct PostgresClosure` with the plugin-specific state * @param session database connection to use * @param refresh_session_pub public key of the refresh session this - * commitment belongs with + * commitment belongs with -- FIXME: should not be needed! * @param i set index (1st dimension) * @param num_links size of the @a commit_link array * @param links[OUT] array of link information to return @@ -1961,7 +1960,7 @@ postgres_insert_refresh_commit_links (void *cls, static int postgres_get_refresh_commit_links (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int i, unsigned int num_links, struct RefreshCommitLink *links) @@ -2026,9 +2025,9 @@ postgres_get_refresh_commit_links (void *cls, static int postgres_insert_refresh_collectable (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + const struct TALER_SessionPublicKey *session_pub, uint16_t newcoin_index, - const struct GNUNET_CRYPTO_rsa_Signature *ev_sig) + const struct TALER_DenominationSignature *ev_sig) { // FIXME: check logic! uint16_t newcoin_index_nbo = htons (newcoin_index); @@ -2036,7 +2035,7 @@ postgres_insert_refresh_collectable (void *cls, size_t buf_size; PGresult *result; - buf_size = GNUNET_CRYPTO_rsa_signature_encode (ev_sig, + buf_size = GNUNET_CRYPTO_rsa_signature_encode (ev_sig->rsa_signature, &buf); { struct TALER_DB_QueryParam params[] = { @@ -2073,7 +2072,7 @@ postgres_insert_refresh_collectable (void *cls, static struct LinkDataList * postgres_get_link_data_list (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub) + const struct TALER_CoinSpendPublicKey *coin_pub) { // FIXME: check logic! struct LinkDataList *ldl; @@ -2146,10 +2145,12 @@ postgres_get_link_data_list (void *cls, ld_buf, ld_buf_size); - sig = GNUNET_CRYPTO_rsa_signature_decode (sig_buf, - sig_buf_size); - denom_pub = GNUNET_CRYPTO_rsa_public_key_decode (pk_buf, - pk_buf_size); + sig + = GNUNET_CRYPTO_rsa_signature_decode (sig_buf, + sig_buf_size); + denom_pub + = GNUNET_CRYPTO_rsa_public_key_decode (pk_buf, + pk_buf_size); GNUNET_free (pk_buf); GNUNET_free (sig_buf); GNUNET_free (ld_buf); @@ -2170,8 +2171,8 @@ postgres_get_link_data_list (void *cls, pos = GNUNET_new (struct LinkDataList); pos->next = ldl; pos->link_data_enc = link_enc; - pos->denom_pub = denom_pub; - pos->ev_sig = sig; + pos->denom_pub.rsa_public_key = denom_pub; + pos->ev_sig.rsa_signature = sig; ldl = pos; } return ldl; @@ -2196,8 +2197,8 @@ postgres_get_link_data_list (void *cls, static int postgres_get_transfer (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, - struct GNUNET_CRYPTO_EcdsaPublicKey *transfer_pub, + const struct TALER_CoinSpendPublicKey *coin_pub, + struct TALER_TransferPublicKey *transfer_pub, struct TALER_EncryptedLinkSecret *shared_secret_enc) { // FIXME: check logic! @@ -2260,7 +2261,7 @@ postgres_get_transfer (void *cls, static struct TALER_MINT_DB_TransactionList * postgres_get_coin_transactions (void *cls, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub) + const struct TALER_CoinSpendPublicKey *coin_pub) { // FIXME: check logic! GNUNET_break (0); // FIXME: implement! diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index 43b226e64..039e74ff7 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -130,7 +130,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, } mks = TALER_MINT_key_state_acquire (); dki = TALER_MINT_get_denom_key (mks, - deposit->coin.denom_pub); + &deposit->coin.denom_pub); TALER_amount_ntoh (&value, &dki->issue.value); TALER_MINT_key_state_release (mks); @@ -211,7 +211,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, */ int TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub) + const struct TALER_ReservePublicKey *reserve_pub) { struct TALER_MINTDB_Session *session; struct ReserveHistory *rh; @@ -255,11 +255,11 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, */ int TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *reserve, - const struct GNUNET_CRYPTO_rsa_PublicKey *denomination_pub, + const struct TALER_ReservePublicKey *reserve, + const struct TALER_DenominationPublicKey *denomination_pub, const char *blinded_msg, size_t blinded_msg_len, - const struct GNUNET_CRYPTO_EddsaSignature *signature) + const struct TALER_ReserveSignature *signature) { struct TALER_MINTDB_Session *session; struct ReserveHistory *rh; @@ -303,8 +303,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, { res = TALER_MINT_reply_withdraw_sign_success (connection, &collectable); - GNUNET_CRYPTO_rsa_signature_free (collectable.sig); - GNUNET_CRYPTO_rsa_public_key_free (collectable.denom_pub); + GNUNET_CRYPTO_rsa_signature_free (collectable.sig.rsa_signature); + GNUNET_CRYPTO_rsa_public_key_free (collectable.denom_pub.rsa_public_key); return res; } GNUNET_assert (GNUNET_NO == res); @@ -387,7 +387,7 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, break; case TALER_MINT_DB_RO_WITHDRAW_COIN: tdki = TALER_MINT_get_denom_key (key_state, - pos->details.withdraw->denom_pub); + &pos->details.withdraw->denom_pub); TALER_amount_ntoh (&value, &tdki->issue.value); if (0 == (res & 2)) @@ -428,7 +428,7 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, rh); /* Balance is good, sign the coin! */ - sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv, + sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, blinded_msg, blinded_msg_len); TALER_MINT_key_state_release (key_state); @@ -440,8 +440,9 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, return TALER_MINT_reply_internal_error (connection, "Internal error"); } - collectable.sig = sig; - collectable.denom_pub = (struct GNUNET_CRYPTO_rsa_PublicKey *) denomination_pub; + /* FIXME: this signature is still blinded, bad name... */ + collectable.sig.rsa_signature = sig; + collectable.denom_pub = *denomination_pub; collectable.reserve_pub = *reserve; GNUNET_CRYPTO_hash (blinded_msg, blinded_msg_len, @@ -494,7 +495,7 @@ refresh_accept_melts (struct MHD_Connection *connection, struct TALER_MINTDB_Session *session, const struct MintKeyState *key_state, const struct GNUNET_HashCode *melt_hash, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + const struct TALER_SessionPublicKey *session_pub, const struct TALER_CoinPublicInfo *coin_public_info, const struct MeltDetails *coin_details, uint16_t oldcoin_index) @@ -508,7 +509,7 @@ refresh_accept_melts (struct MHD_Connection *connection, int res; dki = &TALER_MINT_get_denom_key (key_state, - coin_public_info->denom_pub)->issue; + &coin_public_info->denom_pub)->issue; if (NULL == dki) return (MHD_YES == @@ -607,10 +608,10 @@ refresh_accept_melts (struct MHD_Connection *connection, int TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, const struct GNUNET_HashCode *melt_hash, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, - const struct GNUNET_CRYPTO_EddsaSignature *client_signature, + const struct TALER_SessionPublicKey *refresh_session_pub, + const struct TALER_SessionSignature *client_signature, unsigned int num_new_denoms, - struct GNUNET_CRYPTO_rsa_PublicKey *const*denom_pubs, + const struct TALER_DenominationPublicKey *denom_pubs, unsigned int coin_count, const struct TALER_CoinPublicInfo *coin_public_infos, const struct MeltDetails *coin_melt_details, @@ -773,7 +774,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, * @param transfer_privs private transfer keys * @param melts array of melted coins * @param num_newcoins number of newcoins being generated - * @param denom_pub array of @a num_newcoins keys for the new coins + * @param denom_pubs array of @a num_newcoins keys for the new coins * @return #GNUNET_OK if the committment was honest, * #GNUNET_NO if there was a problem and we generated an error message * #GNUNET_SYSERR if we could not even generate an error message @@ -781,13 +782,13 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, static int check_commitment (struct MHD_Connection *connection, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session, + const struct TALER_SessionPublicKey *refresh_session, unsigned int off, unsigned int num_oldcoins, - const struct GNUNET_CRYPTO_EcdsaPrivateKey *transfer_privs, + const struct TALER_TransferPrivateKey *transfer_privs, const struct RefreshMelt *melts, unsigned int num_newcoins, - struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs) + const struct TALER_DenominationPublicKey *denom_pubs) { unsigned int j; struct TALER_LinkSecret last_shared_secret; @@ -817,14 +818,14 @@ check_commitment (struct MHD_Connection *connection, { struct TALER_TransferSecret transfer_secret; struct TALER_LinkSecret shared_secret; - struct GNUNET_CRYPTO_EcdsaPublicKey transfer_pub_check; + struct TALER_TransferPublicKey transfer_pub_check; - GNUNET_CRYPTO_ecdsa_key_get_public (&transfer_privs[j], - &transfer_pub_check); + GNUNET_CRYPTO_ecdsa_key_get_public (&transfer_privs[j].ecdsa_priv, + &transfer_pub_check.ecdsa_pub); if (0 != memcmp (&transfer_pub_check, &commit_links[j].transfer_pub, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) + sizeof (struct TALER_TransferPublicKey))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "transfer keys do not match\n"); @@ -840,9 +841,9 @@ check_commitment (struct MHD_Connection *connection, /* We're converting key types here, which is not very nice * but necessary and harmless (keys will be thrown away later). */ - GNUNET_CRYPTO_ecdsa_public_to_ecdhe (&melts[j].coin.coin_pub, + GNUNET_CRYPTO_ecdsa_public_to_ecdhe (&melts[j].coin.coin_pub.ecdsa_pub, &coin_ecdhe); - GNUNET_CRYPTO_ecdsa_private_to_ecdhe (&transfer_privs[j], + GNUNET_CRYPTO_ecdsa_private_to_ecdhe (&transfer_privs[j].ecdsa_priv, &transfer_ecdhe); if (GNUNET_OK != GNUNET_CRYPTO_ecc_ecdh (&transfer_ecdhe, @@ -915,7 +916,7 @@ check_commitment (struct MHD_Connection *connection, for (j = 0; j < num_newcoins; j++) { struct TALER_RefreshLinkDecrypted *link_data; - struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; + struct TALER_CoinSpendPublicKey coin_pub; struct GNUNET_HashCode h_msg; char *buf; size_t buf_len; @@ -931,15 +932,15 @@ check_commitment (struct MHD_Connection *connection, ? GNUNET_NO : GNUNET_SYSERR; } - GNUNET_CRYPTO_ecdsa_key_get_public (&link_data->coin_priv, - &coin_pub); + GNUNET_CRYPTO_ecdsa_key_get_public (&link_data->coin_priv.ecdsa_priv, + &coin_pub.ecdsa_pub); GNUNET_CRYPTO_hash (&coin_pub, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), + sizeof (struct TALER_CoinSpendPublicKey), &h_msg); if (0 == (buf_len = GNUNET_CRYPTO_rsa_blind (&h_msg, - link_data->blinding_key, - denom_pubs[j], + link_data->blinding_key.rsa_blinding_key, + denom_pubs[j].rsa_public_key, &buf))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -989,42 +990,45 @@ check_commitment (struct MHD_Connection *connection, * @param coin_off number of the coin * @return NULL on error, otherwise signature over the coin */ -static struct GNUNET_CRYPTO_rsa_Signature * +static struct TALER_DenominationSignature refresh_mint_coin (struct MHD_Connection *connection, struct TALER_MINTDB_Session *session, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session, + const struct TALER_SessionPublicKey *refresh_session, struct MintKeyState *key_state, - const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub, + const struct TALER_DenominationPublicKey *denom_pub, const struct RefreshCommitCoin *commit_coin, unsigned int coin_off) { struct TALER_MINT_DenomKeyIssuePriv *dki; - struct GNUNET_CRYPTO_rsa_Signature *ev_sig; + struct TALER_DenominationSignature ev_sig; - dki = TALER_MINT_get_denom_key (key_state, denom_pub); + dki = TALER_MINT_get_denom_key (key_state, + denom_pub); if (NULL == dki) { GNUNET_break (0); - return NULL; + ev_sig.rsa_signature = NULL; + return ev_sig; } - ev_sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv, - commit_coin->coin_ev, - commit_coin->coin_ev_size); - if (NULL == ev_sig) + ev_sig.rsa_signature + = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, + commit_coin->coin_ev, + commit_coin->coin_ev_size); + if (NULL == ev_sig.rsa_signature) { GNUNET_break (0); - return NULL; + return ev_sig; } if (GNUNET_OK != plugin->insert_refresh_collectable (plugin->cls, session, refresh_session, coin_off, - ev_sig)) + &ev_sig)) { GNUNET_break (0); - GNUNET_CRYPTO_rsa_signature_free (ev_sig); - return NULL; + GNUNET_CRYPTO_rsa_signature_free (ev_sig.rsa_signature); + ev_sig.rsa_signature = NULL; } return ev_sig; } @@ -1046,18 +1050,18 @@ refresh_mint_coin (struct MHD_Connection *connection, */ int TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int kappa, unsigned int num_oldcoins, - struct GNUNET_CRYPTO_EcdsaPrivateKey *const*transfer_privs) + struct TALER_TransferPrivateKey **transfer_privs) { int res; struct TALER_MINTDB_Session *session; struct RefreshSession refresh_session; struct MintKeyState *key_state; struct RefreshMelt *melts; - struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs; - struct GNUNET_CRYPTO_rsa_Signature **ev_sigs; + struct TALER_DenominationPublicKey *denom_pubs; + struct TALER_DenominationSignature *ev_sigs; struct RefreshCommitCoin *commit_coins; unsigned int i; unsigned int j; @@ -1102,7 +1106,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, } } denom_pubs = GNUNET_malloc (refresh_session.num_newcoins * - sizeof (struct GNUNET_CRYPTO_rsa_PublicKey *)); + sizeof (struct TALER_DenominationPublicKey)); if (GNUNET_OK != plugin->get_refresh_order (plugin->cls, session, @@ -1135,7 +1139,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, denom_pubs))) { for (j=0;j<refresh_session.num_newcoins;j++) - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); GNUNET_free (melts); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -1150,7 +1154,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, { GNUNET_break (0); for (j=0;j<refresh_session.num_newcoins;j++) - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); return TALER_MINT_reply_internal_db_error (connection); } @@ -1168,12 +1172,12 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, GNUNET_break (0); GNUNET_free (commit_coins); for (j=0;j<refresh_session.num_newcoins;j++) - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); return TALER_MINT_reply_internal_db_error (connection); } ev_sigs = GNUNET_malloc (refresh_session.num_newcoins * - sizeof (struct GNUNET_CRYPTO_rsa_Signature *)); + sizeof (struct TALER_DenominationSignature)); key_state = TALER_MINT_key_state_acquire (); for (j=0;j<refresh_session.num_newcoins;j++) { @@ -1181,17 +1185,17 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, session, refresh_session_pub, key_state, - denom_pubs[j], + &denom_pubs[j], &commit_coins[j], j); - if (NULL == ev_sigs[j]) + if (NULL == ev_sigs[j].rsa_signature) { TALER_MINT_key_state_release (key_state); for (i=0;i<j;i++) - GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i]); + GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature); GNUNET_free (ev_sigs); for (j=0;j<refresh_session.num_newcoins;j++) - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); GNUNET_free (commit_coins); return TALER_MINT_reply_internal_db_error (connection); @@ -1199,7 +1203,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, } TALER_MINT_key_state_release (key_state); for (j=0;j<refresh_session.num_newcoins;j++) - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); GNUNET_free (commit_coins); @@ -1209,7 +1213,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, { LOG_WARNING ("/refresh/reveal transaction commit failed\n"); for (i=0;i<refresh_session.num_newcoins;i++) - GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i]); + GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature); GNUNET_free (ev_sigs); return TALER_MINT_reply_commit_error (connection); } @@ -1218,7 +1222,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, refresh_session.num_newcoins, ev_sigs); for (i=0;i<refresh_session.num_newcoins;i++) - GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i]); + GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature); GNUNET_free (ev_sigs); return res; } @@ -1235,11 +1239,11 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, */ int TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub) + const struct TALER_CoinSpendPublicKey *coin_pub) { int res; struct TALER_MINTDB_Session *session; - struct GNUNET_CRYPTO_EcdsaPublicKey transfer_pub; + struct TALER_TransferPublicKey transfer_pub; struct TALER_EncryptedLinkSecret shared_secret_enc; struct LinkDataList *ldl; diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h index 52e86f898..fd420bd9b 100644 --- a/src/mint/taler-mint-httpd_db.h +++ b/src/mint/taler-mint-httpd_db.h @@ -53,7 +53,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, */ int TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub); + const struct TALER_ReservePublicKey *reserve_pub); /** @@ -72,11 +72,11 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, */ int TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *reserve, - const struct GNUNET_CRYPTO_rsa_PublicKey *denomination_pub, + const struct TALER_ReservePublicKey *reserve, + const struct TALER_DenominationPublicKey *denomination_pub, const char *blinded_msg, size_t blinded_msg_len, - const struct GNUNET_CRYPTO_EddsaSignature *signature); + const struct TALER_ReserveSignature *signature); /** @@ -88,7 +88,7 @@ struct MeltDetails * Signature allowing the melt (using * a `struct RefreshMeltConfirmSignRequestBody`) to sign over. */ - struct GNUNET_CRYPTO_EcdsaSignature melt_sig; + struct TALER_CoinSpendSignature melt_sig; /** * How much of the coin's value did the client allow to be melted? @@ -129,10 +129,10 @@ struct MeltDetails int TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, const struct GNUNET_HashCode *melt_hash, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, - const struct GNUNET_CRYPTO_EddsaSignature *client_signature, + const struct TALER_SessionPublicKey *refresh_session_pub, + const struct TALER_SessionSignature *client_signature, unsigned int num_new_denoms, - struct GNUNET_CRYPTO_rsa_PublicKey *const*denom_pubs, + const struct TALER_DenominationPublicKey *denom_pubs, unsigned int coin_count, const struct TALER_CoinPublicInfo *coin_public_infos, const struct MeltDetails *coin_melt_details, @@ -157,10 +157,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, */ int TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int kappa, unsigned int num_oldcoins, - struct GNUNET_CRYPTO_EcdsaPrivateKey *const*transfer_privs); + struct TALER_TransferPrivateKey **transfer_privs); /** @@ -174,7 +174,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection, */ int TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub); + const struct TALER_CoinSpendPublicKey *coin_pub); #endif diff --git a/src/mint/taler-mint-httpd_deposit.c b/src/mint/taler-mint-httpd_deposit.c index 810d1c328..bf8121037 100644 --- a/src/mint/taler-mint-httpd_deposit.c +++ b/src/mint/taler-mint-httpd_deposit.c @@ -72,8 +72,8 @@ verify_and_execute_deposit (struct MHD_Connection *connection, if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_WALLET_DEPOSIT, &dr.purpose, - &deposit->csig, - &deposit->coin.coin_pub)) + &deposit->csig.ecdsa_signature, + &deposit->coin.coin_pub.ecdsa_pub)) { LOG_WARNING ("Invalid signature on /deposit request\n"); return TALER_MINT_reply_arg_invalid (connection, @@ -82,7 +82,7 @@ verify_and_execute_deposit (struct MHD_Connection *connection, /* check denomination exists and is valid */ key_state = TALER_MINT_key_state_acquire (); dki = TALER_MINT_get_denom_key (key_state, - deposit->coin.denom_pub); + &deposit->coin.denom_pub); if (NULL == dki) { TALER_MINT_key_state_release (key_state); diff --git a/src/mint/taler-mint-httpd_keystate.c b/src/mint/taler-mint-httpd_keystate.c index ca802e2d3..b795323ee 100644 --- a/src/mint/taler-mint-httpd_keystate.c +++ b/src/mint/taler-mint-httpd_keystate.c @@ -111,7 +111,7 @@ static int reload_pipe[2]; * @return a JSON object describing the denomination key isue (public part) */ static json_t * -denom_key_issue_to_json (struct GNUNET_CRYPTO_rsa_PublicKey *pk, +denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, const struct TALER_MINT_DenomKeyIssue *dki) { struct TALER_Amount value; @@ -139,7 +139,7 @@ denom_key_issue_to_json (struct GNUNET_CRYPTO_rsa_PublicKey *pk, "stamp_expire_deposit", TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend)), "denom_pub", - TALER_JSON_from_rsa_public_key (pk), + TALER_JSON_from_rsa_public_key (pk->rsa_public_key), "value", TALER_JSON_from_amount (&value), "fee_withdraw", @@ -217,7 +217,7 @@ reload_keys_denom_iter (void *cls, return GNUNET_OK; } - GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub, + GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, &denom_key_hash); d2 = GNUNET_memdup (dki, sizeof (struct TALER_MINT_DenomKeyIssuePriv)); @@ -234,7 +234,7 @@ reload_keys_denom_iter (void *cls, return GNUNET_OK; } json_array_append_new (ctx->denom_keys_array, - denom_key_issue_to_json (dki->denom_pub, + denom_key_issue_to_json (&dki->denom_pub, &dki->issue)); return GNUNET_OK; } @@ -435,11 +435,11 @@ TALER_MINT_key_state_acquire (void) */ struct TALER_MINT_DenomKeyIssuePriv * TALER_MINT_get_denom_key (const struct MintKeyState *key_state, - const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub) + const struct TALER_DenominationPublicKey *denom_pub) { struct GNUNET_HashCode hc; - GNUNET_CRYPTO_rsa_public_key_hash (denom_pub, + GNUNET_CRYPTO_rsa_public_key_hash (denom_pub->rsa_public_key, &hc); return GNUNET_CONTAINER_multihashmap_get (key_state->denomkey_map, &hc); @@ -564,16 +564,16 @@ read_again: */ void TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_EddsaSignature *sig) + struct TALER_MintSignature *sig) { struct MintKeyState *key_state; key_state = TALER_MINT_key_state_acquire (); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv, + GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv.eddsa_priv, purpose, - sig)); + &sig->eddsa_signature)); TALER_MINT_key_state_release (key_state); } diff --git a/src/mint/taler-mint-httpd_keystate.h b/src/mint/taler-mint-httpd_keystate.h index 4bb468ea0..faccc8f00 100644 --- a/src/mint/taler-mint-httpd_keystate.h +++ b/src/mint/taler-mint-httpd_keystate.h @@ -67,7 +67,7 @@ TALER_MINT_key_state_release (struct MintKeyState *key_state); */ struct TALER_MINT_DenomKeyIssuePriv * TALER_MINT_get_denom_key (const struct MintKeyState *key_state, - const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub); + const struct TALER_DenominationPublicKey *denom_pub); /** @@ -90,7 +90,7 @@ TALER_MINT_key_reload_loop (void); */ void TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct GNUNET_CRYPTO_EddsaSignature *sig); + struct TALER_MintSignature *sig); /** diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index d6bf3c428..8a024dff2 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -58,14 +58,14 @@ */ static int handle_refresh_melt_binary (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int num_new_denoms, - struct GNUNET_CRYPTO_rsa_PublicKey *const*denom_pubs, + const struct TALER_DenominationPublicKey *denom_pubs, unsigned int coin_count, struct TALER_CoinPublicInfo *coin_public_infos, const struct MeltDetails *coin_melt_details, const struct GNUNET_HashCode *commit_hash, - const struct GNUNET_CRYPTO_EddsaSignature *commit_client_sig, + const struct TALER_SessionSignature *commit_client_sig, unsigned int kappa, struct RefreshCommitCoin *const* commit_coin, struct RefreshCommitLink *const* commit_link) @@ -92,7 +92,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, /* FIXME: also hash session public key here!? #3708 */ for (i = 0; i < num_new_denoms; i++) { - buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pubs[i], + buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pubs[i].rsa_public_key, &buf); GNUNET_CRYPTO_hash_context_read (hash_context, buf, @@ -113,10 +113,11 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, TALER_amount_hton (&body.amount_with_fee, &coin_melt_details->melt_amount_with_fee); - if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_REFRESH_MELT_SESSION, - &body.purpose, - commit_client_sig, - refresh_session_pub)) + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_REFRESH_MELT_SESSION, + &body.purpose, + &commit_client_sig->eddsa_signature, + &refresh_session_pub->eddsa_pub)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "signature invalid (did not verify)\n"); @@ -133,7 +134,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, for (i=0;i<num_new_denoms;i++) { dki = &TALER_MINT_get_denom_key (key_state, - denom_pubs[i])->issue; + &denom_pubs[i])->issue; TALER_amount_ntoh (&value, &dki->value); TALER_amount_ntoh (&fee_withdraw, @@ -161,7 +162,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, /* calculate contribution of the i-th melt by subtracting the fee; add the rest to the total_melt value */ dki = &TALER_MINT_get_denom_key (key_state, - coin_public_infos[i].denom_pub)->issue; + &coin_public_infos[i].denom_pub)->issue; TALER_amount_ntoh (&fee_melt, &dki->fee_refresh); if (GNUNET_OK != @@ -228,14 +229,14 @@ get_coin_public_info (struct MHD_Connection *connection, struct MeltDetails *r_melt_detail) { int ret; - struct GNUNET_CRYPTO_EcdsaSignature melt_sig; - struct GNUNET_CRYPTO_rsa_Signature *sig; - struct GNUNET_CRYPTO_rsa_PublicKey *pk; + struct TALER_CoinSpendSignature melt_sig; + struct TALER_DenominationSignature sig; + struct TALER_DenominationPublicKey pk; struct TALER_Amount amount; struct GNUNET_MINT_ParseFieldSpec spec[] = { TALER_MINT_PARSE_FIXED ("coin_pub", &r_public_info->coin_pub), - TALER_MINT_PARSE_RSA_SIGNATURE ("denom_sig", &sig), - TALER_MINT_PARSE_RSA_PUBLIC_KEY ("denom_pub", &pk), + TALER_MINT_PARSE_RSA_SIGNATURE ("denom_sig", &sig.rsa_signature), + TALER_MINT_PARSE_RSA_PUBLIC_KEY ("denom_pub", &pk.rsa_public_key), TALER_MINT_PARSE_FIXED ("confirm_sig", &melt_sig), TALER_MINT_PARSE_AMOUNT ("value_with_fee", &amount), TALER_MINT_PARSE_END @@ -253,8 +254,8 @@ get_coin_public_info (struct MHD_Connection *connection, TALER_test_coin_valid (r_public_info)) { TALER_MINT_release_parsed_data (spec); - r_public_info->denom_sig = NULL; - r_public_info->denom_pub = NULL; + r_public_info->denom_sig.rsa_signature = NULL; + r_public_info->denom_pub.rsa_public_key = NULL; return (MHD_YES == TALER_MINT_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, @@ -304,8 +305,8 @@ verify_coin_public_info (struct MHD_Connection *connection, if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_REFRESH_MELT_COIN, &body.purpose, - &r_melt_detail->melt_sig, - &r_public_info->coin_pub)) + &r_melt_detail->melt_sig.ecdsa_signature, + &r_public_info->coin_pub.ecdsa_pub)) { if (MHD_YES != TALER_MINT_reply_json_pack (connection, @@ -317,7 +318,7 @@ verify_coin_public_info (struct MHD_Connection *connection, } key_state = TALER_MINT_key_state_acquire (); dki = TALER_MINT_get_denom_key (key_state, - r_public_info->denom_pub); + &r_public_info->denom_pub); if (NULL == dki) { TALER_MINT_key_state_release (key_state); @@ -420,7 +421,7 @@ free_commit_links (struct RefreshCommitLink **commit_link, */ static int handle_refresh_melt_json (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, const json_t *new_denoms, const json_t *melt_coins, const json_t *melt_sig_json, @@ -437,7 +438,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, int res; unsigned int i; unsigned int j; - struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs; + struct TALER_DenominationPublicKey *denom_pubs; unsigned int num_new_denoms; struct TALER_CoinPublicInfo *coin_public_infos; struct MeltDetails *coin_melt_details; @@ -446,20 +447,22 @@ handle_refresh_melt_json (struct MHD_Connection *connection, struct GNUNET_HashContext *hash_context; struct RefreshCommitCoin *commit_coin[kappa]; struct RefreshCommitLink *commit_link[kappa]; - const struct GNUNET_CRYPTO_EddsaSignature commit_client_sig; + const struct TALER_SessionSignature commit_client_sig; num_new_denoms = json_array_size (new_denoms); denom_pubs = GNUNET_malloc (num_new_denoms * - sizeof (struct GNUNET_CRYPTO_rsa_PublicKey *)); + sizeof (struct TALER_DenominationPublicKey)); for (i=0;i<num_new_denoms;i++) { - res = GNUNET_MINT_parse_navigate_json (connection, new_denoms, + res = GNUNET_MINT_parse_navigate_json (connection, + new_denoms, JNAV_INDEX, (int) i, - JNAV_RET_RSA_PUBLIC_KEY, &denom_pubs[i]); + JNAV_RET_RSA_PUBLIC_KEY, + &denom_pubs[i].rsa_public_key); if (GNUNET_OK != res) { for (j=0;j<i;j++) - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); return res; } @@ -483,12 +486,12 @@ handle_refresh_melt_json (struct MHD_Connection *connection, { for (j=0;j<i;j++) { - GNUNET_CRYPTO_rsa_public_key_free (coin_public_infos[j].denom_pub); - GNUNET_CRYPTO_rsa_signature_free (coin_public_infos[j].denom_sig); + GNUNET_CRYPTO_rsa_public_key_free (coin_public_infos[j].denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_signature_free (coin_public_infos[j].denom_sig.rsa_signature); } GNUNET_free (coin_public_infos); for (j=0;j<num_new_denoms;j++) - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (coin_melt_details); GNUNET_free (denom_pubs); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -499,16 +502,16 @@ handle_refresh_melt_json (struct MHD_Connection *connection, { if (0 == memcmp (&coin_public_infos[i].coin_pub, &coin_public_infos[j].coin_pub, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) + sizeof (struct TALER_CoinSpendPublicKey))) { for (j=0;j<i;j++) { - GNUNET_CRYPTO_rsa_public_key_free (coin_public_infos[j].denom_pub); - GNUNET_CRYPTO_rsa_signature_free (coin_public_infos[j].denom_sig); + GNUNET_CRYPTO_rsa_public_key_free (coin_public_infos[j].denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_signature_free (coin_public_infos[j].denom_sig.rsa_signature); } GNUNET_free (coin_public_infos); for (j=0;j<num_new_denoms;j++) - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (coin_melt_details); GNUNET_free (denom_pubs); return TALER_MINT_reply_external_error (connection, @@ -583,7 +586,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, JNAV_INDEX, (int) j, JNAV_RET_DATA, &commit_link[i][j].transfer_pub, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); + sizeof (struct TALER_TransferPublicKey)); if (GNUNET_OK != res) { @@ -596,7 +599,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, GNUNET_CRYPTO_hash_context_read (hash_context, &commit_link[i][j].transfer_pub, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); + sizeof (struct TALER_TransferPublicKey)); res = GNUNET_MINT_parse_navigate_json (connection, secret_encs, @@ -629,7 +632,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, "sig", JNAV_RET_DATA, &commit_client_sig, - sizeof (struct GNUNET_CRYPTO_EddsaSignature)); + sizeof (struct TALER_SessionSignature)); if (GNUNET_OK != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -667,14 +670,12 @@ handle_refresh_melt_json (struct MHD_Connection *connection, free_commit_links (commit_link, kappa, num_oldcoins); for (j=0;j<coin_count;j++) { - GNUNET_CRYPTO_rsa_public_key_free (coin_public_infos[j].denom_pub); - GNUNET_CRYPTO_rsa_signature_free (coin_public_infos[j].denom_sig); + GNUNET_CRYPTO_rsa_public_key_free (coin_public_infos[j].denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_signature_free (coin_public_infos[j].denom_sig.rsa_signature); } GNUNET_free (coin_public_infos); for (j=0;j<num_new_denoms;j++) - { - GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j]); - } + GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (coin_melt_details); GNUNET_free (denom_pubs); return res; @@ -714,7 +715,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, unsigned int num_oldcoins; unsigned int num_newcoins; json_t *coin_detail; - struct GNUNET_CRYPTO_EddsaPublicKey refresh_session_pub; + struct TALER_SessionPublicKey refresh_session_pub; int res; struct GNUNET_MINT_ParseFieldSpec spec[] = { TALER_MINT_PARSE_FIXED ("session_pub", &refresh_session_pub), @@ -819,19 +820,19 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, */ static int handle_refresh_reveal_json (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int kappa, unsigned int num_oldcoins, const json_t *tp_json) { - struct GNUNET_CRYPTO_EcdsaPrivateKey *transfer_privs[kappa - 1]; + struct TALER_TransferPrivateKey *transfer_privs[kappa - 1]; unsigned int i; unsigned int j; int res; for (i = 0; i < kappa - 1; i++) transfer_privs[i] = GNUNET_malloc (num_oldcoins * - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)); + sizeof (struct TALER_TransferPrivateKey)); res = GNUNET_OK; for (i = 0; i < kappa - 1; i++) { @@ -847,7 +848,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, JNAV_INDEX, (int) j, JNAV_RET_DATA, &transfer_privs[i][j], - sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)); + sizeof (struct TALER_TransferPrivateKey)); } } if (GNUNET_OK != res) @@ -887,7 +888,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, const char *upload_data, size_t *upload_data_size) { - struct GNUNET_CRYPTO_EddsaPublicKey refresh_session_pub; + struct TALER_SessionPublicKey refresh_session_pub; int res; unsigned int kappa; unsigned int num_oldcoins; @@ -966,13 +967,13 @@ TALER_MINT_handler_refresh_link (struct RequestHandler *rh, const char *upload_data, size_t *upload_data_size) { - struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; + struct TALER_CoinSpendPublicKey coin_pub; int res; res = TALER_MINT_mhd_request_arg_data (connection, "coin_pub", &coin_pub, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); + sizeof (struct TALER_CoinSpendPublicKey)); if (GNUNET_SYSERR == res) return MHD_NO; if (GNUNET_OK != res) diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index 681b2b922..4f124a15c 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -282,15 +282,15 @@ TALER_MINT_reply_invalid_json (struct MHD_Connection *connection) */ int TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, + const struct TALER_CoinSpendPublicKey *coin_pub, const struct GNUNET_HashCode *h_wire, const struct GNUNET_HashCode *h_contract, uint64_t transaction_id, - const struct GNUNET_CRYPTO_EddsaPublicKey *merchant, + const struct TALER_MerchantPublicKey *merchant, const struct TALER_Amount *amount) { struct TALER_DepositConfirmation dc; - struct GNUNET_CRYPTO_EddsaSignature sig; + struct TALER_MintSignature sig; json_t *sig_json; int ret; @@ -305,7 +305,8 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, dc.merchant = *merchant; TALER_MINT_keys_sign (&dc.purpose, &sig); - sig_json = TALER_JSON_from_eddsa_sig (&dc.purpose, &sig); + sig_json = TALER_JSON_from_eddsa_sig (&dc.purpose, + &sig.eddsa_signature); ret = TALER_MINT_reply_json_pack (connection, MHD_HTTP_OK, "{s:s, s:o}", @@ -351,7 +352,7 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl) &deposit->amount_with_fee); dr.coin_pub = deposit->coin.coin_pub; transaction = TALER_JSON_from_ecdsa_sig (&dr.purpose, - &deposit->csig); + &deposit->csig.ecdsa_signature); break; } case TALER_MINT_DB_TT_REFRESH_MELT: @@ -368,7 +369,7 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl) &melt->amount_with_fee); ms.coin_pub = melt->coin.coin_pub; transaction = TALER_JSON_from_ecdsa_sig (&ms.purpose, - &melt->coin_sig); + &melt->coin_sig.ecdsa_signature); } break; case TALER_MINT_DB_TT_LOCK: @@ -480,7 +481,7 @@ compile_reserve_history (const struct ReserveHistory *rh, case TALER_MINT_DB_RO_WITHDRAW_COIN: dki = TALER_MINT_get_denom_key (key_state, - pos->details.withdraw->denom_pub); + &pos->details.withdraw->denom_pub); TALER_amount_ntoh (&value, &dki->issue.value); if (0 == ret) @@ -499,12 +500,12 @@ compile_reserve_history (const struct ReserveHistory *rh, wr.purpose.purpose = htonl (TALER_SIGNATURE_WITHDRAW); wr.purpose.size = htonl (sizeof (struct TALER_WithdrawRequest)); wr.reserve_pub = pos->details.withdraw->reserve_pub; - GNUNET_CRYPTO_rsa_public_key_hash (pos->details.withdraw->denom_pub, + GNUNET_CRYPTO_rsa_public_key_hash (pos->details.withdraw->denom_pub.rsa_public_key, &wr.h_denomination_pub); wr.h_coin_envelope = pos->details.withdraw->h_coin_envelope; transaction = TALER_JSON_from_eddsa_sig (&wr.purpose, - &pos->details.withdraw->reserve_sig); + &pos->details.withdraw->reserve_sig.eddsa_signature); json_array_append_new (json_history, json_pack ("{s:s, s:o, s:o}", @@ -613,7 +614,7 @@ TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection, json_t *sig_json; int ret; - sig_json = TALER_JSON_from_rsa_signature (collectable->sig); + sig_json = TALER_JSON_from_rsa_signature (collectable->sig.rsa_signature); ret = TALER_MINT_reply_json_pack (connection, MHD_HTTP_OK, "{s:o}", @@ -640,7 +641,7 @@ TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection, */ int TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, + const struct TALER_CoinSpendPublicKey *coin_pub, struct TALER_Amount coin_value, struct TALER_MINT_DB_TransactionList *tl, struct TALER_Amount requested, @@ -654,7 +655,7 @@ TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connect "{s:s, s:o, s:o, s:o, s:o, s:o}", "error", "insufficient funds", "coin-pub", TALER_JSON_from_data (coin_pub, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)), + sizeof (struct TALER_CoinSpendPublicKey)), "original-value", TALER_JSON_from_amount (&coin_value), "residual-value", TALER_JSON_from_amount (&residual), "requested-value", TALER_JSON_from_amount (&requested), @@ -676,7 +677,7 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, uint16_t noreveal_index) { struct RefreshMeltResponseSignatureBody body; - struct GNUNET_CRYPTO_EddsaSignature sig; + struct TALER_MintSignature sig; json_t *sig_json; int ret; @@ -687,7 +688,7 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, TALER_MINT_keys_sign (&body.purpose, &sig); sig_json = TALER_JSON_from_eddsa_sig (&body.purpose, - &sig); + &sig.eddsa_signature); GNUNET_assert (NULL != sig_json); ret = TALER_MINT_reply_json_pack (connection, MHD_HTTP_OK, @@ -710,7 +711,7 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, int TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, unsigned int num_newcoins, - struct GNUNET_CRYPTO_rsa_Signature **sigs) + const struct TALER_DenominationSignature *sigs) { int newcoin_index; json_t *root; @@ -724,7 +725,7 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, list); for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++) json_array_append_new (list, - TALER_JSON_from_rsa_signature (sigs[newcoin_index])); + TALER_JSON_from_rsa_signature (sigs[newcoin_index].rsa_signature)); ret = TALER_MINT_reply_json (connection, root, MHD_HTTP_OK); @@ -777,7 +778,7 @@ TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, */ int TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EcdsaPublicKey *transfer_pub, + const struct TALER_TransferPublicKey *transfer_pub, const struct TALER_EncryptedLinkSecret *shared_secret_enc, const struct LinkDataList *ldl) { @@ -794,14 +795,14 @@ TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection, obj = json_object (); json_object_set_new (obj, "link_enc", TALER_JSON_from_data (ldl->link_data_enc->coin_priv_enc, - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey) + + sizeof (struct TALER_CoinSpendPrivateKey) + ldl->link_data_enc->blinding_key_enc_size)); json_object_set_new (obj, "denom_pub", - TALER_JSON_from_rsa_public_key (ldl->denom_pub)); + TALER_JSON_from_rsa_public_key (ldl->denom_pub.rsa_public_key)); json_object_set_new (obj, "ev_sig", - TALER_JSON_from_rsa_signature (ldl->ev_sig)); + TALER_JSON_from_rsa_signature (ldl->ev_sig.rsa_signature)); json_array_append_new (list, obj); } @@ -812,7 +813,7 @@ TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection, json_object_set_new (root, "transfer_pub", TALER_JSON_from_data (transfer_pub, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))); + sizeof (struct TALER_TransferPublicKey))); json_object_set_new (root, "secret_enc", TALER_JSON_from_data (shared_secret_enc, diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index d42aa29b6..d7e563505 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h @@ -185,11 +185,11 @@ TALER_MINT_reply_invalid_json (struct MHD_Connection *connection); */ int TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, + const struct TALER_CoinSpendPublicKey *coin_pub, const struct GNUNET_HashCode *h_wire, const struct GNUNET_HashCode *h_contract, uint64_t transaction_id, - const struct GNUNET_CRYPTO_EddsaPublicKey *merchant, + const struct TALER_MerchantPublicKey *merchant, const struct TALER_Amount *amount); @@ -276,7 +276,7 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection, */ int TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, + const struct TALER_CoinSpendPublicKey *coin_pub, struct TALER_Amount coin_value, struct TALER_MINT_DB_TransactionList *tl, struct TALER_Amount requested, @@ -294,7 +294,7 @@ TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connect int TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection, unsigned int num_newcoins, - struct GNUNET_CRYPTO_rsa_Signature **sigs); + const struct TALER_DenominationSignature *sigs); /** @@ -332,7 +332,7 @@ TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, */ int TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection, - const struct GNUNET_CRYPTO_EcdsaPublicKey *transfer_pub, + const struct TALER_TransferPublicKey *transfer_pub, const struct TALER_EncryptedLinkSecret *shared_secret_enc, const struct LinkDataList *ldl); diff --git a/src/mint/taler-mint-httpd_withdraw.c b/src/mint/taler-mint-httpd_withdraw.c index b796af946..7d7ca8060 100644 --- a/src/mint/taler-mint-httpd_withdraw.c +++ b/src/mint/taler-mint-httpd_withdraw.c @@ -49,13 +49,13 @@ TALER_MINT_handler_withdraw_status (struct RequestHandler *rh, const char *upload_data, size_t *upload_data_size) { - struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub; + struct TALER_ReservePublicKey reserve_pub; int res; res = TALER_MINT_mhd_request_arg_data (connection, "reserve_pub", &reserve_pub, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); + sizeof (struct TALER_ReservePublicKey)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) @@ -90,17 +90,17 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, { struct TALER_WithdrawRequest wsrd; int res; - struct GNUNET_CRYPTO_rsa_PublicKey *denomination_pub; + struct TALER_DenominationPublicKey denomination_pub; char *denomination_pub_data; size_t denomination_pub_data_size; char *blinded_msg; size_t blinded_msg_len; - struct GNUNET_CRYPTO_EddsaSignature signature; + struct TALER_ReserveSignature signature; res = TALER_MINT_mhd_request_arg_data (connection, "reserve_pub", &wsrd.reserve_pub, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); + sizeof (struct TALER_ReservePublicKey)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) @@ -108,7 +108,7 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, res = TALER_MINT_mhd_request_arg_data (connection, "reserve_sig", &signature, - sizeof (struct GNUNET_CRYPTO_EddsaSignature)); + sizeof (struct TALER_ReserveSignature)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) @@ -148,8 +148,8 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WITHDRAW, &wsrd.purpose, - &signature, - &wsrd.reserve_pub)) + &signature.eddsa_signature, + &wsrd.reserve_pub.eddsa_pub)) { LOG_WARNING ("Client supplied invalid signature for /withdraw/sign request\n"); GNUNET_free (denomination_pub_data); @@ -157,10 +157,11 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, return TALER_MINT_reply_arg_invalid (connection, "reserve_sig"); } - denomination_pub = GNUNET_CRYPTO_rsa_public_key_decode (denomination_pub_data, - denomination_pub_data_size); + denomination_pub.rsa_public_key + = GNUNET_CRYPTO_rsa_public_key_decode (denomination_pub_data, + denomination_pub_data_size); GNUNET_free (denomination_pub_data); - if (NULL == denomination_pub) + if (NULL == denomination_pub.rsa_public_key) { LOG_WARNING ("Client supplied ill-formed denomination public key for /withdraw/sign request\n"); GNUNET_free (blinded_msg); @@ -169,12 +170,12 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh, } res = TALER_MINT_db_execute_withdraw_sign (connection, &wsrd.reserve_pub, - denomination_pub, + &denomination_pub, blinded_msg, blinded_msg_len, &signature); GNUNET_free (blinded_msg); - GNUNET_CRYPTO_rsa_public_key_free (denomination_pub); + GNUNET_CRYPTO_rsa_public_key_free (denomination_pub.rsa_public_key); return res; } diff --git a/src/mint/taler-mint-keycheck.c b/src/mint/taler-mint-keycheck.c index cb46c14e7..370b1c51a 100644 --- a/src/mint/taler-mint-keycheck.c +++ b/src/mint/taler-mint-keycheck.c @@ -70,8 +70,8 @@ signkeys_iter (void *cls, if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNKEY, &ski->issue.purpose, - &ski->issue.signature, - &ski->issue.master_pub)) + &ski->issue.signature.eddsa_signature, + &ski->issue.master_pub.eddsa_pub)) { fprintf (stderr, "Signing key `%s' has invalid signature\n", @@ -130,15 +130,15 @@ denomkeys_iter (void *cls, if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOM, &dki->issue.purpose, - &dki->issue.signature, - &dki->issue.master)) + &dki->issue.signature.eddsa_signature, + &dki->issue.master.eddsa_pub)) { fprintf (stderr, "Denomination key for `%s' has invalid signature\n", alias); return GNUNET_SYSERR; } - GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub, + GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, &hc); if (0 != memcmp (&hc, &dki->issue.denom_hash, diff --git a/src/mint/taler-mint-keyup.c b/src/mint/taler-mint-keyup.c index 759e7c1b3..019ae5b3f 100644 --- a/src/mint/taler-mint-keyup.c +++ b/src/mint/taler-mint-keyup.c @@ -179,12 +179,12 @@ static struct GNUNET_TIME_Absolute now; /** * Master private key of the mint. */ -static struct GNUNET_CRYPTO_EddsaPrivateKey *master_priv; +static struct TALER_MasterPrivateKey master_priv; /** * Master public key of the mint. */ -static struct GNUNET_CRYPTO_EddsaPublicKey *master_pub; +static struct TALER_MasterPublicKey master_pub; /** * Until what time do we provide keys? @@ -440,23 +440,23 @@ create_signkey_issue_priv (struct GNUNET_TIME_Absolute start, struct TALER_MINT_SignKeyIssue *issue = &pi->issue; priv = GNUNET_CRYPTO_eddsa_key_create (); - pi->signkey_priv = *priv; + pi->signkey_priv.eddsa_priv = *priv; GNUNET_free (priv); - issue->master_pub = *master_pub; + issue->master_pub = master_pub; issue->start = GNUNET_TIME_absolute_hton (start); issue->expire = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (start, duration)); - GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv, - &issue->signkey_pub); + GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv.eddsa_priv, + &issue->signkey_pub.eddsa_pub); issue->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNKEY); issue->purpose.size = htonl (sizeof (struct TALER_MINT_SignKeyIssue) - offsetof (struct TALER_MINT_SignKeyIssue, purpose)); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (master_priv, + GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, &issue->purpose, - &issue->signature)); + &issue->signature.eddsa_signature)); } @@ -678,12 +678,14 @@ static void create_denomkey_issue (const struct CoinTypeParams *params, struct TALER_MINT_DenomKeyIssuePriv *dki) { - GNUNET_assert (NULL != - (dki->denom_priv = GNUNET_CRYPTO_rsa_private_key_create (params->rsa_keysize))); - dki->denom_pub = GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv); - GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub, + dki->denom_priv.rsa_private_key + = GNUNET_CRYPTO_rsa_private_key_create (params->rsa_keysize); + GNUNET_assert (NULL != dki->denom_priv.rsa_private_key); + dki->denom_pub.rsa_public_key + = GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, &dki->issue.denom_hash); - dki->issue.master = *master_pub; + dki->issue.master = master_pub; dki->issue.start = GNUNET_TIME_absolute_hton (params->anchor); dki->issue.expire_withdraw = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, @@ -704,9 +706,9 @@ create_denomkey_issue (const struct CoinTypeParams *params, offsetof (struct TALER_MINT_DenomKeyIssuePriv, issue.purpose)); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (master_priv, + GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, &dki->issue.purpose, - &dki->issue.signature)); + &dki->issue.signature.eddsa_signature)); } @@ -764,10 +766,10 @@ mint_keys_update_cointype (void *cls, "Failed to write denomination key information to file `%s'.\n", dkf); *ret = GNUNET_SYSERR; - GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv); + GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv.rsa_private_key); return; } - GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv); + GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv.rsa_private_key); p.anchor = GNUNET_TIME_absolute_add (p.anchor, p.duration_spend); p.anchor = GNUNET_TIME_absolute_subtract (p.anchor, @@ -825,6 +827,7 @@ main (int argc, GNUNET_GETOPT_OPTION_END }; struct GNUNET_TIME_Relative lookahead_sign; + struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_priv; GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("taler-mint-keyup", @@ -872,18 +875,18 @@ main (int argc, "Master key file not given\n"); return 1; } - master_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); - if (NULL == master_priv) + eddsa_priv = GNUNET_CRYPTO_eddsa_key_create_from_file (masterkeyfile); + if (NULL == eddsa_priv) { fprintf (stderr, "Failed to initialize master key from file `%s'\n", masterkeyfile); return 1; } - - master_pub = GNUNET_new (struct GNUNET_CRYPTO_EddsaPublicKey); - GNUNET_CRYPTO_eddsa_key_get_public (master_priv, - master_pub); + master_priv.eddsa_priv = *eddsa_priv; + GNUNET_free (eddsa_priv); + GNUNET_CRYPTO_eddsa_key_get_public (&master_priv.eddsa_priv, + &master_pub.eddsa_pub); /* check if key from file matches the one from the configuration */ { @@ -902,7 +905,7 @@ main (int argc, return 1; } if (0 != - memcmp (master_pub, + memcmp (&master_pub, &master_pub_from_cfg, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) { diff --git a/src/mint/taler_mintdb_plugin.h b/src/mint/taler_mintdb_plugin.h index 83e373340..225228812 100644 --- a/src/mint/taler_mintdb_plugin.h +++ b/src/mint/taler_mintdb_plugin.h @@ -35,7 +35,7 @@ struct BankTransfer /** * Public key of the reserve that was filled. */ - struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub; + struct TALER_ReservePublicKey reserve_pub; /** * Amount that was transferred to the mint. @@ -58,7 +58,7 @@ struct Reserve /** * The reserve's public key. This uniquely identifies the reserve */ - struct GNUNET_CRYPTO_EddsaPublicKey *pub; + struct TALER_ReservePublicKey pub; /** * The balance amount existing in the reserve @@ -83,7 +83,7 @@ struct CollectableBlindcoin /** * Our signature over the (blinded) coin. */ - struct GNUNET_CRYPTO_rsa_Signature *sig; + struct TALER_DenominationSignature sig; /** * Denomination key (which coin was generated). @@ -91,12 +91,12 @@ struct CollectableBlindcoin * AMOUNT *including* fee in what is being signed * as well! */ - struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub; + struct TALER_DenominationPublicKey denom_pub; /** * Public key of the reserve that was drained. */ - struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub; + struct TALER_ReservePublicKey reserve_pub; /** * Hash over the blinded message, needed to verify @@ -108,7 +108,7 @@ struct CollectableBlindcoin * Signature confirming the withdrawl, matching @e reserve_pub, * @e denom_pub and @e h_coin_envelope. */ - struct GNUNET_CRYPTO_EddsaSignature reserve_sig; + struct TALER_ReserveSignature reserve_sig; }; @@ -186,13 +186,13 @@ struct Deposit * by @e h_wire in relation to the contract identified * by @e h_contract. */ - struct GNUNET_CRYPTO_EcdsaSignature csig; + struct TALER_CoinSpendSignature csig; /** * Public key of the merchant. Enables later identification * of the merchant in case of a need to rollback transactions. */ - struct GNUNET_CRYPTO_EddsaPublicKey merchant_pub; + struct TALER_MerchantPublicKey merchant_pub; /** * Hash over the contract between merchant and customer @@ -238,8 +238,10 @@ struct RefreshSession /** * Signature over the commitments by the client, * only valid if @e has_commit_sig is set. + * + * FIXME: The above comment is clearly confused. */ - struct GNUNET_CRYPTO_EddsaSignature commit_sig; + struct TALER_SessionSignature commit_sig; /** * Hash over coins to melt and coins to create of the @@ -250,7 +252,7 @@ struct RefreshSession /** * Signature over the melt by the client. */ - struct GNUNET_CRYPTO_EddsaSignature melt_sig; + struct TALER_SessionSignature melt_sig; /** * Number of coins we are melting. @@ -291,7 +293,7 @@ struct RefreshMelt /** * Signature over the melting operation. */ - struct GNUNET_CRYPTO_EcdsaSignature coin_sig; + struct TALER_CoinSpendSignature coin_sig; /** * Which melting operation should the coin become a part of. @@ -350,7 +352,7 @@ struct RefreshCommitLink /** * Transfer public key (FIXME: explain!) */ - struct GNUNET_CRYPTO_EcdsaPublicKey transfer_pub; + struct TALER_TransferPublicKey transfer_pub; /** * Encrypted shared secret to decrypt the link. @@ -378,12 +380,12 @@ struct LinkDataList /** * Denomination public key, determines the value of the coin. */ - struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub; + struct TALER_DenominationPublicKey denom_pub; /** * Signature over the blinded envelope. */ - struct GNUNET_CRYPTO_rsa_Signature *ev_sig; + struct TALER_DenominationSignature ev_sig; }; @@ -393,14 +395,14 @@ struct LinkDataList struct Lock { /** - * Information about the coin that is being melted. + * Information about the coin that is being locked. */ struct TALER_CoinPublicInfo coin; /** - * Signature over the melting operation. + * Signature over the locking operation. */ - const struct GNUNET_CRYPTO_EcdsaSignature coin_sig; + struct TALER_CoinSpendSignature coin_sig; /** * How much value is being locked? @@ -535,35 +537,35 @@ struct TALER_MINTDB_Plugin * Start a transaction. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn connection to use + * @param sesssion connection to use * @return #GNUNET_OK on success */ int (*start) (void *cls, - struct TALER_MINTDB_Session *db_conn); + struct TALER_MINTDB_Session *sesssion); /** * Commit a transaction. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn connection to use + * @param sesssion connection to use * @return #GNUNET_OK on success */ int (*commit) (void *cls, - struct TALER_MINTDB_Session *db_conn); + struct TALER_MINTDB_Session *sesssion); /** * Abort/rollback a transaction. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn connection to use + * @param sesssion connection to use */ void (*rollback) (void *cls, - struct TALER_MINTDB_Session *db_conn); + struct TALER_MINTDB_Session *sesssion); /** @@ -611,7 +613,7 @@ struct TALER_MINTDB_Plugin * key of the hash of the blinded message. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection to use + * @param sesssion database connection to use * @param h_blind hash of the blinded message * @param collectable corresponding collectable coin (blind signature) * if a coin is found @@ -621,7 +623,7 @@ struct TALER_MINTDB_Plugin */ int (*get_collectable_blindcoin) (void *cls, - struct TALER_MINTDB_Session *db_conn, + struct TALER_MINTDB_Session *sesssion, const struct GNUNET_HashCode *h_blind, struct CollectableBlindcoin *collectable); @@ -631,7 +633,7 @@ struct TALER_MINTDB_Plugin * hash of the blinded message. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection to use + * @param sesssion database connection to use * @param h_blind hash of the blinded message * @param withdraw amount by which the reserve will be withdrawn with this * transaction @@ -643,7 +645,7 @@ struct TALER_MINTDB_Plugin */ int (*insert_collectable_blindcoin) (void *cls, - struct TALER_MINTDB_Session *db_conn, + struct TALER_MINTDB_Session *sesssion, const struct GNUNET_HashCode *h_blind, struct TALER_Amount withdraw, const struct CollectableBlindcoin *collectable); @@ -654,14 +656,14 @@ struct TALER_MINTDB_Plugin * reserve. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn connection to use + * @param sesssion connection to use * @param reserve_pub public key of the reserve * @return known transaction history (NULL if reserve is unknown) */ struct ReserveHistory * (*get_reserve_history) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub); + struct TALER_MINTDB_Session *sesssion, + const struct TALER_ReservePublicKey *reserve_pub); /** @@ -679,7 +681,7 @@ struct TALER_MINTDB_Plugin * Check if we have the specified deposit already in the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param deposit deposit to search for * @return #GNUNET_YES if we know this operation, * #GNUNET_NO if this deposit is unknown to us, @@ -687,7 +689,7 @@ struct TALER_MINTDB_Plugin */ int (*have_deposit) (void *cls, - struct TALER_MINTDB_Session *db_conn, + struct TALER_MINTDB_Session *sesssion, const struct Deposit *deposit); @@ -696,13 +698,13 @@ struct TALER_MINTDB_Plugin * database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn connection to the database + * @param sesssion connection to the database * @param deposit deposit information to store * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ int (*insert_deposit) (void *cls, - struct TALER_MINTDB_Session *db_conn, + struct TALER_MINTDB_Session *sesssion, const struct Deposit *deposit); @@ -710,7 +712,7 @@ struct TALER_MINTDB_Plugin * Lookup refresh session data under the given public key. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database handle to use + * @param sesssion database handle to use * @param refresh_session_pub public key to use for the lookup * @param refresh_session[OUT] where to store the result * @return #GNUNET_YES on success, @@ -719,8 +721,8 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_session) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *refresh_session_pub, struct RefreshSession *refresh_session); @@ -728,7 +730,7 @@ struct TALER_MINTDB_Plugin * Store new refresh session data under the given public key. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database handle to use + * @param sesssion database handle to use * @param refresh_session_pub public key to use to locate the session * @param refresh_session session data to store * @return #GNUNET_YES on success, @@ -736,8 +738,8 @@ struct TALER_MINTDB_Plugin */ int (*create_refresh_session) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *session_pub, const struct RefreshSession *refresh_session); @@ -746,7 +748,7 @@ struct TALER_MINTDB_Plugin * Store the given /refresh/melt request in the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param refresh_session session key of the melt operation * @param oldcoin_index index of the coin to store * @param melt coin melt operation details to store @@ -755,8 +757,8 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_melt) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *refresh_session, uint16_t oldcoin_index, const struct RefreshMelt *melt); @@ -765,7 +767,7 @@ struct TALER_MINTDB_Plugin * Get information about melted coin details from the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param refresh_session session key of the melt operation * @param oldcoin_index index of the coin to retrieve * @param melt melt data to fill in @@ -774,8 +776,8 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_melt) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *refresh_session, uint16_t oldcoin_index, struct RefreshMelt *melt); @@ -785,7 +787,7 @@ struct TALER_MINTDB_Plugin * in a given refresh operation. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param session_pub refresh session key * @param num_newcoins number of coins to generate, size of the @a denom_pubs array * @param denom_pubs array denominations of the coins to create @@ -794,10 +796,10 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_order) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *session_pub, uint16_t num_newcoins, - struct GNUNET_CRYPTO_rsa_PublicKey *const*denom_pubs); + const struct TALER_DenominationPublicKey *denom_pubs); /** @@ -805,7 +807,7 @@ struct TALER_MINTDB_Plugin * create in the given refresh operation. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param session_pub refresh session key * @param num_newcoins size of the @a denom_pubs array * @param denom_pubs[OUT] where to write @a num_newcoins denomination keys @@ -814,10 +816,10 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_order) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *session_pub, uint16_t num_newcoins, - struct GNUNET_CRYPTO_rsa_PublicKey **denom_pubs); + struct TALER_DenominationPublicKey *denom_pubs); /** @@ -825,7 +827,7 @@ struct TALER_MINTDB_Plugin * for the given refresh session in the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection to use + * @param sesssion database connection to use * @param refresh_session_pub refresh session this commitment belongs to * @param i set index (1st dimension), relating to kappa * @param num_newcoins coin index size of the @a commit_coins array @@ -835,8 +837,8 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_commit_coins) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int i, unsigned int num_newcoins, const struct RefreshCommitCoin *commit_coins); @@ -847,22 +849,22 @@ struct TALER_MINTDB_Plugin * given coin of the given refresh session from the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection to use + * @param sesssion database connection to use * @param refresh_session_pub refresh session the commitment belongs to * @param i set index (1st dimension) - * @param j coin index (2nd dimension), corresponds to refreshed (new) coins - * @param commit_coin[OUT] coin commitment to return + * @param num_coins size of the @a commit_coins array + * @param commit_coin[OUT] array of coin commitments to return * @return #GNUNET_OK on success * #GNUNET_NO if not found * #GNUNET_SYSERR on error */ int (*get_refresh_commit_coins) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int i, - unsigned int j, - struct RefreshCommitCoin *commit_coin); + unsigned int num_coins, + struct RefreshCommitCoin *commit_coins); /** @@ -870,7 +872,7 @@ struct TALER_MINTDB_Plugin * for the given refresh session. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection to use + * @param sesssion database connection to use * @param refresh_session_pub public key of the refresh session this * commitment belongs with * @param i set index (1st dimension), relating to kappa @@ -880,8 +882,8 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_commit_links) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int i, unsigned int num_links, const struct RefreshCommitLink *commit_links); @@ -891,7 +893,7 @@ struct TALER_MINTDB_Plugin * for the given refresh session. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection to use + * @param sesssion database connection to use * @param refresh_session_pub public key of the refresh session this * commitment belongs with * @param i set index (1st dimension) @@ -903,10 +905,10 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_commit_links) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *refresh_session_pub, unsigned int i, - unsigned int j, + unsigned int num_links, struct RefreshCommitLink *links); @@ -917,7 +919,7 @@ struct TALER_MINTDB_Plugin * be used to try to obtain the private keys during "/refresh/link". * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param session_pub refresh session * @param newcoin_index coin index * @param ev_sig coin signature @@ -925,10 +927,10 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_collectable) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_SessionPublicKey *session_pub, uint16_t newcoin_index, - const struct GNUNET_CRYPTO_rsa_Signature *ev_sig); + const struct TALER_DenominationSignature *ev_sig); /** @@ -936,14 +938,14 @@ struct TALER_MINTDB_Plugin * information, the denomination keys and the signatures. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param coin_pub public key to use to retrieve linkage data * @return all known link data for the coin */ struct LinkDataList * (*get_link_data_list) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub); + struct TALER_MINTDB_Session *sesssion, + const struct TALER_CoinSpendPublicKey *coin_pub); /** @@ -965,7 +967,7 @@ struct TALER_MINTDB_Plugin * * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param coin_pub public key of the coin * @param transfer_pub[OUT] public transfer key * @param shared_secret_enc[OUT] set to shared secret @@ -975,9 +977,9 @@ struct TALER_MINTDB_Plugin */ int (*get_transfer) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, - struct GNUNET_CRYPTO_EcdsaPublicKey *transfer_pub, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_CoinSpendPublicKey *coin_pub, + struct TALER_TransferPublicKey *transfer_pub, struct TALER_EncryptedLinkSecret *shared_secret_enc); @@ -985,7 +987,7 @@ struct TALER_MINTDB_Plugin * Test if the given /lock request is known to us. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param lock lock operation * @return #GNUNET_YES if known, * #GNUENT_NO if not, @@ -993,7 +995,7 @@ struct TALER_MINTDB_Plugin */ int (*have_lock) (void *cls, - struct TALER_MINTDB_Session *db_conn, + struct TALER_MINTDB_Session *sesssion, const struct Lock *lock); @@ -1001,14 +1003,14 @@ struct TALER_MINTDB_Plugin * Store the given /lock request in the database. * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param lock lock operation * @return #GNUNET_OK on success * #GNUNET_SYSERR on internal error */ int (*insert_lock) (void *cls, - struct TALER_MINTDB_Session *db_conn, + struct TALER_MINTDB_Session *sesssion, const struct Lock *lock); @@ -1017,14 +1019,14 @@ struct TALER_MINTDB_Plugin * with the given coin (/refresh/melt and /deposit operations). * * @param cls the @e cls of this struct with the plugin-specific state - * @param db_conn database connection + * @param sesssion database connection * @param coin_pub coin to investigate * @return list of transactions, NULL if coin is fresh */ struct TALER_MINT_DB_TransactionList * (*get_coin_transactions) (void *cls, - struct TALER_MINTDB_Session *db_conn, - const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub); + struct TALER_MINTDB_Session *sesssion, + const struct TALER_CoinSpendPublicKey *coin_pub); /** diff --git a/src/mint/test_mint_common.c b/src/mint/test_mint_common.c index aa72dfdcd..f6771474c 100644 --- a/src/mint/test_mint_common.c +++ b/src/mint/test_mint_common.c @@ -31,8 +31,10 @@ if (cond) { GNUNET_break (0); goto EXITIF_exit; } \ } while (0) + int -main (int argc, const char *const argv[]) +main (int argc, + const char *const argv[]) { struct TALER_MINT_DenomKeyIssuePriv dki; char *enc; @@ -41,25 +43,26 @@ main (int argc, const char *const argv[]) char *enc_read; size_t enc_read_size; char *tmpfile; - int ret; ret = 1; enc = NULL; enc_read = NULL; tmpfile = NULL; - dki.denom_priv = NULL; - dki_read.denom_priv = NULL; + dki.denom_priv.rsa_private_key = NULL; + dki_read.denom_priv.rsa_private_key = NULL; GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &dki.issue.signature, sizeof (dki) - offsetof (struct TALER_MINT_DenomKeyIssue, signature)); - dki.denom_priv = GNUNET_CRYPTO_rsa_private_key_create (RSA_KEY_SIZE); - enc_size = GNUNET_CRYPTO_rsa_private_key_encode (dki.denom_priv, &enc); + dki.denom_priv.rsa_private_key + = GNUNET_CRYPTO_rsa_private_key_create (RSA_KEY_SIZE); + enc_size = GNUNET_CRYPTO_rsa_private_key_encode (dki.denom_priv.rsa_private_key, + &enc); EXITIF (NULL == (tmpfile = GNUNET_DISK_mktemp ("test_mint_common"))); EXITIF (GNUNET_OK != TALER_MINT_write_denom_key (tmpfile, &dki)); EXITIF (GNUNET_OK != TALER_MINT_read_denom_key (tmpfile, &dki_read)); - enc_read_size = GNUNET_CRYPTO_rsa_private_key_encode (dki_read.denom_priv, + enc_read_size = GNUNET_CRYPTO_rsa_private_key_encode (dki_read.denom_priv.rsa_private_key, &enc_read); EXITIF (enc_size != enc_read_size); EXITIF (0 != memcmp (enc, @@ -75,9 +78,9 @@ main (int argc, const char *const argv[]) GNUNET_free (tmpfile); } GNUNET_free_non_null (enc_read); - if (NULL != dki.denom_priv) - GNUNET_CRYPTO_rsa_private_key_free (dki.denom_priv); - if (NULL != dki_read.denom_priv) - GNUNET_CRYPTO_rsa_private_key_free (dki_read.denom_priv); + if (NULL != dki.denom_priv.rsa_private_key) + GNUNET_CRYPTO_rsa_private_key_free (dki.denom_priv.rsa_private_key); + if (NULL != dki_read.denom_priv.rsa_private_key) + GNUNET_CRYPTO_rsa_private_key_free (dki_read.denom_priv.rsa_private_key); return ret; } diff --git a/src/mint/test_mint_db.c b/src/mint/test_mint_db.c index c80be70c3..0b61818f1 100644 --- a/src/mint/test_mint_db.c +++ b/src/mint/test_mint_db.c @@ -54,14 +54,15 @@ static int result; */ static int check_reserve (struct TALER_MINTDB_Session *session, - struct GNUNET_CRYPTO_EddsaPublicKey *pub, + const struct TALER_ReservePublicKey *pub, uint32_t value, uint32_t fraction, const char *currency, uint64_t expiry) { struct Reserve reserve; - reserve.pub = pub; + + reserve.pub = *pub; FAILIF (GNUNET_OK != plugin->reserve_get (plugin->cls, @@ -80,8 +81,8 @@ check_reserve (struct TALER_MINTDB_Session *session, struct DenomKeyPair { - struct GNUNET_CRYPTO_rsa_PrivateKey *priv; - struct GNUNET_CRYPTO_rsa_PublicKey *pub; + struct TALER_DenominationPrivateKey priv; + struct TALER_DenominationPublicKey pub; }; @@ -91,9 +92,10 @@ create_denom_key_pair (unsigned int size) struct DenomKeyPair *dkp; dkp = GNUNET_new (struct DenomKeyPair); - dkp->priv = GNUNET_CRYPTO_rsa_private_key_create (size); - GNUNET_assert (NULL != dkp->priv); - dkp->pub = GNUNET_CRYPTO_rsa_private_key_get_public (dkp->priv); + dkp->priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (size); + GNUNET_assert (NULL != dkp->priv.rsa_private_key); + dkp->pub.rsa_public_key + = GNUNET_CRYPTO_rsa_private_key_get_public (dkp->priv.rsa_private_key); return dkp; } @@ -101,8 +103,8 @@ create_denom_key_pair (unsigned int size) static void destroy_denon_key_pair (struct DenomKeyPair *dkp) { - GNUNET_CRYPTO_rsa_public_key_free (dkp->pub); - GNUNET_CRYPTO_rsa_private_key_free (dkp->priv); + GNUNET_CRYPTO_rsa_public_key_free (dkp->pub.rsa_public_key); + GNUNET_CRYPTO_rsa_private_key_free (dkp->priv.rsa_private_key); GNUNET_free (dkp); } @@ -121,7 +123,7 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct TALER_MINTDB_Session *session; - struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub; + struct TALER_ReservePublicKey reserve_pub; struct Reserve reserve; struct GNUNET_TIME_Absolute expiry; struct TALER_Amount amount; @@ -172,7 +174,7 @@ run (void *cls, goto drop; } RND_BLK (&reserve_pub); - reserve.pub = &reserve_pub; + reserve.pub = reserve_pub; amount.value = 1; amount.fraction = 1; strcpy (amount.currency, CURRENCY); @@ -209,7 +211,10 @@ run (void *cls, RND_BLK(&h_blind); RND_BLK(&cbc.reserve_sig); cbc.denom_pub = dkp->pub; - cbc.sig = GNUNET_CRYPTO_rsa_sign (dkp->priv, &h_blind, sizeof (h_blind)); + cbc.sig.rsa_signature + = GNUNET_CRYPTO_rsa_sign (dkp->priv.rsa_private_key, + &h_blind, + sizeof (h_blind)); (void) memcpy (&cbc.reserve_pub, &reserve_pub, sizeof (reserve_pub)); @@ -233,7 +238,7 @@ run (void *cls, session, &h_blind, &cbc2)); - FAILIF (NULL == cbc2.denom_pub); + FAILIF (NULL == cbc2.denom_pub.rsa_public_key); FAILIF (0 != memcmp (&cbc2.reserve_sig, &cbc.reserve_sig, sizeof (cbc2.reserve_sig))); @@ -242,8 +247,8 @@ run (void *cls, sizeof (cbc2.reserve_pub))); FAILIF (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (&h_blind, - cbc2.sig, - dkp->pub)); + cbc2.sig.rsa_signature, + dkp->pub.rsa_public_key)); rh = plugin->get_reserve_history (plugin->cls, session, &reserve_pub); @@ -331,12 +336,12 @@ run (void *cls, session)); if (NULL != dkp) destroy_denon_key_pair (dkp); - if (NULL != cbc.sig) - GNUNET_CRYPTO_rsa_signature_free (cbc.sig); - if (NULL != cbc2.denom_pub) - GNUNET_CRYPTO_rsa_public_key_free (cbc2.denom_pub); - if (NULL != cbc2.sig) - GNUNET_CRYPTO_rsa_signature_free (cbc2.sig); + if (NULL != cbc.sig.rsa_signature) + GNUNET_CRYPTO_rsa_signature_free (cbc.sig.rsa_signature); + if (NULL != cbc2.denom_pub.rsa_public_key) + GNUNET_CRYPTO_rsa_public_key_free (cbc2.denom_pub.rsa_public_key); + if (NULL != cbc2.sig.rsa_signature) + GNUNET_CRYPTO_rsa_signature_free (cbc2.sig.rsa_signature); dkp = NULL; } diff --git a/src/util/crypto.c b/src/util/crypto.c index c7a00b9ab..ffc12fed9 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -52,7 +52,8 @@ fatal_error_handler (void *cls, void TALER_gcrypt_init () { - gcry_set_fatalerror_handler (&fatal_error_handler, NULL); + gcry_set_fatalerror_handler (&fatal_error_handler, + NULL); TALER_assert_as (gcry_check_version (NEED_LIBGCRYPT_VERSION), "libgcrypt version mismatch"); /* Disable secure memory. */ @@ -205,11 +206,11 @@ TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input, ret = GNUNET_new (struct TALER_RefreshLinkDecrypted); memcpy (&ret->coin_priv, buf, - sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)); - ret->blinding_key + sizeof (struct TALER_CoinSpendPrivateKey)); + ret->blinding_key.rsa_blinding_key = GNUNET_CRYPTO_rsa_blinding_key_decode (&buf[sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)], input->blinding_key_enc_size); - if (NULL == ret->blinding_key) + if (NULL == ret->blinding_key.rsa_blinding_key) { GNUNET_free (ret); return NULL; @@ -236,7 +237,7 @@ TALER_refresh_encrypt (const struct TALER_RefreshLinkDecrypted *input, struct TALER_RefreshLinkEncrypted *ret; derive_refresh_key (secret, &iv, &skey); - b_buf_size = GNUNET_CRYPTO_rsa_blinding_key_encode (input->blinding_key, + b_buf_size = GNUNET_CRYPTO_rsa_blinding_key_encode (input->blinding_key.rsa_blinding_key, &b_buf); ret = GNUNET_malloc (sizeof (struct TALER_RefreshLinkEncrypted) + b_buf_size); @@ -313,8 +314,8 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info) &c_hash); if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (&c_hash, - coin_public_info->denom_sig, - coin_public_info->denom_pub)) + coin_public_info->denom_sig.rsa_signature, + coin_public_info->denom_pub.rsa_public_key)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "coin signature is invalid\n"); |