Index: lib/rsa.js |
=================================================================== |
--- a/lib/rsa.js |
+++ b/lib/rsa.js |
@@ -18,18 +18,18 @@ |
/* global console */ |
"use strict"; |
/** |
* This is a specialized RSA library meant only to verify SHA1-based signatures. |
*/ |
-const {BigInteger} = require("jsbn"); |
-const Rusha = require("rusha"); |
+import {BigInteger} from "jsbn"; |
+import Rusha from "rusha"; |
let rusha = new Rusha(); |
// Define ASN.1 templates for the data structures used |
function seq(...args) |
{ |
return {type: 0x30, children: args}; |
} |
@@ -161,17 +161,17 @@ |
/** |
* Checks whether the signature is valid for the given public key and data. |
* @param {string} key |
* @param {string} signature |
* @param {string} data |
* @return {boolean} |
*/ |
-function verifySignature(key, signature, data) |
+export function verifySignature(key, signature, data) |
{ |
let keyData = readPublicKey(key); |
if (!keyData) |
return false; |
// We need the exponent as regular number |
keyData.e = parseInt(keyData.e.toString(16), 16); |
@@ -198,9 +198,8 @@ |
return (sha1.compareTo(expected) == 0); |
} |
catch (e) |
{ |
console.warn("Invalid encrypted signature: " + e); |
return false; |
} |
} |
-exports.verifySignature = verifySignature; |