Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bugs found while integrating apollo with KMP SDK #98

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
root = true

[*.{kt,kts}]
ktlint_code_style = ktlint_official
ktlint_standard_no_semi = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_function-signature = disabled
2 changes: 2 additions & 0 deletions .github/workflows/Deployment.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
# kics-scan ignore
name: Deployment

defaults:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
# kics-scan ignore
name: Pull Request CI

defaults:
Expand Down Expand Up @@ -37,10 +39,10 @@ jobs:

- name: Mega-Linter
id: ml
uses: megalinter/megalinter@v6
uses: oxsecurity/megalinter@v7.4.0

- name: Archive production artifacts
if: success() || failure()
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v3
with:
name: Mega-Linter reports
Expand Down
8 changes: 8 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
APPLY_FIXES: none
FILTER_REGEX_EXCLUDE: (karma.config.js|polyfill.js|timeout.js)
VALIDATE_ALL_CODEBASE: true
Expand All @@ -11,3 +12,10 @@ DISABLE_LINTERS:
- BASH_SHELLCHECK
- BASH_EXEC
- REPOSITORY_TRIVY
- REPOSITORY_TRUFFLEHOG
- REPOSITORY_KICS

DISABLE_ERRORS_LINTERS:
- REPOSITORY_TRUFFLEHOG
- REPOSITORY_TRIVY
- REPOSITORY_KICS
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package io.iohk.atala.prism.apollo.utils

import org.bouncycastle.jce.provider.BouncyCastleProvider
import java.security.KeyPair
import java.security.KeyPairGenerator
import org.bouncycastle.crypto.generators.Ed25519KeyPairGenerator
import org.bouncycastle.crypto.params.Ed25519KeyGenerationParameters
import org.bouncycastle.crypto.params.Ed25519PrivateKeyParameters
import org.bouncycastle.crypto.params.Ed25519PublicKeyParameters
import java.security.SecureRandom

