I assume you have
- 2 different keys (128 and 256 bit)
- 2 different sources of ciphertext (1:
AES128
2:AES256
Both:CBC/No Padding
) - Can decrypt 128 ciphertext
- Fail with 256 (everything is garbled and nothing from plaintext is decrypted).
The main difference is the key length of 128 or 256 bit. It specifies the number of repetitions of transformation rounds that convert the input. You probably will never need internal implementation details. AES uses more rounds with larger keys. 10 for 128-bit keys, 14 for 256-bit keys.
Important part is that Block size is always 128 bit for 128 and 256 CBC AES.
Both AES-128-CBC and AES-256-CBC use 128 bit IV.
So my wild guess (without seeing your AES256 code) is that there can be bug somewhere in Block or IV size in your AES256 code.
If you just set key for 128AES with this function, check this docs
gcry_error_t gcry_cipher_setkey (gcry_cipher_hd_t h, const void *k, size_t l)
The length l (in bytes) of the key k must match the required length of the algorithm set for this context or be in the allowed range for algorithms with variable key size. The function checks this and returns an error if there is a problem. A caller should always check for an error.
And you normally don't want to use CBC with NoPadding (unless your data size is always a multiple of 16 bytes) but padding problems garble only the last 16-byte block of plaintext.