Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/rsa.js

Issue 29715555: Issue 6447 - Switch to Harmony modules in lib/* (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created March 6, 2018, 7:42 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« lib/common.js ('K') | « lib/notification.js ('k') | lib/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld