[issue42628] binascii doesn't work on some base64

2021-01-29 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42628] binascii doesn't work on some base64

2021-01-29 Thread Kent Watsen


Kent Watsen  added the comment:

I see.  There are two issues:

1) my `base64` and `openssl` CLI commands were flipped, as you point out, 
giving a false positive - oops ;)

2) more importantly, the base64 value "ue==" is invalid (there is no binary 
input that could possibly generate it) and none of the implementations issued a 
warning or error, which is reasonable IMO.

Thank you for your help.  Please close this issue.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42628] binascii doesn't work on some base64

2021-01-27 Thread Ammar Askar


Ammar Askar  added the comment:

It seems to me that your commands are just sequenced wrong, in Python you're 
performing (examples in parens):

* base64 (ue==) -> decode to binary (0xB9)
* binary (0xB9) -> encode to base64 (uQ==)

whereas in your command line commands you're doing:

* base64 (ue==) -> encode to double base64 (dWU9PQo=)
* double base64 (dWU9PQo=) -> decoded to base64 (ue==)


If we do the same thing on the command line as you're doing in Python, we get:

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

$ echo "ue==" | base64 -d | base64
uQ==

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

--
nosy: +ammar2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42628] binascii doesn't work on some base64

2021-01-23 Thread Kent Watsen


Change by Kent Watsen :


--
nosy:  -kwatsen2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42628] binascii doesn't work on some base64

2021-01-23 Thread Kent Watsen


Kent Watsen  added the comment:

No activity in 3 weeks.  Selecting a couple components to give it a bump.

--
components: +C API, Library (Lib)
nosy: +kwatsen

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42628] binascii doesn't work on some base64

2020-12-12 Thread Kent Watsen


New submission from Kent Watsen :

[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?

--
messages: 382922
nosy: kwatsen2
priority: normal
severity: normal
status: open
title: binascii doesn't work on some base64
type: behavior
versions: Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com