Chris Hillery has proposed merging lp:~zorba-coders/zorba/bug-1188056 into 
lp:zorba/security-module.

Requested reviews:
  Zorba Coders (zorba-coders)
Related bugs:
  Bug #1188056 in Zorba: "Update non-core module "security""
  https://bugs.launchpad.net/zorba/+bug/1188056

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1188056/+merge/182790
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1188056/+merge/182790
Your team Zorba Coders is requested to review the proposed merge of 
lp:~zorba-coders/zorba/bug-1188056 into lp:zorba/security-module.
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt	2012-07-20 16:13:37 +0000
+++ src/CMakeLists.txt	2013-08-29 00:28:25 +0000
@@ -13,14 +13,14 @@
 # limitations under the License.
 
 DECLARE_ZORBA_MODULE (
-  URI "http://www.zorba-xquery.com/modules/cryptography/hmac";
-  VERSION 2.0
+  URI "http://zorba.io/modules/hmac";
+  VERSION 1.0
   FILE "hmac.xq"
   LINK_LIBRARIES ${OPENSSL_LIBRARIES}
 )
 DECLARE_ZORBA_MODULE (
-  URI "http://www.zorba-xquery.com/modules/cryptography/hash";
-  VERSION 2.0
+  URI "http://zorba.io/modules/hash";
+  VERSION 1.0
   FILE "hash.xq"
   LINK_LIBRARIES ${OPENSSL_LIBRARIES}
 )

=== modified file 'src/hash.xq'
--- src/hash.xq	2013-08-09 09:37:05 +0000
+++ src/hash.xq	2013-08-29 00:28:25 +0000
@@ -1,4 +1,4 @@
-xquery version "1.0";
+xquery version "3.0";
 
 (:
  : Copyright 2006-2012 The FLWOR Foundation.
@@ -24,10 +24,10 @@
  : @author Gabriel Petrovay, Markus Pilman, Matthias Brantner
  : @project Zorba/Cryptography/Hash
  :)
-module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hash";;
+module namespace hash = "http://zorba.io/modules/hash";;
 
 declare namespace ver = "http://zorba.io/options/versioning";;
