Skip to content

Commit

Permalink
Update Sm2.php
Browse files Browse the repository at this point in the history
修复bug
  • Loading branch information
lat751608899 committed Aug 26, 2024
1 parent 9c2396d commit fa3c701
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Sm2.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public function decrypt(PrivateKey $privateKey,$data, $mode = 1)
$x2 = $this->decHex($dbC1->getX(), 64);
$y2 = $this->decHex($dbC1->getY(), 64);
$len = strlen($decodeData) - 128 - 64;
$t = $this->kdf($x2 . $y2, $len / 2); // 转成16进制后 字符长度要除以2
$x2bin = pack('H*', str_pad($x2, 64, 0,STR_PAD_LEFT));
$y2bin = pack('H*', str_pad($y2, 64, 0,STR_PAD_LEFT));
$t = $this->kdf($x2bin . $y2bin, $len / 2); // 转成16进制后 字符长度要除以2
if ($mode == 1) { // C1C3C2
$c2 = substr($decodeData, -$len);
$c3 = substr($decodeData, 128,64); // 验证hash数据
Expand Down

0 comments on commit fa3c701

Please sign in to comment.