From b40afa3bb591e108ea61d68e2d0e9c76c6fbf60f Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Tue, 19 Sep 2023 20:12:52 +0300 Subject: [PATCH] Experiment with padding --- source/main/services/browser/auth.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/main/services/browser/auth.ts b/source/main/services/browser/auth.ts index 058c1960..51534cb9 100644 --- a/source/main/services/browser/auth.ts +++ b/source/main/services/browser/auth.ts @@ -1,9 +1,9 @@ import { constants as CryptoConstants, privateDecrypt, publicEncrypt } from "node:crypto"; import { Layerr } from "layerr"; +import { base64ToBytes, bytesToBase64 } from "buttercup"; import { getBrowserPublicKeyString } from "../browserAuth"; import { getConfigValue, setConfigValue } from "../config"; import { BrowserAPIErrorType } from "../../types"; -import { base64ToBytes, bytesToBase64 } from "buttercup"; export async function decryptPayload(clientID: string, payload: string): Promise { // Check that the client is registered, we don't actually @@ -30,6 +30,7 @@ export async function decryptPayload(clientID: string, payload: string): Promise { key: browserPrivateKey, padding: CryptoConstants.RSA_PKCS1_OAEP_PADDING, + // padding: CryptoConstants.RSA_NO_PADDING, oaepHash: "sha256" }, base64ToBytes(payload) @@ -51,11 +52,13 @@ export async function encryptPayload(clientID: string, payload: string): Promise "No client key registered for encryption" ); } + console.log("\n\n\nGOING TO ENCRYPT", clientConfig, payload); // Encrypt const encryptedData = publicEncrypt( { key: clientConfig.publicKey, padding: CryptoConstants.RSA_PKCS1_OAEP_PADDING, + // padding: CryptoConstants.RSA_NO_PADDING, oaepHash: "sha256" }, Buffer.from(payload, "utf-8")