small refactorings (cherry-picked from ccdaae038)
Fix CloudMailin signature digest calculation

Adopt current (deprecated) code from
http://docs.cloudmailin.com/receiving_email/securing_your_email_url_target/

Fixes #1402