Skip to content
Snippets Groups Projects
Commit 929e31e7 authored by Bernardo Cardoso's avatar Bernardo Cardoso
Browse files

Add E2E option to command line and some DEBUG prints

parent 50823fb2
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,7 @@ Optional args: ...@@ -54,6 +54,7 @@ Optional args:
|--registrationcertpath|-r|Enables TLS by passing in path to the registration server certificate file|-r "~/Documents/registration.cert"| |--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"| |--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| |--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 ##Project Structure
......
...@@ -51,6 +51,7 @@ var registrationCertPath string ...@@ -51,6 +51,7 @@ var registrationCertPath string
var registrationAddr string var registrationAddr string
var registrationCode string var registrationCode string
var userEmail string var userEmail string
var end2end bool
var client *api.Client var client *api.Client
// Execute adds all child commands to the root command and sets flags // Execute adds all child commands to the root command and sets flags
...@@ -294,6 +295,11 @@ var rootCmd = &cobra.Command{ ...@@ -294,6 +295,11 @@ var rootCmd = &cobra.Command{
(time.Duration(float64(1000000000) * (float64(1.0) / dummyFrequency))) (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) // 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}) recipientId := new(id.User).SetUints(&[4]uint64{0, 0, 0, destinationUserId})
if message != "" { if message != "" {
...@@ -321,7 +327,7 @@ var rootCmd = &cobra.Command{ ...@@ -321,7 +327,7 @@ var rootCmd = &cobra.Command{
MessageType: int32(cmixproto.Type_TEXT_MESSAGE), MessageType: int32(cmixproto.Type_TEXT_MESSAGE),
Body: wireOut, Body: wireOut,
}, },
CryptoType: format.Unencrypted, CryptoType: cryptoType,
Receiver: recipientId, Receiver: recipientId,
}) })
} }
...@@ -350,7 +356,7 @@ var rootCmd = &cobra.Command{ ...@@ -350,7 +356,7 @@ var rootCmd = &cobra.Command{
MessageType: int32(cmixproto.Type_TEXT_MESSAGE), MessageType: int32(cmixproto.Type_TEXT_MESSAGE),
Body: api.FormatTextMessage(message), Body: api.FormatTextMessage(message),
}, },
CryptoType: format.Unencrypted, CryptoType: cryptoType,
Receiver: recipientId} Receiver: recipientId}
client.Send(message) client.Send(message)
...@@ -445,6 +451,9 @@ func init() { ...@@ -445,6 +451,9 @@ func init() {
rootCmd.Flags().Float64VarP(&dummyFrequency, "dummyfrequency", "", 0, rootCmd.Flags().Float64VarP(&dummyFrequency, "dummyfrequency", "", 0,
"Frequency of dummy messages in Hz. If no message is passed, "+ "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") "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 // Sets the cert paths in comms
......
...@@ -207,6 +207,7 @@ func handleE2ESending(session user.Session, ...@@ -207,6 +207,7 @@ func handleE2ESending(session user.Session,
// TODO handle Send Rekey message to SW // TODO handle Send Rekey message to SW
} }
globals.Log.DEBUG.Printf("E2E encrypting message")
crypto.E2E_Encrypt(sendKey, session.GetGroup(), message) crypto.E2E_Encrypt(sendKey, session.GetGroup(), message)
} }
...@@ -263,6 +264,7 @@ func handleE2EReceiving(session user.Session, ...@@ -263,6 +264,7 @@ func handleE2EReceiving(session user.Session,
// TODO Handle Receiving Keys Rekey (partner rekey) // TODO Handle Receiving Keys Rekey (partner rekey)
} }
globals.Log.DEBUG.Printf("E2E decrypting message")
err := crypto.E2E_Decrypt(recpKey, session.GetGroup(), message) err := crypto.E2E_Decrypt(recpKey, session.GetGroup(), message)
if err != nil { if err != nil {
// TODO handle Garbled message to SW // TODO handle Garbled message to SW
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment