aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-05-30 13:34:34 +0200
committerChristian Grothoff <christian@grothoff.org>2022-05-30 13:34:39 +0200
commit7f902c0fc9bc7e0832d01169e6f580ab671fbf08 (patch)
treed4588c8517adfa195d360c5bb03eb13b1f071a02 /src/util
parentd40da21e905ef9f5370bcd0e693778053878fc34 (diff)
downloadexchange-7f902c0fc9bc7e0832d01169e6f580ab671fbf08.tar.xz
-sketch API for RSA parallel signing
Diffstat (limited to 'src/util')
-rw-r--r--src/util/crypto_helper_rsa.c24
-rw-r--r--src/util/test_helper_rsa.c64
2 files changed, 55 insertions, 33 deletions
diff --git a/src/util/crypto_helper_rsa.c b/src/util/crypto_helper_rsa.c
index d3f498c07..9491b07c9 100644
--- a/src/util/crypto_helper_rsa.c
+++ b/src/util/crypto_helper_rsa.c
@@ -390,9 +390,7 @@ more:
enum TALER_ErrorCode
TALER_CRYPTO_helper_rsa_sign (
struct TALER_CRYPTO_RsaDenominationHelper *dh,
- const struct TALER_RsaPubHashP *h_rsa,
- const void *msg,
- size_t msg_size,
+ const struct TALER_CRYPTO_RsaSignRequest *rsr,
struct TALER_BlindedDenominationSignature *bs)
{
enum TALER_ErrorCode ec = TALER_EC_INVALID;
@@ -411,17 +409,17 @@ TALER_CRYPTO_helper_rsa_sign (
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Requesting signature\n");
{
- char buf[sizeof (struct TALER_CRYPTO_SignRequest) + msg_size];
+ char buf[sizeof (struct TALER_CRYPTO_SignRequest) + rsr->msg_size];
struct TALER_CRYPTO_SignRequest *sr
= (struct TALER_CRYPTO_SignRequest *) buf;
sr->header.size = htons (sizeof (buf));
sr->header.type = htons (TALER_HELPER_RSA_MT_REQ_SIGN);
sr->reserved = htonl (0);
- sr->h_rsa = *h_rsa;
+ sr->h_rsa = *rsr->h_rsa;
memcpy (&sr[1],
- msg,
- msg_size);
+ rsr->msg,
+ rsr->msg_size);
if (GNUNET_OK !=
TALER_crypto_helper_send_all (dh->sock,
buf,
@@ -596,6 +594,18 @@ end:
}
+enum TALER_ErrorCode
+TALER_CRYPTO_helper_rsa_batch_sign (
+ struct TALER_CRYPTO_RsaDenominationHelper *dh,
+ const struct TALER_CRYPTO_RsaSignRequest *rsrs,
+ unsigned int rsrs_length,
+ struct TALER_BlindedDenominationSignature *bss)
+{
+ GNUNET_break (0);
+ return -1; /* FIXME: NOT IMPLEMENTED! */
+}
+
+
void
TALER_CRYPTO_helper_rsa_revoke (
struct TALER_CRYPTO_RsaDenominationHelper *dh,
diff --git a/src/util/test_helper_rsa.c b/src/util/test_helper_rsa.c
index eaf43622a..3f3eafddb 100644
--- a/src/util/test_helper_rsa.c
+++ b/src/util/test_helper_rsa.c
@@ -292,8 +292,9 @@ test_signing (struct TALER_CRYPTO_RsaDenominationHelper *dh)
if (TALER_DENOMINATION_RSA != keys[i].denom_pub.cipher)
continue;
{
- struct TALER_PlanchetDetail pd;
- pd.blinded_planchet.cipher = TALER_DENOMINATION_RSA;
+ struct TALER_PlanchetDetail pd = {
+ .blinded_planchet.cipher = TALER_DENOMINATION_RSA
+ };
GNUNET_assert (GNUNET_YES ==
TALER_planchet_prepare (&keys[i].denom_pub,
@@ -303,19 +304,23 @@ test_signing (struct TALER_CRYPTO_RsaDenominationHelper *dh)
&ach,
&c_hash,
&pd));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Requesting signature over %u bytes with key %s\n",
- (unsigned
- int) pd.blinded_planchet.details.rsa_blinded_planchet.
- blinded_msg_size,
- GNUNET_h2s (&keys[i].h_rsa.hash));
- ec = TALER_CRYPTO_helper_rsa_sign (dh,
- &keys[i].h_rsa,
- pd.blinded_planchet.details.
- rsa_blinded_planchet.blinded_msg,
- pd.blinded_planchet.details.
- rsa_blinded_planchet.blinded_msg_size,
- &ds);
+ {
+ struct TALER_CRYPTO_RsaSignRequest rsr = {
+ .h_rsa = &keys[i].h_rsa,
+ .msg =
+ pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg,
+ .msg_size =
+ pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg_size
+ };
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Requesting signature over %u bytes with key %s\n",
+ (unsigned int) rsr.msg_size,
+ GNUNET_h2s (&rsr.h_rsa->hash));
+ ec = TALER_CRYPTO_helper_rsa_sign (dh,
+ &rsr,
+ &ds);
+ }
TALER_blinded_planchet_free (&pd.blinded_planchet);
}
switch (ec)
@@ -391,8 +396,10 @@ test_signing (struct TALER_CRYPTO_RsaDenominationHelper *dh)
default:
/* unexpected error */
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected error %d\n",
- ec);
+ "Unexpected error %d at %s:%u\n",
+ ec,
+ __FILE__,
+ __LINE__);
return 7;
}
}
@@ -406,14 +413,17 @@ test_signing (struct TALER_CRYPTO_RsaDenominationHelper *dh)
/* check signing does not work if the key is unknown */
{
struct TALER_RsaPubHashP rnd;
+ struct TALER_CRYPTO_RsaSignRequest rsr = {
+ .h_rsa = &rnd,
+ .msg = "Hello",
+ .msg_size = strlen ("Hello")
+ };
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&rnd,
sizeof (rnd));
ec = TALER_CRYPTO_helper_rsa_sign (dh,
- &rnd,
- "Hello",
- strlen ("Hello"),
+ &rsr,
&ds);
if (TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN != ec)
{
@@ -493,14 +503,16 @@ perf_signing (struct TALER_CRYPTO_RsaDenominationHelper *dh,
{
struct GNUNET_TIME_Absolute start = GNUNET_TIME_absolute_get ();
struct GNUNET_TIME_Relative delay;
+ struct TALER_CRYPTO_RsaSignRequest rsr = {
+ .h_rsa = &keys[i].h_rsa,
+ .msg =
+ pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg,
+ .msg_size =
+ pd.blinded_planchet.details.rsa_blinded_planchet.blinded_msg_size
+ };
ec = TALER_CRYPTO_helper_rsa_sign (dh,
- &keys[i].h_rsa,
- pd.blinded_planchet.details.
- rsa_blinded_planchet.blinded_msg,
- pd.blinded_planchet.details.
- rsa_blinded_planchet.
- blinded_msg_size,
+ &rsr,
&ds);
if (TALER_EC_NONE != ec)
break;