* It generates encryption keys insecurely instead of using a cryptographically secure KDF
* It leaks timing information on the MAC comparison
* It makes verification of messages optional; verification should never be optional (in your case, when verification is disabled, I think you have the CBC padding oracle vulnerability)
As an ordinary developer, I just want to use a library like PyCrypto in a safe manner. When I described the language as "jargon" I did not mean to be dismissive of it, but rather to say that libraries like PyCrypto force you to make decisions about terms that are nothing more than jargon to a non-expert -- when really what a non-expert needs is an extremely simple API which makes those decisions on your behalf in a safe manner.
Thanks again and these are humbling lessons to learn.
Please don't do things like this.
PS: It's also not clear if you're doing the HMAC check in a time-invariant manner: https://github.com/jsdalton/secrets.py/blob/master/secrets/c...
I wrote this library recently (primarily to scratch an itch on another project), which really does nothing more than pass sane defaults to PyCrypto and eliminate crypto jargon:
https://github.com/jsdalton/secrets.py
Honestly I think it took more time to wrap my head around the simple use cases than it did to implement this wrapper once I did.