JWS: implement remaining HMAC and RSA algorithms

Implement HS384, HS512, RS384 and RS512, and a drive-by refactoring
of the signing functions.