gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libfints] branch master updated: Polishing INI content gen


From: gnunet
Subject: [GNUnet-SVN] [libfints] branch master updated: Polishing INI content generator.
Date: Thu, 11 Oct 2018 15:44:33 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository libfints.

The following commit(s) were added to refs/heads/master by this push:
     new 309c4e8  Polishing INI content generator.
309c4e8 is described below

commit 309c4e8f90d443f6c982587cdf56a19680e40cd1
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Oct 11 15:43:39 2018 +0200

    Polishing INI content generator.
---
 src/libebics.h     |  10 ++++
 src/message_dump.c |  24 ++++++----
 src/tests.c        |  19 ++++++++
 src/xmlmessages.c  | 132 ++++++++++++++++++++++++++++++++++++-----------------
 4 files changed, 132 insertions(+), 53 deletions(-)

diff --git a/src/libebics.h b/src/libebics.h
index 4105ed1..50eb167 100644
--- a/src/libebics.h
+++ b/src/libebics.h
@@ -38,6 +38,16 @@
 #define EBICS_INI_BASE_DOCUMENT 0
 
 /**
+ * Those indexes point inside the keyList global object.
+ */
+#define EBICS_USER_AUTH_KEY 0
+#define EBICS_USER_ENC_KEY 1
+#define EBICS_USER_SIG_KEY 2
+#define EBICS_BANK_AUTH_KEY 3
+#define EBICS_BANK_ENC_KEY 4
+#define EBICS_BANK_SIG_KEY 5
+
+/**
  * Initializes Libebics.  Init all the dependencies,
  * as well as it allocates the "genex" templates to
  * be copied and instantiated during the library life.
diff --git a/src/message_dump.c b/src/message_dump.c
index fce66d5..f20b6a3 100644
--- a/src/message_dump.c
+++ b/src/message_dump.c
@@ -1,16 +1,20 @@
 /*
   This file is part of libfints
 
-  libfints is free software; you can redistribute it and/or modify it under the
-  terms of the GNU General Public License as published by the Free Software
-  Foundation; either version 3, or (at your option) any later version.
-
-  libfints is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License along with
-  libfints; see the file COPYING.  If not, If not, see 
<http://www.gnu.org/license>
+  libfints is free software; you can redistribute it
+  and/or modify it under the terms of the GNU General
+  Public License as published by the Free Software
+  Foundation; either version 3, or (at your option) any
+  later version.
+
+  libfints is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty
+  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public
+  License along with libfints; see the file COPYING.  If not,
+  If not, see <http://www.gnu.org/license>
 */
 
 
diff --git a/src/tests.c b/src/tests.c
index d40c49d..5a839e2 100644
--- a/src/tests.c
+++ b/src/tests.c
@@ -29,6 +29,22 @@
                        "messagedump", \
                        __VA_ARGS__)
 
+struct EBICS_ARGS_build_header header_args = {
+  .hostID = "EBIXHOST",
+  .partnerID = "PARTNER1",
+  .userID = "USER0001",
+  .productName = "Unknown/Development",
+  .languageCode = "en",
+  .requestBankSignature = false
+};
+
+struct EBICS_ARGS_build_content_ini ini_args = {
+  .partnerID = "PARTNER1",
+  .userID = "USER0001"
+  // had userAuthKey as a field.
+};
+
+
 /**
  * This test merely instantiates documents
  * and checks them against their schemas.
@@ -47,6 +63,9 @@ main (int argc, char **argv)
          "no init lib");
     return EBICS_ERROR;
   }
+
+  // EBICS_generate_message_ini (header_args,
+  //                             ini_args);
   
   EBICS_close_library ();
   
diff --git a/src/xmlmessages.c b/src/xmlmessages.c
index 765eabf..c02ffe0 100644
--- a/src/xmlmessages.c
+++ b/src/xmlmessages.c
@@ -14,6 +14,9 @@
 */
 
 #include "xmlmessages.h"
+#include "libebics.h"
+#include "gnunet/platform.h"
+#include "gnunet/gnunet_util_lib.h"
 
 /**
  * Size of the binary nonce
@@ -27,6 +30,8 @@
 
 #define LOG(level,...) EBICS_util_log_from (__LINE__, __FILE__,__func__,level, 
"xmlmessages",__VA_ARGS__)
 
+extern struct EBICS_Key keyList[];
+
 /**
  * Dump a EBICS_genex_document to LOG_DEBUG.
  *
@@ -202,65 +207,106 @@ void
 EBICS_build_content_ini (void *cls,
                          struct EBICS_genex_document *document)
 {
-  struct EBICS_ARGS_build_content_ini *data = (struct 
EBICS_ARGS_build_content_ini*) cls;
   int retv;
-
-  /* RSAKeyValue content */
   char *modulus;
   char *exponent;
-  util_extract_public_RSAKeyValue (data->userAuthKey->publickey,
-                                   &exponent,
-                                   &modulus);
-
-  /* SignaturePubKeyOrderData content*/
   char date[DATE_STR_SIZE];
