signature.initVerify((PublicKey)key);
if (log.isDebugEnabled()) {
log.debug("Signature provider:" + signature.getProvider());
log.debug("verifying with key: " + key);
}
si.canonicalize(context, new SignerOutputStream(signature));
try {
Type type = getAlgorithmType();
if (type == Type.DSA) {
return signature.verify(convertXMLDSIGtoASN1(sig));