GNU bug report logs -
#66265
Make padding optional with base64
Previous Next
Reported by: Paul Millar <paul.millar <at> desy.de>
Date: Fri, 29 Sep 2023 13:14:02 UTC
Severity: normal
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66265 in the body.
You can then email your comments to 66265 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#66265
; Package
coreutils
.
(Fri, 29 Sep 2023 13:14:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Millar <paul.millar <at> desy.de>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 29 Sep 2023 13:14:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
RFC 4648 says[1]:
> In some circumstances, the use of padding ("=") in base-encoded data
> is not required or used.
Currently, the 'base64' application always includes the padding when
encoding, and prints an warning/error message (on stderr) if padding is
omitted when decoding. Decoding is nonetheless successful (the correct
data is emitted on stdout) if the base64-encoded data omits the padding.
I think the base64 application should be updated to support
base64-encoded data without padding.
My suggestion would be to add an option to base64 to control whether
padding is added when encoding. For decoding, it might make sense to
add an option to control whether padding is expected.
(although, other approaches might be possible)
Cheers,
Paul.
[1] https://datatracker.ietf.org/doc/html/rfc4648#section-3.2
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#66265
; Package
coreutils
.
(Fri, 29 Sep 2023 14:13:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 66265 <at> debbugs.gnu.org (full text, mbox):
On 29/09/2023 10:46, Paul Millar wrote:
> Hi,
>
> RFC 4648 says[1]:
> > In some circumstances, the use of padding ("=") in base-encoded data
> > is not required or used.
>
> Currently, the 'base64' application always includes the padding when
> encoding, and prints an warning/error message (on stderr) if padding is
> omitted when decoding. Decoding is nonetheless successful (the correct
> data is emitted on stdout) if the base64-encoded data omits the padding.
>
> I think the base64 application should be updated to support
> base64-encoded data without padding.
>
> My suggestion would be to add an option to base64 to control whether
> padding is added when encoding. For decoding, it might make sense to
> add an option to control whether padding is expected.
>
> (although, other approaches might be possible)
>
> Cheers,
> Paul.
>
> [1] https://datatracker.ietf.org/doc/html/rfc4648#section-3.2
I agree with this actually.
The main advantage of padding as I see it is when concatenating encoded data.
I.e. that's the only use case where there could be ambiguity in the received
encoded data, as otherwise one can auto assume appropriate padding based on
the input length. I can't see `base64` or `basenc --base64` being used in a
problematic streaming context like that. If the utils themselves read from
a stream in a _single invocation_ they'll deal with partial blocks appropriately.
Looking at it another way, I don't see how base64 data over _separate invocations_
of these utils could be handled now, as they just give errors in this case anyway.
Now there would be a slight loss in error detection as truncated data would
not be noticed, however that is the case for a third of truncated sizes already.
So on input I'm inclined to auto pad.
On output one can trivially remove padding with `tr -d =`,
so I'm inclined to leave that as is.
I.e. we shouldn't need a new option for any of this.
cheers,
Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#66265
; Package
coreutils
.
(Fri, 06 Oct 2023 15:37:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 66265 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 29/09/2023 15:11, Pádraig Brady wrote:
> On 29/09/2023 10:46, Paul Millar wrote:
>> Hi,
>>
>> RFC 4648 says[1]:
>> > In some circumstances, the use of padding ("=") in base-encoded data
>> > is not required or used.
>>
>> Currently, the 'base64' application always includes the padding when
>> encoding, and prints an warning/error message (on stderr) if padding is
>> omitted when decoding. Decoding is nonetheless successful (the correct
>> data is emitted on stdout) if the base64-encoded data omits the padding.
>>
>> I think the base64 application should be updated to support
>> base64-encoded data without padding.
>>
>> My suggestion would be to add an option to base64 to control whether
>> padding is added when encoding. For decoding, it might make sense to
>> add an option to control whether padding is expected.
>>
>> (although, other approaches might be possible)
>>
>> Cheers,
>> Paul.
>>
>> [1] https://datatracker.ietf.org/doc/html/rfc4648#section-3.2
>
> I agree with this actually.
>
> The main advantage of padding as I see it is when concatenating encoded data.
> I.e. that's the only use case where there could be ambiguity in the received
> encoded data, as otherwise one can auto assume appropriate padding based on
> the input length. I can't see `base64` or `basenc --base64` being used in a
> problematic streaming context like that. If the utils themselves read from
> a stream in a _single invocation_ they'll deal with partial blocks appropriately.
> Looking at it another way, I don't see how base64 data over _separate invocations_
> of these utils could be handled now, as they just give errors in this case anyway.
> Now there would be a slight loss in error detection as truncated data would
> not be noticed, however that is the case for a third of truncated sizes already.
>
> So on input I'm inclined to auto pad.
>
> On output one can trivially remove padding with `tr -d =`,
> so I'm inclined to leave that as is.
>
> I.e. we shouldn't need a new option for any of this.
Implementation attached
cheers,
Pádraig
[basenc-autopad.patch (text/x-patch, attachment)]
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Sat, 07 Oct 2023 14:01:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Paul Millar <paul.millar <at> desy.de>
:
bug acknowledged by developer.
(Sat, 07 Oct 2023 14:01:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 66265-done <at> debbugs.gnu.org (full text, mbox):
Pushed.
Marking this as done.
cheers,
Pádraig
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 05 Nov 2023 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 187 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.