gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (74f994d -> e30e470)


From: gnunet
Subject: [libeufin] branch master updated (74f994d -> e30e470)
Date: Mon, 04 Nov 2019 11:40:57 +0100

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

dold pushed a change to branch master
in repository libeufin.

    from 74f994d  formatting
     new c48f481  build system / deps
     new e30e470  wip: EBICS E002 encryption

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nexus/build.gradle                        | 21 +++++++++++----------
 sandbox/build.gradle                      | 24 +++++++++++++-----------
 sandbox/src/main/kotlin/CryptoUtil.kt     | 24 ++++++++++++++++++++++++
 sandbox/src/main/kotlin/Main.kt           |  3 +--
 sandbox/src/test/kotlin/CryptoUtilTest.kt |  7 +++++++
 5 files changed, 56 insertions(+), 23 deletions(-)

diff --git a/nexus/build.gradle b/nexus/build.gradle
index be00062..5f93162 100644
--- a/nexus/build.gradle
+++ b/nexus/build.gradle
@@ -23,16 +23,17 @@ compileTestKotlin {
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
     implementation "io.ktor:ktor-gson:1.1.5"
-    compile group: 'io.ktor', name: 'ktor-gson', version: '0.9.0'
-    compile "org.jetbrains.exposed:exposed:0.17.3"
-    compile "io.ktor:ktor-server-netty:1.2.4"
-    compile "ch.qos.logback:logback-classic:1.2.3"
-    compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
-    compile "javax.xml.bind:jaxb-api:2.3.0"
-    compile group: 'xerces', name: 'xercesImpl', version: '2.6.2-jaxb-1.0.6'
-    compile "javax.activation:activation:1.1"
-    compile "org.glassfish.jaxb:jaxb-runtime:2.3.1"
-    testCompile group: 'junit', name: 'junit', version: '4.12'
+    implementation group: 'io.ktor', name: 'ktor-gson', version: '0.9.0'
+    implementation "org.jetbrains.exposed:exposed:0.17.3"
+    implementation "io.ktor:ktor-server-netty:1.2.4"
+    implementation "ch.qos.logback:logback-classic:1.2.3"
+    implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
+    implementation "javax.xml.bind:jaxb-api:2.3.0"
+    implementation group: 'xerces', name: 'xercesImpl', version: 
'2.6.2-jaxb-1.0.6'
+    implementation "javax.activation:activation:1.1"
+    implementation "org.glassfish.jaxb:jaxb-runtime:2.3.1"
+
+    testImplementation group: 'junit', name: 'junit', version: '4.12'
 }
 
 application {
diff --git a/sandbox/build.gradle b/sandbox/build.gradle
index 59b4a65..71e4896 100644
--- a/sandbox/build.gradle
+++ b/sandbox/build.gradle
@@ -28,19 +28,21 @@ sourceSets {
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
     implementation "io.ktor:ktor-gson:1.1.5"
-    compile group: 'io.ktor', name: 'ktor-gson', version: '0.9.0'
-    compile "org.jetbrains.exposed:exposed:0.17.6"
-    compile "io.ktor:ktor-server-netty:1.2.4"
-    compile "ch.qos.logback:logback-classic:1.2.3"
-    compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
-    compile "javax.xml.bind:jaxb-api:2.3.0"
-    compile group: 'xerces', name: 'xercesImpl', version: '2.6.2-jaxb-1.0.6'
-    compile "javax.activation:activation:1.1"
-    compile "org.glassfish.jaxb:jaxb-runtime:2.3.1"
-    testCompile group: 'junit', name: 'junit', version: '4.12'
+    implementation group: 'io.ktor', name: 'ktor-gson', version: '0.9.0'
+    implementation "org.jetbrains.exposed:exposed:0.17.6"
+    implementation "io.ktor:ktor-server-netty:1.2.4"
+    implementation "ch.qos.logback:logback-classic:1.2.3"
+    implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
+    implementation "javax.xml.bind:jaxb-api:2.3.0"
+    implementation group: 'xerces', name: 'xercesImpl', version: 
'2.6.2-jaxb-1.0.6'
+    implementation "javax.activation:activation:1.1"
+    implementation "org.glassfish.jaxb:jaxb-runtime:2.3.1"
+    implementation 'org.apache.santuario:xmlsec:2.1.4'
+    implementation group: 'org.bouncycastle', name: 'bcprov-jdk16', version: 
'1.45'
+
+    testImplementation group: 'junit', name: 'junit', version: '4.12'
     testImplementation 'org.jetbrains.kotlin:kotlin-test-junit:1.3.50'
     testImplementation 'org.jetbrains.kotlin:kotlin-test:1.3.50'
-    compile 'org.apache.santuario:xmlsec:2.1.4'
 }
 
 application {
diff --git a/sandbox/src/main/kotlin/CryptoUtil.kt 
b/sandbox/src/main/kotlin/CryptoUtil.kt
index 20f5d52..b557bcd 100644
--- a/sandbox/src/main/kotlin/CryptoUtil.kt
+++ b/sandbox/src/main/kotlin/CryptoUtil.kt
@@ -19,16 +19,20 @@
 
 package tech.libeufin.sandbox
 
+import org.bouncycastle.jce.provider.BouncyCastleProvider
 import java.lang.Exception
 import java.math.BigInteger
 import java.security.KeyFactory
 import java.security.KeyPairGenerator
+import java.security.PrivateKey
 import java.security.PublicKey
 import java.security.interfaces.RSAPrivateCrtKey
 import java.security.interfaces.RSAPublicKey
 import java.security.spec.PKCS8EncodedKeySpec
 import java.security.spec.RSAPublicKeySpec
 import java.security.spec.X509EncodedKeySpec
+import javax.crypto.Cipher
+import javax.crypto.KeyGenerator
 
 /**
  * RSA key pair.
@@ -39,7 +43,16 @@ data class RsaCrtKeyPair(val private: RSAPrivateCrtKey, val 
public: RSAPublicKey
  * Helpers for dealing with crypographic operations in EBICS / LibEuFin.
  */
 class CryptoUtil {
+
+    data class EncryptionResult(
+        val encryptedTransactionKey: ByteArray,
+        val pubKeyDigest: ByteArray,
+        val encryptedData: ByteArray
+    )
+
     companion object {
+        private val bouncyCastleProvider = BouncyCastleProvider()
+
         /**
          * Load an RSA private key from its binary PKCS#8 encoding.
          */
@@ -106,5 +119,16 @@ class CryptoUtil {
             val tmp = RSAPublicKeySpec(modulusBigInt, exponentBigInt)
             return keyFactory.generatePublic(tmp) as RSAPublicKey
         }
+
+        fun encryptEbicsE002(data: ByteArray, signingPrivateKey: 
RSAPrivateCrtKey) {
+            val prov = BouncyCastleProvider()
+            val keygen = KeyGenerator.getInstance("AES", bouncyCastleProvider)
+            keygen.init(128)
+            val transportKey = keygen.generateKey()
+
+            val cipher = Cipher.getInstance("AES/CBC/X9.23Padding", 
bouncyCastleProvider)
+            cipher.init(Cipher.ENCRYPT_MODE, transportKey)
+            val encryptedData = cipher.doFinal(data)
+        }
     }
 }
diff --git a/sandbox/src/main/kotlin/Main.kt b/sandbox/src/main/kotlin/Main.kt
index 91f9649..6f40c6e 100644
--- a/sandbox/src/main/kotlin/Main.kt
+++ b/sandbox/src/main/kotlin/Main.kt
@@ -323,8 +323,7 @@ private suspend fun ApplicationCall.ebicsweb() {
         "ebicsNoPubKeyDigestsRequest" -> {
             val requestJaxb = 
XMLUtil.convertDomToJaxb(EbicsNoPubKeyDigestsRequest::class.java, bodyDocument)
             val staticHeader = requestJaxb.value.header.static
-            val orderType = staticHeader.orderDetails.orderType
-            when (orderType) {
+            when (val orderType = staticHeader.orderDetails.orderType) {
                 "HPB" -> {
                     val subscriberKeys = transaction {
                         val ebicsSubscriber =
diff --git a/sandbox/src/test/kotlin/CryptoUtilTest.kt 
b/sandbox/src/test/kotlin/CryptoUtilTest.kt
index 3ea9cfe..4e2c360 100644
--- a/sandbox/src/test/kotlin/CryptoUtilTest.kt
+++ b/sandbox/src/test/kotlin/CryptoUtilTest.kt
@@ -56,4 +56,11 @@ class CryptoUtilTest {
         assertEquals(keyPair.private, otherKeyPair.private)
         assertEquals(keyPair.public, otherKeyPair.public)
     }
+
+    @Test
+    fun testEbicsE002() {
+        val data = "Hello, World!"
+        val keyPair = CryptoUtil.generateRsaKeyPair(1024)
+        CryptoUtil.encryptEbicsE002(data.toByteArray(), keyPair.private)
+    }
 }
\ No newline at end of file

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



reply via email to

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