本文整理汇总了Java中org.bouncycastle.crypto.params.DSAPublicKeyParameters类的典型用法代码示例。如果您正苦于以下问题:Java DSAPublicKeyParameters类的具体用法?Java DSAPublicKeyParameters怎么用?Java DSAPublicKeyParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DSAPublicKeyParameters类属于org.bouncycastle.crypto.params包,在下文中一共展示了DSAPublicKeyParameters类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
public void init(
boolean forSigning,
CipherParameters param)
{
if (forSigning)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
this.random = rParam.getRandom();
this.key = (DSAPrivateKeyParameters)rParam.getParameters();
}
else
{
this.random = new SecureRandom();
this.key = (DSAPrivateKeyParameters)param;
}
}
else
{
this.key = (DSAPublicKeyParameters)param;
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:DSASigner.java
示例2: generateKeyPair
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
public KeyPair generateKeyPair()
{
if (!initialised)
{
DSAParametersGenerator pGen = new DSAParametersGenerator();
pGen.init(strength, certainty, random);
param = new DSAKeyGenerationParameters(random, pGen.generateParameters());
engine.init(param);
initialised = true;
}
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
DSAPublicKeyParameters pub = (DSAPublicKeyParameters)pair.getPublic();
DSAPrivateKeyParameters priv = (DSAPrivateKeyParameters)pair.getPrivate();
return new KeyPair(new BCDSAPublicKey(pub),
new BCDSAPrivateKey(priv));
}
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:KeyPairGeneratorSpi.java
示例3: generateKeyPair
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
public AsymmetricCipherKeyPair generateKeyPair()
{
BigInteger p, q, g, x, y;
DSAParameters dsaParams = param.getParameters();
SecureRandom random = param.getRandom();
q = dsaParams.getQ();
p = dsaParams.getP();
g = dsaParams.getG();
do
{
x = new BigInteger(160, random);
}
while (x.equals(ZERO) || x.compareTo(q) >= 0);
//
// calculate the public key.
//
y = g.modPow(x, p);
return new AsymmetricCipherKeyPair(
new DSAPublicKeyParameters(y, dsaParams),
new DSAPrivateKeyParameters(x, dsaParams));
}
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:26,代码来源:DSAKeyPairGenerator.java
示例4: verifySignature
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
/**
* return true if the value r and s represent a DSA signature for
* the passed in message for standard DSA the message should be a
* SHA-1 hash of the real message to be verified.
*/
public boolean verifySignature(
byte[] message,
BigInteger r,
BigInteger s)
{
DSAParameters params = key.getParameters();
BigInteger m = calculateE(params.getQ(), message);
BigInteger zero = BigInteger.valueOf(0);
if (zero.compareTo(r) >= 0 || params.getQ().compareTo(r) <= 0)
{
return false;
}
if (zero.compareTo(s) >= 0 || params.getQ().compareTo(s) <= 0)
{
return false;
}
BigInteger w = s.modInverse(params.getQ());
BigInteger u1 = m.multiply(w).mod(params.getQ());
BigInteger u2 = r.multiply(w).mod(params.getQ());
u1 = params.getG().modPow(u1, params.getP());
u2 = ((DSAPublicKeyParameters)key).getY().modPow(u2, params.getP());
BigInteger v = u1.multiply(u2).mod(params.getP()).mod(params.getQ());
return v.equals(r);
}
开发者ID:Appdome,项目名称:ipack,代码行数:37,代码来源:DSASigner.java
示例5: generateKeyPair
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
public AsymmetricCipherKeyPair generateKeyPair()
{
DSAParameters dsaParams = param.getParameters();
BigInteger x = generatePrivateKey(dsaParams.getQ(), param.getRandom());
BigInteger y = calculatePublicKey(dsaParams.getP(), dsaParams.getG(), x);
return new AsymmetricCipherKeyPair(
new DSAPublicKeyParameters(y, dsaParams),
new DSAPrivateKeyParameters(x, dsaParams));
}
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:DSAKeyPairGenerator.java
示例6: generatePublicKeyParameter
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
static public AsymmetricKeyParameter generatePublicKeyParameter(
PublicKey key)
throws InvalidKeyException
{
if (key instanceof DSAPublicKey)
{
DSAPublicKey k = (DSAPublicKey)key;
return new DSAPublicKeyParameters(k.getY(),
new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
}
throw new InvalidKeyException("can't identify DSA public key: " + key.getClass().getName());
}
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:DSAUtil.java
示例7: init
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
public void init(
boolean forSigning,
CipherParameters param)
{
SecureRandom providedRandom = null;
if (forSigning)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
this.key = (DSAPrivateKeyParameters)rParam.getParameters();
providedRandom = rParam.getRandom();
}
else
{
this.key = (DSAPrivateKeyParameters)param;
}
}
else
{
this.key = (DSAPublicKeyParameters)param;
}
this.random = initSecureRandom(forSigning && !kCalculator.isDeterministic(), providedRandom);
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:28,代码来源:DSASigner.java
示例8: verifySignature
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
/**
* return true if the value r and s represent a DSA signature for
* the passed in message for standard DSA the message should be a
* SHA-1 hash of the real message to be verified.
*/
public boolean verifySignature(
byte[] message,
BigInteger r,
BigInteger s)
{
DSAParameters params = key.getParameters();
BigInteger q = params.getQ();
BigInteger m = calculateE(q, message);
BigInteger zero = BigInteger.valueOf(0);
if (zero.compareTo(r) >= 0 || q.compareTo(r) <= 0)
{
return false;
}
if (zero.compareTo(s) >= 0 || q.compareTo(s) <= 0)
{
return false;
}
BigInteger w = s.modInverse(q);
BigInteger u1 = m.multiply(w).mod(q);
BigInteger u2 = r.multiply(w).mod(q);
BigInteger p = params.getP();
u1 = params.getG().modPow(u1, p);
u2 = ((DSAPublicKeyParameters)key).getY().modPow(u2, p);
BigInteger v = u1.multiply(u2).mod(p).mod(q);
return v.equals(r);
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:39,代码来源:DSASigner.java
示例9: initVerify
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
/** {@inheritDoc} */
public void initVerify() {
if (verifyKey == null) {
throw new IllegalStateException(
"Verify key must be set prior to initialization.");
}
final DSAPublicKey pubKey = (DSAPublicKey) verifyKey;
final DSAParams params = pubKey.getParams();
final DSAPublicKeyParameters bcParams = new DSAPublicKeyParameters(
pubKey.getY(), new DSAParameters(params.getP(), params.getQ(),
params.getG()));
init(false, bcParams);
}
开发者ID:shivam091,项目名称:Java-Security,代码行数:15,代码来源:DSASignature.java
示例10: JDKDSAPublicKey
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
JDKDSAPublicKey(
DSAPublicKeyParameters params)
{
this.y = params.getY();
this.dsaSpec = new DSAParameterSpec(params.getParameters().getP(), params.getParameters().getQ(), params.getParameters().getG());
}
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:JDKDSAPublicKey.java
示例11: isValidPublicKey
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
public boolean isValidPublicKey(AsymmetricKeyParameter publicKey)
{
return publicKey instanceof DSAPublicKeyParameters;
}
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:TlsDSSSigner.java
示例12: getClientCertificateType
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
static short getClientCertificateType(Certificate clientCertificate, Certificate serverCertificate)
throws IOException
{
if (clientCertificate.isEmpty())
{
return -1;
}
org.bouncycastle.asn1.x509.Certificate x509Cert = clientCertificate.getCertificateAt(0);
SubjectPublicKeyInfo keyInfo = x509Cert.getSubjectPublicKeyInfo();
try
{
AsymmetricKeyParameter publicKey = PublicKeyFactory.createKey(keyInfo);
if (publicKey.isPrivate())
{
throw new TlsFatalAlert(AlertDescription.internal_error);
}
/*
* TODO RFC 5246 7.4.6. The certificates MUST be signed using an acceptable hash/
* signature algorithm pair, as described in Section 7.4.4. Note that this relaxes the
* constraints on certificate-signing algorithms found in prior versions of TLS.
*/
/*
* RFC 5246 7.4.6. Client Certificate
*/
/*
* RSA public key; the certificate MUST allow the key to be used for signing with the
* signature scheme and hash algorithm that will be employed in the certificate verify
* message.
*/
if (publicKey instanceof RSAKeyParameters)
{
validateKeyUsage(x509Cert, KeyUsage.digitalSignature);
return ClientCertificateType.rsa_sign;
}
/*
* DSA public key; the certificate MUST allow the key to be used for signing with the
* hash algorithm that will be employed in the certificate verify message.
*/
if (publicKey instanceof DSAPublicKeyParameters)
{
validateKeyUsage(x509Cert, KeyUsage.digitalSignature);
return ClientCertificateType.dss_sign;
}
/*
* ECDSA-capable public key; the certificate MUST allow the key to be used for signing
* with the hash algorithm that will be employed in the certificate verify message; the
* public key MUST use a curve and point format supported by the server.
*/
if (publicKey instanceof ECPublicKeyParameters)
{
validateKeyUsage(x509Cert, KeyUsage.digitalSignature);
// TODO Check the curve and point format
return ClientCertificateType.ecdsa_sign;
}
// TODO Add support for ClientCertificateType.*_fixed_*
}
catch (Exception e)
{
}
throw new TlsFatalAlert(AlertDescription.unsupported_certificate);
}
开发者ID:Appdome,项目名称:ipack,代码行数:71,代码来源:TlsUtils.java
示例13: BCDSAPublicKey
import org.bouncycastle.crypto.params.DSAPublicKeyParameters; //导入依赖的package包/类
BCDSAPublicKey(
DSAPublicKeyParameters params)
{
this.y = params.getY();
this.dsaSpec = new DSAParameterSpec(params.getParameters().getP(), params.getParameters().getQ(), params.getParameters().getG());
}
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:BCDSAPublicKey.java
注:本文中的org.bouncycastle.crypto.params.DSAPublicKeyParameters类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论