| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * This is a specialized RSA library meant only to verify SHA1-based signatures. | 19 * This is a specialized RSA library meant only to verify SHA1-based signatures. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 let {BigInteger} = require("jsbn"); | 22 let {BigInteger} = require("jsbn"); |
| 23 let Rusha = require("rusha"); | 23 let Rusha = require("rusha"); |
| 24 | 24 |
| 25 let rusha = new Rusha(); | 25 let rusha = new Rusha(); |
| 26 | |
| 27 | 26 |
| 28 // Define ASN.1 templates for the data structures used | 27 // Define ASN.1 templates for the data structures used |
| 29 function seq() | 28 function seq() |
| 30 { | 29 { |
| 31 return {type: 0x30, children: Array.prototype.slice.call(arguments)}; | 30 return {type: 0x30, children: Array.prototype.slice.call(arguments)}; |
| 32 } | 31 } |
| 33 function obj(id) | 32 function obj(id) |
| 34 { | 33 { |
| 35 return {type: 0x06, content: id}; | 34 return {type: 0x06, content: id}; |
| 36 } | 35 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 var expected = new BigInteger(rusha.digest(data), 16); | 182 var expected = new BigInteger(rusha.digest(data), 16); |
| 184 return (sha1.compareTo(expected) == 0); | 183 return (sha1.compareTo(expected) == 0); |
| 185 } | 184 } |
| 186 catch (e) | 185 catch (e) |
| 187 { | 186 { |
| 188 console.log("Invalid encrypted signature: " + e); | 187 console.log("Invalid encrypted signature: " + e); |
| 189 return false; | 188 return false; |
| 190 } | 189 } |
| 191 } | 190 } |
| 192 exports.verifySignature = verifySignature; | 191 exports.verifySignature = verifySignature; |
| LEFT | RIGHT |