summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/msgsecret.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2023-08-05 20:43:19 +0200
committerGitHub <noreply@github.com>2023-08-05 20:43:19 +0200
commit56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (patch)
treeb1355645342667209263cbd355dc0b4254f1e8fe /vendor/go.mau.fi/whatsmeow/msgsecret.go
parent9459495484d6e06a3d46de64fccd8d06f7ccc72c (diff)
downloadmatterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.gz
matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.tar.bz2
matterbridge-msglm-56e7bd01ca09ad52b0c4f48f146a20a4f1b78696.zip
Update dependencies and remove old matterclient lib (#2067)HEADmaster
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/msgsecret.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/msgsecret.go16
1 files changed, 4 insertions, 12 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/msgsecret.go b/vendor/go.mau.fi/whatsmeow/msgsecret.go
index a4cbb17b..5f3e16ac 100644
--- a/vendor/go.mau.fi/whatsmeow/msgsecret.go
+++ b/vendor/go.mau.fi/whatsmeow/msgsecret.go
@@ -7,7 +7,6 @@
package whatsmeow
import (
- "crypto/rand"
"crypto/sha256"
"fmt"
"time"
@@ -19,6 +18,7 @@ import (
"go.mau.fi/whatsmeow/types/events"
"go.mau.fi/whatsmeow/util/gcmutil"
"go.mau.fi/whatsmeow/util/hkdfutil"
+ "go.mau.fi/whatsmeow/util/randbytes"
)
type MsgSecretType string
@@ -107,11 +107,7 @@ func (cli *Client) encryptMsgSecret(chat, origSender types.JID, origMsgID types.
}
secretKey, additionalData := generateMsgSecretKey(useCase, ownID, origMsgID, origSender, baseEncKey)
- iv = make([]byte, 12)
- _, err = rand.Read(iv)
- if err != nil {
- return nil, nil, fmt.Errorf("failed to generate iv: %w", err)
- }
+ iv = randbytes.Make(12)
ciphertext, err = gcmutil.Encrypt(secretKey, iv, plaintext, additionalData)
if err != nil {
return nil, nil, fmt.Errorf("failed to encrypt secret message: %w", err)
@@ -132,7 +128,7 @@ func (cli *Client) encryptMsgSecret(chat, origSender types.JID, origMsgID types.
// }
func (cli *Client) DecryptReaction(reaction *events.Message) (*waProto.ReactionMessage, error) {
encReaction := reaction.Message.GetEncReactionMessage()
- if encReaction != nil {
+ if encReaction == nil {
return nil, ErrNotEncryptedReactionMessage
}
plaintext, err := cli.decryptMsgSecret(reaction, EncSecretReaction, encReaction, encReaction.GetTargetMessageKey())
@@ -225,11 +221,7 @@ func (cli *Client) BuildPollVote(pollInfo *types.MessageInfo, optionNames []stri
//
// resp, err := cli.SendMessage(context.Background(), chat, cli.BuildPollCreation("meow?", []string{"yes", "no"}, 1))
func (cli *Client) BuildPollCreation(name string, optionNames []string, selectableOptionCount int) *waProto.Message {
- msgSecret := make([]byte, 32)
- _, err := rand.Read(msgSecret)
- if err != nil {
- panic(err)
- }
+ msgSecret := randbytes.Make(32)
if selectableOptionCount < 0 || selectableOptionCount > len(optionNames) {
selectableOptionCount = 0
}