diff options
Diffstat (limited to 'src/util/donau_crypto.c')
-rw-r--r-- | src/util/donau_crypto.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/util/donau_crypto.c b/src/util/donau_crypto.c index 6d86466..ffe7b53 100644 --- a/src/util/donau_crypto.c +++ b/src/util/donau_crypto.c @@ -172,3 +172,117 @@ DONAU_donation_receipt_verify ( h_udi, sizeof (*h_udi)); } + +enum GNUNET_GenericReturnValue +DONAU_donation_unit_blind ( + const struct DONAU_DonationUnitPublicKey *du_pub, + const union GNUNET_CRYPTO_BlindingSecretP *budi_secret, + const union GNUNET_CRYPTO_BlindSessionNonce *cs_nonce, + const struct DONAU_UniqueDonorIdentifierNonce *udi_nonce,//message + const struct DONAU_HashDonorTaxId *h_tax_id, //message + const struct DONAU_BatchIssueValues *alg_values, + struct DONAU_UniqueDonorIdentifierHashP *udi_hash, + struct DONAU_BlindedUniqueDonorIdentifier *budi) +{ + struct GNUNET_HashContext *hash_context; + hash_context = GNUNET_CRYPTO_hash_context_start (); + + GNUNET_CRYPTO_hash_context_read (hash_context, + udi_nonce, + sizeof((*udi_nonce))), + GNUNET_CRYPTO_hash_context_read (hash_context, + h_tax_id, + sizeof((*h_tax_id))); + GNUNET_CRYPTO_hash_context_finish (hash_context, + &udi_hash->hash); + + budi->blinded_message + = GNUNET_CRYPTO_message_blind_to_sign (du_pub->bsign_pub_key, + budi_secret, + cs_nonce, + udi_hash, + sizeof (*udi_hash), + alg_values->blinding_inputs); + if (NULL == budi->blinded_message) + return GNUNET_SYSERR; + return GNUNET_OK; +} + +enum GNUNET_GenericReturnValue +DONAU_donation_unit_sig_unblind ( + struct DONAU_DonationUnitSignature *du_sig, + const struct DONAU_BlindedDonationUnitSignature *blind_du_sig, + const union GNUNET_CRYPTO_BlindingSecretP *budi_secret, + const struct DONAU_UniqueDonorIdentifierHashP *udi_hash, + const struct DONAU_BatchIssueValues *alg_values, + const struct DONAU_DonationUnitPublicKey *du_pub) +{ + du_sig->unblinded_sig + = GNUNET_CRYPTO_blind_sig_unblind (blind_du_sig->blinded_sig, + budi_secret, + udi_hash, + sizeof (*udi_hash), + alg_values->blinding_inputs, + du_pub->bsign_pub_key); + if (NULL == du_sig->unblinded_sig) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + +void +DONAU_budi_secret_create ( + const struct DONAU_BudiMasterSecretP *ps, + const struct DONAU_BatchIssueValues *alg_values, + union GNUNET_CRYPTO_BlindingSecretP *bks) +{ + const struct GNUNET_CRYPTO_BlindingInputValues *bi = + alg_values->blinding_inputs; + + switch (bi->cipher) + { + case GNUNET_CRYPTO_BSA_INVALID: + GNUNET_break (0); + return; + case GNUNET_CRYPTO_BSA_RSA: + GNUNET_assert (GNUNET_YES == + GNUNET_CRYPTO_kdf (&bks->rsa_bks, + sizeof (bks->rsa_bks), + "bks", + strlen ("bks"), + ps, + sizeof(*ps), + NULL, + 0)); + return; + case GNUNET_CRYPTO_BSA_CS: + GNUNET_assert (GNUNET_YES == + GNUNET_CRYPTO_kdf (&bks->nonce, + sizeof (bks->nonce), + "bseed", + strlen ("bseed"), + ps, + sizeof(*ps), + &bi->details.cs_values, + sizeof(bi->details.cs_values), + NULL, + 0)); + return; + } + GNUNET_assert (0); +} + + +const struct DONAU_BatchIssueValues * +DONAU_donation_unit_ewv_rsa_singleton () +{ + static struct GNUNET_CRYPTO_BlindingInputValues bi = { + .cipher = GNUNET_CRYPTO_BSA_RSA + }; + static struct DONAU_BatchIssueValues alg_values = { + .blinding_inputs = &bi + }; + return &alg_values; +}
\ No newline at end of file |