Skip to content

Commit

Permalink
publish: v0.12.0 - Rijndael is now implemented!
Browse files Browse the repository at this point in the history
  • Loading branch information
Pure-Peace committed Jun 16, 2021
1 parent 05095ec commit 9a979cc
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ members = [

[package]
name = "peace"
version = "0.11.2"
version = "0.12.0"
authors = ["PurePeace <[email protected]>"]
edition = "2018"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion peace-constants/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "peace-constants"
version = "0.5.2"
version = "0.5.3"
authors = ["PurePeace <[email protected]>"]
edition = "2018"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion peace-constants/src/constants/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub const PEACE_LOCAL_CONFIG_DIR: &str = "./config/peace";
pub const PP_SERVER_LOCAL_CONFIG_DIR: &str = "./config/pp-server";

pub const DB_VERSION: &str = "0.11.0";
pub const PEACE_VERSION: &str = "0.11.2";
pub const PEACE_VERSION: &str = "0.12.0";
pub const PEACE_BANNER: &str = r#"
.-.
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/web/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub async fn osu_submit_modular<'a>(ctx: &Context<'a>, payload: Multipart) -> Ht
};
// Parse submit mutipart data
let submit_parse = Instant::now();
let submit_data =
let mut submit_data =
match SubmitModular::from_mutipart(peace_utils::web::get_mutipart_data(payload).await) {
Some(d) => d,
None => {
Expand All @@ -124,7 +124,7 @@ pub async fn osu_submit_modular<'a>(ctx: &Context<'a>, payload: Multipart) -> Ht
);
// Parse score data
let score_parse = Instant::now();
let mut s = match ScoreData::from_submit_modular(&submit_data).await {
let mut s = match ScoreData::from_submit_modular(&mut submit_data).await {
Some(s) => s,
None => {
warn!(
Expand Down
2 changes: 0 additions & 2 deletions src/objects/peace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ impl Peace {
}

pub async fn start(&mut self) -> std::io::Result<()> {
peace_utils::python::python_rijndael_init();

self.session_recycle().await;

// Start
Expand Down
35 changes: 19 additions & 16 deletions src/objects/scores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub struct SubmitModular {
pub quit: bool, // x (quit 0 or 1)
pub fail_time: i64, // ft (fail time)
#[derivative(Debug = "ignore")]
pub score: Vec<u8>, // score (base64 -> bytes)
pub score: Option<Vec<u8>>, // score (base64 -> bytes)
pub fs: String,
pub beatmap_hash: String, // bmk
pub c1: String,
Expand All @@ -137,7 +137,7 @@ pub struct SubmitModular {
pub osu_version: i32, // osuver
// pub s: String, // s (s??) what's that?
#[derivative(Debug = "ignore")]
pub iv: Vec<u8>, // iv (initialization vector base64 -> bytes)
pub iv: Option<Vec<u8>>, // iv (initialization vector base64 -> bytes)
#[derivative(Debug = "ignore")]
pub score_file: Option<Bytes>, // score (replay file, octet-stream bytes lzma)
}
Expand All @@ -149,7 +149,7 @@ impl SubmitModular {
quit: data.form::<i32>("x")? == 1,
fail_time: data.form("ft")?,
score: match decode(data.form::<String>("score")?) {
Ok(s) => s,
Ok(s) => Some(s),
Err(_err) => return None,
},
fs: data.form("fs")?,
Expand All @@ -160,7 +160,7 @@ impl SubmitModular {
osu_version: data.form("osuver")?,
// s: data.form("s")?, what
iv: match decode(data.form::<String>("iv")?) {
Ok(s) => s,
Ok(s) => Some(s),
Err(_err) => return None,
},
score_file: data.file("score"),
Expand Down Expand Up @@ -195,19 +195,22 @@ pub struct ScoreData {

impl ScoreData {
#[inline(always)]
pub async fn from_submit_modular(submit_data: &SubmitModular) -> Option<Self> {
pub async fn from_submit_modular(submit_data: &mut SubmitModular) -> Option<Self> {
use peace_utils::serdes::try_parse;
let data = match peace_utils::python::submit_modular_decrypt(
submit_data.osu_version,
&submit_data.iv,
&submit_data.score,
) {
Ok(d) => d,
Err(err) => {
warn!("[SubmitModular] Python decrypt failed, err: {:?}", err);
return None;
}
};
let iv = std::mem::replace(&mut submit_data.iv, None);
let score = std::mem::replace(&mut submit_data.score, None);
let data =
match peace_utils::crypto::submit_modular_decrypt(submit_data.osu_version, iv?, score?)
{
Ok(d) => d,
Err(err) => {
warn!(
"[SubmitModular] Rijndael-256-cbc decrypt failed, err: {:?}",
err
);
return None;
}
};
// Check len
if data.len() < 18 {
warn!("[SubmitModular] Invalid score data length ( < 18)");
Expand Down

0 comments on commit 9a979cc

Please sign in to comment.