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


Java ECPoint.Fp方法代码示例

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


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

示例1: DualECSP800DRBG

import org.bouncycastle.math.ec.ECPoint; //导入方法依赖的package包/类
/**
 * Construct a SP800-90A Dual EC DRBG.
 * <p>
 * Minimum entropy requirement is the security strength requested.
 * </p>
 * @param digest source digest to use with the DRB stream.
 * @param securityStrength security strength required (in bits)
 * @param entropySource source of entropy to use for seeding/reseeding.
 * @param personalizationString personalization string to distinguish this DRBG (may be null).
 * @param nonce nonce to further distinguish this DRBG (may be null).
 */
public DualECSP800DRBG(Digest digest, int securityStrength, EntropySource entropySource, byte[] personalizationString, byte[] nonce)
{
    _digest = digest;
    _entropySource = entropySource;
    _securityStrength = securityStrength;

    if (Utils.isTooLarge(personalizationString, MAX_PERSONALIZATION_STRING / 8))
    {
        throw new IllegalArgumentException("Personalization string too large");
    }

    if (entropySource.entropySize() < securityStrength || entropySource.entropySize() > MAX_ENTROPY_LENGTH)
    {
        throw new IllegalArgumentException("EntropySource must provide between " + securityStrength + " and " + MAX_ENTROPY_LENGTH + " bits");
    }

    byte[] entropy = entropySource.getEntropy();
    byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalizationString);

    if (securityStrength <= 128)
    {
        if (Utils.getMaxSecurityStrength(digest) < 128)
        {
            throw new IllegalArgumentException("Requested security strength is not supported by digest");
        }
        _seedlen = 256;
        _outlen = 240 / 8;
        _curve = (ECCurve.Fp)NISTNamedCurves.getByName("P-256").getCurve();
        _P = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p256_Px), new ECFieldElement.Fp(_curve.getQ(), p256_Py));
        _Q = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p256_Qx), new ECFieldElement.Fp(_curve.getQ(), p256_Qy));
    }
    else if (securityStrength <= 192)
    {
        if (Utils.getMaxSecurityStrength(digest) < 192)
        {
            throw new IllegalArgumentException("Requested security strength is not supported by digest");
        }
        _seedlen = 384;
        _outlen = 368 / 8;
        _curve = (ECCurve.Fp)NISTNamedCurves.getByName("P-384").getCurve();
        _P = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p384_Px), new ECFieldElement.Fp(_curve.getQ(), p384_Py));
        _Q = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p384_Qx), new ECFieldElement.Fp(_curve.getQ(), p384_Qy));
    }
    else if (securityStrength <= 256)
    {
        if (Utils.getMaxSecurityStrength(digest) < 256)
        {
            throw new IllegalArgumentException("Requested security strength is not supported by digest");
        }
        _seedlen = 521;
        _outlen = 504 / 8;
        _curve = (ECCurve.Fp)NISTNamedCurves.getByName("P-521").getCurve();
        _P = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p521_Px), new ECFieldElement.Fp(_curve.getQ(), p521_Py));
        _Q = new ECPoint.Fp(_curve, new ECFieldElement.Fp(_curve.getQ(), p521_Qx), new ECFieldElement.Fp(_curve.getQ(), p521_Qy));
    }
    else
    {
        throw new IllegalArgumentException("security strength cannot be greater than 256 bits");
    }

    _s = Utils.hash_df(_digest, seedMaterial, _seedlen);
    _sLength = _s.length;

    _reseedCounter = 0;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:77,代码来源:DualECSP800DRBG.java


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