summaryrefslogtreecommitdiff
path: root/src/util/crypto.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-04-15 18:34:14 +0200
committerChristian Grothoff <christian@grothoff.org>2015-04-15 18:34:14 +0200
commit0a0feeea8679d96cf2b5679562654512d467f0c2 (patch)
tree550c28424dac2eaf6581c03468ed6124ed8fca1c /src/util/crypto.c
parent97e403bb665ccf736a840c28c717fa7b3dc8de30 (diff)
downloadexchange-0a0feeea8679d96cf2b5679562654512d467f0c2.tar.gz
exchange-0a0feeea8679d96cf2b5679562654512d467f0c2.tar.bz2
exchange-0a0feeea8679d96cf2b5679562654512d467f0c2.zip
finish #3777 including testing
Diffstat (limited to 'src/util/crypto.c')
-rw-r--r--src/util/crypto.c40
1 files changed, 39 insertions, 1 deletions
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
@@ -374,6 +373,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.
*