Synss / python-mbedtls

Cryptographic library with an mbed TLS back end
MIT License
79 stars 28 forks source link

Implement padding control for crypto #57

Closed skelsec closed 2 years ago

skelsec commented 2 years ago

NOTE: Please use stackoverflow for support questions. This repository's issues are reserved for feature requests and bug reports.

I am submitting a …

Description

Currently all symmetric block ciphers default to the padding whichever one was set in mbedtls at compilation time. Because it's by default not MBEDTLS_PADDING_NONE the current setup excludes many usecases for the ciphers.

Current behavior

As I see currently it's using MBEDTLS_PADDING_PKCS7.

Expected behavior

Either default to MBEDTLS_PADDING_NONE and have the user's implement padding on their own, or expose the mbedtls_cipher_set_padding_mode to the user. (NOTE: should be applied to both encryption and decryption context a the same time)

Steps to reproduce

Minimal demo of the problem

Other information

Synss commented 2 years ago

or expose the mbedtls_cipher_set_padding_mode to the user.

Is probably easier.

Passing callbacks from Python to C is possible but I prefer to avoid that as much as possible.

Synss commented 2 years ago

I changed my mind. Users can use

I will default to NONE.

skelsec commented 2 years ago

Works for me, please let me know when the code is updated

Synss commented 2 years ago

It is done.