Crypto: continued

Continuation of #1854. Work in progress, just to see if tests pass for now.