Deal with node v11 pipeline()

This commit is contained in:
Tau
2019-04-13 12:31:50 -04:00
parent 5c4d011ac5
commit 7a95536d01

View File

@@ -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),