summaryrefslogtreecommitdiff
path: root/src/util/test_crypto.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-10-31 14:02:54 +0100
committerChristian Grothoff <christian@grothoff.org>2017-10-31 14:02:54 +0100
commit2f2930f1ba0f1708fc4455c66173fd61188a3369 (patch)
treed09c8fa13d7bbd90fd94ceaa2d642e6f2693a9d3 /src/util/test_crypto.c
parentec8146de92d92db2cb0e9453d5ef1b538b852354 (diff)
downloadexchange-2f2930f1ba0f1708fc4455c66173fd61188a3369.tar.gz
exchange-2f2930f1ba0f1708fc4455c66173fd61188a3369.tar.bz2
exchange-2f2930f1ba0f1708fc4455c66173fd61188a3369.zip
major API refactoring, adding planchet generation and coin extraction APIs to the Taler crypto library, thereby simplifying code in withdraw, refresh, tipping, payback and testcases; slight API incompatibilities to previous versions are introduced
Diffstat (limited to 'src/util/test_crypto.c')
-rw-r--r--src/util/test_crypto.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/util/test_crypto.c b/src/util/test_crypto.c
index 953ad94df..4713b3a35 100644
--- a/src/util/test_crypto.c
+++ b/src/util/test_crypto.c
@@ -71,11 +71,11 @@ test_high_level ()
&secret2,
sizeof (secret)));
TALER_planchet_setup_refresh (&secret,
- 0,
- &fc1);
+ 0,
+ &fc1);
TALER_planchet_setup_refresh (&secret,
- 1,
- &fc2);
+ 1,
+ &fc2);
GNUNET_assert (0 !=
memcmp (&fc1,
&fc2,
@@ -84,12 +84,55 @@ test_high_level ()
}
+/**
+ * Test the basic planchet functionality of creating a fresh planchet
+ * and extracting the respective signature.
+ *
+ * @return 0 on success
+ */
+static int
+test_planchets ()
+{
+ struct TALER_PlanchetSecretsP ps;
+ struct TALER_DenominationPrivateKey dk_priv;
+ struct TALER_DenominationPublicKey dk_pub;
+ struct TALER_PlanchetDetail pd;
+ struct GNUNET_CRYPTO_RsaSignature *blind_sig;
+ struct TALER_FreshCoin coin;
+
+ dk_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (1024);
+ dk_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (dk_priv.rsa_private_key);
+ TALER_planchet_setup_random (&ps);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_planchet_prepare (&dk_pub,
+ &ps,
+ &pd));
+ blind_sig = GNUNET_CRYPTO_rsa_sign_blinded (dk_priv.rsa_private_key,
+ pd.coin_ev,
+ pd.coin_ev_size);
+ GNUNET_assert (NULL != blind_sig);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_planchet_to_coin (&dk_pub,
+ blind_sig,
+ &ps,
+ &pd.c_hash,
+ &coin));
+ GNUNET_CRYPTO_rsa_signature_free (blind_sig);
+ GNUNET_CRYPTO_rsa_signature_free (coin.sig.rsa_signature);
+ GNUNET_CRYPTO_rsa_private_key_free (dk_priv.rsa_private_key);
+ GNUNET_CRYPTO_rsa_public_key_free (dk_pub.rsa_public_key);
+ return 0;
+}
+
+
int
main(int argc,
const char *const argv[])
{
if (0 != test_high_level ())
return 1;
+ if (0 != test_planchets ())
+ return 1;
return 0;
}