summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-11-13 19:52:09 +0100
committerChristian Grothoff <christian@grothoff.org>2022-11-13 19:52:09 +0100
commitde2fdc2a9a12acfc15d631f3406c2ff1cffa12ec (patch)
tree1144330d717221f3e157429e023a91a9770bae18 /src/util
parent18aba0abbb427a2e0e76ae88f95fef493e74032d (diff)
downloadexchange-de2fdc2a9a12acfc15d631f3406c2ff1cffa12ec.tar.gz
exchange-de2fdc2a9a12acfc15d631f3406c2ff1cffa12ec.tar.bz2
exchange-de2fdc2a9a12acfc15d631f3406c2ff1cffa12ec.zip
refactor CS derive API in preparation for batch API
Diffstat (limited to 'src/util')
-rw-r--r--src/util/crypto_helper_cs.c38
-rw-r--r--src/util/taler-exchange-secmod-cs.c2
-rw-r--r--src/util/taler-exchange-secmod-rsa.c2
-rw-r--r--src/util/test_helper_cs.c39
4 files changed, 58 insertions, 23 deletions
diff --git a/src/util/crypto_helper_cs.c b/src/util/crypto_helper_cs.c
index 66ecb26ad..409903b34 100644
--- a/src/util/crypto_helper_cs.c
+++ b/src/util/crypto_helper_cs.c
@@ -853,13 +853,12 @@ more:
enum TALER_ErrorCode
TALER_CRYPTO_helper_cs_r_derive_withdraw (
struct TALER_CRYPTO_CsDenominationHelper *dh,
- const struct TALER_CsPubHashP *h_cs,
- const struct TALER_CsNonce *nonce,
+ const struct TALER_CRYPTO_CsDeriveRequest *cdr,
struct TALER_DenominationCSPublicRPairP *crp)
{
return helper_cs_r_derive (dh,
- h_cs,
- nonce,
+ cdr->h_cs,
+ cdr->nonce,
false,
crp);
}
@@ -868,18 +867,41 @@ TALER_CRYPTO_helper_cs_r_derive_withdraw (
enum TALER_ErrorCode
TALER_CRYPTO_helper_cs_r_derive_melt (
struct TALER_CRYPTO_CsDenominationHelper *dh,
- const struct TALER_CsPubHashP *h_cs,
- const struct TALER_CsNonce *nonce,
+ const struct TALER_CRYPTO_CsDeriveRequest *cdr,
struct TALER_DenominationCSPublicRPairP *crp)
{
return helper_cs_r_derive (dh,
- h_cs,
- nonce,
+ cdr->h_cs,
+ cdr->nonce,
true,
crp);
}
+enum TALER_ErrorCode
+TALER_CRYPTO_helper_cs_batch_sign_melt (
+ struct TALER_CRYPTO_CsDenominationHelper *dh,
+ const struct TALER_CRYPTO_CsSignRequest *reqs,
+ unsigned int reqs_length,
+ struct TALER_BlindedDenominationSignature *bss)
+{
+ GNUNET_break (0); // FIXME
+ return -1;
+}
+
+
+enum TALER_ErrorCode
+TALER_CRYPTO_helper_cs_batch_sign_withdraw (
+ struct TALER_CRYPTO_CsDenominationHelper *dh,
+ const struct TALER_CRYPTO_CsSignRequest *reqs,
+ unsigned int reqs_length,
+ struct TALER_BlindedDenominationSignature *bss)
+{
+ GNUNET_break (0); // FIXME
+ return -1;
+}
+
+
void
TALER_CRYPTO_helper_cs_disconnect (
struct TALER_CRYPTO_CsDenominationHelper *dh)
diff --git a/src/util/taler-exchange-secmod-cs.c b/src/util/taler-exchange-secmod-cs.c
index 01f12e14d..13148a16c 100644
--- a/src/util/taler-exchange-secmod-cs.c
+++ b/src/util/taler-exchange-secmod-cs.c
@@ -2170,7 +2170,7 @@ run (void *cls,
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
if (0 == max_workers)
- max_workers = 1; /* FIXME-#7272: or determine from CPU? */
+ max_workers = sysconf (_SC_NPROCESSORS_CONF);
for (unsigned int i = 0; i<max_workers; i++)
if (GNUNET_OK !=
start_worker ())
diff --git a/src/util/taler-exchange-secmod-rsa.c b/src/util/taler-exchange-secmod-rsa.c
index 1cee02ab0..779e12521 100644
--- a/src/util/taler-exchange-secmod-rsa.c
+++ b/src/util/taler-exchange-secmod-rsa.c
@@ -1983,7 +1983,7 @@ run (void *cls,
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
if (0 == max_workers)
- max_workers = 1; /* FIXME-#7272: or determine from CPU? */
+ max_workers = sysconf (_SC_NPROCESSORS_CONF);
for (unsigned int i = 0; i<max_workers; i++)
if (GNUNET_OK !=
start_worker ())
diff --git a/src/util/test_helper_cs.c b/src/util/test_helper_cs.c
index 1a40fa1ef..7c57d50cf 100644
--- a/src/util/test_helper_cs.c
+++ b/src/util/test_helper_cs.c
@@ -289,11 +289,17 @@ test_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh)
"Requesting R derivation with key %s\n",
GNUNET_h2s (&keys[i].h_cs.hash));
alg_values.cipher = TALER_DENOMINATION_CS;
- ec = TALER_CRYPTO_helper_cs_r_derive_withdraw (
- dh,
- &keys[i].h_cs,
- &pd.blinded_planchet.details.cs_blinded_planchet.nonce,
- &alg_values.details.cs_values);
+ {
+ struct TALER_CRYPTO_CsDeriveRequest cdr = {
+ .h_cs = &keys[i].h_cs,
+ .nonce = &pd.blinded_planchet.details.cs_blinded_planchet.nonce
+ };
+
+ ec = TALER_CRYPTO_helper_cs_r_derive_withdraw (
+ dh,
+ &cdr,
+ &alg_values.details.cs_values);
+ }
switch (ec)
{
case TALER_EC_NONE:
@@ -374,6 +380,10 @@ test_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh)
struct TALER_CsPubHashP rnd;
struct TALER_CsNonce nonce;
struct TALER_DenominationCSPublicRPairP crp;
+ struct TALER_CRYPTO_CsDeriveRequest cdr = {
+ .h_cs = &rnd,
+ .nonce = &nonce,
+ };
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&rnd,
@@ -382,8 +392,7 @@ test_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh)
&nonce,
sizeof (nonce));
ec = TALER_CRYPTO_helper_cs_r_derive_withdraw (dh,
- &rnd,
- &nonce,
+ &cdr,
&crp);
if (TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN != ec)
{
@@ -424,6 +433,10 @@ test_signing (struct TALER_CRYPTO_CsDenominationHelper *dh)
{
struct TALER_PlanchetDetail pd;
struct TALER_CRYPTO_CsSignRequest csr;
+ struct TALER_CRYPTO_CsDeriveRequest cdr = {
+ .h_cs = &keys[i].h_cs,
+ .nonce = &pd.blinded_planchet.details.cs_blinded_planchet.nonce
+ };
pd.blinded_planchet.cipher = TALER_DENOMINATION_CS;
// keys[i].denom_pub.cipher = TALER_DENOMINATION_CS;
@@ -434,10 +447,7 @@ test_signing (struct TALER_CRYPTO_CsDenominationHelper *dh)
alg_values.cipher = TALER_DENOMINATION_CS;
ec = TALER_CRYPTO_helper_cs_r_derive_withdraw (
dh,
- &keys[i].h_cs,
- &pd.blinded_planchet.
- details.
- cs_blinded_planchet.nonce,
+ &cdr,
&alg_values.details.cs_values);
if (TALER_EC_NONE != ec)
continue;
@@ -622,6 +632,10 @@ perf_signing (struct TALER_CRYPTO_CsDenominationHelper *dh,
{
struct TALER_CoinPubHashP c_hash;
struct TALER_PlanchetDetail pd;
+ struct TALER_CRYPTO_CsDeriveRequest cdr = {
+ .h_cs = &keys[i].h_cs,
+ .nonce = &pd.blinded_planchet.details.cs_blinded_planchet.nonce
+ };
pd.blinded_planchet.cipher = TALER_DENOMINATION_CS;
TALER_cs_withdraw_nonce_derive (&ps,
@@ -630,8 +644,7 @@ perf_signing (struct TALER_CRYPTO_CsDenominationHelper *dh,
alg_values.cipher = TALER_DENOMINATION_CS;
ec = TALER_CRYPTO_helper_cs_r_derive_melt (
dh,
- &keys[i].h_cs,
- &pd.blinded_planchet.details.cs_blinded_planchet.nonce,
+ &cdr,
&alg_values.details.cs_values);
if (TALER_EC_NONE != ec)
continue;