In the spirit of dropping openssl where possible…
This uses @sipa’s AES impelementation from #5885. As I understand it, he is comfortable with pulling this part in before the rest of fortuna.
The bulk of changes here are tests, the actual changes are small. Tests verify that encryption/decryption/keygen work as expected, but also that the results match openssl’s exactly (including output buffers in failure cases).
The aes-cbc decryption attempts to be done in constant-time, in case it’s re-used in the future in places that may be susceptible to timing attacks. It works with/without padding, so it could be re-used in different contexts. @sipa I copied your structures for AES_Decrypt/AES_Encrypt for the sake of simplicity, so there’s a good bit of duplication here now. I’m happy to re-work with templates, merged classes, separate files, etc.
Besides the unit tests, I’ve also done some quick sanity checks via rpc to verify that switching back and forth between implementations works as expected. Wallets encrypted with openssl still decrypt fine, and likewise the other way around.