Enable USDPL network encryption

This commit is contained in:
NGnius (Graham) 2022-12-03 20:24:12 -05:00
parent 044f768768
commit 8a7816f9f4
15 changed files with 297 additions and 175 deletions

107
backend/Cargo.lock generated
View file

@ -2,6 +2,42 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "aead"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877"
dependencies = [
"generic-array",
]
[[package]]
name = "aes"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
dependencies = [
"cfg-if",
"cipher",
"cpufeatures",
"opaque-debug",
]
[[package]]
name = "aes-gcm-siv"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589c637f0e68c877bbd59a4599bbe849cac8e5f3e4b5a3ebae8f528cd218dcdc"
dependencies = [
"aead",
"aes",
"cipher",
"ctr",
"polyval",
"subtle",
"zeroize",
]
[[package]]
name = "aho-corasick"
version = "0.7.19"
@ -113,6 +149,15 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cipher"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7"
dependencies = [
"generic-array",
]
[[package]]
name = "clap"
version = "3.2.20"
@ -168,6 +213,15 @@ dependencies = [
"typenum",
]
[[package]]
name = "ctr"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea"
dependencies = [
"cipher",
]
[[package]]
name = "deunicode"
version = "0.4.3"
@ -346,6 +400,12 @@ dependencies = [
"libc",
]
[[package]]
name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "http"
version = "0.2.8"
@ -550,6 +610,12 @@ dependencies = [
"libc",
]
[[package]]
name = "obfstr"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b2b2cbbfd8defa51ff24450a61d73b3ff3e158484ddd274a883e886e6fbaa78"
[[package]]
name = "once_cell"
version = "1.13.0"
@ -606,6 +672,18 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "polyval"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1"
dependencies = [
"cfg-if",
"cpufeatures",
"opaque-debug",
"universal-hash",
]
[[package]]
name = "ppv-lite86"
version = "0.2.16"
@ -849,6 +927,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "subtle"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]]
name = "syn"
version = "1.0.98"
@ -1109,6 +1193,16 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "universal-hash"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05"
dependencies = [
"generic-array",
"subtle",
]
[[package]]
name = "url"
version = "2.2.2"
@ -1123,14 +1217,16 @@ dependencies = [
[[package]]
name = "usdpl-back"
version = "0.7.0"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ca96dac4ee471e9534940f99cb36f5212cbfaf4e7779eb3ba970d3c511d9583"
checksum = "58928ed65332c30b9b9be5140fcdab97e45db679a5845d829aa26492765272e5"
dependencies = [
"async-recursion",
"async-trait",
"bytes",
"hex",
"log",
"obfstr",
"tokio",
"usdpl-core",
"warp",
@ -1142,6 +1238,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "862153581fac266458521f49e5906a71c1eee1665cb4c7d71e9586bd34b45394"
dependencies = [
"aes-gcm-siv",
"base64",
]
@ -1276,3 +1373,9 @@ name = "windows_x86_64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]]
name = "zeroize"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd"

View file

@ -8,7 +8,7 @@ license = "MIT"
repository = "https://github.com/NGnius/kaylon"
[dependencies]
usdpl-back = { version = "0.7.0", features = ["decky"]}
usdpl-back = { version = "0.7.2"}
clap = { version = "3.2", features = ["derive", "std"], default-features = false }
@ -27,6 +27,11 @@ regex = { version = "1" }
log = { version = "0.4" }
simplelog = { version = "0.12" }
[features]
default = ["decky"]
decky = ["usdpl-back/decky"]
encrypt = ["usdpl-back/encrypt"]
[profile.release]
debug = false
strip = true

6
backend/Dockerfile Normal file
View file

@ -0,0 +1,6 @@
FROM ghcr.io/steamdeckhomebrew/holo-toolchain-rust:latest
RUN pacman -S --noconfirm git python3
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
ENTRYPOINT [ "/caylon/backend/entrypoint.sh" ]

21
backend/build-docker.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
export USDPL_ENCRYPTION_KEY=$(openssl enc -aes-256-cbc -k caylon -pbkdf2 -P -md sha1 | awk -F= '{if ($1 == "key") print $2}')
echo " --- Rust version info ---"
rustup --version
rustc --version
cargo --version
echo " --- Building plugin backend ---"
cargo build --release --features encrypt
mkdir -p out
cp target/release/caylon out/backend
echo " --- Cleaning up backend ---"
# remove root-owned target folder
cargo clean
echo " --- Building plugin frontend WASM ---"
# TODO allow Dockerfile in root so that it can access src/usdpl_front and rebuild it
cd ../src/usdpl_front && ./rebuild.sh decky encrypt && cd ../../backend

View file

@ -1,8 +1,8 @@
#!/bin/bash
#cargo build --release --target x86_64-unknown-linux-musl
cargo build --target x86_64-unknown-linux-musl
#cross build --release
#cargo build --release --target x86_64-unknown-linux-musl --features encrypt
cargo build --target x86_64-unknown-linux-musl --features encrypt
#cross build --release --features encrypt
mkdir -p ../bin
#cp ./target/x86_64-unknown-linux-musl/release/caylon ../bin/backend

4
backend/create_docker_img.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
# build docker container locally (for testing)
cd .. && docker build -t caylon_backend -f ./backend/Dockerfile . && cd ./backend

8
backend/entrypoint.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
set -e
echo "Container's IP address: `awk 'END{print $1}' /etc/hosts`"
cd /caylon/backend
sudo bash ./build-docker.sh

7
backend/run_docker_img.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
# run docker container locally (for testing)
# assumes you're running in the backend/ dir of the project
docker run -i --entrypoint /caylon/backend/entrypoint.sh -v $PWD/../:/caylon caylon_backend
mkdir -p ../bin
cp ./out/backend ../bin

12
build.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
export USDPL_ENCRYPTION_KEY=$(openssl enc -aes-256-cbc -k caylon -pbkdf2 -P -md sha1 | awk -F= '{if ($1 == "key") print $2}')
echo USDPL key: $USDPL_ENCRYPTION_KEY
cd ./backend && ./build.sh && cd ..
cd ./src/usdpl_front && ./rebuild.sh decky encrypt && cd ../..
npm install && npm run build
unset USDPL_ENCRYPTION_KEY

View file

@ -125,6 +125,24 @@
"action": "json",
"jmespath": "join(' ', [action, to_string(gameID)])"
}
},
{
"element": "event-display",
"title": "JSON -> JS -> Out",
"event": "game-start",
"on_event": {
"action": "sequence",
"steps": [
{
"action": "json",
"jmespath": "join(' ', [action, to_string(gameID)])"
},
{
"action": "javascript",
"run": "console.warn(\"TEST CAYLON game started\", CAYLON_VALUE); CAYLON_VALUE"
}
]
}
}
],
"about": {

View file

@ -4,7 +4,7 @@
"NGnius (Graham) <ngniusness@gmail.com>"
],
"description": "Universal Steam Deck Plugin Library front-end designed for WASM",
"version": "0.6.2",
"version": "0.7.0",
"license": "GPL-3.0-only",
"repository": {
"type": "git",

13
src/usdpl_front/rebuild.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
git clone https://github.com/NGnius/usdpl-rs usdpl-rs
cd usdpl-rs/usdpl-front/
./build.sh $1 $2
cd ../..
cp -f ./usdpl-rs/usdpl-front/pkg/* ./
#rm ./.gitignore
rm -rf ./usdpl-rs

View file

@ -57,14 +57,16 @@ export interface InitOutput {
readonly __wbindgen_export_6: (a: number, b: number, c: number, d: number) => void;
}
export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Synchronously compiles the given `bytes` and instantiates the WebAssembly module.
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {BufferSource} bytes
* @param {SyncInitInput} module
*
* @returns {InitOutput}
*/
export function initSync(bytes: BufferSource): InitOutput;
export function initSync(module: SyncInitInput): InitOutput;
/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and

File diff suppressed because one or more lines are too long

Binary file not shown.