Skip to content

Commit

Permalink
1433: add project config for koblenz, fix import, aligned test values…
Browse files Browse the repository at this point in the history
… and doc values for hash
  • Loading branch information
f1sh1918 committed Jul 29, 2024
1 parent 60031cf commit 396b4c4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import app.ehrenamtskarte.backend.cards.CanonicalJson
import app.ehrenamtskarte.backend.common.utils.Environment
import app.ehrenamtskarte.backend.common.webservice.KOBLENZ_PEPPER_SYS_ENV
import app.ehrenamtskarte.backend.user.KoblenzUser
import app.ehrenamtskarte.backend.verification.CanonicalJson
import org.bouncycastle.crypto.generators.Argon2BytesGenerator
import org.bouncycastle.crypto.params.Argon2Parameters
import java.nio.charset.StandardCharsets
Expand Down Expand Up @@ -51,16 +51,16 @@ class Argon2IdHasher {
val canonicalJson = CanonicalJson.koblenzUserToString(userData)
val hashLength = 32

val pepper = Environment.getVariable(KOBLENZ_PEPPER_SYS_ENV) // TODO handle if Null
val pepperByteArray = pepper?.toByteArray(StandardCharsets.UTF_8)
val pepper = Environment.getVariable(KOBLENZ_PEPPER_SYS_ENV) ?: throw Exception("No koblenz pepper found")
val pepperByteArray = pepper.toByteArray(StandardCharsets.UTF_8)
val params =
Argon2Parameters
.Builder(Argon2Parameters.ARGON2_id)
.withVersion(19)
.withIterations(2)
.withSalt(pepperByteArray)
.withParallelism(1)
.withMemoryAsKB(19)
.withMemoryAsKB(16)
.build()

val generator = Argon2BytesGenerator()
Expand Down
11 changes: 11 additions & 0 deletions backend/src/main/resources/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ projects:
port: 587
username: OVERRIDE_IN_LOCAL_CONFIG
password: OVERRIDE_IN_LOCAL_CONFIG
- id: koblenz.sozialpass.app
importUrl: ""
pipelineName: SozialpassKoblenz
administrationBaseUrl: https://koblenz.sozialpass.app
administrationName: Koblenz-Pass-Verwaltung
timezone: "Europe/Berlin"
smtp:
host: mail.sozialpass.app
port: 587
username: OVERRIDE_IN_LOCAL_CONFIG
password: OVERRIDE_IN_LOCAL_CONFIG
- id: showcase.entitlementcard.app
importUrl: https://example.com
pipelineName: BerechtigungskarteShowcase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class Argon2IdHasherTest {
assertEquals(Environment.getVariable("KOBLENZ_PEPPER"), "123456789ABC")

val hash = Argon2IdHasher.hashKoblenzUserData(KoblenzUser("Karla Koblenz", 12213, "123K"))
val expectedHash = "\$argon2id\$v=19\$m=19,t=2,p=1\$78SNlzz8llqPwetRlp8Lnag/WZGPc5XbimYbShpwVMQ" // This expected output was created with https://argon2.online/
val expectedHash = "\$argon2id\$v=19\$m=16,t=2,p=1\$UIOJZIsSL8vXcuCB82xZ5E8tpH6sQd3d4U0uC02DP40" // This expected output was created with https://argon2.online/
assertEquals(expectedHash, hash)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package app.ehrenamtskarte.backend.cards

import Card
import app.ehrenamtskarte.backend.cards.CanonicalJson.Companion.koblenzUserToString
import app.ehrenamtskarte.backend.helper.CardInfoTestSample
import app.ehrenamtskarte.backend.helper.ExampleCardInfo
import app.ehrenamtskarte.backend.helper.koblenzTestUser
import app.ehrenamtskarte.backend.verification.CanonicalJson.Companion.koblenzUserToString
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
Expand Down
2 changes: 1 addition & 1 deletion docs/CreateKoblenzHash.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Hash with Argon2id with the following parameters:
| Version | 19 |
| Iterations | 2 |
| Parallellism | 1 |
| Memory | 19 |
| Memory | 16 |
| HashLength | 32 |
| Salt | Secret Salt will be shared with Koblenz<br/>for the example use `123456789ABC` |

Expand Down

0 comments on commit 396b4c4

Please sign in to comment.