From 0eb8aab1d29b4aeb6b095856918636e190fa83a0 Mon Sep 17 00:00:00 2001 From: xl Date: Mon, 13 Nov 2023 22:59:34 +0800 Subject: [PATCH] eee --- wchat/wx/V3/Config.php | 20 -------------------- wchat/wx/V3/WxV3PaymentNotify.php | 2 +- wchat/wx/V3/WxV3PaymentTait.php | 5 +++-- 3 files changed, 4 insertions(+), 23 deletions(-) delete mode 100644 wchat/wx/V3/Config.php diff --git a/wchat/wx/V3/Config.php b/wchat/wx/V3/Config.php deleted file mode 100644 index 9ac5a04..0000000 --- a/wchat/wx/V3/Config.php +++ /dev/null @@ -1,20 +0,0 @@ -decrypt($ciphertext, $nonce, $associated_data); + $data = $this->decrypt($ciphertext, $this->getConfig()->getMchKey(), $nonce, $associated_data); $this->notifyModel = new NotifyModel(); $this->notifyModel->amount = $data['amount']; $this->notifyModel->payer = $data['payer']; diff --git a/wchat/wx/V3/WxV3PaymentTait.php b/wchat/wx/V3/WxV3PaymentTait.php index 3bce3a2..63f2e8a 100644 --- a/wchat/wx/V3/WxV3PaymentTait.php +++ b/wchat/wx/V3/WxV3PaymentTait.php @@ -135,11 +135,12 @@ trait WxV3PaymentTait /** * @param string $ciphertext + * @param string $v3Key * @param string $iv * @param string $aad * @return array */ - public function decrypt(string $ciphertext, string $iv = '', string $aad = ''): array + public function decrypt(string $ciphertext, string $v3Key, string $iv = '', string $aad = ''): array { $ciphertext = base64_decode($ciphertext); $authTag = substr($ciphertext, $tailLength = 0 - BLOCK_SIZE); @@ -149,7 +150,7 @@ trait WxV3PaymentTait if ($tagLength > BLOCK_SIZE || ($tagLength < 12 && $tagLength !== 8 && $tagLength !== 4)) { throw new \RuntimeException('The inputs `$ciphertext` incomplete, the bytes length must be one of 16, 15, 14, 13, 12, 8 or 4.'); } - $plaintext = openssl_decrypt(substr($ciphertext, 0, $tailLength), ALGO_AES_256_GCM, $this->getConfig()->getKey(), OPENSSL_RAW_DATA, $iv, $authTag, $aad); + $plaintext = openssl_decrypt(substr($ciphertext, 0, $tailLength), ALGO_AES_256_GCM, $v3Key, OPENSSL_RAW_DATA, $iv, $authTag, $aad); if (false === $plaintext) { throw new \UnexpectedValueException('Decrypting the input $ciphertext failed, please checking your $key and $iv whether or nor correct.'); }