-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
325 changed files
with
1,281 additions
and
1,575 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(libs.bouncycastle) | ||
} |
43 changes: 43 additions & 0 deletions
43
build-tools/src/main/kotlin/org/worldcubeassociation/tnoodle/core/crypto/AsymmetricCipher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.worldcubeassociation.tnoodle.core.crypto | ||
|
||
import org.bouncycastle.util.io.pem.PemReader | ||
import java.io.File | ||
import java.io.Reader | ||
import java.security.* | ||
import java.security.spec.PKCS8EncodedKeySpec | ||
import java.security.spec.X509EncodedKeySpec | ||
|
||
object AsymmetricCipher { | ||
const val ENCRYPTION_ALGORITHM = "RSA" | ||
const val PUBLIC_KEY_PEM = "/rsa/tnoodle_public.pem" | ||
|
||
private val PUBLIC_KEY_BYTES = loadRSAKeyBytesFromResource(PUBLIC_KEY_PEM) | ||
val RSA_PUBLIC_KEY by lazy { generatePublicKey(PUBLIC_KEY_BYTES) } | ||
|
||
private val CIPHER_KEY_FACTORY = KeyFactory.getInstance(ENCRYPTION_ALGORITHM) | ||
|
||
fun loadRSAKeyBytesFromResource(resourcePath: String): ByteArray { | ||
val keyStream = this::class.java.getResourceAsStream(resourcePath) | ||
?: error("RSA key resource not found: $resourcePath") | ||
|
||
return loadRSAKeyBytes(keyStream.reader()) | ||
} | ||
|
||
fun loadRSAKeyBytesFromFile(keyFile: File): ByteArray { | ||
return loadRSAKeyBytes(keyFile.reader()) | ||
} | ||
|
||
private fun loadRSAKeyBytes(keyFileReader: Reader): ByteArray { | ||
return keyFileReader.use { PemReader(it).readPemObject().content } | ||
} | ||
|
||
fun generatePublicKey(keyBytes: ByteArray): PublicKey { | ||
val spec = X509EncodedKeySpec(keyBytes) | ||
return CIPHER_KEY_FACTORY.generatePublic(spec) | ||
} | ||
|
||
fun generatePrivateKey(keyBytes: ByteArray): PrivateKey { | ||
val spec = PKCS8EncodedKeySpec(keyBytes) | ||
return CIPHER_KEY_FACTORY.generatePrivate(spec) | ||
} | ||
} |
15 changes: 8 additions & 7 deletions
15
...noodle/server/crypto/BuildVerification.kt → .../tnoodle/core/crypto/BuildVerification.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
build-tools/src/main/kotlin/org/worldcubeassociation/tnoodle/core/util/FrontendUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.worldcubeassociation.tnoodle.core.util | ||
|
||
object FrontendUtil { | ||
const val FRONTEND_BINDING_PACKAGE = "wca/tnoodle-ui" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!src/main/kotlin/org/worldcubeassociation/tnoodle/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ dependencyResolutionManagement { | |
} | ||
} | ||
} | ||
|
||
include("tools") |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
buildSrc/src/main/kotlin/org/worldcubeassociation/tnoodle/build/BuildSignature.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.worldcubeassociation.tnoodle.build | ||
|
||
import org.gradle.api.Project | ||
import java.io.File | ||
import org.worldcubeassociation.tnoodle.core.crypto.AsymmetricCipher | ||
import org.worldcubeassociation.tnoodle.core.crypto.BuildVerification | ||
|
||
object BuildSignature { | ||
const val SIGNATURE_PACKAGE = BuildVerification.SIGNATURE_PACKAGE | ||
const val SIGNATURE_SUFFIX = BuildVerification.SIGNATURE_SUFFIX | ||
|
||
fun Project.createBuildSignature(signingKeyPath: String, fileToSign: File): ByteArray { | ||
val privateKeyBytes = AsymmetricCipher.loadRSAKeyBytesFromFile(file(signingKeyPath)) | ||
val privateKey = AsymmetricCipher.generatePrivateKey(privateKeyBytes) | ||
|
||
val fileBytes = fileToSign.readBytes() | ||
|
||
val preparedCheck = BuildVerification.SIGNATURE_INSTANCE.apply { | ||
initSign(privateKey) | ||
update(fileBytes) | ||
} | ||
|
||
return preparedCheck.sign() | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...kotlin/configurations/CompilerSettings.kt → ...ciation/tnoodle/build/CompilerSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...c/main/kotlin/configurations/FileUtils.kt → ...ubeassociation/tnoodle/build/FileUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../main/kotlin/configurations/Frameworks.kt → ...beassociation/tnoodle/build/Frameworks.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
buildSrc/src/main/kotlin/org/worldcubeassociation/tnoodle/build/FrontendBindings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.worldcubeassociation.tnoodle.build | ||
|
||
import org.worldcubeassociation.tnoodle.core.util.FrontendUtil | ||
|
||
object FrontendBindings { | ||
const val PACKAGE_ROOT = FrontendUtil.FRONTEND_BINDING_PACKAGE | ||
} |
2 changes: 1 addition & 1 deletion
2
...c/main/kotlin/configurations/Languages.kt → ...ubeassociation/tnoodle/build/Languages.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../kotlin/configurations/ProjectVersions.kt → ...ociation/tnoodle/build/ProjectVersions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../build-tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
cloud/src/main/kotlin/org/worldcubeassociation/tnoodle/cloud/CloudscramblesServer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.worldcubeassociation.tnoodle.cloud | ||
|
||
import io.ktor.server.application.* | ||
import io.ktor.server.routing.* | ||
import org.worldcubeassociation.tnoodle.core.ApplicationHandler | ||
import org.worldcubeassociation.tnoodle.core.TNoodleServer | ||
import org.worldcubeassociation.tnoodle.cloud.routing.HomepageHandler | ||
import org.worldcubeassociation.tnoodle.cloud.routing.PuzzleListHandler | ||
import org.worldcubeassociation.tnoodle.cloud.routing.ScrambleHandler | ||
import org.worldcubeassociation.tnoodle.cloud.routing.ScrambleViewHandler | ||
import org.worldcubeassociation.tnoodle.core.ServerEnvironmentConfig | ||
|
||
object CloudscramblesServer : ApplicationHandler { | ||
override fun spinUp(app: Application) { | ||
val cloudscramblesWrapper = TNoodleServer(GoogleServerEnvironmentConfig) | ||
|
||
app.routing { | ||
HomepageHandler.install(this) | ||
|
||
route("api") { | ||
route("v0") { | ||
ScrambleHandler.install(this) | ||
ScrambleViewHandler.install(this) | ||
PuzzleListHandler.install(this) | ||
} | ||
} | ||
} | ||
|
||
GoogleServerEnvironmentConfig.overrideFontConfig() | ||
|
||
cloudscramblesWrapper.spinUp(app) | ||
} | ||
} | ||
|
Oops, something went wrong.