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


Java ECPublicKeyParameters类代码示例

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


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

示例1: verify

import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
@Override
public boolean verify(byte[] hash, byte[] signature, byte[] publicKey) {
    ASN1InputStream asn1 = new ASN1InputStream(signature);
    try {
        ECDSASigner signer = new ECDSASigner();
        signer.init(false, new ECPublicKeyParameters(curve.getCurve().decodePoint(publicKey), domain));

        DLSequence seq = (DLSequence) asn1.readObject();
        BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();
        BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();
        return signer.verifySignature(hash, r, s);
    } catch (Exception e) {
        return false;
    } finally {
        try {
            asn1.close();
        } catch (IOException ignored) {
        }
    }
}
 
开发者ID:hyperledger-archives,项目名称:fabric-api-archive,代码行数:21,代码来源:BouncyCastleCrypto.java

示例2: JCEECPublicKey

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

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:JCEECPublicKey.java

示例3: generateClientKeyExchange

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

示例4: init

import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
/**
 * initialise the EC Elgamal engine.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:31,代码来源:ECNewPublicKeyTransform.java

示例5: init

import org.bouncycastle.crypto.params.ECPublicKeyParameters; //导入依赖的package包/类
/**
 * initialise the encryptor.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:31,代码来源:ECElGamalEncryptor.java

示例6: init

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

示例7: init

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

示例8: init

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

示例9: BCDSTU4145PublicKey

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

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:BCDSTU4145PublicKey.java

示例10: BCECPublicKey

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

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }

    this.configuration = configuration;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:BCECPublicKey.java

示例11: BCECGOST3410PublicKey

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

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:BCECGOST3410PublicKey.java

示例12: JCEECPublicKey

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

    this.algorithm = algorithm;
    this.q = params.getQ();

    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,代码来源:JCEECPublicKey.java

示例13: init

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

示例14: generateKeyPair

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

示例15: prepareAfterParse

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


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