From 0a0feeea8679d96cf2b5679562654512d467f0c2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 15 Apr 2015 18:34:14 +0200 Subject: finish #3777 including testing --- src/util/crypto.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src/util/crypto.c') diff --git a/src/util/crypto.c b/src/util/crypto.c index 158bb9511..14c14ebce 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -333,7 +333,6 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info) } - /** * Decrypt the shared @a secret from the information in the * encrypted link secret @e secret_enc using the transfer @@ -373,6 +372,45 @@ TALER_link_decrypt_secret (const struct TALER_EncryptedLinkSecretP *secret_enc, } +/** + * Decrypt the shared @a secret from the information in the + * encrypted link secret @e secret_enc using the transfer + * public key and the coin's private key. + * + * @param secret_enc encrypted link secret + * @param transfer_pub transfer public key + * @param coin_priv coin private key + * @param[out] secret set to the shared secret + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error + */ +int +TALER_link_decrypt_secret2 (const struct TALER_EncryptedLinkSecretP *secret_enc, + const struct TALER_TransferPublicKeyP *trans_pub, + const union TALER_CoinSpendPrivateKeyP *coin_priv, + struct TALER_LinkSecretP *secret) +{ + struct TALER_TransferSecretP transfer_secret; + + if (GNUNET_OK != + GNUNET_CRYPTO_ecc_ecdh (&coin_priv->ecdhe_priv, + &trans_pub->ecdhe_pub, + &transfer_secret.key)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + if (GNUNET_OK != + TALER_transfer_decrypt (secret_enc, + &transfer_secret, + secret)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + /** * Encrypt the shared @a secret to generate the encrypted link secret. * Also creates the transfer key. -- cgit v1.2.3