| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the Adblock Plus extension, | 2 * This file is part of the Adblock Plus extension, |
| 3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 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 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Skip padding, see http://tools.ietf.org/html/rfc3447#section-9.2 step 5 | 171 // Skip padding, see http://tools.ietf.org/html/rfc3447#section-9.2 step 5 |
| 172 if (next() != 1) | 172 if (next() != 1) |
| 173 throw "Wrong padding in signature digest"; | 173 throw "Wrong padding in signature digest"; |
| 174 while (next() == 255) {} | 174 while (next() == 255) {} |
| 175 if (digest.charCodeAt(pos - 1) != 0) | 175 if (digest.charCodeAt(pos - 1) != 0) |
| 176 throw "Wrong padding in signature digest"; | 176 throw "Wrong padding in signature digest"; |
| 177 | 177 |
| 178 // Rest is an ASN.1 structure, get the SHA1 hash from it | 178 // Rest is an ASN.1 structure, get the SHA1 hash from it |
| 179 var sha1 = readASN1(digest.substr(pos), signatureTemplate).sha1; | 179 var sha1 = readASN1(digest.substr(pos), signatureTemplate).sha1.toString(1
6); |
| 180 return (sha1.toString(16) == SHA1(data)); | 180 while (sha1.length < 40) |
| 181 sha1 = "0" + sha1; // Zero-pad to the right length |
| 182 return (sha1 == SHA1(data)); |
| 181 } | 183 } |
| 182 catch (e) | 184 catch (e) |
| 183 { | 185 { |
| 184 console.log("Invalid encrypted signature: " + e); | 186 console.log("Invalid encrypted signature: " + e); |
| 185 return false; | 187 return false; |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 189 // Export verifySignature function, everything else is private. | 191 // Export verifySignature function, everything else is private. |
| 190 globalObj.verifySignature = verifySignature; | 192 globalObj.verifySignature = verifySignature; |
| 191 })(this); | 193 })(this); |
| OLD | NEW |