Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python binding doesn't allow non-string data anymore #4470

Open
orzel opened this issue Dec 7, 2024 · 2 comments
Open

Python binding doesn't allow non-string data anymore #4470

orzel opened this issue Dec 7, 2024 · 2 comments
Assignees
Labels

Comments

@orzel
Copy link

orzel commented Dec 7, 2024

At least in PKSign, but probably in other places. The problem is present in both botan2 and botan3. It used to work, i was using it in a project of mine.

When we want to compute the pksign, calling PKSign.update() forces _ctype_str() on the message:
_DLL.botan_pk_op_sign_update(self.__obj, _ctype_str(msg), len(msg))

And _ctype_str has an assert isinstance(s, str)
If i add this in _ctype_str:
if isinstance(s, bytes): return s

Then my code works again. It seems legit, as it's a communication protocol, where one end use botan/python, and the other one uses botan/c(++). The C part has no problem handling non-string binaries.

Another potential problem is that len(msg) doesn't necessarily corespond to len( _ctype_str(msg)).

@randombit
Copy link
Owner

I would guess this worked in Python2 but doesn’t behave correctly with Python3.

@randombit randombit added the bug label Dec 8, 2024
@randombit randombit self-assigned this Dec 8, 2024
@orzel
Copy link
Author

orzel commented Dec 9, 2024

I would guess this worked in Python2 but doesn’t behave correctly with Python3.

Yeah, probably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants