Last active
February 11, 2019 06:24
-
-
Save gaodeng/185536ac8fec82c0b2ca1ea90804fd04 to your computer and use it in GitHub Desktop.
electron 4.x dsa verify bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function verifyDSA() { | |
| let buf = Buffer.from([48, 44, 2, 20, 118, 46, 187, 203, 7, 168, 186, 182, 116, 28, 48, 54, 85, 56, 242, 185, 19, 214, 26, 179, 2, 20, 113, 4, 222, 176, 63, 109, 46, 3, 128, 146, 182, 84, 238, 67, 212, 182, 42, 26, 62, 51]); | |
| let publicKey = `-----BEGIN PUBLIC KEY----- | |
| MIHwMIGoBgcqhkjOOAQBMIGcAkEAmYrgU2Ts6pMYXSR6rqN0itG/WFzW6xFdjTy8 | |
| MVYhnico3i2NIpy+EraW5eHzjS2K5obYM2+78628NiDaSd1DrQIVAJ52LqNirlw3 | |
| WXipDgUARabiH1ppAkBsVui+NGpXqFgyh+Gd60Ac8DHeHfRhrf38ZnJyYrCj7TZV | |
| cYDEAPOnssPXvgj82p8DMwgdUfr1lqBWIPaDHjiVA0MAAkAzwyA2MdQy+dhXiNEg | |
| 1JdOm8bs7DY4Vf0D1Nh8Vd30wJT9J74WSCdbHEPoag0T4qcPfLZKyetVwtYZPKcP | |
| aWE2 | |
| -----END PUBLIC KEY-----`; | |
| let str = `myprj,Test User`; | |
| let crypto = require('crypto'); | |
| let hashes = crypto.getHashes(); | |
| for (let i = 0, l = hashes.length; i < l; ++i) { | |
| let verify = crypto.createVerify(hashes[i]); | |
| verify.update(str); | |
| let rst = verify.verify(publicKey, buf); | |
| if (rst) { | |
| console.log(hashes[i] + "%c succeeded","color:green;font-size:18px;"); | |
| } else { | |
| console.log(hashes[i] + " failed"); | |
| } | |
| } | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment