private function verifySignatures(Object\JWSInterface $jws, Object\JWKSetInterface $jwk_set, $detached_payload = null, &$recipient_index = null)
{
$this->checkPayload($jws, $detached_payload);
$this->checkJWKSet($jwk_set);
$this->checkSignatures($jws);
$nb_signatures = $jws->countSignatures();
for ($i = 0; $i < $nb_signatures; $i++) {
$signature = $jws->getSignature($i);
$result = $this->verifySignature($jws, $jwk_set, $signature, $detached_payload);
if (true === $result) {
$recipient_index = $i;
return;
}
}
throw new \InvalidArgumentException('Unable to verify the JWS.');
}