+  struct EBICS_ARGS_build_content_ini *data;
+
+  xmlChar *iniContent;
+  char *base64content;
+  size_t zLen, b64len;
+  int xLen;
+  char *b64data;
+
+  data = (struct EBICS_ARGS_build_content_ini*) cls;
+
+  GNUNET_assert
+    (0 != (EBICS_KEY_RSA_PUBLIC
+      & keyList[EBICS_USER_AUTH_KEY].type));
+
+  util_extract_public_RSAKeyValue
+    (keyList[EBICS_USER_AUTH_KEY].publickey,
+     &exponent,
+     &modulus);
+
   struct EBICS_MSG_Spec content[] = {
-    EBICS_MSG_op_unique_choice("//esig:SignatureVersion"),
-    EBICS_MSG_op_del_node("//ds:X509Data"),
-    EBICS_MSG_op_set_string("//esig:SignatureVersion","A005"),
-    EBICS_MSG_op_set_string("//esig:PubKeyValue//ds:Modulus", modulus),
-    EBICS_MSG_op_set_string("//esig:PubKeyValue//ds:Exponent", exponent),
-    EBICS_MSG_op_set_string("//esig:TimeStamp", tools_get_timestamp(date)),
-    EBICS_MSG_op_set_string("//esig:PartnerID", data->partnerID),
-    EBICS_MSG_op_set_string("//esig:UserID", data->userID),
-    EBICS_MSG_op_del_node("//schema:ANY"),
-    EBICS_MSG_op_end()
+    EBICS_MSG_op_unique_choice ("//esig:SignatureVersion"),
+    EBICS_MSG_op_del_node ("//ds:X509Data"),
+    EBICS_MSG_op_set_string ("//esig:SignatureVersion",
+                             "A005"),
+    EBICS_MSG_op_set_string ("//esig:PubKeyValue//ds:Modulus",
+                             modulus),
+    EBICS_MSG_op_set_string ("//esig:TimeStamp",
+                             tools_get_timestamp (date)),
+    EBICS_MSG_op_set_string ("//esig:PartnerID",
+                             data->partnerID),
+    EBICS_MSG_op_set_string ("//esig:UserID",
+                             data->userID),
+    EBICS_MSG_op_del_node ("//schema:ANY"),
+    EBICS_MSG_op_set_string
+      ("//esig:PubKeyValue//ds:Exponent",
+       exponent),
+    EBICS_MSG_op_end ()
   };
   EBICS_MSG_parse_spec (content,
-                        data->document);
-  free(modulus);
-  free(exponent);
+                        document);
+  GNUNET_free (modulus);
+  GNUNET_free (exponent);
   
   /* insert base64'ed and zlib'ed data */
-  xmlChar *iniContent;
-  char *base64Content;
-  size_t zLen, b64Len;
-  int xLen;
-  LOG (EBICS_LOGLEVEL_DEBUG, "DUMPING CONTENT!");
-  dump_message(data->document);
-  xmlDocDumpMemoryEnc(data->document->document, &iniContent, &xLen, "utf-8");
+  LOG (EBICS_LOGLEVEL_DEBUG,
+       "DUMPING CONTENT!");
+  dump_message (document);
+  xmlDocDumpMemoryEnc (document->document,
+                       &iniContent,
+                       &xLen,
+                       "utf-8");
+
+  zLen = compressBound ((size_t) xLen);
+  char *zData = malloc (zLen);
+  retv = compress ((unsigned char *) zData,
+                   &zLen,
+                   iniContent,
+                   xLen);
 
-  zLen = compressBound ((size_t)xLen);
-  char *zData = malloc(zLen);
-  retv = compress ((unsigned char*) zData, &zLen, iniContent, xLen);
-  LOG (EBICS_LOGLEVEL_INFO, "Size: %lu, FinalSize: %lu", (size_t)xLen, zLen);
+  LOG (EBICS_LOGLEVEL_INFO,
+       "Size: %lu, FinalSize: %lu",
+       (size_t) xLen,
+       zLen);
 
-  b64Len = EBICS_UTIL_base64_encode((char*)zData, zLen, &base64Content);
-  char *b64Data = realloc(base64Content, b64Len+1);
-  b64Data[b64Len] = 0;
-  base64Content = b64Data;
+  b64len = EBICS_UTIL_base64_encode ((char *) zData,
+                                     zLen,
+                                     &base64content);
+
+  b64data = realloc (base64content,
+                     b64len + 1);
 
-  LOG (EBICS_LOGLEVEL_INFO, "Compressed and base64ed. len: %lu, Content:\n%s", 
b64Len,base64Content);
+  /* 0-terminate the b64 segment */
+  b64data[b64len] = 0;
+  base64content = b64data;
+
+  LOG (EBICS_LOGLEVEL_INFO,
+       "Compressed and base64ed. Len: %lu, Content:\n%s",
+       b64len,
+       base64content);
 
   struct EBICS_MSG_Spec body[] = {
-    EBICS_MSG_op_set_string("//ebics:OrderDetails//ebics:OrderType", "INI"),
-    
EBICS_MSG_op_set_string("//ebics:body//ebics:DataTransfer/ebics:OrderData", 
base64Content),
+    EBICS_MSG_op_set_string
+      ("//ebics:OrderDetails//ebics:OrderType",
+       "INI"),
+    EBICS_MSG_op_set_string
+      ("//ebics:body//ebics:DataTransfer/ebics:OrderData",
+       base64content),
+
     EBICS_MSG_op_end()
   };
-  EBICS_MSG_parse_spec(body, document);
-  xmlFree(iniContent);
-  free(base64Content);
-  free(zData);
+
+  EBICS_MSG_parse_spec (body,
+                        document);
+  xmlFree (iniContent);
+  GNUNET_free (base64content);
+  GNUNET_free (zData);
 }
 
 void

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]