Author kwatsen2
Recipients kwatsen2
Date 2020-12-12.21:23:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607808198.75.0.933631782561.issue42628@roundup.psfhosted.org>
In-reply-to
Content
[Tested on 3.8.2 and 3.9.0, bug may manifest in other versions too]

The IETF sometimes uses the dummy base64 value "base64encodedvalue==" in specifications in lieu of a block of otherwise meaningless b64.  

Even though it is a dummy value, the value should be convertible to binary and back again.  This works using the built-in command `base64` as well as OpenSSL command line, but binascii is unable to do it.  See below:

$ echo "base64encodedvalue==" | base64 | base64 -d
base64encodedvalue==

$ echo "base64encodedvalue==" | openssl enc -base64 -A | openssl enc -d base64 -A
base64encodedvalue==                                                                                                         

$ printf "import binascii\nprint(binascii.b2a_base64(binascii.a2b_base64('base64encodedvalue=='), newline=False).decode('ascii'))" |  python -
base64encodedvaluQ==

After some investigation, it appears that almost any valid base64 matching the pattern "??==" fails.  For instance:

$ printf "import binascii\nprint(binascii.b2a_base64(binascii.a2b_base64('ue=='), newline=False).decode('ascii'))" |  python -                                                           
uQ==

$ printf "import binascii\nprint(binascii.b2a_base64(binascii.a2b_base64('aa=='), newline=False).decode('ascii'))" |  python -                                                           
aQ==

$ printf "import binascii\nprint(binascii.b2a_base64(binascii.a2b_base64('a0=='), newline=False).decode('ascii'))" |  python -                                                           
aw==


Is this a bug?
History
Date User Action Args
2020-12-12 21:23:18kwatsen2setrecipients: + kwatsen2
2020-12-12 21:23:18kwatsen2setmessageid: <1607808198.75.0.933631782561.issue42628@roundup.psfhosted.org>
2020-12-12 21:23:18kwatsen2linkissue42628 messages
2020-12-12 21:23:18kwatsen2create