diff --git a/common/pom.xml b/common/pom.xml
index a472baea..6624d84e 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -19,6 +19,10 @@
com.google.guava
guava
+
+ com.google.inject
+ guice
+
com.google.jimfs
jimfs
diff --git a/common/src/main/java/dev/openrs2/common/CommonModule.kt b/common/src/main/java/dev/openrs2/common/CommonModule.kt
new file mode 100644
index 00000000..bda823be
--- /dev/null
+++ b/common/src/main/java/dev/openrs2/common/CommonModule.kt
@@ -0,0 +1,14 @@
+package dev.openrs2.common
+
+import com.google.inject.AbstractModule
+import com.google.inject.Scopes
+import dev.openrs2.common.crypto.RsaKeyProvider
+import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters
+
+class CommonModule : AbstractModule() {
+ override fun configure() {
+ bind(RSAPrivateCrtKeyParameters::class.java)
+ .toProvider(RsaKeyProvider::class.java)
+ .`in`(Scopes.SINGLETON)
+ }
+}
diff --git a/common/src/main/java/dev/openrs2/common/crypto/RsaKeyProvider.kt b/common/src/main/java/dev/openrs2/common/crypto/RsaKeyProvider.kt
new file mode 100644
index 00000000..97dd7d1c
--- /dev/null
+++ b/common/src/main/java/dev/openrs2/common/crypto/RsaKeyProvider.kt
@@ -0,0 +1,22 @@
+package dev.openrs2.common.crypto
+
+import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters
+import java.nio.file.Files
+import java.nio.file.Paths
+import javax.inject.Provider
+
+class RsaKeyProvider : Provider {
+ override fun get(): RSAPrivateCrtKeyParameters {
+ return if (Files.exists(PATH)) {
+ Rsa.readPrivateKey(PATH)
+ } else {
+ val (_, private) = Rsa.generateKeyPair()
+ Rsa.writePrivateKey(PATH, private)
+ private
+ }
+ }
+
+ companion object {
+ private val PATH = Paths.get("conf/private.key")
+ }
+}
diff --git a/conf/.gitignore b/conf/.gitignore
new file mode 100644
index 00000000..b8bd887f
--- /dev/null
+++ b/conf/.gitignore
@@ -0,0 +1 @@
+/private.key
diff --git a/pom.xml b/pom.xml
index 013a329d..f8b3f979 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,11 @@
guava
28.2-jre
+
+ com.google.inject
+ guice
+ 4.2.2
+
com.google.jimfs
jimfs