[hipl-commit] [trunk] Rev 3905: Splitting misc.c continued (bug id 1139). Separate file for key lengths.

  • From: Miika Komu <miika@xxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Wed, 10 Mar 2010 13:34:38 +0200

Committer: Miika Komu <miika@xxxxxx>
Date: Wed Mar 10 13:34:35 2010 +0200
Revision: 3905
Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Splitting misc.c continued (bug id 1139). Separate file for key lengths.

Modified:
  A  lib/core/keylen.c
  A  lib/core/keylen.h
  M  Makefile.am
  M  firewall/user_ipsec_esp.c
  M  firewall/user_ipsec_sadb.c
  M  hipd/hadb.c
  M  hipd/input.c
  M  lib/core/crypto.c
  M  lib/core/misc.c
  M  lib/core/misc.h
  M  lib/tool/xfrmapi.c
  M  test/auth_performance.c

=== modified file 'Makefile.am'
--- Makefile.am 2010-03-09 21:23:38 +0000
+++ Makefile.am 2010-03-10 11:34:35 +0000
@@ -257,6 +257,7 @@
                                  lib/core/hip_udp.c \
                                  lib/core/solve.c \
                                  lib/core/transform.c \
+                                 lib/core/keylen.c \
                                  lib/core/sqlitedbapi.c \
                                  lib/core/hashchain_store.c \
                                  lib/core/hip_statistics.c \

=== modified file 'firewall/user_ipsec_esp.c'
--- firewall/user_ipsec_esp.c   2010-03-09 21:23:38 +0000
+++ firewall/user_ipsec_esp.c   2010-03-10 11:34:35 +0000
@@ -34,6 +34,7 @@
 #include "lib/core/prefix.h"
 #include "lib/core/misc.h"
 #include "lib/tool/checksum.h"
+#include "lib/core/keylen.h"
 
 /* for some reason the ICV for ESP authentication is truncated to 12 bytes */
 #define ICV_LENGTH 12

=== modified file 'firewall/user_ipsec_sadb.c'
--- firewall/user_ipsec_sadb.c  2010-02-17 17:38:08 +0000
+++ firewall/user_ipsec_sadb.c  2010-03-10 11:34:35 +0000
@@ -23,6 +23,7 @@
 #include "firewall.h"
 #include "lib/core/ife.h"
 #include "lib/core/misc.h"
