Skip to content

Commit

Permalink
Fixed RSA Sign and Verify character encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
n1474335 committed Oct 23, 2024
1 parent d635cca commit 895a929
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/operations/RSASign.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RSASign extends Operation {
const privateKey = forge.pki.decryptRsaPrivateKey(key, password);
// Generate message hash
const md = MD_ALGORITHMS[mdAlgo].create();
md.update(input, "utf8");
md.update(input, "raw");
// Sign message hash
const sig = privateKey.sign(md);
return sig;
Expand Down
2 changes: 1 addition & 1 deletion src/core/operations/RSAVerify.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RSAVerify extends Operation {
const pubKey = forge.pki.publicKeyFromPem(pemKey);
// Generate message digest
const md = MD_ALGORITHMS[mdAlgo].create();
md.update(message, "utf8");
md.update(message, "raw");
// Compare signed message digest and generated message digest
const result = pubKey.verify(md.digest().bytes(), input);
return result ? "Verified OK" : "Verification Failure";
Expand Down

0 comments on commit 895a929

Please sign in to comment.