diff options
author | David Howells <dhowells@redhat.com> | 2021-11-17 15:48:06 +0000 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2022-01-07 13:42:16 +0000 |
commit | 5d439467b802f5c6393b20d57662500dfb177c8f (patch) | |
tree | ed356351e8e25095ef79610b904314d5774b814a /crypto/cipher.c | |
parent | df98e87f2091774c377ddfaedfe64bd90ed4bdca (diff) | |
download | linux-5d439467b802f5c6393b20d57662500dfb177c8f.tar.gz linux-5d439467b802f5c6393b20d57662500dfb177c8f.tar.bz2 linux-5d439467b802f5c6393b20d57662500dfb177c8f.zip |
cachefiles: Implement key to filename encoding
Implement a function to encode a binary cookie key as something that can be
used as a filename. Four options are considered:
(1) All printable chars with no '/' characters. Prepend a 'D' to indicate
the encoding but otherwise use as-is.
(2) Appears to be an array of __be32. Encode as 'S' plus a list of
hex-encoded 32-bit ints separated by commas. If a number is 0, it is
rendered as "" instead of "0".
(3) Appears to be an array of __le32. Encoded as (2) but with a 'T'
encoding prefix.
(4) Encoded as base64 with an 'E' prefix plus a second char indicating how
much padding is involved. A non-standard base64 encoding is used
because '/' cannot be used in the encoded form.
If (1) is not possible, whichever of (2), (3) or (4) produces the shortest
string is selected (hex-encoding a number may be less dense than base64
encoding it).
Note that the prefix characters have to be selected from the set [DEIJST@]
lest cachefilesd remove the files because it recognise the name.
Changes
=======
ver #2:
- Fix a short allocation that didn't allow for a string terminator[1]
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/bcefb8f2-576a-b3fc-cc29-89808ebfd7c1@linux.alibaba.com/ [1]
Link: https://lore.kernel.org/r/163819640393.215744.15212364106412961104.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906940529.143852.17352132319136117053.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967149827.1823006.6088580775428487961.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021549223.640689.14762875188193982341.stgit@warthog.procyon.org.uk/ # v4
Diffstat (limited to 'crypto/cipher.c')
0 files changed, 0 insertions, 0 deletions