[packaging] Branch 'upstream' - 3 commits - Horde_Secret-0.0.2/Secret.php package.xml

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Sat Jan 15 00:14:04 CET 2011


 Horde_Secret-0.0.2/Secret.php |  173 ++++++++++++++++++++++++++++++++++++++++++
 package.xml                   |   69 ++++++++++++++++
 2 files changed, 242 insertions(+)

New commits:
commit 2592df611b16d9773ccc20fafdece05f7434875e
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Jan 14 21:43:48 2011 +0100

    Imported Upstream version 0.0.2


commit 7f48eefbcdaf5345965fd99f9290bda040402989
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Jan 14 21:43:47 2011 +0100

    Imported Upstream version 0.0.2

diff --git a/Horde_Secret-0.0.2/Secret.php b/Horde_Secret-0.0.2/Secret.php
new file mode 100644
index 0000000..70ac926
--- /dev/null
+++ b/Horde_Secret-0.0.2/Secret.php
@@ -0,0 +1,173 @@
+<?php
+/**
+ * The Secret:: class provides an API for encrypting and decrypting
+ * small pieces of data with the use of a shared key.
+ *
+ * The Secret:: functions use the Horde Cipher:: class if mcrypt is not
+ * available.
+ *
+ * $Horde: framework/Secret/Secret.php,v 1.51 2006/02/28 18:11:51 slusarz Exp $
+ *
+ * Copyright 1999-2006 Chuck Hagenbuch <chuck at horde.org>
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author  Chuck Hagenbuch <chuck at horde.org>
+ * @since   Horde 1.3
+ * @package Horde_Secret
+ */
+class Secret {
+
+    /**
+     * Take a small piece of data and encrypt it with a key.
+     *
+     * @param string $key      The key to use for encryption.
+     * @param string $message  The plaintext message.
+     *
+     * @return string  The ciphertext message.
+     */
+    function write($key, $message)
+    {
+        if (Util::extensionExists('mcrypt')) {
+            $td = @mcrypt_module_open(MCRYPT_GOST, '', MCRYPT_MODE_ECB, '');
+            if ($td) {
+                $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
+                @mcrypt_generic_init($td, $key, $iv);
+                $encrypted_data = @mcrypt_generic($td, $message);
+                @mcrypt_generic_deinit($td);
+
+                return $encrypted_data;
+            }
+        }
+
+        static $cipherCache = array();
+        $cacheIdx = md5($key);
+
+        if (!isset($cipherCache[$cacheIdx])) {
+            require_once 'Horde/Cipher.php';
+
+            $cipherCache[$cacheIdx] = &Horde_Cipher::factory('blowfish');
+            $cipherCache[$cacheIdx]->setBlockMode('ofb64');
+            $cipherCache[$cacheIdx]->setKey($key);
+        }
+
+        return $cipherCache[$cacheIdx]->encrypt($message);
+    }
+
+    /**
+     * Decrypt a message encrypted with Secret::write().
+     *
+     * @param string $key      The key to use for decryption.
+     * @param string $message  The ciphertext message.
+     *
+     * @return string  The plaintext message.
+     */
+    function read($key, $ciphertext)
+    {
+        if (Util::extensionExists('mcrypt')) {
+            $td = @mcrypt_module_open(MCRYPT_GOST, '', MCRYPT_MODE_ECB, '');
+            if ($td) {
+                $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
+                @mcrypt_generic_init($td, $key, $iv);
+                $decrypted_data = @mdecrypt_generic($td, $ciphertext);
+                @mcrypt_generic_deinit($td);
+
+                // Strip padding characters.
+                return rtrim($decrypted_data, "\0");
+            }
+        }
+
+        static $cipherCache;
+        $cacheIdx = md5($key);
+
+        if (!is_array($cipherCache) || !isset($cipherCache[$cacheIdx])) {
+            require_once 'Horde/Cipher.php';
+
+            $cipherCache[$cacheIdx] = &Horde_Cipher::factory('blowfish');
+            $cipherCache[$cacheIdx]->setBlockMode('ofb64');
+            $cipherCache[$cacheIdx]->setKey($key);
+        }
+
+        return $cipherCache[$cacheIdx]->decrypt($ciphertext);
+    }
+
+    /**
+     * Generate a secret key (for encryption), either using a random
+     * md5 string and storing it in a cookie if the user has cookies
+     * enabled, or munging some known values if they don't.
+     *
+     * @param string $keyname  The name of the key to set.
+     *
+     * @return string  The secret key that has been generated.
+     */
+    function setKey($keyname = 'generic')
+    {
+        global $conf;
+
+        $timeout = $conf['session']['timeout'] ? time() + $conf['session']['timeout'] : 0;
+
+        if (isset($_COOKIE[$conf['session']['name']])) {
+            if (isset($_COOKIE[$keyname . '_key'])) {
+                $key = $_COOKIE[$keyname . '_key'];
+            } else {
+                $key = md5(mt_rand());
+                $_COOKIE[$keyname . '_key'] = $key;
+                @setcookie($keyname . '_key', $key, $timeout, $conf['cookie']['path'],
+                           $conf['cookie']['domain'], $conf['use_ssl'] == 1 ? 1 : 0);
+            }
+        } else {
+            $key = session_id();
+            @setcookie($keyname . '_key', $key, $timeout, $conf['cookie']['path'],
+                       $conf['cookie']['domain'], $conf['use_ssl'] == 1 ? 1 : 0);
+        }
+
+        return $key;
+    }
+
+    /**
+     * Return a secret key, either from a cookie, or if the cookie
+     * isn't there, assume we are using a munged version of a known
+     * base value.
+     *
+     * @param string $keyname  The name of the key to get.
+     *
+     * @return string  The secret key.
+     */
+    function getKey($keyname = 'generic')
+    {
+        static $keycache = array();
+
+        if (!isset($keycache[$keyname])) {
+            if (isset($_COOKIE[$keyname . '_key'])) {
+                $keycache[$keyname] = $_COOKIE[$keyname . '_key'];
+            } else {
+                global $conf;
+                $keycache[$keyname] = session_id();
+                @setcookie($keyname . '_key', $keycache[$keyname],
+                           $conf['session']['timeout'] ? time() + $conf['session']['timeout'] : 0,
+                           $conf['cookie']['path'], $conf['cookie']['domain'], $conf['use_ssl'] == 1 ? 1 : 0);
+            }
+        }
+
+        return $keycache[$keyname];
+    }
+
+    /**
+     * Clears a secret key entry from the current cookie.
+     *
+     * @param string $keyname  The name of the key to clear.
+     *
+     * @return boolean  True if key existed, false if not.
+     */
+    function clearKey($keyname = 'generic')
+    {
+        if (isset($_COOKIE[$GLOBALS['conf']['session']['name']]) &&
+            isset($_COOKIE[$keyname . '_key'])) {
+            unset($_COOKIE[$keyname . '_key']);
+            return true;
+        }
+        return false;
+    }
+
+}
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 2711a06..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,6 +0,0 @@
-php-horde-secret (0.0.2-1) stable; urgency=low
-
-  * Secret Encryption API
-
- -- Jeroen van Meeuwen <vanmeeuwen at kolabsys.com>  Fri, 14 Jan 2011 11:11:11 +1111
-
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 3f716f4..0000000
--- a/debian/control
+++ /dev/null
@@ -1,12 +0,0 @@
-Source: php-horde-secret
-Section: web
-Priority: optional
-Maintainer: Jeroen van Meeuwen <vanmeeuwen at kolabsys.com>
-Build-Depends: debhelper (>= 5)
-Build-Depends-Indep: php-pear, pear-horde-channel
-Standards-Version: 3.9.1
-
-Package: php-horde-secret
-Architecture: all
-Depends: php-pear (>= 5.2.0-8), pear-horde-channel
-Description: Secret Encryption API
diff --git a/debian/gbp.conf b/debian/gbp.conf
deleted file mode 100644
index f26a0d5..0000000
--- a/debian/gbp.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-[DEFAULT]
-debian-branch = master
-
-[git-buildpackage]
-export-dir = ../builds/php-horde-secret
-ignore-new = True
-upstream-tag = upstream/0.0.2
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 600cf2c..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/make -f
-
-PEAR ?= /usr/bin/pear
-pear_pkg = $(shell ls |grep Horde_Secret)
-package = php-horde-secret
-
-configure: configure-stamp
-configure-stamp:
-	dh_testdir
-	touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
-	dh_testdir
-	touch build-stamp
-
-clean:
-	dh_testdir
-	dh_testroot
-	if [ -f $(pear_pkg)/package.xml ]; then \
-	     rm $(pear_pkg)/package.xml; \
-	fi
-	dh_clean build-stamp configure-stamp
-
-install: build
-	dh_testdir
-	dh_testroot
-	dh_clean -k
-	dh_installdirs
-
-	# Add here commands to install the package into debian/package.
-	cp package.xml $(pear_pkg)/package.xml;
-	$(PEAR) install -O -n -f -P debian/$(package) $(pear_pkg)/package.xml;
-	rm -f debian/$(package)/usr/share/php/.filemap;
-	rm -f debian/$(package)/usr/share/php/.lock;
-	rm -rf debian/$(package)/usr/share/php/.channels;
-	rm -rf debian/$(package)/usr/share/php/.depdblock;
-	rm -rf debian/$(package)/usr/share/php/.depdb;
-	rm -rf debian/$(package)/usr/share/php/.registry/.channel.pecl.php.net;
-	rm -rf debian/$(package)/usr/share/php/.registry/.channel.__uri;
-
-	 # remove duplicated files, these files are in /usr/share/doc/package
-	rm -rf debian/$(package)/usr/share/php/tests;
-	rm -rf debian/$(package)/usr/share/php/docs;
-
-	 # remove created tmp dir
-	rm -rf debian/$(package)/tmp
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-	dh_testdir
-	dh_testroot
-	dh_installdocs
-	dh_installexamples
-	dh_installchangelogs
-	dh_compress
-	dh_fixperms
-	dh_installdeb
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
-
diff --git a/package.xml b/package.xml
new file mode 100644
index 0000000..6565a21
--- /dev/null
+++ b/package.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Horde_Secret</name>
+ <channel>pear.horde.org</channel>
+ <summary>Secret Encryption API</summary>
+ <description>The Secret:: class provides an API for encrypting and decrypting small pieces of data with the use of a shared key.</description>
+ <lead>
+  <name>Chuck Hagenbuch</name>
+  <user>chuck</user>
+  <email>chuck at horde.org</email>
+  <active>yes</active>
+ </lead>
+ <date>2006-05-08</date>
+ <time>23:11:03</time>
+ <version>
+  <release>0.0.2</release>
+  <api>0.0.2</api>
+ </version>
+ <stability>
+  <release>alpha</release>
+  <api>alpha</api>
+ </stability>
+ <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
+ <notes>Converted to package.xml 2.0 for pear.horde.org</notes>
+ <contents>
+  <dir name="/">
+   <file baseinstalldir="/Horde" md5sum="0896a6d9c627562588d909e2535d0e0d" name="Secret.php" role="php" />
+  </dir>
+ </contents>
+ <dependencies>
+  <required>
+   <php>
+    <min>4.0.0</min>
+   </php>
+   <pearinstaller>
+    <min>1.4.0b1</min>
+   </pearinstaller>
+   <package>
+    <name>Horde_Cipher</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
+    <name>Horde_Util</name>
+    <channel>pear.horde.org</channel>
+   </package>
+  </required>
+  <optional>
+   <extension>
+    <name>mcrypt</name>
+   </extension>
+  </optional>
+ </dependencies>
+ <phprelease />
+ <changelog>
+  <release>
+   <version>
+    <release>0.0.1</release>
+    <api>0.0.1</api>
+   </version>
+   <stability>
+    <release>alpha</release>
+    <api>alpha</api>
+   </stability>
+   <date>2003-07-05</date>
+   <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
+   <notes>Initial release as a PEAR package</notes>
+  </release>
+ </changelog>
+</package>


