diff --git a/auth/callback.go b/auth/callback.go index 5925c7a4d21f705e861b55c51740744562071b62..3151fdb43de00b988d3356ea1833c9979c83cfba 100644 --- a/auth/callback.go +++ b/auth/callback.go @@ -50,7 +50,13 @@ func (m *Manager) StartProcesses() (stoppable.Stoppable, error) { func (m *Manager) processAuthMessage(msg message.Receive) { authStore := m.storage.Auth() //lookup the message, check if it is an auth request - cmixMsg := format.Unmarshal(msg.Payload) + cmixMsg, err := format.Unmarshal(msg.Payload) + if err != nil { + jww.WARN.Printf("Invalid message when unmarshalling: %s", + err.Error()) + // Ignore this message + return + } fp := cmixMsg.GetKeyFP() jww.INFO.Printf("RAW AUTH FP: %v", fp) // this takes the request lock if it is a specific fp, all diff --git a/fileTransfer/receive.go b/fileTransfer/receive.go index c1974176d183aed4ff24f9777d35e78d7f9b1753..9a70f5853212bae431653c096d9168d567008b2a 100644 --- a/fileTransfer/receive.go +++ b/fileTransfer/receive.go @@ -59,7 +59,10 @@ func (m *Manager) receive(rawMsgs chan message.Receive, stop *stoppable.Single) // error, it can be either marked as used not used. func (m *Manager) readMessage(msg message.Receive) (format.Message, error) { // Unmarshal payload into cMix message - cMixMsg := format.Unmarshal(msg.Payload) + cMixMsg, err := format.Unmarshal(msg.Payload) + if err != nil { + return cMixMsg, err + } // Unmarshal cMix message contents into a file part message partMsg, err := unmarshalPartMessage(cMixMsg.GetContents()) diff --git a/fileTransfer/send_test.go b/fileTransfer/send_test.go index 45c273e90bb41657c4ff9042808bcb1497bf93be..ee10658b1fe6c190cbaa9a04879c72829a726787 100644 --- a/fileTransfer/send_test.go +++ b/fileTransfer/send_test.go @@ -1007,7 +1007,7 @@ func TestManager_getPartSize(t *testing.T) { primeByteLen := m.store.Cmix().GetGroup().GetP().ByteLen() cmixMsgUsedLen := format.AssociatedDataSize filePartMsgUsedLen := fmMinSize - expected := 2*primeByteLen - cmixMsgUsedLen - filePartMsgUsedLen + expected := 2*primeByteLen - cmixMsgUsedLen - filePartMsgUsedLen-1 // Get the part size partSize, err := m.getPartSize() diff --git a/go.mod b/go.mod index a228f9cbda83777d8c6e72c737723c9087de4db5..a117f5b8a19f06e9386c28cf4be978d2687027cd 100644 --- a/go.mod +++ b/go.mod @@ -7,11 +7,13 @@ require ( github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/protobuf v1.5.2 github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect + github.com/liyue201/goqr v0.0.0-20200803022322-df443203d4ea // indirect github.com/magiconair/properties v1.8.4 // indirect github.com/mitchellh/mapstructure v1.4.0 // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/pelletier/go-toml v1.8.1 // indirect github.com/pkg/errors v0.9.1 + github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect github.com/smartystreets/assertions v1.0.1 // indirect github.com/spf13/afero v1.5.1 // indirect github.com/spf13/cast v1.3.1 // indirect @@ -19,13 +21,14 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/viper v1.7.1 gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 - gitlab.com/elixxir/comms v0.0.4-0.20211230212713-e8d2ff321eda - gitlab.com/elixxir/crypto v0.0.7-0.20211230212606-1aefb03de56c + gitlab.com/elixxir/comms v0.0.4-0.20211208211635-ad88fa2850b0 + gitlab.com/elixxir/crypto v0.0.7-0.20211208211534-e1c1462d945f gitlab.com/elixxir/ekv v0.1.5 - gitlab.com/elixxir/primitives v0.0.3-0.20211230211304-a134acdc9129 - gitlab.com/xx_network/comms v0.0.4-0.20211227194445-c099754b3cda - gitlab.com/xx_network/crypto v0.0.5-0.20211227194420-f311e8920467 + gitlab.com/elixxir/primitives v0.0.3-0.20211208211148-752546cf2e46 + gitlab.com/xx_network/comms v0.0.4-0.20211202195810-9dfc0b6cdb28 + gitlab.com/xx_network/crypto v0.0.5-0.20211014163843-57b345890686 gitlab.com/xx_network/primitives v0.0.4-0.20211222205802-03e9d7d835b0 + gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5 // indirect golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 golang.org/x/net v0.0.0-20210525063256-abc453219eb5 google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect diff --git a/go.sum b/go.sum index cc684ee91f1a0b9d1bb23f5dc7436e3412220f2d..fa3ba9b92c02d45db608817f4850af4d7750a08d 100644 --- a/go.sum +++ b/go.sum @@ -99,6 +99,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -263,6 +264,7 @@ github.com/zeebo/assert v0.0.0-20181109011804-10f827ce2ed6/go.mod h1:yssERNPivll github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY= github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/blake3 v0.0.4/go.mod h1:YOZo8A49yNqM0X/Y+JmDUZshJWLt1laHsNSn5ny2i34= +github.com/zeebo/blake3 v0.1.0/go.mod h1:YOZo8A49yNqM0X/Y+JmDUZshJWLt1laHsNSn5ny2i34= github.com/zeebo/blake3 v0.1.1 h1:Nbsts7DdKThRHHd+YNlqiGlRqGEF2bE2eXN+xQ1hsEs= github.com/zeebo/blake3 v0.1.1/go.mod h1:G9pM4qQwjRzF1/v7+vabMj/c5mWpGZ2Wzo3Eb4z0pb4= github.com/zeebo/pcg v0.0.0-20181207190024-3cdc6b625a05/go.mod h1:Gr+78ptB0MwXxm//LBaEvBiaXY7hXJ6KGe2V32X2F6E= @@ -270,10 +272,19 @@ github.com/zeebo/pcg v1.0.0 h1:dt+dx+HvX8g7Un32rY9XWoYnd0NmKmrIzpHF7qiTDj0= github.com/zeebo/pcg v1.0.0/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 h1:Gi6rj4mAlK0BJIk1HIzBVMjWNjIUfstrsXC2VqLYPcA= gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k= +gitlab.com/elixxir/comms v0.0.3 h1:7cFvBZddX/8JSY5MvfPpg21niV88IpeqQkoKs15erZM= +gitlab.com/elixxir/comms v0.0.3/go.mod h1:5p7oz4yFrK037rPap6ooaWrloJrzuVZ4jnzOdvgyqnU= +gitlab.com/elixxir/comms v0.0.4-0.20211208211635-ad88fa2850b0 h1:Xv0xV8zID5in8IqrJT0L6/QQiFEyQRgL6ibXCZlSIRA= +gitlab.com/elixxir/comms v0.0.4-0.20211208211635-ad88fa2850b0/go.mod h1:Q/9VctYnyN1T92Q/WhrFXYGWu819cKX33iRPvf6I63U= gitlab.com/elixxir/comms v0.0.4-0.20211230212713-e8d2ff321eda h1:b9hHPe2cpxHGt8dH8HDjVDccIJYdbz766oc8l13LI9U= gitlab.com/elixxir/comms v0.0.4-0.20211230212713-e8d2ff321eda/go.mod h1:sinBt/nli+x5PQPu3blVEjTHmFKikeij3fZKERzCZZ8= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA= +gitlab.com/elixxir/crypto v0.0.4/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA= +gitlab.com/elixxir/crypto v0.0.6 h1:c94CGzBTV7LgInGHfmeJHrqq9nIc/WEOLUd9OeQBN74= +gitlab.com/elixxir/crypto v0.0.6/go.mod h1:V8lricBRpa8v1ySymXQ1/lsb+8/lSak5S7ZWRT6OACY= +gitlab.com/elixxir/crypto v0.0.7-0.20211208211534-e1c1462d945f h1:owzmRi0kBBWUJIZ50XB9ZmxcVJB4ZTlnh3sbKOi3HJ8= +gitlab.com/elixxir/crypto v0.0.7-0.20211208211534-e1c1462d945f/go.mod h1:ftTGW5CHKj1QyLpF7BniMw1awB27KWKYwIV1aBrO39k= gitlab.com/elixxir/crypto v0.0.7-0.20211230212606-1aefb03de56c h1:Yc0z75TY0iedBk/zulX26ChSan0z9Duc/ujWFrtxrJc= gitlab.com/elixxir/crypto v0.0.7-0.20211230212606-1aefb03de56c/go.mod h1:0j3psSl79Z0QjbpHrIaYjSlEwLyagQwMHLxdrPS0egg= gitlab.com/elixxir/ekv v0.1.5 h1:R8M1PA5zRU1HVnTyrtwybdABh7gUJSCvt1JZwUSeTzk= @@ -282,20 +293,32 @@ gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZ gitlab.com/elixxir/primitives v0.0.0-20200804170709-a1896d262cd9/go.mod h1:p0VelQda72OzoUckr1O+vPW0AiFe0nyKQ6gYcmFSuF8= gitlab.com/elixxir/primitives v0.0.0-20200804182913-788f47bded40/go.mod h1:tzdFFvb1ESmuTCOl1z6+yf6oAICDxH2NPUemVgoNLxc= gitlab.com/elixxir/primitives v0.0.1/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2YKnw5c+LJCE= +gitlab.com/elixxir/primitives v0.0.2/go.mod h1:3fxFHSlQhkV4vs+S0dZEz3Om3m+40WX8L806yvSnNFc= +gitlab.com/elixxir/primitives v0.0.3-0.20201116174806-97f190989704/go.mod h1:3fxFHSlQhkV4vs+S0dZEz3Om3m+40WX8L806yvSnNFc= +gitlab.com/elixxir/primitives v0.0.3-0.20211208211148-752546cf2e46 h1:KL/CVczLH7VXy9snvr7WJG2YtJRoHGfL9o9pY+CKzdw= +gitlab.com/elixxir/primitives v0.0.3-0.20211208211148-752546cf2e46/go.mod h1:zZy8AlOISFm5IG4G4sylypnz7xNBfZ5mpXiibqJT8+8= gitlab.com/elixxir/primitives v0.0.3-0.20211230211304-a134acdc9129 h1:gufg1cknksHPD7Slwh9f0ajLe1J5Td+yMWaVNeWsdaI= gitlab.com/elixxir/primitives v0.0.3-0.20211230211304-a134acdc9129/go.mod h1:zA+1Lp9fGPo6pl1QxtMoNPLeZJ1O5m4kcH7HNxePQnQ= gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw= +gitlab.com/xx_network/comms v0.0.3/go.mod h1:YViGbRj7FjJYoaO4NpALGEd9dK/l8uUT000FEBbUTL8= +gitlab.com/xx_network/comms v0.0.4-0.20211202195810-9dfc0b6cdb28 h1:CEZJfCiV6F6GQnWiYqoEjlzL2KpLipRy/ccV2smgf0E= +gitlab.com/xx_network/comms v0.0.4-0.20211202195810-9dfc0b6cdb28/go.mod h1:wR9Vx0KZLrIs0g2Efcp0UwFPStjcDRWkg/DJLVQI2vw= gitlab.com/xx_network/comms v0.0.4-0.20211227194445-c099754b3cda h1:oWl8TuAgdx/6J9lwdH8wYGSb4W6D5TG1AZkzbA8EzbE= gitlab.com/xx_network/comms v0.0.4-0.20211227194445-c099754b3cda/go.mod h1:5arueRMa2MNa6dALnfJwyZOhqhV53Gqc+tlHRz+Ycjw= gitlab.com/xx_network/crypto v0.0.3/go.mod h1:DF2HYvvCw9wkBybXcXAgQMzX+MiGbFPjwt3t17VRqRE= gitlab.com/xx_network/crypto v0.0.4/go.mod h1:+lcQEy+Th4eswFgQDwT0EXKp4AXrlubxalwQFH5O0Mk= +gitlab.com/xx_network/crypto v0.0.5-0.20201124194022-366c10b1bce0/go.mod h1:+lcQEy+Th4eswFgQDwT0EXKp4AXrlubxalwQFH5O0Mk= +gitlab.com/xx_network/crypto v0.0.5-0.20211014163843-57b345890686 h1:mEjKISxi9LrguYgz6evroFwsfxH78/hYmr32yws+WV0= +gitlab.com/xx_network/crypto v0.0.5-0.20211014163843-57b345890686/go.mod h1:GeUUB5eMlu7G1u7LXpClfOyUYsSDxAhiZBf+RZeGftc= gitlab.com/xx_network/crypto v0.0.5-0.20211227194420-f311e8920467 h1:LkZtWBYrM2e7QRf5aaBAcy7s7CpYGhAqgXRFVCdBRy4= gitlab.com/xx_network/crypto v0.0.5-0.20211227194420-f311e8920467/go.mod h1:c+x0w3Xk6QZe5w2Redn5SiaBpqAhgNSfwBr0JGa/yyo= gitlab.com/xx_network/primitives v0.0.0-20200803231956-9b192c57ea7c/go.mod h1:wtdCMr7DPePz9qwctNoAUzZtbOSHSedcK++3Df3psjA= gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK9xevzWCaPO7b1wiluVJGk7R5ZsuC7pHY5hteZFQug= gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc= +gitlab.com/xx_network/primitives v0.0.4-0.20211014163031-53405cf191fb/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= gitlab.com/xx_network/primitives v0.0.4-0.20211222205802-03e9d7d835b0 h1:IHHb59DJEKk02HgfxddqK2ilvkRMAUdPIBFn8rmjjIg= gitlab.com/xx_network/primitives v0.0.4-0.20211222205802-03e9d7d835b0/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= +gitlab.com/xx_network/ring v0.0.2/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM= gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5 h1:FY+4Rh1Q2rgLyv10aKJjhWApuKRCR/054XhreudfAvw= gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -316,6 +339,7 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200707235045-ab33eee955e0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= @@ -354,6 +378,7 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201029221708-28c70e62bb1d/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -385,7 +410,9 @@ golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200917073148-efd3b9a0ff20/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -398,6 +425,7 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -444,6 +472,7 @@ google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBr google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20201030142918-24207fddd1c3/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 h1:Zk6zlGXdtYdcY5TL+VrbTfmifvk3VvsXopCpszsHPBA= google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -478,6 +507,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= diff --git a/groupChat/receive.go b/groupChat/receive.go index b2915735ca0eea7e44e16ae12fc8526e197dba24..93a149c4e0e480d4d56b98123ce1627cf5962d55 100644 --- a/groupChat/receive.go +++ b/groupChat/receive.go @@ -87,8 +87,11 @@ func (m Manager) receive(rawMsgs chan message.Receive, stop *stoppable.Single) { func (m *Manager) readMessage(msg message.Receive) (gs.Group, group.MessageID, time.Time, *id.ID, []byte, bool, error) { // Unmarshal payload into cMix message - cMixMsg := format.Unmarshal(msg.Payload) - + cMixMsg, err := format.Unmarshal(msg.Payload) + if err != nil { + return gs.Group{}, group.MessageID{}, time.Time{}, nil, nil, + false, err + } // Unmarshal cMix message contents to get public message format pubMsg, err := unmarshalPublicMsg(cMixMsg.GetContents()) if err != nil { diff --git a/network/message/sendCmix.go b/network/message/sendCmix.go index 6f3aa5eb1f395ccaf26772473566afddb2b38371..c91e86dde23c1b91996f51f93df973cc74a90e84 100644 --- a/network/message/sendCmix.go +++ b/network/message/sendCmix.go @@ -172,7 +172,7 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message, wrappedMsg.Target = target.Marshal() jww.TRACE.Printf("[sendCMIX] sendFunc %s", host) - timeout := calculateSendTimeout(bestRound, maxTimeout) + timeout = calculateSendTimeout(bestRound, maxTimeout) jww.TRACE.Printf("[sendCMIX] sendFunc %s timeout %s", host, timeout) result, err := comms.SendPutMessage(host, wrappedMsg, @@ -184,7 +184,7 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message, timeout = calculatedTimeout } - result, err := comms.SendPutMessage(host, wrappedMsg, + result, err = comms.SendPutMessage(host, wrappedMsg, timeout) jww.TRACE.Printf("[sendCMIX] sendFunc %s putmsg", host) if err != nil { diff --git a/single/manager_test.go b/single/manager_test.go index 4a37dc6a454d1dbe5e861c18d1ffdd58e9e7fa75..acffc2f62eca15feaf1c1305cbf084cdbf0e4c64 100644 --- a/single/manager_test.go +++ b/single/manager_test.go @@ -64,7 +64,7 @@ func TestManager_StartProcesses(t *testing.T) { DhPubKey: m.store.E2e().GetDHPublicKey(), } tag := "Test tag" - payload := make([]byte, 131) + payload := make([]byte, 130) rand.New(rand.NewSource(42)).Read(payload) callback, callbackChan := createReceiveComm() @@ -150,7 +150,7 @@ func TestManager_StartProcesses_Stop(t *testing.T) { DhPubKey: m.store.E2e().GetDHPublicKey(), } tag := "Test tag" - payload := make([]byte, 131) + payload := make([]byte, 130) rand.New(rand.NewSource(42)).Read(payload) callback, callbackChan := createReceiveComm() diff --git a/single/receiveResponse.go b/single/receiveResponse.go index 72a613b74acba023868fa3d34ab3c2e21b64c62a..7c27bda09a9082f171a7a4d35304b42f111c0227 100644 --- a/single/receiveResponse.go +++ b/single/receiveResponse.go @@ -70,7 +70,10 @@ func (m *Manager) processesResponse(rid *id.ID, ephID ephemeral.Id, } // Unmarshal CMIX message - cmixMsg := format.Unmarshal(msgBytes) + cmixMsg, err := format.Unmarshal(msgBytes) + if err != nil { + return err + } // Ensure the fingerprints match fp := cmixMsg.GetKeyFP() diff --git a/single/reception.go b/single/reception.go index 7616af03228ec5e643b1da4a1c20ad936d1332d9..e1aa8e08d3341e6bf3bdb4d5354d6e4cf90dfda6 100644 --- a/single/reception.go +++ b/single/reception.go @@ -35,7 +35,12 @@ func (m *Manager) receiveTransmissionHandler(rawMessages chan message.Receive, "single-use transmission.") // Check if message is a single-use transmit message - cmixMsg := format.Unmarshal(msg.Payload) + cmixMsg, err := format.Unmarshal(msg.Payload) + if err != nil { + jww.ERROR.Printf("Could not unmarshal msg: %s", + err.Error()) + continue + } if fp != cmixMsg.GetKeyFP() { // If the verification fails, then ignore the message as it is // likely garbled or for a different protocol diff --git a/single/reception_test.go b/single/reception_test.go index ff56ce6cd135c72221383a1c2330b435a48f5c06..efa83406dbb27791d2a209430043520b4a30c4c3 100644 --- a/single/reception_test.go +++ b/single/reception_test.go @@ -23,7 +23,7 @@ func TestManager_receiveTransmissionHandler(t *testing.T) { DhPubKey: m.store.E2e().GetDHPublicKey(), } tag := "Test tag" - payload := make([]byte, 131) + payload := make([]byte, 130) rand.New(rand.NewSource(42)).Read(payload) callback, callbackChan := createReceiveComm() @@ -91,7 +91,7 @@ func TestManager_receiveTransmissionHandler_FingerPrintError(t *testing.T) { DhPubKey: m.store.E2e().GetGroup().NewInt(42), } tag := "Test tag" - payload := make([]byte, 131) + payload := make([]byte, 130) rand.New(rand.NewSource(42)).Read(payload) callback, callbackChan := createReceiveComm() @@ -128,7 +128,7 @@ func TestManager_receiveTransmissionHandler_ProcessMessageError(t *testing.T) { DhPubKey: m.store.E2e().GetDHPublicKey(), } tag := "Test tag" - payload := make([]byte, 131) + payload := make([]byte, 130) rand.New(rand.NewSource(42)).Read(payload) callback, callbackChan := createReceiveComm() @@ -167,7 +167,7 @@ func TestManager_receiveTransmissionHandler_TagFpError(t *testing.T) { DhPubKey: m.store.E2e().GetDHPublicKey(), } tag := "Test tag" - payload := make([]byte, 131) + payload := make([]byte, 130) rand.New(rand.NewSource(42)).Read(payload) msg, _, _, _, err := m.makeTransmitCmixMessage(partner, payload, tag, 8, 32, diff --git a/single/response_test.go b/single/response_test.go index c19f472bafa42e122aea75f3f1085f3fc2f522cb..2a6c74521b593b490f3ee53f92aeff488f6bba7f 100644 --- a/single/response_test.go +++ b/single/response_test.go @@ -23,7 +23,7 @@ import ( func TestManager_GetMaxResponsePayloadSize(t *testing.T) { m := newTestManager(0, false, t) cmixPrimeSize := m.store.Cmix().GetGroup().GetP().ByteLen() - expectedSize := 2*cmixPrimeSize - format.KeyFPLen - format.MacLen - format.RecipientIDLen - responseMinSize + expectedSize := 2*cmixPrimeSize - format.KeyFPLen - format.MacLen - format.RecipientIDLen - responseMinSize-1 testSize := m.GetMaxResponsePayloadSize() if expectedSize != testSize { diff --git a/single/transmission_test.go b/single/transmission_test.go index dac7546eb5eef223a030c902cab6bdd57ec03968..548cefa7c0be402eda3671278a4234e6fb610672 100644 --- a/single/transmission_test.go +++ b/single/transmission_test.go @@ -26,7 +26,7 @@ func TestManager_GetMaxTransmissionPayloadSize(t *testing.T) { m := newTestManager(0, false, t) cmixPrimeSize := m.store.Cmix().GetGroup().GetP().ByteLen() e2ePrimeSize := m.store.E2e().GetGroup().GetP().ByteLen() - expectedSize := 2*cmixPrimeSize - e2ePrimeSize - format.KeyFPLen - format.MacLen - format.RecipientIDLen - transmitPlMinSize - transmitMessageVersionSize + expectedSize := 2*cmixPrimeSize - e2ePrimeSize - format.KeyFPLen - format.MacLen - format.RecipientIDLen - transmitPlMinSize - transmitMessageVersionSize-1 testSize := m.GetMaxTransmissionPayloadSize() if expectedSize != testSize { @@ -260,7 +260,7 @@ func TestManager_makeTransmitCmixMessage(t *testing.T) { DhPubKey: m.store.E2e().GetGroup().NewInt(42), } tag := "Test tag" - payload := make([]byte, 131) + payload := make([]byte, 130) rand.New(rand.NewSource(42)).Read(payload) maxMsgs := uint8(8) timeNow := netTime.Now() diff --git a/storage/cmix/roundKeys_test.go b/storage/cmix/roundKeys_test.go index 0b701375bab6fee74bd509bab1d208f33dcde61b..1a360385cffa22784aef101c9b95dda900f899c2 100644 --- a/storage/cmix/roundKeys_test.go +++ b/storage/cmix/roundKeys_test.go @@ -23,28 +23,44 @@ import ( func TestRoundKeys_Encrypt_Consistency(t *testing.T) { const numKeys = 5 - expectedPayload := []byte{240, 199, 83, 226, 28, 164, 104, 139, 171, 255, 234, 86, 170, 65, 29, 254, 100, 4, 81, - 112, 154, 115, 224, 245, 29, 60, 226, 209, 135, 75, 108, 62, 95, 185, 211, 56, 83, 55, 250, 159, 173, 176, 137, - 181, 1, 155, 228, 223, 170, 232, 71, 225, 55, 27, 189, 218, 146, 74, 134, 133, 105, 17, 69, 105, 160, 60, 206, - 32, 244, 175, 98, 142, 217, 27, 92, 132, 225, 146, 171, 59, 2, 191, 220, 125, 212, 81, 114, 98, 75, 253, 93, - 126, 48, 230, 249, 118, 215, 90, 231, 126, 43, 235, 151, 191, 23, 77, 147, 98, 212, 86, 89, 42, 189, 24, 124, - 189, 201, 184, 82, 152, 255, 137, 119, 21, 74, 118, 157, 114, 229, 232, 36, 185, 104, 101, 132, 23, 79, 65, 195, - 53, 222, 27, 66, 80, 123, 252, 109, 254, 44, 120, 114, 126, 237, 159, 252, 185, 187, 95, 255, 31, 41, 245, 225, - 95, 101, 118, 190, 233, 44, 5, 42, 239, 140, 70, 216, 211, 129, 43, 189, 1, 11, 111, 2, 64, 254, 44, 87, 164, - 28, 188, 227, 1, 32, 134, 183, 156, 84, 222, 79, 27, 210, 124, 46, 153, 56, 122, 117, 17, 171, 85, 232, 112, - 170, 10, 31, 115, 17, 119, 233, 150, 200, 183, 198, 74, 70, 179, 135, 27, 195, 190, 56, 126, 143, 226, 93, 16, - 46, 147, 248, 128, 124, 182, 254, 187, 223, 187, 54, 181, 62, 89, 202, 176, 25, 249, 139, 167, 26, 98, 143, 3, - 78, 54, 116, 201, 6, 33, 158, 225, 254, 106, 15, 6, 175, 96, 2, 63, 0, 59, 188, 124, 120, 147, 95, 24, 26, 115, - 235, 154, 240, 65, 226, 133, 91, 249, 223, 55, 122, 0, 76, 225, 104, 101, 242, 46, 136, 122, 127, 159, 0, 9, - 210, 42, 181, 31, 94, 20, 106, 175, 195, 56, 223, 165, 217, 164, 93, 55, 190, 253, 192, 249, 117, 226, 222, 65, - 82, 136, 36, 58, 3, 246, 76, 101, 24, 20, 50, 89, 22, 144, 184, 38, 82, 103, 2, 48, 59, 73, 75, 58, 33, 206, 49, - 88, 201, 44, 176, 242, 248, 254, 127, 101, 62, 57, 103, 75, 213, 73, 30, 146, 223, 118, 104, 126, 189, 179, 132, - 25, 183, 178, 65, 131, 72, 121, 42, 170, 40, 186, 65, 73, 175, 234, 52, 10, 171, 36, 165, 24, 156, 12, 198, 100, - 77, 137, 91, 221, 152, 219, 207, 244, 44, 126, 178, 119, 133, 147, 158, 54, 188, 52, 10, 63, 138, 180, 44, 29, - 40, 236, 255, 163, 208, 2, 212, 184, 50, 157, 82, 199, 90, 1, 205, 214, 143, 123, 92, 210, 88, 98, 182, 197, 49, - 170, 100, 143, 145, 9, 156, 0, 45, 59, 196, 6, 8, 157, 98, 15, 111, 162, 51, 12, 223, 0, 173, 187, 178, 1, 156, - 68, 183, 64, 178, 250, 40, 65, 50, 161, 96, 163, 106, 14, 43, 179, 75, 199, 15, 223, 192, 121, 144, 223, 167, - 254, 150, 188} + expectedPayload := []byte{220, 95, 160, 88, 229, 136, 42, 254, 239, 32, + 57, 120, 7, 187, 69, 66, 199, 95, 136, 118, 130, 192, 167, 143, + 94, 80, 250, 22, 85, 47, 200, 208, 68, 179, 143, 31, 21, 215, + 17, 117, 179, 170, 67, 59, 14, 158, 116, 249, 10, 116, 166, 127, + 168, 26, 11, 41, 129, 166, 133, 135, 93, 217, 61, 99, 29, 198, + 86, 34, 83, 72, 158, 44, 178, 57, 158, 168, 107, 43, 54, 107, + 183, 16, 149, 133, 109, 166, 154, 248, 185, 218, 32, 11, 200, + 191, 240, 197, 27, 21, 82, 198, 42, 109, 79, 28, 116, 64, 34, + 44, 178, 75, 142, 79, 17, 31, 17, 196, 104, 20, 44, 125, 80, 72, + 205, 76, 23, 69, 132, 176, 180, 211, 193, 200, 175, 149, 133, 2, + 153, 114, 21, 239, 107, 46, 237, 41, 48, 188, 241, 97, 89, 65, + 213, 218, 73, 38, 213, 194, 113, 142, 203, 176, 124, 222, 172, + 128, 152, 228, 18, 128, 26, 122, 199, 192, 255, 84, 222, 165, + 77, 199, 57, 56, 7, 72, 20, 158, 133, 90, 63, 68, 145, 54, 34, + 223, 152, 157, 105, 217, 30, 111, 83, 4, 200, 125, 120, 189, + 232, 146, 130, 84, 119, 240, 144, 166, 111, 6, 56, 26, 93, 95, + 69, 225, 103, 174, 211, 204, 66, 181, 33, 198, 65, 140, 53, 255, + 37, 120, 204, 59, 128, 70, 54, 228, 26, 197, 107, 186, 22, 93, + 189, 234, 89, 217, 90, 133, 153, 189, 114, 73, 75, 55, 77, 209, + 136, 102, 193, 60, 241, 25, 101, 238, 162, 49, 94, 219, 46, 152, + 100, 120, 152, 131, 78, 128, 226, 47, 21, 253, 171, 40, 122, 161, + 69, 56, 102, 63, 89, 160, 209, 219, 142, 51, 179, 165, 243, 70, + 137, 24, 221, 105, 39, 0, 214, 201, 221, 184, 104, 165, 44, 82, + 13, 239, 197, 80, 252, 200, 115, 146, 200, 51, 63, 173, 88, 163, + 3, 214, 135, 89, 118, 99, 197, 98, 80, 176, 150, 139, 71, 6, 7, + 37, 252, 82, 225, 187, 212, 65, 4, 154, 28, 170, 224, 242, 17, + 68, 245, 73, 234, 216, 255, 2, 168, 235, 116, 147, 252, 217, 85, + 157, 38, 243, 43, 213, 250, 219, 124, 86, 155, 129, 99, 195, + 217, 163, 9, 133, 217, 6, 77, 127, 88, 168, 217, 84, 66, 224, + 90, 11, 210, 218, 215, 143, 239, 221, 138, 231, 57, 149, 175, + 221, 188, 128, 169, 28, 215, 39, 147, 36, 52, 146, 75, 20, 228, + 230, 197, 1, 80, 38, 208, 139, 4, 240, 163, 104, 158, 49, 29, + 248, 206, 79, 52, 203, 219, 178, 46, 81, 170, 100, 14, 253, 150, + 240, 191, 92, 18, 23, 94, 73, 110, 212, 237, 84, 86, 102, 32, + 78, 209, 207, 213, 117, 141, 148, 218, 209, 253, 220, 108, 135, + 163, 159, 134, 125, 6, 225, 163, 35, 115, 146, 103, 169, 152, + 251, 188, 125, 159, 185, 119, 67, 80, 92, 232, 208, 1, 32, 144, + 250, 32, 187} expectedKmacs := [][]byte{{110, 235, 79, 128, 16, 94, 181, 95, 101, 152, 187, 204, 87, 236, 211, 102, 88, 130, 191, 103, 23, 229, diff --git a/storage/utility/cmixMessageBuffer.go b/storage/utility/cmixMessageBuffer.go index 8c67658932ab64e75d91e2272f3b94c9c90f6314..e072f05d4bf1dbc7fab4ba5371c32ba786f63860 100644 --- a/storage/utility/cmixMessageBuffer.go +++ b/storage/utility/cmixMessageBuffer.go @@ -137,7 +137,11 @@ func (cmb *CmixMessageBuffer) Next() (format.Message, *id.ID, bool) { } sm := m.(storedMessage) - msg := format.Unmarshal(sm.Msg) + msg, err := format.Unmarshal(sm.Msg) + if err != nil { + jww.FATAL.Panicf("Could not unmarshal for stored cmix "+ + "message buffer: %+v", err) + } recpient, err := id.Unmarshal(sm.Recipient) if err != nil { jww.FATAL.Panicf("Could nto get an id for stored cmix "+ diff --git a/storage/utility/meteredCmixMessageBuffer.go b/storage/utility/meteredCmixMessageBuffer.go index 8060b4781fc25af49b97251abcb87981e9929cff..ed1920ff42f2cf0f122549584ef11d480d43ebbb 100644 --- a/storage/utility/meteredCmixMessageBuffer.go +++ b/storage/utility/meteredCmixMessageBuffer.go @@ -149,7 +149,11 @@ func (mcmb *MeteredCmixMessageBuffer) Next() (format.Message, uint, time.Time, b "update: %s", err) } - msfFormat := format.Unmarshal(msg.M) + msfFormat, err := format.Unmarshal(msg.M) + if err != nil { + jww.FATAL.Panicf("Failed to unmarshal message after count "+ + "update: %s", err) + } return msfFormat, rtnCnt, msg.Timestamp, true }