actual class KMMEdKeyPair actual constructor(actual val privateKey: KMMEdPrivateKey, actual val publicKey: KMMEdPublicKey) {
actual class KMMEdKeyPair actual constructor(
actual val privateKey: KMMEdPrivateKey,
actual val publicKey: KMMEdPublicKey
) {
actual companion object : Ed25519KeyPairGeneration {
override fun generateKeyPair(): KMMEdKeyPair {
val provider = BouncyCastleProvider()
val generator = KeyPairGenerator.getInstance("Ed25519", provider)
val javaKeyPair: KeyPair = generator.generateKeyPair()
val generator = Ed25519KeyPairGenerator()
generator.init(Ed25519KeyGenerationParameters(SecureRandom()))
val pair = generator.generateKeyPair()
return KMMEdKeyPair(
KMMEdPrivateKey(javaKeyPair.private.encoded),
KMMEdPublicKey(javaKeyPair.public.encoded)
privateKey = KMMEdPrivateKey((pair.private as Ed25519PrivateKeyParameters).encoded),
publicKey = KMMEdPublicKey((pair.public as Ed25519PublicKeyParameters).encoded),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package io.iohk.atala.prism.apollo.utils

import org.bouncycastle.jcajce.spec.XDHParameterSpec
import org.bouncycastle.jce.provider.BouncyCastleProvider
import java.security.KeyPairGenerator
import org.bouncycastle.crypto.generators.X25519KeyPairGenerator
import org.bouncycastle.crypto.params.X25519KeyGenerationParameters
import org.bouncycastle.crypto.params.X25519PrivateKeyParameters
import org.bouncycastle.crypto.params.X25519PublicKeyParameters
import java.security.SecureRandom

actual class KMMX25519KeyPair actual constructor(
actual val privateKey: KMMX25519PrivateKey,
actual val publicKey: KMMX25519PublicKey
) {
actual companion object : X25519KeyPairGeneration {
override fun generateKeyPair(): KMMX25519KeyPair {
val provider = BouncyCastleProvider()
val kpg = KeyPairGenerator.getInstance("X25519", provider)
kpg.initialize(XDHParameterSpec(XDHParameterSpec.X25519))
val javaKeyPair = kpg.generateKeyPair()
val generator = X25519KeyPairGenerator()
generator.init(X25519KeyGenerationParameters(SecureRandom()))
val keyPair = generator.generateKeyPair()

return KMMX25519KeyPair(
KMMX25519PrivateKey(javaKeyPair.private.encoded),
KMMX25519PublicKey(javaKeyPair.public.encoded)
KMMX25519PrivateKey((keyPair.private as X25519PrivateKeyParameters).encoded),
KMMX25519PublicKey((keyPair.public as X25519PublicKeyParameters).encoded)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package io.iohk.atala.prism.apollo.utils

import org.bouncycastle.jce.provider.BouncyCastleProvider
import java.security.KeyPair
import java.security.KeyPairGenerator
import org.bouncycastle.crypto.generators.Ed25519KeyPairGenerator
import org.bouncycastle.crypto.params.Ed25519KeyGenerationParameters
import org.bouncycastle.crypto.params.Ed25519PrivateKeyParameters
import org.bouncycastle.crypto.params.Ed25519PublicKeyParameters
import java.security.SecureRandom

actual class KMMEdKeyPair actual constructor(actual val privateKey: KMMEdPrivateKey, actual val publicKey: KMMEdPublicKey) {
actual class KMMEdKeyPair actual constructor(
actual val privateKey: KMMEdPrivateKey,
actual val publicKey: KMMEdPublicKey
) {
actual companion object : Ed25519KeyPairGeneration {
override fun generateKeyPair(): KMMEdKeyPair {
val provider = BouncyCastleProvider()
val generator = KeyPairGenerator.getInstance("Ed25519", provider)
val javaKeyPair: KeyPair = generator.generateKeyPair()
val generator = Ed25519KeyPairGenerator()
generator.init(Ed25519KeyGenerationParameters(SecureRandom()))
val pair = generator.generateKeyPair()
return KMMEdKeyPair(
KMMEdPrivateKey(javaKeyPair.private.encoded),
KMMEdPublicKey(javaKeyPair.public.encoded)
privateKey = KMMEdPrivateKey((pair.private as Ed25519PrivateKeyParameters).encoded),
publicKey = KMMEdPublicKey((pair.public as Ed25519PublicKeyParameters).encoded),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package io.iohk.atala.prism.apollo.utils

import org.bouncycastle.jcajce.spec.XDHParameterSpec
import org.bouncycastle.jce.provider.BouncyCastleProvider
import java.security.KeyPairGenerator
import org.bouncycastle.crypto.generators.X25519KeyPairGenerator
import org.bouncycastle.crypto.params.X25519KeyGenerationParameters
import org.bouncycastle.crypto.params.X25519PrivateKeyParameters
import org.bouncycastle.crypto.params.X25519PublicKeyParameters
import java.security.SecureRandom

actual class KMMX25519KeyPair actual constructor(
actual val privateKey: KMMX25519PrivateKey,
actual val publicKey: KMMX25519PublicKey
) {
actual companion object : X25519KeyPairGeneration {
override fun generateKeyPair(): KMMX25519KeyPair {
val provider = BouncyCastleProvider()
val kpg = KeyPairGenerator.getInstance("X25519", provider)
kpg.initialize(XDHParameterSpec(XDHParameterSpec.X25519))
val javaKeyPair = kpg.generateKeyPair()
val generator = X25519KeyPairGenerator()
generator.init(X25519KeyGenerationParameters(SecureRandom()))
val keyPair = generator.generateKeyPair()

return KMMX25519KeyPair(
KMMX25519PrivateKey(javaKeyPair.private.encoded),
KMMX25519PublicKey(javaKeyPair.public.encoded)
KMMX25519PrivateKey((keyPair.private as X25519PrivateKeyParameters).encoded),
KMMX25519PublicKey((keyPair.public as X25519PublicKeyParameters).encoded)
)
}
}
Expand Down
Loading