Пример #1
0
/**
 * @brief Derive an authentication key
 * @param key authentication key
 * @param rkey root key
 * @param salt salt
 * @param salt_len size of the salt
 * @param argp pair of void * & size_t for context chunks, terminated by NULL
 */
void
GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
                                 const struct GNUNET_CRYPTO_AesSessionKey *rkey,
                                 const void *salt, size_t salt_len,
                                 va_list argp)
{
    GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key), salt, salt_len, rkey->key,
                         sizeof (rkey->key), argp);
}
Пример #2
0
/**
 * @brief Derive an IV
 *
 * @param iv initialization vector
 * @param skey session key
 * @param salt salt for the derivation
 * @param salt_len size of the salt
 * @param argp pairs of void * & size_t for context chunks, terminated by NULL
 */
void
GNUNET_CRYPTO_symmetric_derive_iv_v (struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
                               const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
                               const void *salt, size_t salt_len, va_list argp)
{
  char aes_salt[salt_len + 4];
  char twofish_salt[salt_len + 4];

  memcpy (aes_salt, salt, salt_len);
  memcpy (&aes_salt[salt_len], "AES!", 4);
  memcpy (twofish_salt, salt, salt_len);
  memcpy (&twofish_salt[salt_len], "FISH", 4);
  GNUNET_CRYPTO_kdf_v (iv->aes_iv, sizeof (iv->aes_iv),
                       aes_salt, salt_len + 4,
                       skey->aes_key, sizeof (skey->aes_key),
                       argp);
  GNUNET_CRYPTO_kdf_v (iv->twofish_iv, sizeof (iv->twofish_iv),
                       twofish_salt, salt_len + 4,
                       skey->twofish_key, sizeof (skey->twofish_key),
                       argp);
}