diff --git a/README.md b/README.md index d5c0f15dec9f45da4441a91fa8b31307add6de22..d1db8870f1d44ee31e5d677f9e4d78b1d89c7660 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Optional args: |--registrationcertpath|-r|Enables TLS by passing in path to the registration server certificate file|-r "~/Documents/registration.cert"| |--registrationaddr|-a|Address:Port for connecting to the registration server|-a "localhost:11420"| |--dummyfrequency| |How often dummy messages should be sent per second. This flag is likely to be replaced when we implement better dummy message sending.|--dummyfrequency 0.5| +|--end2end| |Send messages with E2E encryption to destination user|--end2end| ##Project Structure diff --git a/cmd/root.go b/cmd/root.go index 62b8378e6370c001c235d85a6934c64da0210997..a3fbc4ab9f8836031d421445ee69c10f0c8ba10d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -51,6 +51,7 @@ var registrationCertPath string var registrationAddr string var registrationCode string var userEmail string +var end2end bool var client *api.Client // Execute adds all child commands to the root command and sets flags @@ -294,6 +295,11 @@ var rootCmd = &cobra.Command{ (time.Duration(float64(1000000000) * (float64(1.0) / dummyFrequency))) } + cryptoType := format.Unencrypted + if end2end { + cryptoType = format.E2E + } + // Only send a message if we have a message to send (except dummy messages) recipientId := new(id.User).SetUints(&[4]uint64{0, 0, 0, destinationUserId}) if message != "" { @@ -319,10 +325,10 @@ var rootCmd = &cobra.Command{ Sender: userID, TypedBody: parse.TypedBody{ MessageType: int32(cmixproto.Type_TEXT_MESSAGE), - Body: wireOut, + Body: wireOut, }, - CryptoType: format.Unencrypted, - Receiver: recipientId, + CryptoType: cryptoType, + Receiver: recipientId, }) } } @@ -348,10 +354,10 @@ var rootCmd = &cobra.Command{ Sender: userID, TypedBody: parse.TypedBody{ MessageType: int32(cmixproto.Type_TEXT_MESSAGE), - Body: api.FormatTextMessage(message), + Body: api.FormatTextMessage(message), }, - CryptoType: format.Unencrypted, - Receiver: recipientId} + CryptoType: cryptoType, + Receiver: recipientId} client.Send(message) timer = time.NewTimer(dummyPeriod) @@ -424,9 +430,9 @@ func init() { "Registration Code") rootCmd.PersistentFlags().StringVarP(&userEmail, - "email", "E", - "", - "Email to register for User Discovery") + "email", "E", + "", + "Email to register for User Discovery") rootCmd.PersistentFlags().StringVarP(&sessionFile, "sessionfile", "f", "", "Passes a file path for loading a session. "+ @@ -445,6 +451,9 @@ func init() { rootCmd.Flags().Float64VarP(&dummyFrequency, "dummyfrequency", "", 0, "Frequency of dummy messages in Hz. If no message is passed, "+ "will transmit a random message. Dummies are only sent if this flag is passed") + + rootCmd.PersistentFlags().BoolVarP(&end2end, "end2end", "", false, + "Send messages with E2E encryption to destination user") } // Sets the cert paths in comms diff --git a/io/messaging.go b/io/messaging.go index fedc00f56d9517fb72419dd654dba5a4ed548c8c..ce7e6d2f7bfec45c6beca193f4df99f97a2b6433 100644 --- a/io/messaging.go +++ b/io/messaging.go @@ -207,6 +207,7 @@ func handleE2ESending(session user.Session, // TODO handle Send Rekey message to SW } + globals.Log.DEBUG.Printf("E2E encrypting message") crypto.E2E_Encrypt(sendKey, session.GetGroup(), message) } @@ -263,6 +264,7 @@ func handleE2EReceiving(session user.Session, // TODO Handle Receiving Keys Rekey (partner rekey) } + globals.Log.DEBUG.Printf("E2E decrypting message") err := crypto.E2E_Decrypt(recpKey, session.GetGroup(), message) if err != nil { // TODO handle Garbled message to SW