Remove deprecated bundle field

This commit is contained in:
Andrea Maria Piana 2019-09-10 13:33:37 +02:00
parent 8a6d5a6b49
commit f51fd2e639
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
6 changed files with 47 additions and 77 deletions

View File

@ -330,7 +330,7 @@ func (s *EncryptionServiceMultiDeviceSuite) TestMaxDevicesRefreshedBundle() {
msg2, err := alice1.BuildDirectMessage(aliceKey, &bobKey.PublicKey, []byte("test"))
s.Require().NoError(err)
alice1Bundle = msg2.Message.GetBundle()
alice1Bundle = msg2.Message.GetBundles()[0]
// Bob processes the bundle
_, err = bob1.ProcessPublicBundle(bobKey, alice1Bundle)

View File

@ -157,7 +157,7 @@ func (p *Protocol) Start(myIdentity *ecdsa.PrivateKey) error {
return nil
}
func (p *Protocol) addBundle(myIdentityKey *ecdsa.PrivateKey, msg *ProtocolMessage, sendSingle bool) error {
func (p *Protocol) addBundle(myIdentityKey *ecdsa.PrivateKey, msg *ProtocolMessage) error {
logger := p.logger.With(zap.String("site", "addBundle"))
// Get a bundle
@ -175,13 +175,7 @@ func (p *Protocol) addBundle(myIdentityKey *ecdsa.PrivateKey, msg *ProtocolMessa
return err
}
if sendSingle {
// DEPRECATED: This is only for backward compatibility, remove once not
// an issue anymore
msg.Bundle = bundle
} else {
msg.Bundles = []*Bundle{bundle}
}
msg.Bundles = []*Bundle{bundle}
return nil
}
@ -194,7 +188,7 @@ func (p *Protocol) BuildPublicMessage(myIdentityKey *ecdsa.PrivateKey, payload [
PublicMessage: payload,
}
err := p.addBundle(myIdentityKey, message, false)
err := p.addBundle(myIdentityKey, message)
if err != nil {
return nil, err
}
@ -235,7 +229,7 @@ func (p *Protocol) BuildDirectMessage(myIdentityKey *ecdsa.PrivateKey, publicKey
DirectMessage: directMessage,
}
err = p.addBundle(myIdentityKey, message, true)
err = p.addBundle(myIdentityKey, message)
if err != nil {
return nil, err
}
@ -287,7 +281,7 @@ func (p *Protocol) BuildDHMessage(myIdentityKey *ecdsa.PrivateKey, destination *
DirectMessage: encryptionResponse,
}
err = p.addBundle(myIdentityKey, message, true)
err = p.addBundle(myIdentityKey, message)
if err != nil {
return nil, err
}
@ -425,17 +419,6 @@ func (p *Protocol) HandleMessage(
return nil, errors.New("encryption service not initialized")
}
// Process bundle, deprecated, here for backward compatibility
if bundle := protocolMessage.GetBundle(); bundle != nil {
// Should we stop processing if the bundle cannot be verified?
addedBundles, err := p.ProcessPublicBundle(myIdentityKey, bundle)
if err != nil {
return nil, err
}
p.onAddedBundlesHandler(addedBundles)
}
// Process bundles
for _, bundle := range protocolMessage.GetBundles() {
// Should we stop processing if the bundle cannot be verified?
@ -468,8 +451,7 @@ func (p *Protocol) HandleMessage(
return nil, err
}
// Handle protocol negotiation for compatible clients
bundles := append(protocolMessage.GetBundles(), protocolMessage.GetBundle())
bundles := protocolMessage.GetBundles()
version := getProtocolVersion(bundles, protocolMessage.GetInstallationId())
logger.Debug("direct message version", zap.Uint32("version", version))
if version >= sharedSecretNegotiationVersion {

View File

@ -415,8 +415,6 @@ func (m *DirectMessageProtocol) GetPayload() []byte {
// Top-level protocol message
type ProtocolMessage struct {
// An optional bundle is exchanged with each message
Bundle *Bundle `protobuf:"bytes,1,opt,name=bundle,proto3" json:"bundle,omitempty"`
// The device id of the sender
InstallationId string `protobuf:"bytes,2,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
// List of bundles
@ -455,13 +453,6 @@ func (m *ProtocolMessage) XXX_DiscardUnknown() {
var xxx_messageInfo_ProtocolMessage proto.InternalMessageInfo
func (m *ProtocolMessage) GetBundle() *Bundle {
if m != nil {
return m.Bundle
}
return nil
}
func (m *ProtocolMessage) GetInstallationId() string {
if m != nil {
return m.InstallationId
@ -506,41 +497,41 @@ func init() {
func init() { proto.RegisterFile("protocol_message.proto", fileDescriptor_4e37b52004a72e16) }
var fileDescriptor_4e37b52004a72e16 = []byte{
// 565 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0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1c, 0x05, 0x00, 0x00,
// 563 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xdd, 0x8e, 0xd3, 0x3c,
0x10, 0x55, 0x92, 0xdd, 0xfe, 0x4c, 0xd3, 0x1f, 0xf9, 0xfb, 0x58, 0x45, 0xd5, 0x5e, 0x94, 0x88,
0x15, 0x05, 0xa1, 0x48, 0xb4, 0x48, 0x8b, 0xb8, 0x84, 0x22, 0x95, 0x45, 0x2b, 0xad, 0x8c, 0x40,
0x88, 0x9b, 0xc8, 0xad, 0xcd, 0x62, 0x91, 0x3a, 0x51, 0xec, 0x56, 0xe4, 0x19, 0x78, 0x34, 0x6e,
0x78, 0x24, 0x14, 0x27, 0x6e, 0xdd, 0x9f, 0xbd, 0x8b, 0x8f, 0x67, 0xce, 0xcc, 0x39, 0xe3, 0x09,
0x5c, 0x64, 0x79, 0xaa, 0xd2, 0x65, 0x9a, 0xc4, 0x2b, 0x26, 0x25, 0xb9, 0x67, 0x91, 0x06, 0x10,
0x30, 0xb1, 0xcc, 0x8b, 0x4c, 0xf1, 0x54, 0x84, 0x05, 0xf8, 0x9f, 0xf8, 0xbd, 0x60, 0xf4, 0x2e,
0x67, 0x1f, 0x59, 0x81, 0x9e, 0x40, 0x4f, 0xea, 0x73, 0x9c, 0xe5, 0x2c, 0xfe, 0xc9, 0x8a, 0xc0,
0x19, 0x39, 0x63, 0x1f, 0xfb, 0xd2, 0x8e, 0x0a, 0xa0, 0xb9, 0x61, 0xb9, 0xe4, 0xa9, 0x08, 0xdc,
0x91, 0x33, 0xee, 0x62, 0x73, 0x44, 0xcf, 0x60, 0xb0, 0xad, 0x6a, 0x42, 0x3c, 0x1d, 0xd2, 0x37,
0xf8, 0x97, 0x0a, 0x0e, 0x7f, 0xbb, 0xd0, 0x78, 0xbb, 0x16, 0x34, 0x61, 0x68, 0x08, 0x2d, 0x4e,
0x99, 0x50, 0x5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 0x59, 0xa6, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x5b, 0x5f, 0x6b, 0xf0,
0x04, 0x00, 0x00,
}

View File

@ -64,9 +64,6 @@ message DirectMessageProtocol {
// Top-level protocol message
message ProtocolMessage {
// An optional bundle is exchanged with each message
Bundle bundle = 1;
// The device id of the sender
string installation_id = 2;

View File

@ -104,7 +104,7 @@ func (s *ProtocolServiceTestSuite) TestBuildDirectMessage() {
msg := msgSpec.Message
s.NotNil(msg, "It creates a messages")
s.NotNilf(msg.GetBundle(), "It adds a bundle to the message")
s.NotNilf(msg.GetBundles(), "It adds a bundle to the message")
directMessage := msg.GetDirectMessage()
s.NotNilf(directMessage, "It sets the direct message")
@ -156,7 +156,7 @@ func (s *ProtocolServiceTestSuite) TestSecretNegotiation() {
s.NoError(err)
s.NotNil(msgSpec, "It creates a message spec")
bundle := msgSpec.Message.GetBundle()
bundle := msgSpec.Message.GetBundles()[0]
s.Require().NotNil(bundle)
signedPreKeys := bundle.GetSignedPreKeys()

View File

@ -152,7 +152,7 @@ func _000002_add_chatsUpDbSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "000002_add_chats.up.db.sql", size: 569, mode: os.FileMode(0644), modTime: time.Unix(1567170206, 0)}
info := bindataFileInfo{name: "000002_add_chats.up.db.sql", size: 569, mode: os.FileMode(0644), modTime: time.Unix(1567414857, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x89, 0xb, 0x12, 0x5, 0x4b, 0xda, 0xab, 0xb2, 0x47, 0x1b, 0x66, 0xe, 0x47, 0x8a, 0xb0, 0x9c, 0xa0, 0xe4, 0x12, 0xa4, 0xf9, 0xaa, 0x72, 0xba, 0xd9, 0x17, 0x8f, 0xac, 0x7f, 0xfd, 0x85, 0xa9}}
return a, nil
}