BigInteger u1, u2, v;
// parameters and public key
BigInteger p, q, g, y;
DSAParams params;
int n1, n2;
byte bytes[];
byte digest[];
// checking up on signature's ASN1
try {
byte dummy;
n1 = sigBytes[offset + 3];
n2 = sigBytes[offset + n1 + 5];
if (sigBytes[offset + 0] != 0x30 || sigBytes[offset + 2] != 2
|| sigBytes[offset + n1 + 4] != 2
|| sigBytes[offset + 1] != (n1 + n2 + 4) || n1 > 21
|| n2 > 21
|| (length != 0 && (sigBytes[offset + 1] + 2) > length)) {
throw new SignatureException(Messages.getString("security.16F")); //$NON-NLS-1$
}
dummy = sigBytes[5 + n1 + n2]; // to check length of sigBytes
} catch (ArrayIndexOutOfBoundsException e) {
throw new SignatureException(Messages.getString("security.170")); //$NON-NLS-1$
}
digest = msgDigest.digest();
bytes = new byte[n1];
System.arraycopy(sigBytes, offset + 4, bytes, 0, n1);
r = new BigInteger(bytes);
bytes = new byte[n2];
System.arraycopy(sigBytes, offset + 6 + n1, bytes, 0, n2);
s = new BigInteger(bytes);
params = dsaKey.getParams();
p = params.getP();
q = params.getQ();
g = params.getG();
y = ((DSAPublicKey) dsaKey).getY();
// forming signature according algorithm described in chapter 6 of DSA standard
if (r.signum() != 1 || r.compareTo(q) != -1 || s.signum() != 1