summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-08 16:56:33 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-08 16:56:33 +0200
commit11ae9f030e13d07c505a4d5477d592ddb4b3acf6 (patch)
tree69ce120a7c60c84d0d074bab8fe2cd26e77300dc /src/util
parent2348fe4ae8ffe93765d5c56c3cc5d4490eae946d (diff)
fix sign api for to address #6164
Diffstat (limited to 'src/util')
-rw-r--r--src/util/crypto_ecc.c8
-rw-r--r--src/util/gnunet-crypto-tvg.c58
-rw-r--r--src/util/perf_crypto_asymmetric.c14
-rw-r--r--src/util/test_crypto_ecdsa.c33
-rw-r--r--src/util/test_crypto_eddsa.c13
5 files changed, 69 insertions, 57 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c
index d2cbe9450..4c1169f43 100644
--- a/src/util/crypto_ecc.c
+++ b/src/util/crypto_ecc.c
@@ -688,7 +688,7 @@ data_to_ecdsa_value (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose)
* @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/
int
-GNUNET_CRYPTO_ecdsa_sign (
+GNUNET_CRYPTO_ecdsa_sign_ (
const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
struct GNUNET_CRYPTO_EcdsaSignature *sig)
@@ -750,7 +750,7 @@ GNUNET_CRYPTO_ecdsa_sign (
* @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/
int
-GNUNET_CRYPTO_eddsa_sign (
+GNUNET_CRYPTO_eddsa_sign_ (
const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
struct GNUNET_CRYPTO_EddsaSignature *sig)
@@ -786,7 +786,7 @@ GNUNET_CRYPTO_eddsa_sign (
* @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
*/
int
-GNUNET_CRYPTO_ecdsa_verify (
+GNUNET_CRYPTO_ecdsa_verify_ (
uint32_t purpose,
const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
const struct GNUNET_CRYPTO_EcdsaSignature *sig,
@@ -860,7 +860,7 @@ GNUNET_CRYPTO_ecdsa_verify (
* @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
*/
int
-GNUNET_CRYPTO_eddsa_verify (
+GNUNET_CRYPTO_eddsa_verify_ (
uint32_t purpose,
const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
const struct GNUNET_CRYPTO_EddsaSignature *sig,
diff --git a/src/util/gnunet-crypto-tvg.c b/src/util/gnunet-crypto-tvg.c
index a09a6ff50..e0ef9a622 100644
--- a/src/util/gnunet-crypto-tvg.c
+++ b/src/util/gnunet-crypto-tvg.c
@@ -124,16 +124,19 @@ run (void *cls,
struct GNUNET_CRYPTO_EddsaPublicKey pub;
struct GNUNET_CRYPTO_EddsaSignature sig;
struct TestSignatureDataPS data = { 0 };
+
priv = GNUNET_CRYPTO_eddsa_key_create ();
GNUNET_CRYPTO_eddsa_key_get_public (priv, &pub);
- data.purpose.size = htonl (sizeof (struct TestSignatureDataPS));
- data.purpose.size = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (priv, &data.purpose,
- &sig));
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_verify (0,
- &data.purpose,
- &sig,
- &pub));
+ data.purpose.size = htonl (sizeof (data));
+ data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
+ GNUNET_CRYPTO_eddsa_sign (priv,
+ &data,
+ &sig);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST,
+ &data,
+ &sig,
+ &pub));
printf ("eddsa sig:\n");
display_data (" priv", priv, sizeof (struct
@@ -151,15 +154,16 @@ run (void *cls,
char *salt = "I'm very salty";
char *ctx = "I'm a context chunk, also known as 'info' in the RFC";
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_kdf (&out,
- out_len,
- salt,
- strlen (salt),
- ikm,
- strlen (ikm),
- ctx,
- strlen (ctx),
- NULL));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_kdf (&out,
+ out_len,
+ salt,
+ strlen (salt),
+ ikm,
+ strlen (ikm),
+ ctx,
+ strlen (ctx),
+ NULL));
printf ("kdf:\n");
display_data (" salt", salt, strlen (salt));
@@ -210,15 +214,19 @@ run (void *cls,
size_t sig_enc_length;
skey = GNUNET_CRYPTO_rsa_private_key_create (2048);
pkey = GNUNET_CRYPTO_rsa_private_key_get_public (skey);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &message_hash,
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+ &message_hash,
sizeof (struct GNUNET_HashCode));
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &bks, sizeof (struct
- GNUNET_CRYPTO_RsaBlindingKeySecret));
- GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_rsa_blind (&message_hash,
- &bks,
- pkey,
- &blinded_data,
- &blinded_len));
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+ &bks,
+ sizeof (struct
+ GNUNET_CRYPTO_RsaBlindingKeySecret));
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_rsa_blind (&message_hash,
+ &bks,
+ pkey,
+ &blinded_data,
+ &blinded_len));
blinded_sig = GNUNET_CRYPTO_rsa_sign_blinded (skey, blinded_data,
blinded_len);
sig = GNUNET_CRYPTO_rsa_unblind (blinded_sig, &bks, pkey);
diff --git a/src/util/perf_crypto_asymmetric.c b/src/util/perf_crypto_asymmetric.c
index 7594733b0..49d9ec644 100644
--- a/src/util/perf_crypto_asymmetric.c
+++ b/src/util/perf_crypto_asymmetric.c
@@ -93,18 +93,18 @@ main (int argc, char *argv[])
start = GNUNET_TIME_absolute_get ();
for (i = 0; i < l; i++)
GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign (eddsa[i],
- &sig[i].purp,
- &sig[i].sig));
+ GNUNET_CRYPTO_eddsa_sign_ (eddsa[i],
+ &sig[i].purp,
+ &sig[i].sig));
log_duration ("EdDSA", "sign HashCode");
start = GNUNET_TIME_absolute_get ();
for (i = 0; i < l; i++)
GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_verify (0,
- &sig[i].purp,
- &sig[i].sig,
- &dspub[i]));
+ GNUNET_CRYPTO_eddsa_verify_ (0,
+ &sig[i].purp,
+ &sig[i].sig,
+ &dspub[i]));
log_duration ("EdDSA", "verify HashCode");
start = GNUNET_TIME_absolute_get ();
diff --git a/src/util/test_crypto_ecdsa.c b/src/util/test_crypto_ecdsa.c
index 826097d52..190c58d7d 100644
--- a/src/util/test_crypto_ecdsa.c
+++ b/src/util/test_crypto_ecdsa.c
@@ -55,7 +55,8 @@ testSignVerify ()
for (i = 0; i < ITER; i++)
{
fprintf (stderr, "%s", "."); fflush (stderr);
- if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig))
+ if (GNUNET_SYSERR ==
+ GNUNET_CRYPTO_ecdsa_sign_ (key, &purp, &sig))
{
fprintf (stderr,
"%s",
@@ -64,16 +65,18 @@ testSignVerify ()
continue;
}
if (GNUNET_SYSERR ==
- GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, &purp, &sig,
- &pkey))
+ GNUNET_CRYPTO_ecdsa_verify_ (GNUNET_SIGNATURE_PURPOSE_TEST,
+ &purp, &sig,
+ &pkey))
{
printf ("GNUNET_CRYPTO_ecdsa_verify failed!\n");
ok = GNUNET_SYSERR;
continue;
}
if (GNUNET_SYSERR !=
- GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
- &purp, &sig, &pkey))
+ GNUNET_CRYPTO_ecdsa_verify_ (
+ GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
+ &purp, &sig, &pkey))
{
printf ("GNUNET_CRYPTO_ecdsa_verify failed to fail!\n");
ok = GNUNET_SYSERR;
@@ -104,33 +107,33 @@ testDeriveSignVerify ()
purp.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose));
purp.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
- if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (dpriv, &purp, &sig))
+ if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign_ (dpriv, &purp, &sig))
{
fprintf (stderr, "%s", "GNUNET_CRYPTO_ecdsa_sign returned SYSERR\n");
GNUNET_free (dpriv);
return GNUNET_SYSERR;
}
if (GNUNET_SYSERR ==
- GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST,
- &purp, &sig,
- &dpub))
+ GNUNET_CRYPTO_ecdsa_verify_ (GNUNET_SIGNATURE_PURPOSE_TEST,
+ &purp, &sig,
+ &dpub))
{
printf ("GNUNET_CRYPTO_ecdsa_verify failed!\n");
GNUNET_free (dpriv);
return GNUNET_SYSERR;
}
if (GNUNET_SYSERR !=
- GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST,
- &purp, &sig,
- &pkey))
+ GNUNET_CRYPTO_ecdsa_verify_ (GNUNET_SIGNATURE_PURPOSE_TEST,
+ &purp, &sig,
+ &pkey))
{
printf ("GNUNET_CRYPTO_ecdsa_verify failed to fail!\n");
GNUNET_free (dpriv);
return GNUNET_SYSERR;
}
if (GNUNET_SYSERR !=
- GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
- &purp, &sig, &dpub))
+ GNUNET_CRYPTO_ecdsa_verify_ (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
+ &purp, &sig, &dpub))
{
printf ("GNUNET_CRYPTO_ecdsa_verify failed to fail!\n");
GNUNET_free (dpriv);
@@ -160,7 +163,7 @@ testSignPerformance ()
for (i = 0; i < ITER; i++)
{
fprintf (stderr, "%s", "."); fflush (stderr);
- if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (key, &purp, &sig))
+ if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign_ (key, &purp, &sig))
{
fprintf (stderr, "%s",
"GNUNET_CRYPTO_ecdsa_sign returned SYSERR\n");
diff --git a/src/util/test_crypto_eddsa.c b/src/util/test_crypto_eddsa.c
index c0ad387e1..87990cbac 100644
--- a/src/util/test_crypto_eddsa.c
+++ b/src/util/test_crypto_eddsa.c
@@ -56,23 +56,24 @@ testSignVerify ()
for (unsigned int i = 0; i < ITER; i++)
{
fprintf (stderr, "%s", "."); fflush (stderr);
- if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign (key, &purp, &sig))
+ if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign_ (key, &purp, &sig))
{
fprintf (stderr, "%s", "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n");
ok = GNUNET_SYSERR;
continue;
}
if (GNUNET_SYSERR ==
- GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, &purp, &sig,
- &pkey))
+ GNUNET_CRYPTO_eddsa_verify_ (GNUNET_SIGNATURE_PURPOSE_TEST, &purp, &sig,
+ &pkey))
{
printf ("GNUNET_CRYPTO_eddsa_verify failed!\n");
ok = GNUNET_SYSERR;
continue;
}
if (GNUNET_SYSERR !=
- GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
- &purp, &sig, &pkey))
+ GNUNET_CRYPTO_eddsa_verify_ (
+ GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
+ &purp, &sig, &pkey))
{
printf ("GNUNET_CRYPTO_eddsa_verify failed to fail!\n");
ok = GNUNET_SYSERR;
@@ -105,7 +106,7 @@ testSignPerformance ()
for (unsigned int i = 0; i < ITER; i++)
{
fprintf (stderr, "%s", "."); fflush (stderr);
- if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign (key, &purp, &sig))
+ if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_sign_ (key, &purp, &sig))
{
fprintf (stderr, "%s", "GNUNET_CRYPTO_eddsa_sign returned SYSERR\n");
ok = GNUNET_SYSERR;