+#include "lib/core/keylen.h"
 
 /* hash functions used for calculating the entries' hashes
  *

=== modified file 'hipd/hadb.c'
--- hipd/hadb.c 2010-03-09 18:26:22 +0000
+++ hipd/hadb.c 2010-03-10 11:34:35 +0000
@@ -12,6 +12,7 @@
 #include "lib/core/hostid.h"
 #include "lib/core/hip_udp.h"
 #include "lib/core/solve.h"
+#include "lib/core/keylen.h"
 
 #define HIP_HADB_SIZE 53
 #define HIP_MAX_HAS 100

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-03-09 18:26:22 +0000
+++ hipd/input.c        2010-03-10 11:34:35 +0000
@@ -28,6 +28,7 @@
 #include "lib/core/hip_udp.h"
 #include "lib/core/solve.h"
 #include "lib/core/transform.h"
+#include "lib/core/keylen.h"
 #include "dh.h"
 #include "lib/core/misc.h"
 #include "hidb.h"

=== modified file 'lib/core/crypto.c'
--- lib/core/crypto.c   2010-03-09 18:26:22 +0000
+++ lib/core/crypto.c   2010-03-10 11:34:35 +0000
@@ -33,6 +33,7 @@
 
 #include "config.h"
 #include "crypto.h"
+#include "keylen.h"
 
 #ifdef CONFIG_HIP_PERFORMANCE
 #include "lib/performance/performance.h"

=== added file 'lib/core/keylen.c'
--- lib/core/keylen.c   1970-01-01 00:00:00 +0000
+++ lib/core/keylen.c   2010-03-10 11:34:35 +0000
@@ -0,0 +1,103 @@
+/**
+ * @file
+ *
+ * Distributed under <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>
+ *
+ * @brief Various key length calculation functions
+ *
+ * @author Miika Komu <miika@xxxxxx>
+ */
+
+#include "keylen.h"
+#include "protodefs.h"
+#include "debug.h"
+
+/**
+ * get encryption key length for a transform
+ *
+ * @param tid transform
+ * @return the encryption key length of the chosen transform,
+ *         or negative  on error.
+ */
+int hip_enc_key_length(int tid)
+{
+    int ret = -1;
+
+    switch (tid) {
+    case HIP_ESP_AES_SHA1:
+        ret = 16;
+        break;
+    case HIP_ESP_3DES_SHA1:
+        ret = 24;
+        break;
+    case HIP_ESP_NULL_SHA1:
+    case HIP_ESP_NULL_NULL:
+        ret = 0;
+        break;
+    default:
+        HIP_ERROR("unknown tid=%d\n", tid);
+        HIP_ASSERT(0);
+        break;
+    }
+
+    return ret;
+}
+
+/**
+ * get hmac key length of a transform
+ *
+ * @param tid transform
+ * @return the encryption key length based of the chosen transform,
+ *         or negative  on error.
+ */
+int hip_hmac_key_length(int tid)
+{
+    int ret = -1;
+    switch (tid) {
+    case HIP_ESP_AES_SHA1:
+    case HIP_ESP_3DES_SHA1:
+    case HIP_ESP_NULL_SHA1:
+        ret = 20;
+        break;
+    case HIP_ESP_NULL_NULL:
+        ret = 0;
+        break;
+    default:
+        HIP_ERROR("unknown tid=%d\n", tid);
+        HIP_ASSERT(0);
+        break;
+    }
+
+    return ret;
+}
+
+
+/**
+ * get authentication key length for an ESP transform
+ *
+ * @param tid transform
+ * @return the authentication key length for the chosen transform.
+ * or negative on error
+ */
+int hip_auth_key_length_esp(int tid)
+{
+    int ret = -1;
+
+    switch (tid) {
+    case HIP_ESP_AES_SHA1:
+    case HIP_ESP_NULL_SHA1:
+    case HIP_ESP_3DES_SHA1:
+        ret = 20;
+        break;
+    case HIP_ESP_NULL_NULL:
+        ret = 0;
+        break;
+    default:
+        HIP_ERROR("unknown tid=%d\n", tid);
+        HIP_ASSERT(0);
+        break;
+    }
+
+    return ret;
+}
+

=== added file 'lib/core/keylen.h'
--- lib/core/keylen.h   1970-01-01 00:00:00 +0000
+++ lib/core/keylen.h   2010-03-10 11:34:35 +0000
@@ -0,0 +1,8 @@
+#ifndef HIP_LIB_CORE_KEYLEN_H
+#define HIP_LIB_CORE_KEYLEN_H
+
+int hip_auth_key_length_esp(int tid);
+int hip_hmac_key_length(int tid);
+int hip_enc_key_length(int tid);
+
+#endif /* HIP_LIB_CORE_KEYLEN_H */

=== modified file 'lib/core/misc.c'
--- lib/core/misc.c     2010-03-10 11:14:55 +0000
+++ lib/core/misc.c     2010-03-10 11:34:35 +0000
@@ -193,94 +193,6 @@
     return hip_hash_hit(ptr1) != hip_hash_hit(ptr2);
 }
 
