Allow messages to be decrypted from previous bundles (#1400)

Currently we only decrypt messages if received on the current bundle.
This changes the behavior so that messages can be decrypted if sent to
previous bundles as well, as otherwise is a bit restrictive
This commit is contained in:
Andrea Maria Piana 2019-02-28 13:09:43 +01:00 committed by GitHub
parent 259a32cd9d
commit 38e5335e18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 3 deletions

View File

@ -1 +1 @@
0.23.0-beta.6
0.23.0-beta.7

View File

@ -114,7 +114,7 @@ func (s *EncryptionService) ConfirmMessagesProcessed(messageIDs [][]byte) error
id := confirmationIDString(idByte)
confirmationData, ok := s.messageIDs[id]
if !ok {
s.log.Warn("Could not confirm message", "messageID", id)
s.log.Debug("Could not confirm message", "messageID", id)
continue
}

View File

@ -858,6 +858,10 @@ func (s *EncryptionServiceTestSuite) TestRefreshedBundle() {
s.NotNil(x3dhHeader1)
s.Equal(bobBundle1.GetSignedPreKeys()[bobInstallationID].GetSignedPreKey(), x3dhHeader1.GetId())
// Bob decrypts the message
_, err = s.bob.DecryptPayload(bobKey, &aliceKey.PublicKey, aliceInstallationID, encryptionResponse1, defaultMessageID)
s.Require().NoError(err)
// We add the second bob bundle
_, err = s.alice.ProcessPublicBundle(aliceKey, bobBundle2)
s.Require().NoError(err)
@ -875,6 +879,9 @@ func (s *EncryptionServiceTestSuite) TestRefreshedBundle() {
s.NotNil(x3dhHeader2)
s.Equal(bobBundle2.GetSignedPreKeys()[bobInstallationID].GetSignedPreKey(), x3dhHeader2.GetId())
// Bob decrypts the message
_, err = s.bob.DecryptPayload(bobKey, &aliceKey.PublicKey, aliceInstallationID, encryptionResponse2, defaultMessageID)
s.Require().NoError(err)
}
func (s *EncryptionServiceTestSuite) TestMessageConfirmation() {

View File

@ -465,7 +465,7 @@ func (s *SQLLitePersistence) GetAnyPrivateBundle(myIdentityKey []byte, installat
func (s *SQLLitePersistence) GetPrivateKeyBundle(bundleID []byte) ([]byte, error) {
stmt, err := s.db.Prepare(`SELECT private_key
FROM bundles
WHERE expired = 0 AND signed_pre_key = ? LIMIT 1`)
WHERE signed_pre_key = ? LIMIT 1`)
if err != nil {
return nil, err
}