On Sat, May 16, 2020 at 4:33 PM Liu, Changcheng
<changcheng.liu(a)intel.com> wrote:
Hi all,
I'm trying to accelerate base64 encode/decode in Ceph.
There's one contradictory logic in ceph_armor & ceph_unarmor:
1. ceph_armor:
It won't add new breakline '\n' in the encoded result.
https://github.com/ceph/ceph/blob/master/src/common/armor.c#L85
Note: line_width is always 0
https://github.com/ceph/ceph/blob/master/src/common/armor.c#L96
2. ceph_unarmor:
It will use specific logic to deal with the new breakline in '\n'
https://github.com/ceph/ceph/blob/master/src/common/armor.c#L106
Why do we implement it in this way? Which version of base64 RFC is
followd by Ceph?
It is common to have base64 strings that have line breaks in them, so
our decoding function needs to be able to handle that whether we use
it or not. We do have ceph_armor_line_break() that can be used in
theory (although it's not being used right now). There are cases where
we need to handle base64 strings that were encoded by external
sources, so code needs to be resilient and handle these cases.
Yehuda