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


Java AsymmetricCipherKeyPair.getPrivate方法代码示例

本文整理汇总了Java中org.bouncycastle.crypto.AsymmetricCipherKeyPair.getPrivate方法的典型用法代码示例。如果您正苦于以下问题:Java AsymmetricCipherKeyPair.getPrivate方法的具体用法?Java AsymmetricCipherKeyPair.getPrivate怎么用?Java AsymmetricCipherKeyPair.getPrivate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.AsymmetricCipherKeyPair的用法示例。


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

示例1: generateKeyPair

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public KeyPair generateKeyPair()
{
    if (!initialised)
    {
        param = new RainbowKeyGenerationParameters(random, new RainbowParameters(new RainbowParameterSpec().getVi()));

        engine.init(param);
        initialised = true;
    }

    AsymmetricCipherKeyPair pair = engine.generateKeyPair();
    RainbowPublicKeyParameters pub = (RainbowPublicKeyParameters)pair.getPublic();
    RainbowPrivateKeyParameters priv = (RainbowPrivateKeyParameters)pair.getPrivate();

    return new KeyPair(new BCRainbowPublicKey(pub),
        new BCRainbowPrivateKey(priv));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:RainbowKeyPairGeneratorSpi.java

示例2: generateClientKeyExchange

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public void generateClientKeyExchange(OutputStream output)
    throws IOException
{
    if (agreementCredentials != null)
    {
        return;
    }

    AsymmetricCipherKeyPair ecAgreeClientKeyPair = TlsECCUtils.generateECKeyPair(context.getSecureRandom(),
        ecAgreeServerPublicKey.getParameters());
    this.ecAgreeClientPrivateKey = (ECPrivateKeyParameters)ecAgreeClientKeyPair.getPrivate();

    byte[] point = TlsECCUtils.serializeECPublicKey(serverECPointFormats,
        (ECPublicKeyParameters)ecAgreeClientKeyPair.getPublic());

    TlsUtils.writeOpaque8(point, output);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:TlsECDHKeyExchange.java

示例3: generateKeyPair

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

示例4: ECDSAgeneratePublicAndPrivateKey

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
/*************
 * This method will create the ECDSA public and private key which is returned in a Byte array of Byte arrays, index 0 is the private key and
 * index 1 of the array will return the ECDSA public key
 * 
 * -Wisdom: This guy didn't check whether the returned Private Key would be more than 32.
 * @return
 
 */
private byte[][] ECDSAgeneratePublicAndPrivateKey(){
       int length = 0;
       byte[][] keys;
       
    do{
        
	ECKeyPairGenerator gen = new ECKeyPairGenerator();
	SecureRandom secureRandom = new SecureRandom();
        X9ECParameters secnamecurves = SECNamedCurves.getByName("secp256k1");
	ECDomainParameters ecParams = new ECDomainParameters(secnamecurves.getCurve(), secnamecurves.getG(), secnamecurves.getN(), secnamecurves.getH());
	ECKeyGenerationParameters keyGenParam = new ECKeyGenerationParameters(ecParams, secureRandom);
	gen.init(keyGenParam);
	AsymmetricCipherKeyPair kp = gen.generateKeyPair();
	ECPrivateKeyParameters privatekey = (ECPrivateKeyParameters)kp.getPrivate();
	ECPoint dd = secnamecurves.getG().multiply(privatekey.getD());
	byte[] publickey=new byte[65];
	System.arraycopy(dd.getY().toBigInteger().toByteArray(), 0, publickey, 64-dd.getY().toBigInteger().toByteArray().length+1, dd.getY().toBigInteger().toByteArray().length);
	System.arraycopy(dd.getX().toBigInteger().toByteArray(), 0, publickey, 32-dd.getX().toBigInteger().toByteArray().length+1, dd.getX().toBigInteger().toByteArray().length);
	publickey[0]=4;
        length = privatekey.getD().toByteArray().length;
        keys = new byte[][]{privatekey.getD().toByteArray(),publickey};
        
    }while(length != 32);
	return keys;
}
 
开发者ID:wisdomcsharp,项目名称:SSI_Bitcoin-Storage,代码行数:34,代码来源:Address.java

示例5: generateKeyPair

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public KeyPair generateKeyPair()
{
    if (!initialised)
    {
        init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom());
    }

    AsymmetricCipherKeyPair pair = engine.generateKeyPair();
    GOST3410PublicKeyParameters pub = (GOST3410PublicKeyParameters)pair.getPublic();
    GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate();

    return new KeyPair(new BCGOST3410PublicKey(pub, gost3410Params), new BCGOST3410PrivateKey(priv, gost3410Params));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:14,代码来源:KeyPairGeneratorSpi.java

示例6: generateEphemeralClientKeyExchange

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public static DHPrivateKeyParameters generateEphemeralClientKeyExchange(SecureRandom random,
                                                                        DHParameters dhParams, OutputStream output)
    throws IOException
{

    AsymmetricCipherKeyPair dhAgreeClientKeyPair = generateDHKeyPair(random, dhParams);
    DHPrivateKeyParameters dhAgreeClientPrivateKey = (DHPrivateKeyParameters)dhAgreeClientKeyPair
        .getPrivate();

    BigInteger Yc = ((DHPublicKeyParameters)dhAgreeClientKeyPair.getPublic()).getY();
    byte[] keData = BigIntegers.asUnsignedByteArray(Yc);
    TlsUtils.writeOpaque16(keData, output);

    return dhAgreeClientPrivateKey;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:TlsDHUtils.java

示例7: generateKeyPair

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public KeyPair generateKeyPair()
{
    AsymmetricCipherKeyPair pair = engine.generateKeyPair();
    RSAKeyParameters pub = (RSAKeyParameters)pair.getPublic();
    RSAPrivateCrtKeyParameters priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();

    return new KeyPair(new BCRSAPublicKey(pub),
        new BCRSAPrivateCrtKey(priv));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:KeyPairGeneratorSpi.java

示例8: initEnc

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public ECPoint initEnc(SM2 sm2, ECPoint userKey) {
    AsymmetricCipherKeyPair key = sm2.ecc_key_pair_generator.generateKeyPair();
    ECPrivateKeyParameters ecpriv = (ECPrivateKeyParameters) key.getPrivate();
    ECPublicKeyParameters ecpub = (ECPublicKeyParameters) key.getPublic();
    BigInteger k = ecpriv.getD();
    ECPoint c1 = ecpub.getQ();
    this.p2 = userKey.multiply(k);
    reset();
    return c1;
}
 
开发者ID:nuls-io,项目名称:nuls,代码行数:11,代码来源:Cipher.java

示例9: createNew

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
/**
 * Create a new PrivateKey using the platform provided secure random source.
 *
 * @param compressed set to false if you relly want legacy format
 * @return new PrivateKey
 */
public static PrivateKey createNew(boolean compressed) {
    ECKeyPairGenerator generator = new ECKeyPairGenerator();
    ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(domain, secureRandom);
    generator.init(keygenParams);
    AsymmetricCipherKeyPair keypair = generator.generateKeyPair();
    ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();
    ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic();
    return new PrivateKey(privParams.getD(), compressed, pubParams.getQ().getEncoded(compressed));
}
 
开发者ID:DigitalAssetCom,项目名称:-deprecated-hlp-candidate,代码行数:16,代码来源:PrivateKey.java

示例10: createNewPrivateKey

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
@Override
public byte[] createNewPrivateKey() {
    ECKeyPairGenerator generator = new ECKeyPairGenerator();
    ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(domain, secureRandom);
    generator.init(keygenParams);
    AsymmetricCipherKeyPair keypair = generator.generateKeyPair();
    ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();
    return privParams.getD().toByteArray();
}
 
开发者ID:hyperledger-archives,项目名称:fabric-api,代码行数:10,代码来源:BouncyCastleCrypto.java

示例11: setEcDhParams

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
protected void setEcDhParams() {
    msg.prepareComputations();
    generateNamedCurveList(msg);
    generatePointFormatList(msg);
    prepareCurveType(msg);
    prepareNamedCurve(msg);

    ECDomainParameters ecParams = generateEcParameters(msg);
    AsymmetricCipherKeyPair keyPair = TlsECCUtils.generateECKeyPair(chooser.getContext().getBadSecureRandom(),
            ecParams);

    pubEcParams = (ECPublicKeyParameters) keyPair.getPublic();
    privEcParams = (ECPrivateKeyParameters) keyPair.getPrivate();
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:15,代码来源:ECDHEServerKeyExchangePreparator.java

示例12: generateEphemeralClientKeyExchange

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public static DHPrivateKeyParameters generateEphemeralClientKeyExchange(SecureRandom random, DHParameters dhParams,
    OutputStream output) throws IOException
{
    AsymmetricCipherKeyPair kp = generateDHKeyPair(random, dhParams);

    DHPublicKeyParameters dhPublic = (DHPublicKeyParameters) kp.getPublic();
    writeDHParameter(dhPublic.getY(), output);

    return (DHPrivateKeyParameters) kp.getPrivate();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:11,代码来源:TlsDHUtils.java

示例13: generateEphemeralClientKeyExchange

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public static ECPrivateKeyParameters generateEphemeralClientKeyExchange(SecureRandom random, short[] ecPointFormats,
    ECDomainParameters ecParams, OutputStream output) throws IOException
{
    AsymmetricCipherKeyPair kp = generateECKeyPair(random, ecParams);

    ECPublicKeyParameters ecPublicKey = (ECPublicKeyParameters) kp.getPublic();
    writeECPoint(ecPointFormats, ecPublicKey.getQ(), output);

    return (ECPrivateKeyParameters) kp.getPrivate();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:11,代码来源:TlsECCUtils.java

示例14: generateECDSAKey

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
static private OneKey generateECDSAKey(String curveName, CBORObject curve) {                
    X9ECParameters p = NISTNamedCurves.getByName(curveName);
    
    ECDomainParameters parameters = new ECDomainParameters(p.getCurve(), p.getG(), p.getN(), p.getH());
    ECKeyPairGenerator pGen = new ECKeyPairGenerator();
    ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(parameters, null);
    pGen.init(genParam);

    AsymmetricCipherKeyPair p1 = pGen.generateKeyPair();

    ECPublicKeyParameters keyPublic = (ECPublicKeyParameters) p1.getPublic();
    ECPrivateKeyParameters keyPrivate = (ECPrivateKeyParameters) p1.getPrivate();

    byte[] rgbX = keyPublic.getQ().normalize().getXCoord().getEncoded();
    byte[] rgbY = keyPublic.getQ().normalize().getYCoord().getEncoded();
    boolean signY = true;
    byte[] rgbD = keyPrivate.getD().toByteArray();

    OneKey key = new OneKey();

    key.add(KeyKeys.KeyType, KeyKeys.KeyType_EC2);
    key.add(KeyKeys.EC2_Curve, curve);
    key.add(KeyKeys.EC2_X, CBORObject.FromObject(rgbX));
    key.add(KeyKeys.EC2_Y, CBORObject.FromObject(rgbY));
    key.add(KeyKeys.EC2_D, CBORObject.FromObject(rgbD));

    return key;        
}
 
开发者ID:cose-wg,项目名称:COSE-JAVA,代码行数:29,代码来源:OneKey.java

示例15: perform

import org.bouncycastle.crypto.AsymmetricCipherKeyPair; //导入方法依赖的package包/类
public TestResult perform()
{
    BigInteger              r = new BigInteger("860d82c60e9502cd00c0e9e1f6563feafec304801974d745c5e02079946f729e",16);
    BigInteger              s = new BigInteger("7ef49264ef022801aaa03033cd97915235fbab4c823ed936b0f360c22114688a",16);
    GOST3410ParametersGenerator  pGen = new GOST3410ParametersGenerator();

    pGen.init(1024, 2, init_random);

    GOST3410Parameters           params = pGen.generateParameters();

    if (!pValue.equals(params.getP()) || !qValue.equals(params.getQ()))
    {
        return new SimpleTestResult(false, getName() + ": p or q wrong");
    }

    GOST3410KeyPairGenerator         GOST3410KeyGen = new GOST3410KeyPairGenerator();
    GOST3410KeyGenerationParameters  genParam = new GOST3410KeyGenerationParameters(keyRandom, params);

    GOST3410KeyGen.init(genParam);

    AsymmetricCipherKeyPair  pair = GOST3410KeyGen.generateKeyPair();

    ParametersWithRandom param = new ParametersWithRandom(pair.getPrivate(), random);

    GOST3410Signer GOST3410 = new GOST3410Signer();

    GOST3410.init(true, param);

    BigInteger[] sig = GOST3410.generateSignature(hashmessage);

    if (!r.equals(sig[0]))
    {
        return new SimpleTestResult(false, getName()
            + ": r component wrong." + Strings.lineSeparator()
            + " expecting: " + r.toString(16) + Strings.lineSeparator()
            + " got      : " + sig[0].toString(16));
    }

    if (!s.equals(sig[1]))
    {
        return new SimpleTestResult(false, getName()
            + ": s component wrong." + Strings.lineSeparator()
            + " expecting: " + s.toString(16) + Strings.lineSeparator()
            + " got      : " + sig[1].toString(16));
    }

    GOST3410.init(false, pair.getPublic());

    if (GOST3410.verifySignature(hashmessage, sig[0], sig[1]))
    {
        return new SimpleTestResult(true, getName() + ": Okay");
    }
    else
    {
        return new SimpleTestResult(false, getName() + ": verification fails");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:58,代码来源:GOST3410Test.java


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