more RSA abstraction work

This commit is contained in:
Christian Grothoff 2021-11-05 17:19:47 +01:00
parent 9668e2e4fb
commit 2549fb6dc7
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 21 additions and 27 deletions

View File

@ -875,8 +875,8 @@ setup_key (struct DenominationKey *dk,
"write", "write",
dk->filename); dk->filename);
GNUNET_free (buf); GNUNET_free (buf);
GNUNET_CRYPTO_rsa_private_key_free (priv.details.rsa_private_key); TALER_denom_priv_free (&priv);
GNUNET_CRYPTO_rsa_public_key_free (pub.details.rsa_public_key); TALER_denom_pub_free (&pub);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
GNUNET_free (buf); GNUNET_free (buf);

View File

@ -103,12 +103,11 @@ test_planchets (void)
&ps, &ps,
&c_hash, &c_hash,
&pd)); &pd));
blind_sig.cipher = TALER_DENOMINATION_RSA; GNUNET_assert (GNUNET_OK ==
blind_sig.details.blinded_rsa_signature TALER_denom_sign_blinded (&blind_sig,
= GNUNET_CRYPTO_rsa_sign_blinded (dk_priv.details.rsa_private_key, &dk_priv,
pd.coin_ev, pd.coin_ev,
pd.coin_ev_size); pd.coin_ev_size));
GNUNET_assert (NULL != blind_sig.details.blinded_rsa_signature);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_planchet_to_coin (&dk_pub, TALER_planchet_to_coin (&dk_pub,
&blind_sig, &blind_sig,

View File

@ -309,10 +309,10 @@ test_signing (struct TALER_CRYPTO_DenominationHelper *dh)
{ {
/* signature invalid */ /* signature invalid */
GNUNET_break (0); GNUNET_break (0);
GNUNET_CRYPTO_rsa_signature_free (rs.details.rsa_signature); TALER_denom_sig_free (&rs);
return 7; return 7;
} }
GNUNET_CRYPTO_rsa_signature_free (rs.details.rsa_signature); TALER_denom_sig_free (&rs);
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received valid signature for key %s\n", "Received valid signature for key %s\n",
@ -386,12 +386,10 @@ perf_signing (struct TALER_CRYPTO_DenominationHelper *dh)
struct TALER_BlindedDenominationSignature ds; struct TALER_BlindedDenominationSignature ds;
enum TALER_ErrorCode ec; enum TALER_ErrorCode ec;
struct TALER_CoinPubHash m_hash; struct TALER_CoinPubHash m_hash;
struct GNUNET_CRYPTO_RsaBlindingKeySecret bks;
struct GNUNET_TIME_Relative duration; struct GNUNET_TIME_Relative duration;
struct TALER_PlanchetSecretsP ps;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, TALER_planchet_setup_random (&ps);
&bks,
sizeof (bks));
GNUNET_CRYPTO_hash ("Hello", GNUNET_CRYPTO_hash ("Hello",
strlen ("Hello"), strlen ("Hello"),
&m_hash.hash); &m_hash.hash);
@ -410,15 +408,14 @@ perf_signing (struct TALER_CRYPTO_DenominationHelper *dh)
keys[i].validity_duration.rel_value_us) keys[i].validity_duration.rel_value_us)
continue; continue;
{ {
void *buf; struct TALER_CoinPubHash c_hash;
size_t buf_size; struct TALER_PlanchetDetail pd;
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
TALER_rsa_blind (&m_hash, TALER_planchet_prepare (&keys[i].denom_pub,
&bks, &ps,
keys[i].denom_pub.details.rsa_public_key, &c_hash,
&buf, &pd));
&buf_size));
/* use this key as long as it works */ /* use this key as long as it works */
while (1) while (1)
{ {
@ -427,8 +424,8 @@ perf_signing (struct TALER_CRYPTO_DenominationHelper *dh)
ds = TALER_CRYPTO_helper_denom_sign (dh, ds = TALER_CRYPTO_helper_denom_sign (dh,
&keys[i].h_denom_pub, &keys[i].h_denom_pub,
buf, pd.coin_ev,
buf_size, pd.coin_ev_size,
&ec); &ec);
if (TALER_EC_NONE != ec) if (TALER_EC_NONE != ec)
break; break;
@ -440,7 +437,7 @@ perf_signing (struct TALER_CRYPTO_DenominationHelper *dh)
if (NUM_SIGN_TESTS == j) if (NUM_SIGN_TESTS == j)
break; break;
} }
GNUNET_free (buf); GNUNET_free (pd.coin_ev);
} }
} /* for i */ } /* for i */
} /* for j */ } /* for j */
@ -527,9 +524,7 @@ run_test (void)
for (unsigned int i = 0; i<MAX_KEYS; i++) for (unsigned int i = 0; i<MAX_KEYS; i++)
if (keys[i].valid) if (keys[i].valid)
{ {
GNUNET_CRYPTO_rsa_public_key_free ( TALER_denom_pub_free (&keys[i].denom_pub);
keys[i].denom_pub.details.rsa_public_key);
keys[i].denom_pub.details.rsa_public_key = NULL;
GNUNET_assert (num_keys > 0); GNUNET_assert (num_keys > 0);
num_keys--; num_keys--;
} }