[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libeufin] branch master updated: fix integer instantiation
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libeufin] branch master updated: fix integer instantiation |
Date: |
Thu, 17 Oct 2019 17:41:30 +0200 |
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 537e5d6 fix integer instantiation
537e5d6 is described below
commit 537e5d6a77664d3968f68106e105855f692ff0f8
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Oct 17 17:41:21 2019 +0200
fix integer instantiation
---
sandbox/src/main/kotlin/DB.kt | 50 +++++++++++++++++------------
sandbox/src/main/kotlin/Main.kt | 11 +++----
sandbox/src/test/kotlin/DbTest.kt | 1 -
sandbox/src/test/kotlin/InnerIniLoadTest.kt | 30 +++++++++++++++++
sandbox/src/test/kotlin/RsaTest.kt | 14 +++++++-
5 files changed, 78 insertions(+), 28 deletions(-)
diff --git a/sandbox/src/main/kotlin/DB.kt b/sandbox/src/main/kotlin/DB.kt
index 0cb1086..7405cb4 100644
--- a/sandbox/src/main/kotlin/DB.kt
+++ b/sandbox/src/main/kotlin/DB.kt
@@ -147,6 +147,28 @@ class EbicsSystem(id: EntityID<Int>) : IntEntity(id) {
var systemId by EbicsSystems.systemId
}
+/**
+ * This table stores RSA public keys.
+ */
+object EbicsPublicKeys: IntIdTable() {
+ val pub = binary("pub", PUBLIC_KEY_MAX_LENGTH)
+ val state = customEnumeration(
+ "state",
+ "ENUM('MISSING', 'NEW', 'RELEASED')",
+ {KeyStates.values()[it as Int]},
+ {it.name})
+}
+
+
+/**
+ * Definition of a row in the keys table
+ */
+class EbicsPublicKey(id: EntityID<Int>) : IntEntity(id) {
+ companion object : IntEntityClass<EbicsPublicKey>(EbicsPublicKeys)
+ var pub by EbicsPublicKeys.pub
+ var state by EbicsPublicKeys.state
+}
+
/**
* Subscribers table. This table associates users with partners
* and systems. Each value can appear multiple times in the same column.
@@ -156,9 +178,9 @@ object EbicsSubscribers: IntIdTable() {
val partnerId = reference("PartnerId", EbicsPartners)
val systemId = reference("SystemId", EbicsSystems)
- val signatureKey = reference("signatureKey", EbicsPublicKey).nullable()
- val encryptionKey = reference("encryptionKey", EbicsPublicKey).nullable()
- val authorizationKey = reference("authorizationKey",
EbicsPublicKey).nullable()
+ val signatureKey = reference("signatureKey", EbicsPublicKeys).nullable()
+ val encryptionKey = reference("encryptionKey", EbicsPublicKeys).nullable()
+ val authorizationKey = reference("authorizationKey",
EbicsPublicKeys).nullable()
val state = customEnumeration(
"state",
@@ -174,9 +196,9 @@ class EbicsSubscriber(id: EntityID<Int>) : IntEntity(id) {
var partnerId by EbicsPartner referencedOn EbicsSubscribers.partnerId
var systemId by EbicsSystem referencedOn EbicsSubscribers.systemId
- var signatureKey by EbicsPublicKey.id
- var encryptionKey by EbicsPublicKey.id
- var authorizationKey by EbicsPublicKey.id
+ var signatureKey by EbicsPublicKey optionalReferencedOn
EbicsSubscribers.signatureKey
+ var encryptionKey by EbicsPublicKey optionalReferencedOn
EbicsSubscribers.encryptionKey
+ var authorizationKey by EbicsPublicKey optionalReferencedOn
EbicsSubscribers.authorizationKey
var state by EbicsSubscribers.state
}
@@ -195,22 +217,10 @@ fun createSubscriber() : EbicsSubscriber {
}
-/**
- * This table stores RSA public keys.
- */
-object EbicsPublicKey: IntIdTable() {
- val pub = binary("pub", PUBLIC_KEY_MAX_LENGTH)
- val state = customEnumeration(
- "state",
- "ENUM('MISSING', 'NEW', 'RELEASED')",
- {KeyStates.values()[it as Int]},
- {it.name})
-}
-
/**
* This table stores RSA private keys.
*/
-object EbicsPrivateKEy: IntIdTable() {
+object EbicsPrivateKey: IntIdTable() {
val pub = binary("priv", PRIV_KEY_MAX_LENGTH)
}
@@ -228,4 +238,4 @@ fun dbCreateTables() {
EbicsSubscribers
)
}
-}
\ No newline at end of file
+}
diff --git a/sandbox/src/main/kotlin/Main.kt b/sandbox/src/main/kotlin/Main.kt
index df930a5..aaa6fd3 100644
--- a/sandbox/src/main/kotlin/Main.kt
+++ b/sandbox/src/main/kotlin/Main.kt
@@ -102,12 +102,13 @@ fun downcastXml(document: Document, node: String, type:
String) : Document {
* @param modulus
* @return key
*/
-fun loadRsaPublicKey (exponent: ByteArray, modulus: ByteArray) : PublicKey {
+fun loadRsaPublicKey (modulus: ByteArray, exponent: ByteArray) : PublicKey {
+
+ val modulusBigInt = BigInteger(1, modulus)
+ val exponentBigInt = BigInteger(1, exponent)
- val exponentBigInt = BigInteger(exponent)
- val modulusBigInt = BigInteger(modulus)
val keyFactory = KeyFactory.getInstance("RSA")
- val tmp = RSAPublicKeySpec(exponentBigInt, modulusBigInt)
+ val tmp = RSAPublicKeySpec(modulusBigInt, exponentBigInt)
return keyFactory.generatePublic(tmp)
}
@@ -315,8 +316,6 @@ private suspend fun ApplicationCall.ebicsweb() {
return
}
- logger.debug(EbicsUsers.userId.name)
-
// store key in database
diff --git a/sandbox/src/test/kotlin/DbTest.kt
b/sandbox/src/test/kotlin/DbTest.kt
index 68f49e1..1f99b69 100644
--- a/sandbox/src/test/kotlin/DbTest.kt
+++ b/sandbox/src/test/kotlin/DbTest.kt
@@ -28,7 +28,6 @@ class DbTest {
pub = "BINARYVALUE".toByteArray()
state = KeyStates.NEW
}
-
subscriber.authorizationKey = key
}
}
diff --git a/sandbox/src/test/kotlin/InnerIniLoadTest.kt
b/sandbox/src/test/kotlin/InnerIniLoadTest.kt
new file mode 100644
index 0000000..74fb724
--- /dev/null
+++ b/sandbox/src/test/kotlin/InnerIniLoadTest.kt
@@ -0,0 +1,30 @@
+package tech.libeufin.sandbox
+
+import org.junit.Test
+import tech.libeufin.messages.ebics.keyrequest.SignaturePubKeyOrderDataType
+import java.math.BigInteger
+
+class InnerIniLoadTest {
+
+ val jaxbKey = {
+ val classLoader = ClassLoader.getSystemClassLoader()
+ val file = classLoader.getResource(
+ "ebics_ini_inner_key.xml"
+ )
+ xmlProcess.convertStringToJaxb(
+ SignaturePubKeyOrderDataType::class.java,
+ file.readText()
+ )
+ }()
+
+ @Test
+ fun loadInnerKey() {
+
+ val modulus =
jaxbKey.value.signaturePubKeyInfo.pubKeyValue.rsaKeyValue.modulus
+ val exponent =
jaxbKey.value.signaturePubKeyInfo.pubKeyValue.rsaKeyValue.exponent
+
+ loadRsaPublicKey(modulus, exponent)
+ }
+
+
+}
\ No newline at end of file
diff --git a/sandbox/src/test/kotlin/RsaTest.kt
b/sandbox/src/test/kotlin/RsaTest.kt
index c4637e8..836d88d 100644
--- a/sandbox/src/test/kotlin/RsaTest.kt
+++ b/sandbox/src/test/kotlin/RsaTest.kt
@@ -11,9 +11,21 @@ class RsaTest {
@Test
fun loadFromModulusAndExponent() {
-
val key = loadRsaPublicKey(publicExponent.toByteArray(),
publicModulus.toByteArray())
println(key.toString())
+ }
+
+ /**
+ * Values generating helper.
+ */
+ @Test
+ fun getBase64Values() {
+ println(
+ "Modulus:
${Base64.getEncoder().encodeToString(publicModulus.toByteArray())}"
+ )
+ println(
+ "Exponent:
${Base64.getEncoder().encodeToString(publicExponent.toByteArray())}"
+ )
}
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [libeufin] branch master updated: fix integer instantiation,
gnunet <=