I need to encrypt with AES-256, but I ALSO need a key size LARGER than 32 bytes. I have a function that takes text, a key, and an IV, and returns the encrypted text. It works with everything smaller than 32 bytes, but anything larger gives me an error.
So essentially, how can I implement a way to use keys larger than 32 bytes? I've already tried splitting the key into a vector of 32-byte (or less) strings, then using those as the keys, but I couldn't figure out a way to uniformly encrypt the text with all of those keys at once, so what can I do?
With AES-256 the key size is always 32 bytes long (256/8 = 32).
When the input secret is not exactly 32 bytes and/or of poor quality, a key derivation function is used. With keys of sufficient entropy a simple hashing function such as SHA-256, is sufficient.
In other words, just feed your input key through SHA-256 and out comes a 32-byte key usable for AES-256.