Skip to content

Commit 7fcfa57

Browse files
Add clarification on binary data and base64 encoding to Appendices (#3362)
* Add clarification on binary data and base64 encoding (closes #3341) * Add changelog fragment * Delete 3362.clarification
1 parent 933bb8d commit 7fcfa57

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

content/appendices.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ When decoding Base64, implementations SHOULD accept input with or
4747
without padding characters wherever possible, to ensure maximum
4848
interoperability.
4949

50+
## Binary data
51+
52+
In some cases it is necessary to encapsulate binary data, for example,
53+
public keys or signatures. Given that JSON cannot safely represent raw
54+
binary data, all binary values should be encoded and represented in
55+
JSON as unpadded Base64 strings as described above.
56+
57+
In cases where the Matrix specification refers to either opaque byte
58+
or opaque Base64 values, the value is considered to be opaque AFTER
59+
Base64 decoding, rather than the encoded representation itself.
60+
61+
It is safe for a client or homeserver implementation to check for
62+
correctness of a Base64-encoded value at any point, and to altogether
63+
reject a value which is not encoded properly. However, this is optional
64+
and is considered to be an implementation detail.
65+
66+
Special consideration is given for future protocol transformations,
67+
such as those which do not use JSON, where Base64 encoding may not be
68+
necessary in order to represent a binary value safely. In these cases,
69+
Base64 encoding of binary values may be skipped altogether.
70+
5071
## Signing JSON
5172

5273
Various points in the Matrix specification require JSON objects to be

0 commit comments

Comments
 (0)