Skip to contentSkip to conversation

Opkg support for smime (pkcs7) packages list signing

PATCH In review Camille Moncelier 2 participants 3 messages Oct 15, 2009 – Oct 26, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Opkg support for smime (pkcs7) packages list signing

As promised :) here is a patch allowing opkg to authenticate a package list using smime and openssl instead of gpgme

Example:

# Sign a package list:
openssl smime -sign -in /path/to/repo/Packages \
       -signer /root/server.pem -binary \
       -outform PEM -out /path/to/repo/Packages.sig

# Configuration in /etc/opkg/opkg.conf
option check_signature 1
option signature_ca_file /etc/serverCA.pem

# option signature_ca_path /path/to/certs/dir
# opkg update
Downloading http://repo:8000/Packages
Updated list of available packages in /usr/lib/opkg/lists/angstrom
Downloading http://repo:8000/Packages.sig
Signature check passed

# Package list corruption or MIM:
Downloading http://repo:8000/Packages
Updated list of available packages in /usr/lib/opkg/lists/angstrom Downloading http://repo:8000/Packages.sig
Signature check failed
Collected errors:
 * Verification failure

Camille Moncelier
http://devlife.org/

opkg_cmd.c +5 -4
Index: libopkg/opkg_cmd.c
===================================================================
@@ -259,8 +259,7 @@
 			    list_file_name);
 	  }
 	  free(url);
-
-#ifdef HAVE_GPGME
+#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
           if (conf->check_signature) {
               /* download detached signitures to verify the package lists */
               /* get the url for the sig file */
@@ -273,7 +272,8 @@
               /* create temporary file for it */
               char *tmp_file_name;
 
-              sprintf_alloc (&tmp_file_name, "%s/%s", tmp, "Packages.sig");
+              /* Put the signature in the right place */
+              sprintf_alloc (&tmp_file_name, "%s/%s.sig", lists_dir, src->name);
 
               err = opkg_download(conf, url, tmp_file_name, NULL, NULL);
               if (err) {
@@ -287,7 +287,8 @@
                   else
                       opkg_message (conf, OPKG_NOTICE, "Signature check failed\n");
               }
-              unlink (tmp_file_name);
+              /* We shouldn't unlink the signature ! */
+              // unlink (tmp_file_name);
               free (tmp_file_name);
               free (url);
           }
opkg.c +1 -1
Index: libopkg/opkg.c
===================================================================
@@ -850,7 +850,7 @@
     }
     free (url);
 
-#ifdef HAVE_GPGME
+#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
     if ( opkg->conf->check_signature ) {
         char *sig_file_name;
         /* download detached signitures to verify the package lists */
opkg_conf.c +2 -0
Index: libopkg/opkg_conf.c
===================================================================
@@ -75,6 +75,8 @@
 	  { "proxy_user", OPKG_OPT_TYPE_STRING, &conf->proxy_user },
 	  { "query-all", OPKG_OPT_TYPE_BOOL, &conf->query_all },
 	  { "verbosity", OPKG_OPT_TYPE_BOOL, &conf->verbosity },
+	  { "signature_ca_file", OPKG_OPT_TYPE_STRING, &conf->signature_ca_file },
+	  { "signature_ca_path", OPKG_OPT_TYPE_STRING, &conf->signature_ca_path },
 	  { NULL }
      };
 
opkg_conf.h +3 -0
Index: libopkg/opkg_conf.h
===================================================================
@@ -82,6 +82,9 @@
      char *proxy_user;
      char *proxy_passwd;
 
+     char *signature_ca_file;
+     char *signature_ca_path;
+
      hash_table_t pkg_hash;
      hash_table_t file_hash;
      hash_table_t obs_file_hash;
opkg_download.c +140 -2

168 lines not on this page · raw message

opkg_install.c +3 -1
Index: libopkg/opkg_install.c
===================================================================
@@ -834,7 +834,7 @@
      }
 
      /* check that the repository is valid */
-     #if HAVE_GPGME
+     #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL)
      char *list_file_name, *sig_file_name, *lists_dir;
 
      /* check to ensure the package has come from a repository */
@@ -851,6 +851,8 @@
        {
          if (opkg_verify_file (conf, list_file_name, sig_file_name))
            return OPKG_INSTALL_ERR_SIGNATURE;
+       }else{
+         return OPKG_INSTALL_ERR_SIGNATURE;
        }
 
        free (lists_dir);
args.c +1 -1
Index: libopkg/args.c
===================================================================
@@ -62,7 +62,7 @@
      if (conf_file_dir == NULL || conf_file_dir[0] == '\0') {
 	  conf_file_dir = ARGS_DEFAULT_CONF_FILE_DIR;
      }
-     sprintf_alloc(&args->conf_file, "%s/%s", conf_file_dir,
+     sprintf_alloc(&args->conf_file, "%s/%s", OPKGETCDIR,
 		   ARGS_DEFAULT_CONF_FILE_NAME);
 
      args->force_defaults = ARGS_DEFAULT_FORCE_DEFAULTS;
configure.ac +23 -0
Index: configure.ac
===================================================================
@@ -37,7 +37,18 @@
   AC_DEFINE(HAVE_CURL, 1, [Define if you want CURL support])
 fi
 
+# check for openssl
+AC_ARG_ENABLE(openssl,
+              AC_HELP_STRING([--enable-openssl], [Enable signature checking with OpenSSL
+      [[default=no]] ]),
+    [want_openssl="$enableval"], [want_openssl="no"])
 
+if test "x$want_openssl" = "xyes"; then
+  PKG_CHECK_MODULES(OPENSSL, openssl)
+  AC_DEFINE(HAVE_OPENSSL, 1, [Define if you want OpenSSL support])
+fi
+
+
 dnl **********
 dnl GPGME
 dnl **********
@@ -160,6 +171,18 @@
 fi
 
 
+dnl Some special cases for the wow64 build
+if test "x$want_gpgme" = "xyes"
+then
+	if test "x$want_openssl" = "xyes"
+	then
+	AC_MSG_ERROR([--enable-gpg and --enable-openssl are mutually exclusive.
+Use --disable-gpg if you want OpenSSL smime signatures])
+	fi
+fi
+
+
+
 AC_SUBST(opkglibdir)
 AC_SUBST(opkgetcdir)
 
#2 lore raw

Hi,

Quoted 2 lines · Camille Moncelier

As promised :) here is a patch allowing opkg to authenticate a package list using smime and openssl instead of gpgme

nice, this might be an interesting feature in future. Any reaction from the opkg maintainers so far?

Greetings

Florian

Signature · 5 lines
The dream of yesterday                  Florian Boor
is the hope of today                    Tel: +49 271-771091-15
and the reality of tomorrow.            Fax: +49 271-771091-19
[Robert Hutchings Goddard, 1904]        [email protected]
                                        http://www.kernelconcepts.de/en
#3 lore raw

Nope, no reactions, it seems opkg mainteners are quite busy sometimes.

Quoted 29 lines · Florian Boor

Hi,

Quoted 2 lines · Camille Moncelier

As promised :) here is a patch allowing opkg to authenticate a package list using smime and openssl instead of gpgme

nice, this might be an interesting feature in future. Any reaction from the opkg maintainers so far?

Greetings

Florian

--
The dream of yesterday                  Florian Boor
is the hope of today                    Tel: +49 271-771091-15 and the reality of tomorrow.            Fax: +49 271-771091-19 [Robert Hutchings Goddard, 1904]        [email protected]
                                       http://www.kernelconcepts.de/en

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "opkg-devel" group. To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/opkg-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Signature · 2 lines
Camille Moncelier
http://devlife.org/