Fix RSA operations
This commit is contained in:
parent
18c6b9bc09
commit
1c0ecd29c2
@ -8,6 +8,7 @@
|
|||||||
import Operation from "../Operation";
|
import Operation from "../Operation";
|
||||||
import OperationError from "../errors/OperationError";
|
import OperationError from "../errors/OperationError";
|
||||||
import forge from "node-forge/dist/forge.min.js";
|
import forge from "node-forge/dist/forge.min.js";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
import { MD_ALGORITHMS } from "../lib/RSA.mjs";
|
import { MD_ALGORITHMS } from "../lib/RSA.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +27,7 @@ class RSASign extends Operation {
|
|||||||
this.description = "Sign a plaintext message with a PEM encoded RSA key.";
|
this.description = "Sign a plaintext message with a PEM encoded RSA key.";
|
||||||
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "byteArray";
|
this.outputType = "string";
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
name: "RSA Private Key (PEM)",
|
name: "RSA Private Key (PEM)",
|
||||||
@ -61,10 +62,9 @@ class RSASign extends Operation {
|
|||||||
// Generate message hash
|
// Generate message hash
|
||||||
const md = MD_ALGORITHMS[mdAlgo].create();
|
const md = MD_ALGORITHMS[mdAlgo].create();
|
||||||
md.update(input, "utf8");
|
md.update(input, "utf8");
|
||||||
// Convert signature UTF-16 string to byteArray
|
// Sign message hash
|
||||||
const encoder = new TextEncoder();
|
const sig = privateKey.sign(md);
|
||||||
const signature = encoder.encode(privateKey.sign(md));
|
return sig;
|
||||||
return signature;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new OperationError(err);
|
throw new OperationError(err);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
import forge from "node-forge/dist/forge.min.js";
|
import forge from "node-forge/dist/forge.min.js";
|
||||||
import { MD_ALGORITHMS } from "../lib/RSA.mjs";
|
import { MD_ALGORITHMS } from "../lib/RSA.mjs";
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ class RSAVerify extends Operation {
|
|||||||
this.module = "Ciphers";
|
this.module = "Ciphers";
|
||||||
this.description = "Verify a message against a signature and a public PEM encoded RSA key.";
|
this.description = "Verify a message against a signature and a public PEM encoded RSA key.";
|
||||||
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
||||||
this.inputType = "byteArray";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user