added check that the hash algorithm in the public key is the same as in the header