-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Current tsp sdk offers the seal() and open() api that:
- seal() produces contiguous encoded data to be carried in a transport layer message where the encoded data is in a contiguous payload
- similarly, open() takes contiguous encoded data and verifies, and if encrypted, decrypts.
Some application scenarios however may use transport mechanisms where they wish to embed TSP envelope, payload, and signature in non-contiguous locations.
One such example is from the Matrix community where they may wish to use the TSP's signed but not encrypted messages to be carried over Matrix transparently (i.e. TSP messages being carried over Matrix messages). In this case, they would like to embed the TSP envelope and signature parts in Matrix's signature field, while leaving the unencrypted plaintext in its content field.
In such a scheme, the sender would still need to construct the encoded TSP message to generate the signature, and, in order for the receiver to verify such a Matrix message, it would need to reconstruct the contiguous TSP encoded message for signature and sender VID verification.
While the above Matrix example uses non-encrypted TSP messages, we could envision other applications where TSP encrypted messages are used instead. Therefore, it would be nice if we could design an api that can support both cases.
To better facilitate similar schemes, we propose to add a new api that:
- seal_nc() will generate correct signature in the same way as seal(), but the output will be in 3 parts: envelope, payload, signature. CESR encoding ensures that the 3 parts are concat'able - a simple concat() operation can reproduce the identical seal() output. The payload may be encrypted or non-encrypted.
- open_nc() will take in 3 parts: envelope, payload, signature, then it converts to a contiguous tsp message then verifies in the same way as open(). This should be possible again because CESR encoding. The payload may be encrypted or non-encrypted.
- tsp_payload_encode() is a helper function where the input is cleartext unencoded message (from Matrix) and output is encoded TSP payload which can be concat'ed to produce contiguous tsp message for verification.
The above Matrix application can then:
- On sending side, call seal_nc(). Concat envelope and signature to be carried in Matrix signature. Discard the encoded payload. Unencoded plaintext is already carried in normal Matrix message.
- On receive side, call tsp_payload_encode() to generate encoded payload from plaintext, then open_nc() to verify.
The above description is based on my basic understanding of its requirements. Please comment/edit as needed to make sure we have a more precise definition of this requirement. Note that the Matrix app MAY construct the above on its own by parsing/decoupling the CESR encoded message - but - I think an appropriately designed API could reduce work and error for application developers.
Below is an example of Matrix message in such use:
