-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
st2api encrypt of £ (and other utf-8 chars) fails with python stacktrace #4513
Comments
make that utf-8 special characters |
nickbaum
added a commit
to nickbaum/st2
that referenced
this issue
Jan 30, 2019
WARNING: I'm no crypto expert, so please review with care. I ran into this same issue when trying to encrypt utf-8 text: StackStorm#4513 I believe the problem is that the plaintext is padded before it's encoded, and the encoding changes the length of the data. Moving the encoding before the padding seems to resolve the issue.
Update: the tests failed for that pull request, I added a comment describing the issue but don't have a solution yet. |
Thanks for reporting this issue and sorry for the delay. We will have a look as soon as we get a chance. |
Kami
added a commit
that referenced
this issue
Jan 31, 2019
handle unicode (utf-8) data. Previously we didn't correctly convert string to bytes before padding data which resulted in incorrectly padded data (incorrect length) so the actual encryption step failed. Thanks to @dswebbthg for reporting this issue. Resolves #4513.
Kami
added a commit
that referenced
this issue
Feb 18, 2019
handle unicode (utf-8) data. Previously we didn't correctly convert string to bytes before padding data which resulted in incorrectly padded data (incorrect length) so the actual encryption step failed. Thanks to @dswebbthg for reporting this issue. Resolves #4513.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SUMMARY
Provide a quick summary of your bug or feature request.
ISSUE TYPE
Pick one below and delete the rest:
STACKSTORM VERSION
Paste the output of
st2 --version
:root@stackstorm-ha-st2client-68fdcb57f-xnxkv:/opt/stackstorm# st2 --version
st2 3.0dev (9577ff9), on Python 3.6.7
OS / ENVIRONMENT / INSTALL METHOD
kubernetes using ubuntu 18.04 using helm
STEPS TO REPRODUCE
root@stackstorm-ha-st2client-68fdcb57f-xnxkv:/opt/stackstorm# st2 key set --scope=system --encrypt test '£'
ERROR: 400 Client Error: Bad Request
MESSAGE: The length of the provided data is not a multiple of the block length. for url: http://stackstorm-ha-st2api:9101/keys/test
During handling of the above exception, another exception occurred:
error log from the st2api container
2019-01-23 16:06:14,301 ERROR [-] Failed to call controller function "put" for operation "st2api.controllers.v1.keyvalue:key_value_pair_controller.put": The length of the provided data is not a multiple of the block length.
Traceback (most recent call last):
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2api/controllers/v1/keyvalue.py", line 301, in put
kvp_db = KeyValuePairAPI.to_model(kvp)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/models/api/keyvalue.py", line 175, in to_model
value = symmetric_encrypt(KeyValuePairAPI.crypto_key, value)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/crypto.py", line 186, in symmetric_encrypt
return cryptography_symmetric_encrypt(encrypt_key=encrypt_key, plaintext=plaintext)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/crypto.py", line 237, in cryptography_symmetric_encrypt
ciphertext_bytes = encryptor.update(data) + encryptor.finalize()
File "/opt/stackstorm/st2/lib/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 159, in finalize
data = self._ctx.finalize()
File "/opt/stackstorm/st2/lib/python3.6/site-packages/cryptography/hazmat/backends/openssl/ciphers.py", line 173, in finalize
"The length of the provided data is not a multiple of "
ValueError: The length of the provided data is not a multiple of the block length.
EXPECTED RESULTS
we should be able to encrypt the £ sign
ACTUAL RESULTS
http 400 and a python stacktrace on the api
The text was updated successfully, but these errors were encountered: