
org.spongycastle.crypto.params.DSAPublicKeyParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle
intended for the Android platform. Android unfortunately ships with a stripped-down version of
Bouncy Castle, which prevents easy upgrades - Spongy Castle overcomes this and provides a full,
up-to-date version of the Bouncy Castle cryptographic libs.
The newest version!
package org.spongycastle.crypto.params;
import java.math.BigInteger;
public class DSAPublicKeyParameters
extends DSAKeyParameters
{
private static final BigInteger ONE = BigInteger.valueOf(1);
private static final BigInteger TWO = BigInteger.valueOf(2);
private BigInteger y;
public DSAPublicKeyParameters(
BigInteger y,
DSAParameters params)
{
super(false, params);
this.y = validate(y, params);
}
private BigInteger validate(BigInteger y, DSAParameters params)
{
if (params != null)
{
if (TWO.compareTo(y) <= 0 && params.getP().subtract(TWO).compareTo(y) >= 0
&& ONE.equals(y.modPow(params.getQ(), params.getP())))
{
return y;
}
throw new IllegalArgumentException("y value does not appear to be in correct group");
}
else
{
return y; // we can't validate without params, fortunately we can't use the key either...
}
}
public BigInteger getY()
{
return y;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy