forked from Hay1tsme/artemis
[mai2] Support encryption (#130)
Similar to O.N.G.E.K.I. and CHUNITHM, with the caveat that the obfuscated endpoint is created using `md5(endpoint + salt)` instead of using PBKDF2 like other games. Tested and confirmed working on FESTiVAL+. The current implementation is also affected by #129, so I'm open to ideas. Reviewed-on: Hay1tsme/artemis#130 Co-authored-by: beerpsi <beerpsi@duck.com> Co-committed-by: beerpsi <beerpsi@duck.com>
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
from typing import Dict
|
||||
|
||||
from core.config import CoreConfig
|
||||
|
||||
|
||||
@ -70,8 +72,32 @@ class Mai2UploadsConfig:
|
||||
)
|
||||
|
||||
|
||||
class Mai2CryptoConfig:
|
||||
def __init__(self, parent_config: "Mai2Config") -> None:
|
||||
self.__config = parent_config
|
||||
|
||||
@property
|
||||
def keys(self) -> Dict[int, list[str]]:
|
||||
"""
|
||||
in the form of:
|
||||
internal_version: [key, iv, salt]
|
||||
key and iv are hex strings
|
||||
salt is a normal UTF-8 string
|
||||
"""
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "mai2", "crypto", "keys", default={}
|
||||
)
|
||||
|
||||
@property
|
||||
def encrypted_only(self) -> bool:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "mai2", "crypto", "encrypted_only", default=False
|
||||
)
|
||||
|
||||
|
||||
class Mai2Config(dict):
|
||||
def __init__(self) -> None:
|
||||
self.server = Mai2ServerConfig(self)
|
||||
self.deliver = Mai2DeliverConfig(self)
|
||||
self.uploads = Mai2UploadsConfig(self)
|
||||
self.crypto = Mai2CryptoConfig(self)
|
Reference in New Issue
Block a user