The AES_ENCRYPT and AES_DECRYPT functions accept keys of any size and transform them internally to 128-bit key.
- A key shorter than128-bit will be right filled with zeros
- A key larger than 128 bit will be xored with redundant bytes.
The AES standard (FIPS 197) doesn't cover non standard key sizes, it mentions only that key size have to be 128, 192 or 256 (depending on block cipher mode).
Bad side effects of current implementation:
- Encrypted data is no interoperable with other applications (most applications and crypto libraries reject wrong key sizes)
- It can result in producing very weak keys, e.g.
Add session variable
which allows the following modes:
*OFF: use old key and iv derivation routines
*STRICT: only accept keys and ivs with correct sizes