Skip to content

Commit 895a929

Browse files
committed
Fixed RSA Sign and Verify character encodings
1 parent d635cca commit 895a929

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/core/operations/RSASign.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class RSASign extends Operation {
6060
const privateKey = forge.pki.decryptRsaPrivateKey(key, password);
6161
// Generate message hash
6262
const md = MD_ALGORITHMS[mdAlgo].create();
63-
md.update(input, "utf8");
63+
md.update(input, "raw");
6464
// Sign message hash
6565
const sig = privateKey.sign(md);
6666
return sig;

src/core/operations/RSAVerify.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class RSAVerify extends Operation {
6060
const pubKey = forge.pki.publicKeyFromPem(pemKey);
6161
// Generate message digest
6262
const md = MD_ALGORITHMS[mdAlgo].create();
63-
md.update(message, "utf8");
63+
md.update(message, "raw");
6464
// Compare signed message digest and generated message digest
6565
const result = pubKey.verify(md.digest().bytes(), input);
6666
return result ? "Verified OK" : "Verification Failure";

0 commit comments

Comments
 (0)