cleaning up types used some more: also use a new struct for the transfer key secret

This commit is contained in:
Christian Grothoff 2015-01-27 22:05:31 +01:00
parent 27a72fdafe
commit 162af316d3
3 changed files with 28 additions and 15 deletions

View File

@ -240,6 +240,20 @@ TALER_data_to_string_alloc (const void *buf,
/* ****************** Refresh crypto primitives ************* */ /* ****************** Refresh crypto primitives ************* */
/**
* Secret used to decrypt the key to decrypt link secrets.
*/
struct TALER_TransferSecret
{
/**
* Secret used to encrypt/decrypt the `struct TALER_LinkSecret`.
* Must be (currently) a hash as this is what
* #GNUNET_CRYPTO_ecc_ecdh() returns to us.
*/
struct GNUNET_HashCode key;
};
/** /**
* Secret used to decrypt refresh links. * Secret used to decrypt refresh links.
*/ */
@ -312,15 +326,14 @@ struct TALER_RefreshLinkDecrypted
* Use the @a trans_sec (from ECDHE) to decrypt the @a secret_enc * Use the @a trans_sec (from ECDHE) to decrypt the @a secret_enc
* to obtain the @a secret to decrypt the linkage data. * to obtain the @a secret to decrypt the linkage data.
* *
* @param secret_enc encrypted secret (FIXME: use different type!) * @param secret_enc encrypted secret
* @param trans_sec transfer secret (FIXME: use different type?) * @param trans_sec transfer secret
* @param secret shared secret for refresh link decryption * @param secret shared secret for refresh link decryption
* (FIXME: use different type?)
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc, TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc,
const struct GNUNET_HashCode *trans_sec, const struct TALER_TransferSecret *trans_sec,
struct TALER_LinkSecret *secret); struct TALER_LinkSecret *secret);
@ -329,13 +342,13 @@ TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc,
* to obtain the @a secret_enc. * to obtain the @a secret_enc.
* *
* @param secret shared secret for refresh link decryption * @param secret shared secret for refresh link decryption
* @param trans_sec transfer secret (FIXME: use different type?) * @param trans_sec transfer secret
* @param secret_enc[out] encrypted secret * @param secret_enc[out] encrypted secret
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
TALER_transfer_encrypt (const struct TALER_LinkSecret *secret, TALER_transfer_encrypt (const struct TALER_LinkSecret *secret,
const struct GNUNET_HashCode *trans_sec, const struct TALER_TransferSecret *trans_sec,
struct TALER_EncryptedLinkSecret *secret_enc); struct TALER_EncryptedLinkSecret *secret_enc);

View File

@ -918,7 +918,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
{ {
struct RefreshCommitLink commit_link; struct RefreshCommitLink commit_link;
struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub;
struct GNUNET_HashCode transfer_secret; struct TALER_TransferSecret transfer_secret;
struct TALER_LinkSecret shared_secret; struct TALER_LinkSecret shared_secret;
res = TALER_MINT_DB_get_refresh_commit_link (db_conn, res = TALER_MINT_DB_get_refresh_commit_link (db_conn,
@ -946,7 +946,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CRYPTO_ecc_ecdh ((const struct GNUNET_CRYPTO_EcdhePrivateKey *) &transfer_privs[i+off][j], GNUNET_CRYPTO_ecc_ecdh ((const struct GNUNET_CRYPTO_EcdhePrivateKey *) &transfer_privs[i+off][j],
(const struct GNUNET_CRYPTO_EcdhePublicKey *) &coin_pub, (const struct GNUNET_CRYPTO_EcdhePublicKey *) &coin_pub,
&transfer_secret)) &transfer_secret.key))
{ {
GNUNET_break (0); GNUNET_break (0);
// FIXME: return 'internal error'? // FIXME: return 'internal error'?

View File

@ -102,7 +102,7 @@ derive_refresh_key (const struct TALER_LinkSecret *secret,
* @param[out] skey set to session key * @param[out] skey set to session key
*/ */
static void static void
derive_transfer_key (const struct GNUNET_HashCode *secret, derive_transfer_key (const struct TALER_TransferSecret *secret,
struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
struct GNUNET_CRYPTO_SymmetricSessionKey *skey) struct GNUNET_CRYPTO_SymmetricSessionKey *skey)
{ {
@ -112,12 +112,12 @@ derive_transfer_key (const struct GNUNET_HashCode *secret,
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey), GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
ctx_key, strlen (ctx_key), ctx_key, strlen (ctx_key),
secret, sizeof (struct GNUNET_HashCode), secret, sizeof (struct TALER_TransferSecret),
NULL, 0)); NULL, 0));
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector), GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector),
ctx_iv, strlen (ctx_iv), ctx_iv, strlen (ctx_iv),
secret, sizeof (struct GNUNET_HashCode), secret, sizeof (struct TALER_TransferSecret),
NULL, 0)); NULL, 0));
} }
@ -127,13 +127,13 @@ derive_transfer_key (const struct GNUNET_HashCode *secret,
* to obtain the @a secret to decrypt the linkage data. * to obtain the @a secret to decrypt the linkage data.
* *
* @param secret_enc encrypted secret * @param secret_enc encrypted secret
* @param trans_sec transfer secret (FIXME: use different type?) * @param trans_sec transfer secret
* @param secret shared secret for refresh link decryption * @param secret shared secret for refresh link decryption
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc, TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc,
const struct GNUNET_HashCode *trans_sec, const struct TALER_TransferSecret *trans_sec,
struct TALER_LinkSecret *secret) struct TALER_LinkSecret *secret)
{ {
struct GNUNET_CRYPTO_SymmetricInitializationVector iv; struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
@ -155,13 +155,13 @@ TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc,
* to obtain the @a secret_enc. * to obtain the @a secret_enc.
* *
* @param secret shared secret for refresh link decryption * @param secret shared secret for refresh link decryption
* @param trans_sec transfer secret (FIXME: use different type?) * @param trans_sec transfer secret
* @param secret_enc[out] encrypted secret * @param secret_enc[out] encrypted secret
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
*/ */
int int
TALER_transfer_encrypt (const struct TALER_LinkSecret *secret, TALER_transfer_encrypt (const struct TALER_LinkSecret *secret,
const struct GNUNET_HashCode *trans_sec, const struct TALER_TransferSecret *trans_sec,
struct TALER_EncryptedLinkSecret *secret_enc) struct TALER_EncryptedLinkSecret *secret_enc)
{ {
struct GNUNET_CRYPTO_SymmetricInitializationVector iv; struct GNUNET_CRYPTO_SymmetricInitializationVector iv;