[hipl-commit] [trunk] Rev 3655: Moved crypto.c from tools to core.

  • From: Miika Komu <miika@xxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 16 Feb 2010 23:54:28 +0200

Committer: Miika Komu <miika@xxxxxx>
Date: Tue Feb 16 23:54:14 2010 +0200
Revision: 3655
Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Moved crypto.c from tools to core.
  Fixed many tab problems to get the commit through.

Modified:
  R  lib/tool/crypto.c => lib/core/crypto.c
  R  lib/tool/crypto.h => lib/core/crypto.h
  M  Makefile.am
  M  firewall/rule_management.c
  M  hipd/blind.h
  M  hipd/close.h
  M  hipd/dh.h
  M  hipd/hipd.h
  M  hipd/input.c
  M  hipd/keymat.h
  M  lib/core/builder.c
  M  lib/core/getendpointinfo.c
  M  lib/tool/pk.c
  M  lib/tool/pk.h
  M  test/auth_performance.c
  M  test/dh_performance.c
  M  test/first_test.h
  M  test/hipsetup.c
  M  test/misc_install.h
  M  lib/core/crypto.c
  M  lib/core/crypto.h

=== modified file 'Makefile.am'
--- Makefile.am 2010-02-08 15:18:06 +0000
+++ Makefile.am 2010-02-16 21:54:14 +0000
@@ -10,7 +10,7 @@
 EXTRA_DIST += doc/base-exchange-relay.png doc/base-exchange-rvs.png
 EXTRA_DIST += hipsock jip
 EXTRA_DIST += test/packaging/create-package.sh
-EXTRA_DIST += test/packaging/hipl-rpm.spec test/packaging/hipl-deb.spec 
+EXTRA_DIST += test/packaging/hipl-rpm.spec test/packaging/hipl-deb.spec
 EXTRA_DIST += test/packaging/debbuild
 EXTRA_DIST += test/packaging/rh-init.d-hipd test/packaging/rh-init.d-hipfw 
test/packaging/rh-init.d-dnsproxy
 EXTRA_DIST += test/packaging/debian-init.d-hipd 
test/packaging/debian-init.d-hipfw test/packaging/debian-init.d-dnsproxy
@@ -257,7 +257,7 @@
                     hipd/hit_to_ip.c \
                     hipd/update_legacy.c \
                     hipd/hadb_legacy.c \
-                    hipd/heartbeat.c 
+                    hipd/heartbeat.c
 if HIP_I3
 hipd_hipd_SOURCES += hipd/hi3.c
 endif
@@ -350,14 +350,14 @@
                                  lib/core/sqlitedbapi.c \
                                  lib/core/hashchain_store.c \
                                  lib/core/hip_statistics.c \
-                                 lib/core/getendpointinfo.c
+                                 lib/core/getendpointinfo.c \
+                                 lib/core/crypto.c
 
 if HIP_PRIVSEP
 lib_core_libhipcore_la_SOURCES += lib/core/hip_capability.c
 endif
 
-lib_tool_libhiptool_la_SOURCES = lib/tool/crypto.c \
-                                 lib/tool/pk.c \
+lib_tool_libhiptool_la_SOURCES = lib/tool/pk.c \
                                  lib/tool/nlink.c \
                                  lib/tool/lutil.c
 
@@ -435,7 +435,7 @@
                               i3/chord/process.c \
                               i3/chord/stabilize.c \
                               i3/chord/util.c \
-                              i3/utils/gen_utils.c 
+                              i3/utils/gen_utils.c
 
 
 i3_chord_gen_conf_SOURCES = i3/chord/gen_conf.c
@@ -484,7 +484,7 @@
                                      i3/i3_client/ping_thread.c \
                                      i3/i3_client/http.c \
                                      i3/i3_client/qsort.c
-                                     
+
 i3_utils_libutils_a_SOURCES = i3/utils/byteorder.c \
                               i3/utils/eprintf.c \
                               i3/utils/gen_utils.c \
@@ -693,7 +693,7 @@
 if HIP_DHT
 agent_hipagent_LDADD += lib/dht/libhipdht.la
 endif
-                 
+
 if HIP_PERFORMANCE
 agent_hipagent_LDADD += lib/performance/libperformance.la
 endif
@@ -731,7 +731,7 @@
 endif
 
 CLEANFILES = tools/hipdnsproxy tools/hipdnskeyparse
-             
+
 ###### PYTHON stuff below ######
 # TODO python parts still needs clean-up
 if HAVE_PYTHON
