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


Java ECPrivateKeyParameters类代码示例

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


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

示例1: generateClientKeyExchange

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

示例2: init

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
public void init(boolean forSigning, CipherParameters param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            param = rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
        }

        this.key = (ECPrivateKeyParameters)param;
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }

}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:DSTU4145Signer.java

示例3: init

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
public void init(
    boolean                 forSigning,
    CipherParameters        param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:ECDSASigner.java

示例4: init

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
public void init(
    boolean          forSigning, 
    CipherParameters param) 
{
    this.forSigning = forSigning;
    
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:ECNRSigner.java

示例5: JCEECPrivateKey

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
JCEECPrivateKey(
    String                  algorithm,
    ECPrivateKeyParameters  params,
    ECParameterSpec         spec)
{
    ECDomainParameters      dp = params.getParameters();

    this.algorithm = algorithm;
    this.d = params.getD();

    if (spec == null)
    {
        this.ecSpec = new ECParameterSpec(
                        dp.getCurve(),
                        dp.getG(),
                        dp.getN(),
                        dp.getH(),
                        dp.getSeed());
    }
    else
    {
        this.ecSpec = spec;
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:25,代码来源:JCEECPrivateKey.java

示例6: generatePrivateKeyParameter

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

        return new ECPrivateKeyParameters(
                        k.getD(),
                        new ECDomainParameters(s.getCurve(), s.getG(), s.getN()));
    }
                    
    throw new InvalidKeyException("can't identify EC private key.");
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:17,代码来源:ECUtil.java

示例7: init

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
public void init(
       boolean                 forSigning,
       CipherParameters        param)
{
       if (forSigning)
       {
           if (param instanceof ParametersWithRandom)
           {
               ParametersWithRandom    rParam = (ParametersWithRandom)param;

               this.random = rParam.getRandom();
               this.key = (ECPrivateKeyParameters)rParam.getParameters();
           }
           else
           {
               this.random = new SecureRandom();
               this.key = (ECPrivateKeyParameters)param;
           }
       }
       else
       {
	    this.key = (ECPublicKeyParameters)param;
       }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:25,代码来源:ECDSASigner.java

示例8: generateKeyPair

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
/**
    * Given the domain parameters this routine generates an EC key
    * pair in accordance with X9.62 section 5.2.1 pages 26, 27.
    */
   public AsymmetricCipherKeyPair generateKeyPair()
   {
	BigInteger n = params.getN();
	int			  nBitLength = n.bitLength();
	BigInteger d;

	do
	{
		d = new BigInteger(nBitLength, random);
	}
	while (d.equals(ZERO)  || (d.compareTo(n) >= 0));

	ECPoint Q = params.getG().multiply(d);

	return new AsymmetricCipherKeyPair(
           new ECPublicKeyParameters(Q, params),
		new ECPrivateKeyParameters(d, params));
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:23,代码来源:ECKeyPairGenerator.java

示例9: prepareAfterParse

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
@Override
public void prepareAfterParse() {
    try {
        msg.prepareComputations();
        List<ECPointFormat> pointFormatList = chooser.getServerSupportedPointFormats();
        ECPointFormat[] formatArray = pointFormatList.toArray(new ECPointFormat[pointFormatList.size()]);
        short[] pointFormats = ECCUtilsBCWrapper.convertPointFormats(formatArray);
        ECPublicKeyParameters clientPublicKey = TlsECCUtils.deserializeECPublicKey(pointFormats,
                getDomainParameters(chooser.getEcCurveType(), chooser.getSelectedCurve()), msg.getPublicKey()
                        .getValue());
        CustomECPoint customClientKey = new CustomECPoint(clientPublicKey.getQ().getRawXCoord().toBigInteger(),
                clientPublicKey.getQ().getRawYCoord().toBigInteger());
        msg.getComputations().setClientPublicKey(customClientKey);

        BigInteger privatekey = chooser.getServerEcPrivateKey();
        computePremasterSecret(clientPublicKey,
                new ECPrivateKeyParameters(privatekey, clientPublicKey.getParameters()));
        preparePremasterSecret(msg);
        prepareClientRandom(msg);
    } catch (IOException ex) {
        throw new PreparationException("Could prepare ECDHClientKeyExchange Message after Parse", ex);
    }
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:24,代码来源:ECDHClientKeyExchangePreparator.java

示例10: calculateAgreement

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
public BigInteger calculateAgreement(CipherParameters pubKey)
{
    if (Properties.isOverrideSet("org.bouncycastle.ec.disable_mqv"))
    {
        throw new IllegalStateException("ECMQV explicitly disabled");
    }

    MQVPublicParameters pubParams = (MQVPublicParameters)pubKey;

    ECPrivateKeyParameters staticPrivateKey = privParams.getStaticPrivateKey();

    ECPoint agreement = calculateMqvAgreement(staticPrivateKey.getParameters(), staticPrivateKey,
        privParams.getEphemeralPrivateKey(), privParams.getEphemeralPublicKey(),
        pubParams.getStaticPublicKey(), pubParams.getEphemeralPublicKey()).normalize();

    if (agreement.isInfinity())
    {
        throw new IllegalStateException("Infinity is not a valid agreement value for MQV");
    }

    return agreement.getAffineXCoord().toBigInteger();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:23,代码来源:ECMQVBasicAgreement.java

示例11: ECDSAgeneratePublicAndPrivateKey

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

示例12: sign

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
@Override
public byte[] sign(byte[] hash, byte[] privateKey) {
    ECDSASigner signer = new ECDSASigner(new HMacDSAKCalculator(new SHA256Digest()));
    signer.init(true, new ECPrivateKeyParameters(new BigInteger(privateKey), domain));
    BigInteger[] signature = signer.generateSignature(hash);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        DERSequenceGenerator seq = new DERSequenceGenerator(baos);
        seq.addObject(new ASN1Integer(signature[0]));
        seq.addObject(new ASN1Integer(toCanonicalS(signature[1])));
        seq.close();
        return baos.toByteArray();
    } catch (IOException e) {
        return new byte[0];
    }
}
 
开发者ID:hyperledger-archives,项目名称:fabric-api-archive,代码行数:17,代码来源:BouncyCastleCrypto.java

示例13: generateSharedSecret

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
/**
 * Generate a shared AES key using ECDH.
 */
public static byte[] generateSharedSecret(byte[] privateKey, byte[] publicKey) {
  try {
    ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec(SECP256K1);
    ECDomainParameters domain =
        new ECDomainParameters(spec.getCurve(), spec.getG(), spec.getN(), spec.getH());
    ECPublicKeyParameters pubKey =
        new ECPublicKeyParameters(spec.getCurve().decodePoint(publicKey), domain);
    ECPrivateKeyParameters prvkey =
        new ECPrivateKeyParameters(new BigInteger(1, privateKey), domain);

    ECDHBasicAgreement agreement = new ECDHBasicAgreement();
    agreement.init(prvkey);
    byte[] password = agreement.calculateAgreement(pubKey).toByteArray();

    return Aes.generateKey(ByteUtilities.toHexString(password), password);

  } catch (Exception e) {
    LOGGER.error(null, e);
    return new byte[0];
  }
}
 
开发者ID:Braveno,项目名称:cosigner,代码行数:25,代码来源:Secp256k1.java

示例14: calculateAgreement

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
public BigInteger calculateAgreement(CipherParameters pubKey)
{
    MQVPublicParameters pubParams = (MQVPublicParameters)pubKey;

    ECPrivateKeyParameters staticPrivateKey = privParams.getStaticPrivateKey();

    ECPoint agreement = calculateMqvAgreement(staticPrivateKey.getParameters(), staticPrivateKey,
        privParams.getEphemeralPrivateKey(), privParams.getEphemeralPublicKey(),
        pubParams.getStaticPublicKey(), pubParams.getEphemeralPublicKey()).normalize();

    if (agreement.isInfinity())
    {
        throw new IllegalStateException("Infinity is not a valid agreement value for MQV");
    }

    return agreement.getAffineXCoord().toBigInteger();
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:18,代码来源:ECMQVBasicAgreement.java

示例15: sign

import org.bouncycastle.crypto.params.ECPrivateKeyParameters; //导入依赖的package包/类
@Override
public byte[] sign (byte[] hash) throws ValidationException
{
	if ( priv == null )
	{
		throw new ValidationException ("Need private key to sign");
	}
	ECDSASigner signer = new ECDSASigner (new HMacDSAKCalculator (new SHA256Digest ()));
	signer.init (true, new ECPrivateKeyParameters (priv, domain));
	BigInteger[] signature = signer.generateSignature (hash);
	ByteArrayOutputStream s = new ByteArrayOutputStream ();
	try
	{
		DERSequenceGenerator seq = new DERSequenceGenerator (s);
		seq.addObject (new ASN1Integer (signature[0]));
		seq.addObject (new ASN1Integer (signature[1]));
		seq.close ();
		return s.toByteArray ();
	}
	catch ( IOException e )
	{
	}
	return null;
}
 
开发者ID:bitsofproof,项目名称:bop-bitcoin-client,代码行数:25,代码来源:ECKeyPair.java


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