commit 2b82884971f0788e99b1e25633eb17d4c34ce617
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Jan 14 21:43:46 2011 +0100

    Initial debian packaging

diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..2711a06
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,6 @@
+php-horde-secret (0.0.2-1) stable; urgency=low
+
+  * Secret Encryption API
+
+ -- Jeroen van Meeuwen <vanmeeuwen at kolabsys.com>  Fri, 14 Jan 2011 11:11:11 +1111
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..3f716f4
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,12 @@
+Source: php-horde-secret
+Section: web
+Priority: optional
+Maintainer: Jeroen van Meeuwen <vanmeeuwen at kolabsys.com>
+Build-Depends: debhelper (>= 5)
+Build-Depends-Indep: php-pear, pear-horde-channel
+Standards-Version: 3.9.1
+
+Package: php-horde-secret
+Architecture: all
+Depends: php-pear (>= 5.2.0-8), pear-horde-channel
+Description: Secret Encryption API
diff --git a/debian/gbp.conf b/debian/gbp.conf
new file mode 100644
index 0000000..f26a0d5
--- /dev/null
+++ b/debian/gbp.conf
@@ -0,0 +1,7 @@
+[DEFAULT]
+debian-branch = master
+
+[git-buildpackage]
+export-dir = ../builds/php-horde-secret
+ignore-new = True
+upstream-tag = upstream/0.0.2
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..600cf2c
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,70 @@
+#!/usr/bin/make -f
+
+PEAR ?= /usr/bin/pear
+pear_pkg = $(shell ls |grep Horde_Secret)
+package = php-horde-secret
+
+configure: configure-stamp
+configure-stamp:
+	dh_testdir
+	touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+	dh_testdir
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	if [ -f $(pear_pkg)/package.xml ]; then \
+	     rm $(pear_pkg)/package.xml; \
+	fi
+	dh_clean build-stamp configure-stamp
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	# Add here commands to install the package into debian/package.
+	cp package.xml $(pear_pkg)/package.xml;
+	$(PEAR) install -O -n -f -P debian/$(package) $(pear_pkg)/package.xml;
+	rm -f debian/$(package)/usr/share/php/.filemap;
+	rm -f debian/$(package)/usr/share/php/.lock;
+	rm -rf debian/$(package)/usr/share/php/.channels;
+	rm -rf debian/$(package)/usr/share/php/.depdblock;
+	rm -rf debian/$(package)/usr/share/php/.depdb;
+	rm -rf debian/$(package)/usr/share/php/.registry/.channel.pecl.php.net;
+	rm -rf debian/$(package)/usr/share/php/.registry/.channel.__uri;
+
+	 # remove duplicated files, these files are in /usr/share/doc/package
+	rm -rf debian/$(package)/usr/share/php/tests;
+	rm -rf debian/$(package)/usr/share/php/docs;
+
+	 # remove created tmp dir
+	rm -rf debian/$(package)/tmp
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installdocs
+	dh_installexamples
+	dh_installchangelogs
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
+




More information about the packaging-commits mailing list