diff --git a/src/idz/setup.ts b/src/idz/setup.ts index e7bc157..cd5233f 100644 --- a/src/idz/setup.ts +++ b/src/idz/setup.ts @@ -1,6 +1,7 @@ import { createCipheriv, createDecipheriv } from "crypto"; import { Socket } from "net"; -import { pipeline } from "stream"; +import { pipeline as pipelineWithCallback } from "stream"; +import { promisify } from "util"; import { byteString, modPow } from "./bigint"; import { Decoder } from "./decoder"; @@ -8,6 +9,10 @@ import { Encoder } from "./encoder"; import { Request } from "./request"; import { Response } from "./response"; +// Drops the stupid mandatory callback parameter crap + +const pipeline = promisify(pipelineWithCallback); + // Proof-of-concept, so we only ever use one of the ten RSA key pairs // (SEGA shipped their central server private keys for god knows what reason) @@ -54,15 +59,16 @@ export function setup(socket: Socket): Session { // Set up pipeline // + const input = new Decoder(); + const output = new Encoder(); const keybuf = byteString(sessionKey, 0x10); - const input = pipeline( + + pipeline( socket, createDecipheriv("aes-128-ecb", keybuf, null).setAutoPadding(false), - new Decoder() + input ); - const output = new Encoder(); - pipeline( output, createCipheriv("aes-128-ecb", keybuf, null).setAutoPadding(false),