ably-flutter icon indicating copy to clipboard operation
ably-flutter copied to clipboard

Symmetric encryption: `PresenceMessage.fromEncoded` and `Message.fromEncoded`

Open ben-xD opened this issue 4 years ago • 9 comments

PR https://github.com/ably/ably-flutter/pull/192 does not yet include decryption of messages which are passed to PresenceMessage.fromEncoded and Message.fromEncoded, as per TP4 and TM3. This is intended for when messages are persisted to disk, or received outside of the Ably clients.

┆Issue is synchronized with this Jira Story by Unito

ben-xD avatar Nov 09 '21 10:11 ben-xD

Internal slack discussion on this issue: https://ably-real-time.slack.com/archives/C0178QGC093/p1645099695085259

ikurek avatar Feb 17 '22 12:02 ikurek

A couple of additional notes that we’ve collected together with @ikbalkaya :

  • Flutter SDK does not encrypt or decrypt messages - they’re encrypted and decrypted on native platform side, so it’s not really possible to save or do anything with encrypted message on Flutter side. The only use for Message.fromEncrypted seems to be a case, where message is provided to Flutter application from source other that our SDK, f.e. REST API. If message comes from our SDK, it’s automatically decrypted before it reaches Flutter SDK
  • Since the whole encryption is done on native platforms, the implementation shouldn’t probably be done on Flutter side, but rather it should be a proxy to native methods
  • Encryption implementation in sample app doesn't seem to work - see #334

ikurek avatar Feb 17 '22 17:02 ikurek

If we are going to implement this, even if the implementation is delegated away to the platform native layer (most appropriate), then we should test with: https://github.com/ably/ably-common/tree/main/test-resources

QuintinWillison avatar Feb 28 '22 15:02 QuintinWillison

I'll admit that I'm struggling a little bit to work out what the original use case for these methods was, however having discussed with @ikurek and @ikbalkaya we have concluded that - on balance - we should probably implement this. Igor has pointed out that we may need present a slightly different API to that presented in the spec, due to idiomatic constraints in Flutter/Dart.

QuintinWillison avatar Feb 28 '22 16:02 QuintinWillison

I'll admit that I'm struggling a little bit to work out what the original use case for these methods was

Imagine consuming messages via some mechanism that doesn't involve an Ably library - for example taking them from a Kinesis queue, or being passed a message on invocation of a lambda. You need to be able to decode those messages to get the original payload.

paddybyers avatar Feb 28 '22 21:02 paddybyers

I've discussed this with @maratal and ably-cocoa doesn't have a public implementation of Message.fromEncoded so for now there's nothing that I can use to bridge from Dart to iOS SDK

ikurek avatar Mar 10 '22 15:03 ikurek

https://github.com/ably/ably-cocoa/issues/1305 @ikurek

maratal avatar Mar 10 '22 16:03 maratal

https://github.com/ably/ably-cocoa/pull/1307

maratal avatar Mar 14 '22 00:03 maratal

This is also not fully implemented on ably-java, see:https://github.com/ably/ably-java/issues/752

ikurek avatar Mar 14 '22 13:03 ikurek