3
2
forked from Dniel97/artemis

add keychip ID to auth key

This commit is contained in:
Hay1tsme 2023-11-30 18:17:40 -05:00
parent a1569bca9d
commit ffc0f2fa5e
2 changed files with 4 additions and 4 deletions

View File

@ -182,7 +182,7 @@ class AimedbProtocol(Protocol):
) )
if user_id and user_id > 0 and self.config.aimedb.id_secret: if user_id and user_id > 0 and self.config.aimedb.id_secret:
auth_key = create_sega_auth_key(user_id, req.head.game_id, req.head.store_id, self.config.aimedb.id_secret) auth_key = create_sega_auth_key(user_id, req.head.game_id, req.head.store_id, req.head.keychip_id, self.config.aimedb.id_secret)
if auth_key is not None: if auth_key is not None:
auth_key_extra_len = 256 - len(auth_key) auth_key_extra_len = 256 - len(auth_key)
auth_key_full = auth_key.encode() + (b"\0" * auth_key_extra_len) auth_key_full = auth_key.encode() + (b"\0" * auth_key_extra_len)
@ -254,7 +254,7 @@ class AimedbProtocol(Protocol):
resp = ADBFelicaLookup2Response.from_req(req.head, user_id, access_code) resp = ADBFelicaLookup2Response.from_req(req.head, user_id, access_code)
if user_id and user_id > 0 and self.config.aimedb.id_secret: if user_id and user_id > 0 and self.config.aimedb.id_secret:
auth_key = create_sega_auth_key(user_id, req.head.game_id, req.head.store_id, self.config.aimedb.id_secret) auth_key = create_sega_auth_key(user_id, req.head.game_id, req.head.store_id, req.head.keychip_id, self.config.aimedb.id_secret)
if auth_key is not None: if auth_key is not None:
auth_key_extra_len = 256 - len(auth_key) auth_key_extra_len = 256 - len(auth_key)
auth_key_full = auth_key.encode() + (b"\0" * auth_key_extra_len) auth_key_full = auth_key.encode() + (b"\0" * auth_key_extra_len)

View File

@ -64,10 +64,10 @@ class Utils:
return cls.real_title_port_ssl return cls.real_title_port_ssl
def create_sega_auth_key(aime_id: int, game: str, place_id: int, b64_secret: str, err_logger: str = 'aimedb') -> Optional[str]: def create_sega_auth_key(aime_id: int, game: str, place_id: int, keychip_id: str, b64_secret: str, err_logger: str = 'aimedb') -> Optional[str]:
logger = logging.getLogger(err_logger) logger = logging.getLogger(err_logger)
try: try:
return jwt.encode({ "aime_id": aime_id, "game": game, "place_id": place_id, "exp": int(datetime.now(tz=timezone.utc).timestamp()) + 86400 }, b64decode(b64_secret), algorithm="HS256") return jwt.encode({ "aime_id": aime_id, "game": game, "place_id": place_id, "keychip_id": keychip_id, "exp": int(datetime.now(tz=timezone.utc).timestamp()) + 86400 }, b64decode(b64_secret), algorithm="HS256")
except jwt.InvalidKeyError: except jwt.InvalidKeyError:
logger.error("Failed to encode Sega Auth Key because the secret is invalid!") logger.error("Failed to encode Sega Auth Key because the secret is invalid!")
return None return None