Skip to content

Commit

Permalink
Experiment with padding
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed Sep 19, 2023
1 parent 68c314b commit b40afa3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/main/services/browser/auth.ts
Original file line number Diff line number Diff line change
@@ -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<string> {
// Check that the client is registered, we don't actually
Expand All @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit b40afa3

Please sign in to comment.