-declare option ver:module-version "2.0";
+declare option ver:module-version "1.0";
 
 (:~
  : Computes the MD5 hash of the string provided as parameter.

=== modified file 'src/hash.xq.src/hash.h'
--- src/hash.xq.src/hash.h	2013-07-30 18:47:17 +0000
+++ src/hash.xq.src/hash.h	2013-08-29 00:28:25 +0000
@@ -49,7 +49,7 @@
     virtual ~HashModule();
     
     virtual String
-    getURI() const { return "http://www.zorba-xquery.com/modules/cryptography/hash";; }
+    getURI() const { return "http://zorba.io/modules/hash";; }
     
     virtual ExternalFunction*
     getExternalFunction(const String& aLocalname);
@@ -120,16 +120,17 @@
       {
         if (aMessage.getTypeCode() == store::XS_BASE64BINARY)
         {
-          String lTmpDecodedBuf;
           size_t lLen;
           const char* lTmp = aMessage.getBase64BinaryValue(lLen);
+          char *lTmpDecodedBuf;
           if (aDecode)
           {
-            String lTmpEncoded;
             // lTmpDecodedBuf is used to make sure lMsg is still alive during HMAC_Update
-            base64::decode(lTmp, lLen, &lTmpDecodedBuf);
-            lTmp = lTmpDecodedBuf.c_str();
-            lLen = lTmpDecodedBuf.size();
+            lTmpDecodedBuf = (char *)malloc(lLen*sizeof(char)+1);
+            base64::decode(lTmp, lLen, lTmpDecodedBuf);
+            lTmp = lTmpDecodedBuf;
+            lLen = strlen(lTmpDecodedBuf);
+            free(lTmpDecodedBuf);
           }
           (*hash)(
             reinterpret_cast<const unsigned char*>(lTmp),

=== modified file 'src/hmac.xq'
--- src/hmac.xq	2013-08-09 09:37:05 +0000
+++ src/hmac.xq	2013-08-29 00:28:25 +0000
@@ -1,4 +1,4 @@
-xquery version "1.0";
+xquery version "3.0";
 
 (:
  : Copyright 2006-2012 The FLWOR Foundation.
@@ -28,10 +28,10 @@
  : @project Zorba/Cryptography/HMAC
  :
  :)
-module namespace hmac = "http://www.zorba-xquery.com/modules/cryptography/hmac";;
+module namespace hmac = "http://zorba.io/modules/hmac";;
 
 declare namespace ver = "http://zorba.io/options/versioning";;
-declare option ver:module-version "2.0";
+declare option ver:module-version "1.0";
 
 (:~
  : Calculate the HMAC for the given message and secret-key involving

=== modified file 'src/hmac.xq.src/hmac.cpp'
--- src/hmac.xq.src/hmac.cpp	2013-07-30 18:36:20 +0000
+++ src/hmac.xq.src/hmac.cpp	2013-08-29 00:28:25 +0000
@@ -120,7 +120,7 @@
     lMsg << aAlg << ": unsupported hash algorithm";
     throw USER_EXCEPTION(
         HMACModule::getItemFactory()->createQName(
-        "http://www.zorba-xquery.com/modules/cryptography/hmac";, "unsupported-algorithm"),
+        "http://zorba.io/modules/hmac";, "unsupported-algorithm"),
         lMsg.str());
   }
 }
@@ -213,16 +213,17 @@
   }
   else
   {
-    String lTmpDecodedBuf;
     size_t lSize;
     const char* lMsg = lItem.getBase64BinaryValue(lSize);
+    char *lTmpDecodedBuf;
     if (lItem.isEncoded())
     {
-      String lTmpEncoded;
       // lTmpDecodedBuf is used to make sure lMsg is still alive during HMAC_Update
-      base64::decode(lMsg, lSize, &lTmpDecodedBuf);
-      lMsg = lTmpDecodedBuf.c_str();
-      lSize = lTmpDecodedBuf.size();
+      lTmpDecodedBuf = (char *)malloc(lSize*sizeof(char)+1);
+      base64::decode(lMsg, lSize, lTmpDecodedBuf);
+      lMsg = lTmpDecodedBuf;
+      lSize = strlen(lTmpDecodedBuf);
+      free(lTmpDecodedBuf);
     }
     HMAC_Update(
         &ctx,

=== modified file 'src/hmac.xq.src/hmac.h'
--- src/hmac.xq.src/hmac.h	2012-07-20 16:13:37 +0000
+++ src/hmac.xq.src/hmac.h	2013-08-29 00:28:25 +0000
@@ -49,7 +49,7 @@
       virtual ~HMACModule();
   
       virtual String
-      getURI() const { return "http://www.zorba-xquery.com/modules/cryptography/hmac";; }
+      getURI() const { return "http://zorba.io/modules/hmac";; }
   
       virtual ExternalFunction*
       getExternalFunction(const String& aLocalname);

=== modified file 'test/Queries/security/hash-binary.xq'
--- test/Queries/security/hash-binary.xq	2012-07-20 03:32:59 +0000
+++ test/Queries/security/hash-binary.xq	2013-08-29 00:28:25 +0000
@@ -1,4 +1,4 @@
-import module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hash";;
+import module namespace hash = "http://zorba.io/modules/hash";;
 import module namespace f = "http://expath.org/ns/file";;
 
 xs:hexBinary(hash:hash-binary(f:read-binary(resolve-uri("ls")), "sha256"))

=== modified file 'test/Queries/security/hash-binary2.xq'
--- test/Queries/security/hash-binary2.xq	2012-10-23 21:12:37 +0000
+++ test/Queries/security/hash-binary2.xq	2013-08-29 00:28:25 +0000
@@ -1,5 +1,5 @@
 import module namespace f = "http://expath.org/ns/file";;
-import module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hash";;
+import module namespace hash = "http://zorba.io/modules/hash";;
 
 variable $f := f:read-binary(resolve-uri("ls"));
 

=== modified file 'test/Queries/security/hash-md5.xq'
--- test/Queries/security/hash-md5.xq	2012-07-20 16:13:37 +0000
+++ test/Queries/security/hash-md5.xq	2013-08-29 00:28:25 +0000
@@ -1,5 +1,5 @@
 (: Values compared to php -r 'echo base64_encode(sha1($string, true));' :)
-import module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hash";;
+import module namespace hash = "http://zorba.io/modules/hash";;
 
 xs:hexBinary(hash:md5("abc")),
 hash:md5("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")

=== modified file 'test/Queries/security/hash-sha1.xq'
--- test/Queries/security/hash-sha1.xq	2011-07-05 03:24:29 +0000
+++ test/Queries/security/hash-sha1.xq	2013-08-29 00:28:25 +0000
@@ -1,5 +1,5 @@
 (: Values compared to php -r 'echo base64_encode(sha1($string, true));' :)
-import module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hash";;
+import module namespace hash = "http://zorba.io/modules/hash";;
 
 hash:sha1("abc"),
 hash:sha1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")

=== modified file 'test/Queries/security/hash-sha256.xq'
--- test/Queries/security/hash-sha256.xq	2012-07-20 16:13:37 +0000
+++ test/Queries/security/hash-sha256.xq	2013-08-29 00:28:25 +0000
@@ -1,5 +1,5 @@
 (: Values compared to php -r 'echo base64_encode(sha1($string, true));' :)
-import module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hash";;
+import module namespace hash = "http://zorba.io/modules/hash";;
 
 hash:hash("abc", "sha256"),
 hash:hash("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "sha256"),

=== modified file 'test/Queries/security/hmac-sha1.xq'
--- test/Queries/security/hmac-sha1.xq	2011-07-05 03:24:29 +0000
+++ test/Queries/security/hmac-sha1.xq	2013-08-29 00:28:25 +0000
@@ -1,4 +1,4 @@
-import module namespace hmac = "http://www.zorba-xquery.com/modules/cryptography/hmac";;
+import module namespace hmac = "http://zorba.io/modules/hmac";;
 
 hmac:sha1("foo", "bar"),
 hmac:sha1("GET&amp;http%3A%2F%2Ftwitter.com%2Faccount%2Fverify_credentials.xml&amp;oauth_consumer_key%3DAJNRLGd7aT0SvQMLjudog%26oauth_nonce%3D4996802908718844015%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1274195088%26oauth_token%3D131201600-tHRlNpwN6JmJsNjDYBgHgccV9fvdOD5e4f8j3BZd%26oauth_version%3D1.0", "TfV0JLBWBBslSuCLwrWcC8q4PxPGmFSgyhc4ewHNY4")

=== modified file 'test/Queries/security/hmac-sha256.xq'
--- test/Queries/security/hmac-sha256.xq	2012-07-20 16:13:37 +0000
+++ test/Queries/security/hmac-sha256.xq	2013-08-29 00:28:25 +0000
@@ -1,4 +1,4 @@
-import module namespace hash = "http://www.zorba-xquery.com/modules/cryptography/hmac";;
+import module namespace hash = "http://zorba.io/modules/hmac";;
 import module namespace f = "http://expath.org/ns/file";;
 
 hash:compute-binary(xs:base64Binary("Zm9vCg=="), "bar", "sha256"),

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to