
Security foundation offering AES-256-GCM authenticated encryption, ephemeral X25519+HKDF-SHA256 handshake with Ed25519 transcript signatures, hardware-backed non-exportable P‑256 device identity, high-level object encryption and JSON helpers.
A Kotlin Multiplatform security foundation for Compose Multiplatform and native Android/iOS applications.
Package: com.ishant.security
Modules:
:security — Core KMP library (cryptography, key abstractions, hardware identity, serialization helpers, handshake, and tests). Contains all crypto and keystore implementations (AndroidDeviceIdentityKeyStore, IosDeviceIdentityKeyStore, and JvmDeviceIdentityKeyStore).:app — Unified Compose Multiplatform application sharing the exact same Compose UI (commonMain/App.kt) across Android, Desktop, and iOS.iosApp — Xcode iOS project wrapping the shared Compose Multiplatform UI (ComposeApp.framework) inside a standard ComposeUIViewController.Security foundation with AES-256-GCM encryption and an authenticated ephemeral X25519 + HKDF-SHA256 handshake protocol. This repository is structured as a Kotlin Multiplatform library with a unified Compose Multiplatform sample application running on Android, Desktop, and iOS.
Add the dependency to your project's build.gradle.kts:
dependencies {
implementation("io.github.kratos1996:kmp-security:1.0.2")
}settings.gradle.kts:dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}dependencies {
implementation("com.github.Kratos1996:KMP_Security:1.0.2")
}KMP_Security/
├── security/ # Core KMP Security Library (All crypto and keystore logic)
│ ├── src/commonMain/ # AES-256-GCM, SecurityManager, Handshake, Session, Models
│ ├── src/androidMain/ # AndroidDeviceIdentityKeyStore (Android Keystore P-256 ECDSA)
│ ├── src/iosMain/ # IosDeviceIdentityKeyStore (Secure Enclave P-256 ECDSA)
│ ├── src/jvmMain/ # JvmDeviceIdentityKeyStore (JCA ECDSA P-256 file/memory keystore)
│ ├── src/commonTest/ # Cross-platform unit tests
│ └── src/jvmTest/ # JVM Keystore & crypto test suite
├── app/ # Unified Compose Multiplatform Sample Application
│ ├── src/commonMain/ # Shared Compose UI (App.kt with Tabs: Encrypt/Decrypt & Automated Demos)
│ ├── src/androidMain/ # Android entry point (MainActivity.kt)
│ ├── src/desktopMain/ # Desktop entry point (Main.kt)
│ └── src/iosMain/ # iOS entry point (MainViewController.kt -> ComposeUIViewController)
└── iosApp/ # Xcode iOS Shell
├── iosApp/ # Hosts ComposeView (ContentView.swift -> MainViewController())
└── iosApp.xcodeproj # Xcode project embedding ComposeApp.framework
CURRENT_VERSION (1) and ALGORITHM ("AES-256-GCM") generated directly via Gradle SecurityBuildConfig.client-to-server & server-to-client) and pinned Ed25519 server transcript signatures.@Serializable Kotlin models using kotlinx.serialization.// Inside a suspend function or coroutine scope
val key = RawAesKey(keyBytes) // 32-byte key from secure key management
val aes = Aes256Gcm()
val encrypted: EncryptedPayload = aes.encrypt(
plaintext = "sensitive payload".encodeToByteArray(),
key = key,
associatedData = "context:v1".encodeToByteArray(),
)
val decryptedBytes = aes.decrypt(
payload = encrypted,
key = key,
associatedData = "context:v1".encodeToByteArray(),
)val manager = SecurityManager()
val profile = UserProfile(userId = "usr_101", email = "user@example.com", roles = listOf("USER"))
// Encrypt Kotlin @Serializable Object
val encryptedPayload = manager.encryptObject(
value = profile,
serializer = UserProfile.serializer(),
key = key,
associatedData = "user_profile_context".encodeToByteArray(),
)
// Decrypt Kotlin Object
val decryptedProfile: UserProfile = manager.decryptObject(
payload = encryptedPayload,
serializer = UserProfile.serializer(),
key = key,
associatedData = "user_profile_context".encodeToByteArray(),
)val keyStore = AndroidDeviceIdentityKeyStore()
val identityKey = keyStore.getOrCreate() // Generates non-exportable P-256 ECDSA key in Android Keystore
val challengeSignature = keyStore.sign(challengeBytes)
// Send identityKey.keyId, identityKey.publicKeyDer, and challengeSignature to backend for verificationThe :app module provides a Jetpack Compose UI for testing the security library directly on an Android device or emulator:
AES-256-GCM, copy JSON payload to Android Clipboard, paste ciphertext, and decrypt back to plaintext.The :app module provides a single, unified Compose Multiplatform UI (app/src/commonMain/kotlin/com/ishant/security/sample/App.kt) that runs natively on Android, Desktop (JVM), and iOS:
./gradlew :app:assembleDebug# Launch Compose Desktop window
./gradlew :app:desktopRun
# Or package standalone executable UberJar
./gradlew :app:packageUberJarForCurrentOSThe iosApp directory hosts a standard Xcode wrapper that displays the shared Compose Multiplatform UI through ComposeUIViewController:
# Build the Xcode project for iOS Simulator
xcodebuild -project iosApp/iosApp.xcodeproj -scheme iosApp -destination "platform=iOS Simulator,name=iPhone 18 Pro" build CODE_SIGNING_ALLOWED=NO
# Or open in Xcode:
open iosApp/iosApp.xcodeprojRun unit tests across all platforms:
# Run JVM tests (including JvmDeviceIdentityKeyStore tests)
./gradlew :security:jvmTest
# Run Android unit tests
./gradlew :security:testDebugUnitTest
# Run iOS simulator native tests
./gradlew :security:iosSimulatorArm64TestSee SECURITY.md, SECURITY_PROTOCOL.md, and CHANGELOG.md.
Created and maintained by Ishant Sharma (@Kratos1996).
Email: ishant.sharma1947@gmail.com
A Kotlin Multiplatform security foundation for Compose Multiplatform and native Android/iOS applications.
Package: com.ishant.security
Modules:
:security — Core KMP library (cryptography, key abstractions, hardware identity, serialization helpers, handshake, and tests). Contains all crypto and keystore implementations (AndroidDeviceIdentityKeyStore, IosDeviceIdentityKeyStore, and JvmDeviceIdentityKeyStore).:app — Unified Compose Multiplatform application sharing the exact same Compose UI (commonMain/App.kt) across Android, Desktop, and iOS.iosApp — Xcode iOS project wrapping the shared Compose Multiplatform UI (ComposeApp.framework) inside a standard ComposeUIViewController.Security foundation with AES-256-GCM encryption and an authenticated ephemeral X25519 + HKDF-SHA256 handshake protocol. This repository is structured as a Kotlin Multiplatform library with a unified Compose Multiplatform sample application running on Android, Desktop, and iOS.
Add the dependency to your project's build.gradle.kts:
dependencies {
implementation("io.github.kratos1996:kmp-security:1.0.2")
}settings.gradle.kts:dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}dependencies {
implementation("com.github.Kratos1996:KMP_Security:1.0.2")
}KMP_Security/
├── security/ # Core KMP Security Library (All crypto and keystore logic)
│ ├── src/commonMain/ # AES-256-GCM, SecurityManager, Handshake, Session, Models
│ ├── src/androidMain/ # AndroidDeviceIdentityKeyStore (Android Keystore P-256 ECDSA)
│ ├── src/iosMain/ # IosDeviceIdentityKeyStore (Secure Enclave P-256 ECDSA)
│ ├── src/jvmMain/ # JvmDeviceIdentityKeyStore (JCA ECDSA P-256 file/memory keystore)
│ ├── src/commonTest/ # Cross-platform unit tests
│ └── src/jvmTest/ # JVM Keystore & crypto test suite
├── app/ # Unified Compose Multiplatform Sample Application
│ ├── src/commonMain/ # Shared Compose UI (App.kt with Tabs: Encrypt/Decrypt & Automated Demos)
│ ├── src/androidMain/ # Android entry point (MainActivity.kt)
│ ├── src/desktopMain/ # Desktop entry point (Main.kt)
│ └── src/iosMain/ # iOS entry point (MainViewController.kt -> ComposeUIViewController)
└── iosApp/ # Xcode iOS Shell
├── iosApp/ # Hosts ComposeView (ContentView.swift -> MainViewController())
└── iosApp.xcodeproj # Xcode project embedding ComposeApp.framework
CURRENT_VERSION (1) and ALGORITHM ("AES-256-GCM") generated directly via Gradle SecurityBuildConfig.client-to-server & server-to-client) and pinned Ed25519 server transcript signatures.@Serializable Kotlin models using kotlinx.serialization.// Inside a suspend function or coroutine scope
val key = RawAesKey(keyBytes) // 32-byte key from secure key management
val aes = Aes256Gcm()
val encrypted: EncryptedPayload = aes.encrypt(
plaintext = "sensitive payload".encodeToByteArray(),
key = key,
associatedData = "context:v1".encodeToByteArray(),
)
val decryptedBytes = aes.decrypt(
payload = encrypted,
key = key,
associatedData = "context:v1".encodeToByteArray(),
)val manager = SecurityManager()
val profile = UserProfile(userId = "usr_101", email = "user@example.com", roles = listOf("USER"))
// Encrypt Kotlin @Serializable Object
val encryptedPayload = manager.encryptObject(
value = profile,
serializer = UserProfile.serializer(),
key = key,
associatedData = "user_profile_context".encodeToByteArray(),
)
// Decrypt Kotlin Object
val decryptedProfile: UserProfile = manager.decryptObject(
payload = encryptedPayload,
serializer = UserProfile.serializer(),
key = key,
associatedData = "user_profile_context".encodeToByteArray(),
)val keyStore = AndroidDeviceIdentityKeyStore()
val identityKey = keyStore.getOrCreate() // Generates non-exportable P-256 ECDSA key in Android Keystore
val challengeSignature = keyStore.sign(challengeBytes)
// Send identityKey.keyId, identityKey.publicKeyDer, and challengeSignature to backend for verificationThe :app module provides a Jetpack Compose UI for testing the security library directly on an Android device or emulator:
AES-256-GCM, copy JSON payload to Android Clipboard, paste ciphertext, and decrypt back to plaintext.The :app module provides a single, unified Compose Multiplatform UI (app/src/commonMain/kotlin/com/ishant/security/sample/App.kt) that runs natively on Android, Desktop (JVM), and iOS:
./gradlew :app:assembleDebug# Launch Compose Desktop window
./gradlew :app:desktopRun
# Or package standalone executable UberJar
./gradlew :app:packageUberJarForCurrentOSThe iosApp directory hosts a standard Xcode wrapper that displays the shared Compose Multiplatform UI through ComposeUIViewController:
# Build the Xcode project for iOS Simulator
xcodebuild -project iosApp/iosApp.xcodeproj -scheme iosApp -destination "platform=iOS Simulator,name=iPhone 18 Pro" build CODE_SIGNING_ALLOWED=NO
# Or open in Xcode:
open iosApp/iosApp.xcodeprojRun unit tests across all platforms:
# Run JVM tests (including JvmDeviceIdentityKeyStore tests)
./gradlew :security:jvmTest
# Run Android unit tests
./gradlew :security:testDebugUnitTest
# Run iOS simulator native tests
./gradlew :security:iosSimulatorArm64TestSee SECURITY.md, SECURITY_PROTOCOL.md, and CHANGELOG.md.
Created and maintained by Ishant Sharma (@Kratos1996).
Email: ishant.sharma1947@gmail.com