@@ -753,19 +753,19 @@
              tools/DNS/lazy.py \
              tools/DNS/Status.py \
              tools/DNS/Serialization.py
-             
+
 dnsdir = $(pyexecdir)/tools/DNS
 
 tools_hipdnsproxy_PYTHON = tools/dnsproxy.py \
                            tools/pyip6.py \
                            tools/hosts.py \
                            tools/util.py
-                           
+
 tools_hipdnsproxydir = $(pyexecdir)/tools/hipdnsproxy
 
 tools_hipdnskeyparse_PYTHON = tools/parse-key-3.py \
                               tools/myasn.py
-                              
+
 tools_hipdnskeyparsedir = $(pyexecdir)/tools/hipdnskeyparse
 
 endif # HAVE_PYTHON

=== modified file 'firewall/rule_management.c'
--- firewall/rule_management.c  2010-02-14 12:08:28 +0000
+++ firewall/rule_management.c  2010-02-16 21:54:14 +0000
@@ -35,7 +35,7 @@
 #include "rule_management.h"
 #include "helpers.h"
 #include "lib/core/builder.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "lib/core/debug.h"
 
 /* string tokens for rule parsing */

=== modified file 'hipd/blind.h'
--- hipd/blind.h        2010-02-10 22:32:46 +0000
+++ hipd/blind.h        2010-02-16 21:54:14 +0000
@@ -2,7 +2,7 @@
 #define BLIND_H
 
 #include "lib/core/debug.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "lib/core/ife.h"
 #include "lib/core/state.h"
 #include "lib/core/builder.h"

=== modified file 'hipd/close.h'
--- hipd/close.h        2010-01-19 11:26:32 +0000
+++ hipd/close.h        2010-02-16 21:54:14 +0000
@@ -9,7 +9,7 @@
 #include "output.h"
 #include "lib/core/debug.h"
 #include "keymat.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "lib/core/misc.h"
 #include "lib/tool/pk.h"
 

=== modified file 'hipd/dh.h'
--- hipd/dh.h   2010-02-10 22:32:46 +0000
+++ hipd/dh.h   2010-02-16 21:54:14 +0000
@@ -2,7 +2,7 @@
 #define HIP_SECURITY_H
 
 #include "hadb.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 
 int hip_insert_dh(u8 *buffer, int bufsize, int group_id);
 void hip_dh_uninit(void);

=== modified file 'hipd/hipd.h'
--- hipd/hipd.h 2010-02-10 22:32:46 +0000
+++ hipd/hipd.h 2010-02-16 21:54:14 +0000
@@ -17,7 +17,7 @@
   #include "config.h"
 #endif /* HAVE_CONFIG_H */
 
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "cookie.h"
 #include "user.h"
 #include "lib/core/debug.h"

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-02-16 08:35:10 +0000
+++ hipd/input.c        2010-02-16 21:54:14 +0000
@@ -26,7 +26,7 @@
 #include "oppdb.h"
 #include "user.h"
 #include "keymat.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "lib/core/builder.h"
 #include "dh.h"
 #include "lib/core/misc.h"

