- fix SNSDecodeMiniProgramData

This commit is contained in:
gazebo
2018-12-28 15:02:00 +08:00
parent babc357d23
commit 4e0adf45d0

View File

@@ -290,8 +290,15 @@ func (a *API) SNSDecodeMiniProgramData(encryptedData, sessionKey, iv string) (de
if err != nil {
return nil, err
}
cfbdec := cipher.NewCFBDecrypter(c, decodedDataList[2])
cfbdec := cipher.NewCBCDecrypter(c, decodedDataList[2][:c.BlockSize()])
decryptedData = make([]byte, len(decodedDataList[0]))
cfbdec.XORKeyStream(decryptedData, decodedDataList[0])
cfbdec.CryptBlocks(decryptedData, decodedDataList[0])
decryptedData = PKCS7UnPadding(decryptedData)
return decryptedData, nil
}
func PKCS7UnPadding(origData []byte) []byte {
length := len(origData)
unpadding := int(origData[length-1])
return origData[:(length - unpadding)]
}