1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-08 14:42:26 +08:00

增加iv校验 (#482)

This commit is contained in:
okhowang
2021-09-16 12:21:40 +08:00
committed by GitHub
parent c021336a3c
commit 00b13cda0d
2 changed files with 19 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"github.com/silenceper/wechat/v2/miniprogram/context"
)
@@ -90,6 +91,9 @@ func GetCipherText(sessionKey, encryptedData, iv string) ([]byte, error) {
if err != nil {
return nil, err
}
if len(ivBytes) != aes.BlockSize {
return nil, fmt.Errorf("bad iv length %d", len(ivBytes))
}
block, err := aes.NewCipher(aesKey)
if err != nil {
return nil, err