=== modified file 'hipd/keymat.h'
--- hipd/keymat.h       2010-02-10 22:32:46 +0000
+++ hipd/keymat.h       2010-02-16 21:54:14 +0000
@@ -3,7 +3,7 @@
 
 #include "lib/core/list.h"
 #include "lib/core/misc.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "lib/core/state.h"
 
 void hip_make_keymat(char *kij, size_t kij_len,

=== modified file 'lib/core/builder.c'
--- lib/core/builder.c  2010-02-12 10:47:40 +0000
+++ lib/core/builder.c  2010-02-16 21:54:14 +0000
@@ -64,7 +64,7 @@
 
 #include "builder.h"
 #include "hipd/input.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 
 /* Not needed, already defined in netinet/in.h */
 /* #define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } */
@@ -4601,12 +4601,12 @@
 /**
  * Builds NAT port parameter
  *
- * @param msg          a pointer to a HIP packet common header
- * @param port         NAT port number
- * @param param                parameter to create. Currently it is either
- *          HIP_SET_SRC_NAT_PORT or HIP_SET_DST_NAT_PORT
+ * @param msg a pointer to a HIP packet common header
+ * @param port NAT port number
+ * @param param parameter to create. Currently it is either
+ *              HIP_SET_SRC_NAT_PORT or HIP_SET_DST_NAT_PORT
  *
- * @return     zero on success, non-zero otherwise.
+ * @return zero on success, non-zero otherwise.
  */
 int hip_build_param_nat_port(hip_common_t *msg,
                              const in_port_t port,

=== renamed file 'lib/tool/crypto.c' => 'lib/core/crypto.c'
--- lib/tool/crypto.c   2010-02-16 21:21:36 +0000
+++ lib/core/crypto.c   2010-02-16 21:54:14 +0000
@@ -7,8 +7,6 @@
  * Diffie-Hellman groups and shared key generation, DSA/RSA key
  * creation and disk storage, signing, verifying and HMAC creation.
  *
- * One function has been borrowed from OpenHIP (BN_bin2bn)
- *
  * @brief HIP crypto management functions using OpenSSL
  *
  * @author Mika Kousa <mkousa@xxxxxx>
@@ -442,25 +440,6 @@
     return err;
 }
 
-/**
- * BN_bin2bn() chops off the leading zero(es) of the BIGNUM,
- * so that numbers end up being left shifted. This fixes that by
- * enforcing an expected destination length
- *
- * @note This function is originally from OpenHIP
- */
-int bn2bin_safe(const BIGNUM *a, unsigned char *to, int len)
-{
-    int padlen = len - BN_num_bytes(a);
-    /* add leading zeroes when needed */
-    if (padlen > 0) {
-        memset(to, 0, padlen);
-    }
-    BN_bn2bin(a, &to[padlen]);
-    /* return value from BN_bn2bin() may differ from length */
-    return len;
-}
-
 /*
  * return 0 on success.
  */
@@ -687,11 +666,6 @@
 {
     RSA *rsa = NULL;
 
-    /* if (bits < 1 || bits > HIP_MAX_RSA_KEY_LEN) {
-     * HIP_ERROR("create_rsa_key failed (illegal bits value %d)\n", bits);
-     * goto err_out;
-     * } Checked before calling function */
-
     /* generate private and public keys */
 #ifdef ANDROID_CHANGES
     BIGNUM *bn;

=== renamed file 'lib/tool/crypto.h' => 'lib/core/crypto.h'
--- lib/tool/crypto.h   2010-02-11 00:01:07 +0000
+++ lib/core/crypto.h   2010-02-16 21:54:14 +0000
@@ -98,7 +98,6 @@
 int load_rsa_private_key(const char *filename, RSA **rsa);
 int load_dsa_public_key(const char *filenamebase, DSA **dsa);
 int load_rsa_public_key(const char *filename, RSA **rsa);
-int bn2bin_safe(const BIGNUM *a, unsigned char *to, int len);
 int impl_dsa_sign(u8 *digest, DSA *dsa, u8 *signature);
 int impl_dsa_verify(u8 *digest, DSA *dsa, u8 *signature);
 int hip_write_hmac(int type, const void *key, void *in, int in_len, void *out);

=== modified file 'lib/core/getendpointinfo.c'
--- lib/core/getendpointinfo.c  2010-02-16 19:01:36 +0000
+++ lib/core/getendpointinfo.c  2010-02-16 21:54:14 +0000
@@ -44,7 +44,7 @@
 #endif /* HAVE_CONFIG_H */
 
 #include "builder.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "icomm.h"
 #include "debug.h"
 #include "getendpointinfo.h"

=== modified file 'lib/tool/pk.c'
--- lib/tool/pk.c       2010-02-16 18:19:36 +0000
+++ lib/tool/pk.c       2010-02-16 21:54:14 +0000
@@ -239,3 +239,22 @@
 #endif
     return verify((DSA *) peer_pub, msg, 0);
 }
+
+/**
+ * BN_bin2bn() chops off the leading zero(es) of the BIGNUM,
+ * so that numbers end up being left shifted. This fixes that by
+ * enforcing an expected destination length
+ *
+ * @note This function is originally from OpenHIP
+ */
+int bn2bin_safe(const BIGNUM *a, unsigned char *to, int len)
+{
+    int padlen = len - BN_num_bytes(a);
+    /* add leading zeroes when needed */
+    if (padlen > 0) {
+        memset(to, 0, padlen);
+    }
+    BN_bn2bin(a, &to[padlen]);
+    /* return value from BN_bn2bin() may differ from length */
+    return len;
+}

=== modified file 'lib/tool/pk.h'
--- lib/tool/pk.h       2010-02-16 18:19:36 +0000
+++ lib/tool/pk.h       2010-02-16 21:54:14 +0000
@@ -2,11 +2,12 @@
 #define HIP_PK_H
 
 #include "hipd/hidb.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 
 int hip_dsa_verify(void *priv_key, struct hip_common *msg);
 int hip_dsa_sign(void *peer_pub, struct hip_common *msg);
 int hip_rsa_verify(void *priv_key, struct hip_common *msg);
 int hip_rsa_sign(void *peer_pub, struct hip_common *msg);
+int bn2bin_safe(const BIGNUM *a, unsigned char *to, int len);
 
 #endif /* HIP_PK_H */

=== modified file 'test/auth_performance.c'
--- test/auth_performance.c     2010-02-11 09:57:04 +0000
+++ test/auth_performance.c     2010-02-16 21:54:14 +0000
@@ -9,7 +9,7 @@
 #endif /* HAVE_CONFIG_H */
 
 #include "lib/core/hip_statistics.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #ifdef CONFIG_HIP_ECDSA
 #include <openssl/ecdsa.h>
 #endif /* CONFIG_HIP_ECDSA  */
@@ -23,9 +23,9 @@
 #define ECDSA_CURVE NID_sect163r1
 
 /*!
- * \brief   Determine and print the gettimeofday time resolution.
+ * \brief Determine and print the gettimeofday time resolution.
  *
- * \author     Tobias Heer
+ * \author Tobias Heer
  *
  * Determine the time resolution of gettimeofday.
  *

=== modified file 'test/dh_performance.c'
--- test/dh_performance.c       2010-02-12 10:47:40 +0000
+++ test/dh_performance.c       2010-02-16 21:54:14 +0000
@@ -23,7 +23,7 @@
   #include "config.h"
 #endif /* HAVE_CONFIG_H */
 
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "lib/core/hashchain.h"
 
 #include "lib/performance/performance.h"
@@ -76,7 +76,7 @@
  *
  * Prints all possible command line options.
  *
- * \author     Tobias Heer
+ * \author Tobias Heer
  *
  * \param progname The name of the executable
  * \return void
@@ -105,7 +105,7 @@
  *
  * Takes the input parameters, parses them and returns the option switches.
  *
- * \author     Tobias Heer
+ * \author Tobias Heer
  *
  * \param argv The arguments array.
  * \param sw_create_dh How many DH keys should be used?
@@ -248,9 +248,9 @@
 }
 
 /*!
- * \brief   Determine and print the gettimeofday time resolution.
+ * \brief Determine and print the gettimeofday time resolution.
  *
- * \author     Tobias Heer
+ * \author Tobias Heer
  *
  * Determine the time resolution of gettimeofday.
  *
@@ -282,7 +282,7 @@
  *
  * Starts a time interval.
  *
- * \author     Tobias Heer
+ * \author Tobias Heer
  *
  * \param timeval timeval struct from the OS.
  * \return void
@@ -297,7 +297,7 @@
  *
  * Concludes a time interval and returns the past time.
  *
- * \author     Tobias Heer
+ * \author Tobias Heer
  *
  * \param timeval timeval struct from the OS.
  * \return passed time since beginning of the interval.
@@ -313,7 +313,7 @@
 /*!
  * \brief Main function that performs the measurements.
  *
- * \author     Tobias Heer
+ * \author Tobias Heer
  *
  * \param argc Number of command line arguments
  * \param argv Command line argument array

=== modified file 'test/first_test.h'
--- test/first_test.h   2010-01-19 11:26:32 +0000
+++ test/first_test.h   2010-02-16 21:54:14 +0000
@@ -7,7 +7,7 @@
 
 #include "conntest.h"
 #include "lib/core/debug.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "misc_install.h"
 
 #define DEFAULT_PORT 1111

=== modified file 'test/hipsetup.c'
--- test/hipsetup.c     2010-02-11 09:57:04 +0000
+++ test/hipsetup.c     2010-02-16 21:54:14 +0000
@@ -7,7 +7,7 @@
 #include <unistd.h>
 
 #include "lib/core/debug.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 #include "hipsetup.h"
 #include "misc_install.h"
 #include "lib/core/getendpointinfo.h"

=== modified file 'test/misc_install.h'
--- test/misc_install.h 2010-01-19 11:26:32 +0000
+++ test/misc_install.h 2010-02-16 21:54:14 +0000
@@ -7,7 +7,7 @@
 #include <unistd.h>
 #include "conntest.h"
 #include "lib/core/debug.h"
-#include "lib/tool/crypto.h"
+#include "lib/core/crypto.h"
 
 int init_daemon(void);
 int install_module(void);

Other related posts:

  • » [hipl-commit] [trunk] Rev 3655: Moved crypto.c from tools to core. - Miika Komu