gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Add new (failing) test case.


From: gnunet
Subject: [libeufin] branch master updated: Add new (failing) test case.
Date: Tue, 19 Nov 2019 17:21:13 +0100

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

marcello pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 0117c91  Add new (failing) test case.
0117c91 is described below

commit 0117c917e88bf2abb5827f4046b921f99b3910a2
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Nov 19 17:18:43 2019 +0100

    Add new (failing) test case.
    
    sign_str = X002_sign(document)
    sign_jaxb = convert(sign_str)
    sign_doc = convert(sign_jaxb)
    X002_verify(sign_doc) => FAIL!
---
 nexus/src/main/kotlin/Containers.kt    | 37 +++++++++++++++++++++++++++++++++
 sandbox/src/main/python/libeufin-cli   | 15 ++++++++++++++
 sandbox/src/test/kotlin/XmlUtilTest.kt | 38 ++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+)

diff --git a/nexus/src/main/kotlin/Containers.kt 
b/nexus/src/main/kotlin/Containers.kt
new file mode 100644
index 0000000..f45058a
--- /dev/null
+++ b/nexus/src/main/kotlin/Containers.kt
@@ -0,0 +1,37 @@
+package tech.libeufin.nexus
+
+import javax.crypto.SecretKey
+import org.w3c.dom.Document
+
+
+/**
+ * This class is a mere container that keeps data found
+ * in the database and that is further needed to sign / verify
+ * / make messages.  And not all the values are needed all
+ * the time.
+ */
+data class EbicsContainer(
+
+    // needed to verify responses
+    val bankAuthPubBlob: ByteArray? = null,
+
+    val bankEncPubBlob: ByteArray? = null,
+
+    // needed to send the message
+    val ebicsUrl: String? = null,
+
+    // needed to craft further messages
+    val hostId: String? = null,
+
+    // needed to encrypt order data during all the phases
+    val plainTransactionKey: SecretKey? = null,
+
+    // needed to decrypt data coming from the bank
+    val customerEncPrivBlob: ByteArray? = null,
+
+    // needed to sign documents
+    val customerAuthPrivBlob: ByteArray? = null,
+
+    // signed document to send to the bank
+    var doc: Document? = null
+)
\ No newline at end of file
diff --git a/sandbox/src/main/python/libeufin-cli 
b/sandbox/src/main/python/libeufin-cli
index f2df675..5c7404b 100755
--- a/sandbox/src/main/python/libeufin-cli
+++ b/sandbox/src/main/python/libeufin-cli
@@ -40,6 +40,21 @@ def ini(obj, customer_id):
     print(resp.content.decode("utf-8"))
 
 
+
+
+@ebics.command(help="Give and get keys.")
+@click.pass_context
+@click.option(
+    "--customer-id",
+    help="numerical ID of the customer at the Nexus",
+    required=False,
+    default=1)
+def prepare(ctx, customer_id):
+    ctx.invoke(ini)
+    ctx.invoke(hia)
+    ctx.invoke(sync)
+
+
 @ebics.command(help="send HTD message")
 @click.pass_context
 @click.option(
diff --git a/sandbox/src/test/kotlin/XmlUtilTest.kt 
b/sandbox/src/test/kotlin/XmlUtilTest.kt
index 967ce58..c672c65 100644
--- a/sandbox/src/test/kotlin/XmlUtilTest.kt
+++ b/sandbox/src/test/kotlin/XmlUtilTest.kt
@@ -1,10 +1,12 @@
 package tech.libeufin.sandbox
 
+import org.apache.xml.security.binding.xmldsig.SignatureType
 import org.junit.Test
 import org.junit.Assert.*
 import org.junit.rules.ExpectedException
 import org.xml.sax.SAXParseException
 import tech.libeufin.schema.ebics_h004.EbicsKeyManagementResponse
+import tech.libeufin.schema.ebics_h004.EbicsResponse
 import tech.libeufin.schema.ebics_h004.EbicsTypes
 import tech.libeufin.schema.ebics_h004.HTDResponseOrderData
 import java.rmi.UnmarshalException
@@ -111,6 +113,42 @@ class XmlUtilTest {
         kotlin.test.assertFalse(XMLUtil.verifyEbicsDocument(doc, 
otherPair.public))
     }
 
+    @Test
+    fun verifySigningWithConversion() {
+
+        val pair = CryptoUtil.generateRsaKeyPair(2048)
+
+        val response = EbicsResponse().apply {
+            version = "H004"
+            header = EbicsResponse.Header().apply {
+                _static = EbicsResponse.StaticHeaderType()
+                mutable = EbicsResponse.MutableHeaderType().apply {
+                    this.reportText = "foo"
+                    this.returnCode = "bar"
+                    this.transactionPhase = 
EbicsTypes.TransactionPhaseType.INITIALISATION
+                }
+            }
+            authSignature = SignatureType()
+            body = EbicsResponse.Body().apply {
+                returnCode = EbicsResponse.ReturnCode().apply {
+                    authenticate = true
+                    value = "asdf"
+                }
+            }
+        }
+
+        val signature = signEbicsResponseX002(response, pair.private)
+        val signatureJaxb = 
XMLUtil.convertStringToJaxb<EbicsResponse>(signature)
+
+        assertTrue(
+
+            XMLUtil.verifyEbicsDocument(
+                XMLUtil.convertJaxbToDocument(signatureJaxb.value),
+                pair.public
+            )
+        )
+    }
+
     @Test
     fun multiAuthSigningTest() {
         val doc = XMLUtil.parseStringIntoDom("""

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



reply via email to

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