-/**
- * get encryption key length for a transform
- *
- * @param tid transform
- * @return the encryption key length of the chosen transform,
- *         or negative  on error.
- */
-int hip_enc_key_length(int tid)
-{
-    int ret = -1;
-
-    switch (tid) {
-    case HIP_ESP_AES_SHA1:
-        ret = 16;
-        break;
-    case HIP_ESP_3DES_SHA1:
-        ret = 24;
-        break;
-    case HIP_ESP_NULL_SHA1:
-    case HIP_ESP_NULL_NULL:
-        ret = 0;
-        break;
-    default:
-        HIP_ERROR("unknown tid=%d\n", tid);
-        HIP_ASSERT(0);
-        break;
-    }
-
-    return ret;
-}
-
-/**
- * get hmac key length of a transform
- *
- * @param tid transform
- * @return the encryption key length based of the chosen transform,
- *         or negative  on error.
- */
-int hip_hmac_key_length(int tid)
-{
-    int ret = -1;
-    switch (tid) {
-    case HIP_ESP_AES_SHA1:
-    case HIP_ESP_3DES_SHA1:
-    case HIP_ESP_NULL_SHA1:
-        ret = 20;
-        break;
-    case HIP_ESP_NULL_NULL:
-        ret = 0;
-        break;
-    default:
-        HIP_ERROR("unknown tid=%d\n", tid);
-        HIP_ASSERT(0);
-        break;
-    }
-
-    return ret;
-}
-
-
-/**
- * get authentication key length for an ESP transform
- *
- * @param tid transform
- * @return the authentication key length for the chosen transform.
- * or negative on error
- */
-int hip_auth_key_length_esp(int tid)
-{
-    int ret = -1;
-
-    switch (tid) {
-    case HIP_ESP_AES_SHA1:
-    case HIP_ESP_NULL_SHA1:
-    case HIP_ESP_3DES_SHA1:
-        ret = 20;
-        break;
-    case HIP_ESP_NULL_NULL:
-        ret = 0;
-        break;
-    default:
-        HIP_ERROR("unknown tid=%d\n", tid);
-        HIP_ASSERT(0);
-        break;
-    }
-
-    return ret;
-}
 
 /**
  * convert a string into a binary IPv4 address (a wrapper for inet_pton())
@@ -376,11 +288,6 @@
     return err;
 }
 
-
-
-
-
-
 /**
  * get the state of the bex for a pair of ip addresses.
  *

=== modified file 'lib/core/misc.h'
--- lib/core/misc.h     2010-03-09 21:23:38 +0000
+++ lib/core/misc.h     2010-03-10 11:34:35 +0000
@@ -123,9 +123,6 @@
 int convert_string_to_address_v4(const char *str, struct in_addr *ip);
 int convert_string_to_address(const char *str, struct in6_addr *ip6);
 
-int hip_auth_key_length_esp(int tid);
-int hip_hmac_key_length(int tid);
-int hip_enc_key_length(int tid);
 uint64_t hip_get_current_birthday(void);
 int hip_convert_hit_to_str(const hip_hit_t *hit, const char *prefix, char 
*str);
 

=== modified file 'lib/tool/xfrmapi.c'
--- lib/tool/xfrmapi.c  2010-03-09 18:26:22 +0000
+++ lib/tool/xfrmapi.c  2010-03-10 11:34:35 +0000
@@ -19,6 +19,7 @@
 #include "config.h"
 #include "lib/tool/nlink.h"
 #include "lib/core/hip_udp.h"
+#include "lib/core/keylen.h"
 
 #include "xfrmapi.h"
 

=== modified file 'test/auth_performance.c'
--- test/auth_performance.c     2010-03-09 18:26:22 +0000
+++ test/auth_performance.c     2010-03-10 11:34:35 +0000
@@ -19,6 +19,7 @@
 
 #include "config.h"
 #include "lib/core/hip_statistics.h"
+#include "lib/core/keylen.h"
 #include "lib/core/crypto.h"
 
 // only use ecdsa when available

Other related posts:

  • » [hipl-commit] [trunk] Rev 3905: Splitting misc.c continued (bug id 1139). Separate file for key lengths. - Miika Komu