From 661176cb3a4c4952edd9c9bf022fabbf82bc4a1d Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Tue, 17 Jul 2018 22:39:45 +0200 Subject: [PATCH] Olm m.room.encrypted example --- ...room.encrypted => m.room.encrypted#megolm} | 8 ++---- event-schemas/examples/m.room.encrypted#olm | 14 ++++++++++ event-schemas/schema/m.room.encrypted | 28 ++++++++++++++----- 3 files changed, 37 insertions(+), 13 deletions(-) rename event-schemas/examples/{m.room.encrypted => m.room.encrypted#megolm} (57%) create mode 100644 event-schemas/examples/m.room.encrypted#olm diff --git a/event-schemas/examples/m.room.encrypted b/event-schemas/examples/m.room.encrypted#megolm similarity index 57% rename from event-schemas/examples/m.room.encrypted rename to event-schemas/examples/m.room.encrypted#megolm index 0e7e677a..1f9b7520 100644 --- a/event-schemas/examples/m.room.encrypted +++ b/event-schemas/examples/m.room.encrypted#megolm @@ -1,7 +1,7 @@ { "content": { "algorithm": "m.megolm.v1.aes-sha2", - "ciphertext": "AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg2yyOwAtHaZTwyNg37afzg8f3r9IsN9rH4RNFg7MaZencUJe4qvELiDiopUjy5wYVDAtqdBzer5bWRD9ldxp1FLgbQvBcjkkywYjCsmsq6+hArILd9oAQZnGKn/qLsK+5uNX3PaWzDRC9wZPQvWYYPCTov3jCwXKTPsLKIiTrcCXDqMvnn8m+T3zF1/I2zqxg158tnUwWWIw51UO", + "ciphertext": "AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...", "device_id": "RJYKSTBOIE", "sender_key": "IlRMeOPX2e0MurIyfWEucYBRVOEEUMrOHqn/8mLqMjA", "session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ" @@ -10,9 +10,5 @@ "room_id": "!Cuyf34gef24t:localhost", "origin_server_ts": 1476648761524, "sender": "@example:localhost", - "type": "m.room.encrypted", - "unsigned": { - "age": 158, - "transaction_id": "m1476648745605.19" - } + "type": "m.room.encrypted" } diff --git a/event-schemas/examples/m.room.encrypted#olm b/event-schemas/examples/m.room.encrypted#olm new file mode 100644 index 00000000..abb23c31 --- /dev/null +++ b/event-schemas/examples/m.room.encrypted#olm @@ -0,0 +1,14 @@ +{ + "type": "m.room.encrypted", + "sender": "@example:localhost", + "content": { + "algorithm": "m.olm.v1.curve25519-aes-sha2", + "sender_key": "Szl29ksW/L8yZGWAX+8dY1XyFi+i5wm+DRhTGkbMiwU", + "ciphertext": { + "7qZcfnBmbEGzxxaWfBjElJuvn7BZx+lSz/SvFrDF/z8": { + "type": 0, + "body": "AwogGJJzMhf/S3GQFXAOrCZ3iKyGU5ZScVtjI0KypTYrW..." + } + } + } +} diff --git a/event-schemas/schema/m.room.encrypted b/event-schemas/schema/m.room.encrypted index cf3e4b4a..664b10cf 100644 --- a/event-schemas/schema/m.room.encrypted +++ b/event-schemas/schema/m.room.encrypted @@ -1,8 +1,6 @@ --- allOf: - # this is a bit of a lie; if the event is sent as a to-device event it won't - # have the room event fields. We really ought to use different event types :/ - - $ref: core-event-schema/room_event.yaml + - $ref: core-event-schema/event.yaml description: |- This event type is used when sending encrypted events. It can be used either @@ -14,16 +12,32 @@ properties: properties: algorithm: type: string + enum: + - m.olm.curve25519-aes-sha256 + - m.megolm.v1.aes-sha description: |- The encryption algorithm used to encrypt this event. The value of this field determines which other properties will be present. ciphertext: - type: - - object - - string + oneOf: + - type: string + - type: object + additionalProperties: + type: object + title: CiphertextInfo + properties: + body: + type: string + description: The encrypted payload. + type: + type: integer + description: The Olm message type. description: |- - Normally required. The encrypted content of the event. + The encrypted content of the event. Either the encrypted payload + itself, in the case of a Megolm event, or a map from the recipient + Curve25519 identity key to ciphertext information, in the case of an + Olm event. For more details, see `Messaging Algorithms`_. required: - algorithm type: object