diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-04-08 16:56:33 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-04-08 16:56:33 +0200 |
commit | 11ae9f030e13d07c505a4d5477d592ddb4b3acf6 (patch) | |
tree | 69ce120a7c60c84d0d074bab8fe2cd26e77300dc /src/util/gnunet-crypto-tvg.c | |
parent | 2348fe4ae8ffe93765d5c56c3cc5d4490eae946d (diff) | |
download | gnunet-11ae9f030e13d07c505a4d5477d592ddb4b3acf6.tar.gz gnunet-11ae9f030e13d07c505a4d5477d592ddb4b3acf6.zip |
fix sign api for to address #6164
Diffstat (limited to 'src/util/gnunet-crypto-tvg.c')
-rw-r--r-- | src/util/gnunet-crypto-tvg.c | 58 |
1 files changed, 33 insertions, 25 deletions
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, | |||
124 | struct GNUNET_CRYPTO_EddsaPublicKey pub; | 124 | struct GNUNET_CRYPTO_EddsaPublicKey pub; |
125 | struct GNUNET_CRYPTO_EddsaSignature sig; | 125 | struct GNUNET_CRYPTO_EddsaSignature sig; |
126 | struct TestSignatureDataPS data = { 0 }; | 126 | struct TestSignatureDataPS data = { 0 }; |
127 | |||
127 | priv = GNUNET_CRYPTO_eddsa_key_create (); | 128 | priv = GNUNET_CRYPTO_eddsa_key_create (); |
128 | GNUNET_CRYPTO_eddsa_key_get_public (priv, &pub); | 129 | GNUNET_CRYPTO_eddsa_key_get_public (priv, &pub); |
129 | data.purpose.size = htonl (sizeof (struct TestSignatureDataPS)); | 130 | data.purpose.size = htonl (sizeof (data)); |
130 | data.purpose.size = htonl (GNUNET_SIGNATURE_PURPOSE_TEST); | 131 | data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST); |
131 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (priv, &data.purpose, | 132 | GNUNET_CRYPTO_eddsa_sign (priv, |
132 | &sig)); | 133 | &data, |
133 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_verify (0, | 134 | &sig); |
134 | &data.purpose, | 135 | GNUNET_assert (GNUNET_OK == |
135 | &sig, | 136 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, |
136 | &pub)); | 137 | &data, |
138 | &sig, | ||
139 | &pub)); | ||
137 | 140 | ||
138 | printf ("eddsa sig:\n"); | 141 | printf ("eddsa sig:\n"); |
139 | display_data (" priv", priv, sizeof (struct | 142 | display_data (" priv", priv, sizeof (struct |
@@ -151,15 +154,16 @@ run (void *cls, | |||
151 | char *salt = "I'm very salty"; | 154 | char *salt = "I'm very salty"; |
152 | char *ctx = "I'm a context chunk, also known as 'info' in the RFC"; | 155 | char *ctx = "I'm a context chunk, also known as 'info' in the RFC"; |
153 | 156 | ||
154 | GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_kdf (&out, | 157 | GNUNET_assert (GNUNET_OK == |
155 | out_len, | 158 | GNUNET_CRYPTO_kdf (&out, |
156 | salt, | 159 | out_len, |
157 | strlen (salt), | 160 | salt, |
158 | ikm, | 161 | strlen (salt), |
159 | strlen (ikm), | 162 | ikm, |
160 | ctx, | 163 | strlen (ikm), |
161 | strlen (ctx), | 164 | ctx, |
162 | NULL)); | 165 | strlen (ctx), |
166 | NULL)); | ||
163 | 167 | ||
164 | printf ("kdf:\n"); | 168 | printf ("kdf:\n"); |
165 | display_data (" salt", salt, strlen (salt)); | 169 | display_data (" salt", salt, strlen (salt)); |
@@ -210,15 +214,19 @@ run (void *cls, | |||
210 | size_t sig_enc_length; | 214 | size_t sig_enc_length; |
211 | skey = GNUNET_CRYPTO_rsa_private_key_create (2048); | 215 | skey = GNUNET_CRYPTO_rsa_private_key_create (2048); |
212 | pkey = GNUNET_CRYPTO_rsa_private_key_get_public (skey); | 216 | pkey = GNUNET_CRYPTO_rsa_private_key_get_public (skey); |
213 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &message_hash, | 217 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, |
218 | &message_hash, | ||
214 | sizeof (struct GNUNET_HashCode)); | 219 | sizeof (struct GNUNET_HashCode)); |
215 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &bks, sizeof (struct | 220 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, |
216 | GNUNET_CRYPTO_RsaBlindingKeySecret)); | 221 | &bks, |
217 | GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_rsa_blind (&message_hash, | 222 | sizeof (struct |
218 | &bks, | 223 | GNUNET_CRYPTO_RsaBlindingKeySecret)); |
219 | pkey, | 224 | GNUNET_assert (GNUNET_YES == |
220 | &blinded_data, | 225 | GNUNET_CRYPTO_rsa_blind (&message_hash, |
221 | &blinded_len)); | 226 | &bks, |
227 | pkey, | ||
228 | &blinded_data, | ||
229 | &blinded_len)); | ||
222 | blinded_sig = GNUNET_CRYPTO_rsa_sign_blinded (skey, blinded_data, | 230 | blinded_sig = GNUNET_CRYPTO_rsa_sign_blinded (skey, blinded_data, |
223 | blinded_len); | 231 | blinded_len); |
224 | sig = GNUNET_CRYPTO_rsa_unblind (blinded_sig, &bks, pkey); | 232 | sig = GNUNET_CRYPTO_rsa_unblind (blinded_sig, &bks, pkey); |