fix(ecdsa): correct unescape error in ECDSA Sign and ECDSA Verify op
This commit is contained in:
parent
314a14a45b
commit
118576f257
@ -6,7 +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 { fromHex } from "../lib/Hex.mjs";
|
import { fromHex, toHexFast } from "../lib/Hex.mjs";
|
||||||
import { toBase64 } from "../lib/Base64.mjs";
|
import { toBase64 } from "../lib/Base64.mjs";
|
||||||
import r from "jsrsasign";
|
import r from "jsrsasign";
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ class ECDSASign extends Operation {
|
|||||||
this.module = "Ciphers";
|
this.module = "Ciphers";
|
||||||
this.description = "Sign a plaintext message with a PEM encoded EC key.";
|
this.description = "Sign a plaintext message with a PEM encoded EC key.";
|
||||||
this.infoURL = "https://wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm";
|
this.infoURL = "https://wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm";
|
||||||
this.inputType = "string";
|
this.inputType = "ArrayBuffer";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ class ECDSASign extends Operation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} input
|
* @param {ArrayBuffer} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
@ -79,7 +79,7 @@ class ECDSASign extends Operation {
|
|||||||
throw new OperationError("Provided key is not a private key.");
|
throw new OperationError("Provided key is not a private key.");
|
||||||
}
|
}
|
||||||
sig.init(key);
|
sig.init(key);
|
||||||
const signatureASN1Hex = sig.signString(input);
|
const signatureASN1Hex = sig.signHex(toHexFast(new Uint8Array(input)));
|
||||||
|
|
||||||
let result;
|
let result;
|
||||||
switch (outputFormat) {
|
switch (outputFormat) {
|
||||||
|
|||||||
@ -151,8 +151,8 @@ class ECDSAVerify extends Operation {
|
|||||||
throw new OperationError("Provided key is not a public key.");
|
throw new OperationError("Provided key is not a public key.");
|
||||||
}
|
}
|
||||||
sig.init(key);
|
sig.init(key);
|
||||||
const messageStr = Utils.convertToByteString(msg, msgFormat);
|
const messageByteArray = Utils.convertToByteArray(msg, msgFormat);
|
||||||
sig.updateString(messageStr);
|
sig.updateHex(toHexFast(messageByteArray));
|
||||||
const result = sig.verify(signatureASN1Hex);
|
const result = sig.verify(signatureASN1Hex);
|
||||||
return result ? "Verified OK" : "Verification Failure";
|
return result ? "Verified OK" : "Verification Failure";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user