Skip to content

Commit

Permalink
sm2: fix check c3 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Apr 23, 2024
1 parent 96173c2 commit 0561ec7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sm2.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ function adaptSM2 (ecdsa) {
md.update(plaintext)
md.update(new Uint8Array(util.integerToBytes(s.getY().toBigInteger(), SM2_BYTE_SIZE)))
const hash = md.digestRaw()
let xor
let difference = 0
for (let i = 0; i < hash.length; i++) {
xor = hash[i] ^ c3[i]
difference |= hash[i] ^ c3[i]
}
if (xor !== 0) {
if (difference !== 0) {
throw new Error('sm2: decryption error')
}

Expand Down

0 comments on commit 0561ec7

Please sign in to comment.