protected function _checkCipherKeySize(CipherAlgorithmIdentifier $algo,
        string $key)
    {
        if ($algo instanceof BlockCipherAlgorithmIdentifier) {
            if (strlen($key) != $algo->keySize()) {
                throw new \UnexpectedValueException(
                    sprintf('Key length for %s must be %d, %d given.',
                        $algo->name(), $algo->keySize(), strlen($key)));
            }
        }
    }