当前位置: 首页>>代码示例>>Java>>正文


Java DSAPrivateKeyParameters类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.params.DSAPrivateKeyParameters的典型用法代码示例。如果您正苦于以下问题:Java DSAPrivateKeyParameters类的具体用法?Java DSAPrivateKeyParameters怎么用?Java DSAPrivateKeyParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DSAPrivateKeyParameters类属于org.bouncycastle.crypto.params包,在下文中一共展示了DSAPrivateKeyParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的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.DSAPrivateKeyParameters; //导入依赖的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.DSAPrivateKeyParameters; //导入依赖的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: generateKeyPair

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的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

示例5: generatePrivateKeyParameter

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
static public AsymmetricKeyParameter generatePrivateKeyParameter(
    PrivateKey    key)
    throws InvalidKeyException
{
    if (key instanceof DSAPrivateKey)
    {
        DSAPrivateKey    k = (DSAPrivateKey)key;

        return new DSAPrivateKeyParameters(k.getX(),
            new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
    }
                    
    throw new InvalidKeyException("can't identify DSA private key.");
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:DSAUtil.java

示例6: init

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的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

示例7: generateSignature

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
/**
 * generate a signature for the given message using the key we were
 * initialised with. For conventional DSA the message should be a SHA-1
 * hash of the message of interest.
 *
 * @param message the message that will be verified later.
 */
public BigInteger[] generateSignature(
    byte[] message)
{
    DSAParameters   params = key.getParameters();
    BigInteger      q = params.getQ();
    BigInteger      m = calculateE(q, message);
    BigInteger      x = ((DSAPrivateKeyParameters)key).getX();

    if (kCalculator.isDeterministic())
    {
        kCalculator.init(q, x, message);
    }
    else
    {
        kCalculator.init(q, random);
    }

    BigInteger  k = kCalculator.nextK();

    BigInteger  r = params.getG().modPow(k, params.getP()).mod(q);

    k = k.modInverse(q).multiply(m.add(x.multiply(r)));

    BigInteger  s = k.mod(q);

    return new BigInteger[]{ r, s };
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:35,代码来源:DSASigner.java

示例8: initSign

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
/** {@inheritDoc} */
public void initSign() {
	if (signKey == null) {
		throw new IllegalStateException(
				"Sign key must be set prior to initialization.");
	}

	final DSAPrivateKey privKey = (DSAPrivateKey) signKey;
	final DSAParams params = privKey.getParams();
	final DSAPrivateKeyParameters bcParams = new DSAPrivateKeyParameters(
			privKey.getX(), new DSAParameters(params.getP(), params.getQ(),
					params.getG()));
	init(true, bcParams);
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:15,代码来源:DSASignature.java

示例9: generateSignature

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
/**
 * generate a signature for the given message using the key we were
 * initialised with. For conventional DSA the message should be a SHA-1
 * hash of the message of interest.
 *
 * @param message the message that will be verified later.
 */
public BigInteger[] generateSignature(
    byte[] message)
{
    DSAParameters   params = key.getParameters();
    BigInteger      m = calculateE(params.getQ(), message);

    if (kCalculator.isDeterministic())
    {
        kCalculator.init(params.getQ(), ((DSAPrivateKeyParameters)key).getX(), message);
    }
    else
    {
        kCalculator.init(params.getQ(), random);
    }

    BigInteger  k = kCalculator.nextK();

    BigInteger  r = params.getG().modPow(k, params.getP()).mod(params.getQ());

    k = k.modInverse(params.getQ()).multiply(
                m.add(((DSAPrivateKeyParameters)key).getX().multiply(r)));

    BigInteger  s = k.mod(params.getQ());

    BigInteger[]  res = new BigInteger[2];

    res[0] = r;
    res[1] = s;

    return res;
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:39,代码来源:DSASigner.java

示例10: generateSignature

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
/**
 * generate a signature for the given message using the key we were
 * initialised with. For conventional DSA the message should be a SHA-1
 * hash of the message of interest.
 *
 * @param message the message that will be verified later.
 */
public BigInteger[] generateSignature(
    byte[] message)
{
    DSAParameters   params = key.getParameters();
    BigInteger      m = calculateE(params.getQ(), message);
    BigInteger      k;
    int                  qBitLength = params.getQ().bitLength();

    do 
    {
        k = new BigInteger(qBitLength, random);
    }
    while (k.compareTo(params.getQ()) >= 0);

    BigInteger  r = params.getG().modPow(k, params.getP()).mod(params.getQ());

    k = k.modInverse(params.getQ()).multiply(
                m.add(((DSAPrivateKeyParameters)key).getX().multiply(r)));

    BigInteger  s = k.mod(params.getQ());

    BigInteger[]  res = new BigInteger[2];

    res[0] = r;
    res[1] = s;

    return res;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:36,代码来源:DSASigner.java

示例11: generates1024bitKeys

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
@Test
public void generates1024bitKeys() throws Exception {
    final AsymmetricCipherKeyPair pair = DsaKeyGenerator.dsa1024().generate(random);

    assertThat(pair.getPrivate())
            .isInstanceOf(DSAPrivateKeyParameters.class);

    final DSAPrivateKeyParameters privateKeys = (DSAPrivateKeyParameters) pair.getPrivate();
    assertThat(privateKeys.getParameters().getP().toByteArray().length)
            .isEqualTo(129);
}
 
开发者ID:codahale,项目名称:gpgj,代码行数:12,代码来源:DsaKeyGeneratorTest.java

示例12: generates2048bitKeys

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
@Test
public void generates2048bitKeys() throws Exception {
    final AsymmetricCipherKeyPair pair = DsaKeyGenerator.dsa2048().generate(random);

    assertThat(pair.getPrivate())
            .isInstanceOf(DSAPrivateKeyParameters.class);

    final DSAPrivateKeyParameters privateKeys = (DSAPrivateKeyParameters) pair.getPrivate();
    assertThat(privateKeys.getParameters().getP().toByteArray().length)
            .isIn(257);
}
 
开发者ID:codahale,项目名称:gpgj,代码行数:12,代码来源:DsaKeyGeneratorTest.java

示例13: generates3072bitKeys

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
@Test
public void generates3072bitKeys() throws Exception {
    final AsymmetricCipherKeyPair pair = DsaKeyGenerator.dsa3072().generate(random);

    assertThat(pair.getPrivate())
            .isInstanceOf(DSAPrivateKeyParameters.class);

    final DSAPrivateKeyParameters privateKeys = (DSAPrivateKeyParameters) pair.getPrivate();
    assertThat(privateKeys.getParameters().getP().toByteArray().length)
            .isIn(385);
}
 
开发者ID:codahale,项目名称:gpgj,代码行数:12,代码来源:DsaKeyGeneratorTest.java

示例14: enableClientAuthentication

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
public void enableClientAuthentication(Certificate clientCertificate,
    AsymmetricKeyParameter clientPrivateKey)
{
    if (clientCertificate == null)
    {
        throw new IllegalArgumentException("'clientCertificate' cannot be null");
    }
    if (clientCertificate.certs.length == 0)
    {
        throw new IllegalArgumentException("'clientCertificate' cannot be empty");
    }
    if (clientPrivateKey == null)
    {
        throw new IllegalArgumentException("'clientPrivateKey' cannot be null");
    }
    if (!clientPrivateKey.isPrivate())
    {
        throw new IllegalArgumentException("'clientPrivateKey' must be private");
    }

    if (clientPrivateKey instanceof RSAKeyParameters)
    {
        clientSigner = new TlsRSASigner();
    }
    else if (clientPrivateKey instanceof DSAPrivateKeyParameters)
    {
        clientSigner = new TlsDSSSigner();
    }
    else
    {
        throw new IllegalArgumentException("'clientPrivateKey' type not supported: "
            + clientPrivateKey.getClass().getName());
    }

    this.clientCert = clientCertificate;
    this.clientPrivateKey = clientPrivateKey;
}
 
开发者ID:coova,项目名称:jradius,代码行数:38,代码来源:DefaultTlsClient.java

示例15: JDKDSAPrivateKey

import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; //导入依赖的package包/类
JDKDSAPrivateKey(
    DSAPrivateKeyParameters  params)
{
    this.x = params.getX();
    this.dsaSpec = new DSAParameterSpec(params.getParameters().getP(), params.getParameters().getQ(), params.getParameters().getG());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:JDKDSAPrivateKey.java


注:本文中的org.bouncycastle.crypto.params.DSAPrivateKeyParameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。