Add a third default.
[oweals/gnunet.git] / src / util / crypto_hash.c
index 47baf660fe4f83c368d7234afec13984eee58855..e14e7c898392d0b85141a6ec63f983ae4d1981e4 100644 (file)
  */
 
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_disk_lib.h"
-#include "gnunet_strings_lib.h"
+#include "gnunet_util_lib.h"
 #include <gcrypt.h>
 
 #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -277,12 +274,12 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
 int
 GNUNET_CRYPTO_hash_from_string2 (const char *enc,
                                  size_t enclen,
-                                struct GNUNET_HashCode *result)
+                                 struct GNUNET_HashCode *result)
 {
   char upper_enc[enclen];
-  charup_ptr = upper_enc;
+  char *up_ptr = upper_enc;
 
-  GNUNET_STRINGS_utf8_toupper(enc, &up_ptr);
+  GNUNET_STRINGS_utf8_toupper (enc, up_ptr);
 
   return GNUNET_STRINGS_string_to_data (upper_enc, enclen,
                                        (unsigned char*) result,
@@ -292,7 +289,7 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc,
 
 /**
  * @ingroup hash
- * 
+ *
  * Compute the distance between 2 hashcodes.  The computation must be
  * fast, not involve bits[0] or bits[4] (they're used elsewhere), and be
  * somewhat consistent. And of course, the result should be a positive
@@ -395,16 +392,16 @@ GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode * a, const struct GNUNET_Ha
  */
 void
 GNUNET_CRYPTO_hash_to_aes_key (const struct GNUNET_HashCode *hc,
-                               struct GNUNET_CRYPTO_AesSessionKey *skey,
-                               struct GNUNET_CRYPTO_AesInitializationVector *iv)
+                               struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
+                               struct GNUNET_CRYPTO_SymmetricInitializationVector *iv)
 {
   GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_AesSessionKey),
+                 GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
                                     "Hash key derivation", strlen ("Hash key derivation"),
                                     hc, sizeof (struct GNUNET_HashCode),
                                     NULL, 0));
   GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_AesInitializationVector),
+                 GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector),
                                     "Initialization vector derivation", strlen ("Initialization vector derivation"),
                                     hc, sizeof (struct GNUNET_HashCode),
                                     NULL, 0));
@@ -460,7 +457,7 @@ GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode * first,
  * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
  */
 int
-GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1, 
+GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
                         const struct GNUNET_HashCode *h2)
 {
   unsigned int *i1;
@@ -521,7 +518,7 @@ GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1,
  */
 void
 GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
-                               const struct GNUNET_CRYPTO_AesSessionKey *rkey,
+                               const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
                                const void *salt, size_t salt_len, ...)
 {
   va_list argp;
@@ -542,13 +539,13 @@ GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
  */
 void
 GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
-                                 const struct GNUNET_CRYPTO_AesSessionKey *rkey,
+                                 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
                                  const void *salt, size_t salt_len,
                                  va_list argp)
 {
-  GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key), 
-                       salt, salt_len, 
-                       rkey, sizeof (struct GNUNET_CRYPTO_AesSessionKey),
+  GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key),
+                       salt, salt_len,
+                       rkey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
                        argp);
 }