#1102 Replace legacy Python base64 invocations
Closed: Fixed None Opened 9 years ago by edewata.

The encodestring() and decodestring() are legacy interface according to Python docs (https://docs.python.org/2/library/base64.html). All invocations of these methods should be replaced with b64encode() and b64decode(), respectively.

Proposed milestone: 10.3


Per CS/DS meeting of 08/18/2014, moving ticket to 10.3.

encodestring() and b64encode() work slightly different. encodestring() always prepends a \n. Does it make any difference?

>>> base64.encodestring('example')
'ZXhhbXBsZQ==\n'
>>> base64.b64encode('example')
'ZXhhbXBsZQ=='
>>> base64.decodestring(base64.b64encode('example'))
'example'
>>> base64.b64decode(base64.b64encode('example'))
'example'

It depends on how it's used.

In drmtest.py the encodestring() is used to display binary data:

print "Nonce Data: " + base64.encodestring(key_data.nonce_data)

It doesn't matter since it's only used for logging/troubleshooting.

In key.py the encodestring() is used to serialize binary parameters to be sent to the server:

data = base64.encodestring(encrypted_data)

It might matter if the server relies on the '\n' prefix being there, but I highly doubt it. In any case the server should strip/ignore all whitespaces before processing the encoded data. If it doesn't, it's server's problem.

Per Dogtag 10.2.6 TRIAGE meeting of 06/30/2015: 10.2.6

Patch posted on pki-devel for review.

Per impromptu 10.2.6 meeting of 7/17/2025: 10.2.7

Per CS/DS Meeting of 08/03/2015: 10.3

Pushed to master 344caf335d94e7aa3a32bdd850ed1363088c896d

Metadata Update from @edewata:
- Issue assigned to cheimes
- Issue set to the milestone: 10.3.0

7 years ago

Dogtag PKI is moving from Pagure issues to GitHub issues. This means that existing or new
issues will be reported and tracked through Dogtag PKI's GitHub Issue tracker.

This issue has been cloned to GitHub and is available here:
https://github.com/dogtagpki/pki/issues/1665

If you want to receive further updates on the issue, please navigate to the
GitHub issue and click on Subscribe button.

Thank you for understanding, and we apologize for any inconvenience.

Login to comment on this ticket.

Metadata