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


Java ECDomainParameters.getH方法代码示例

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


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

示例1: JCEECPrivateKey

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

示例2: JCEECPublicKey

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

示例3: getParameterSpec

import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
/**
 * return a parameter spec representing the passed in named
 * curve. The routine returns null if the curve is not present.
 * 
 * @param name the name of the curve requested
 * @return a parameter spec for the curve, null if it is not available.
 */
public static ECNamedCurveParameterSpec getParameterSpec(
    String  name)
{
    ECDomainParameters  ecP = ECGOST3410NamedCurves.getByName(name);
    if (ecP == null)
    {
        try
        {
            ecP = ECGOST3410NamedCurves.getByOID(new ASN1ObjectIdentifier(name));
        }
        catch (IllegalArgumentException e)
        {
            return null; // not an oid.
        }
    }
    
    if (ecP == null)
    {
        return null;
    }

    return new ECNamedCurveParameterSpec(
                                    name,
                                    ecP.getCurve(),
                                    ecP.getG(),
                                    ecP.getN(),
                                    ecP.getH(),
                                    ecP.getSeed());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:37,代码来源:ECGOST3410NamedCurveTable.java

示例4: encrypt

import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
/**
 * Generate and encapsulate a random session key.
 *
 * @param out    the output buffer for the encapsulated key.
 * @param outOff the offset for the output buffer.
 * @param keyLen the length of the session key.
 * @return the random session key.
 */
public CipherParameters encrypt(byte[] out, int outOff, int keyLen)
    throws IllegalArgumentException
{
    if (!(key instanceof ECPublicKeyParameters))
    {
        throw new IllegalArgumentException("Public key required for encryption");
    }

    ECPublicKeyParameters ecPubKey = (ECPublicKeyParameters)key;
    ECDomainParameters ecParams = ecPubKey.getParameters();
    ECCurve curve = ecParams.getCurve();
    BigInteger n = ecParams.getN();
    BigInteger h = ecParams.getH();

    // Generate the ephemeral key pair    
    BigInteger r = BigIntegers.createRandomInRange(ONE, n, rnd);

    // Compute the static-ephemeral key agreement
    BigInteger rPrime = CofactorMode ? r.multiply(h).mod(n) : r;

    ECMultiplier basePointMultiplier = createBasePointMultiplier();

    ECPoint[] ghTilde = new ECPoint[]{ 
        basePointMultiplier.multiply(ecParams.getG(), r),
        ecPubKey.getQ().multiply(rPrime)
    };

    // NOTE: More efficient than normalizing each individually
    curve.normalizeAll(ghTilde);

    ECPoint gTilde = ghTilde[0], hTilde = ghTilde[1];

    // Encode the ephemeral public key
    byte[] C = gTilde.getEncoded(false);
    System.arraycopy(C, 0, out, outOff, C.length);

    // Encode the shared secret value
    byte[] PEH = hTilde.getAffineXCoord().getEncoded();

    return deriveKey(keyLen, C, PEH);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:50,代码来源:ECIESKeyEncapsulation.java

示例5: decrypt

import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
/**
 * Decrypt an encapsulated session key.
 *
 * @param in     the input buffer for the encapsulated key.
 * @param inOff  the offset for the input buffer.
 * @param inLen  the length of the encapsulated key.
 * @param keyLen the length of the session key.
 * @return the session key.
 */
public CipherParameters decrypt(byte[] in, int inOff, int inLen, int keyLen)
    throws IllegalArgumentException
{
    if (!(key instanceof ECPrivateKeyParameters))
    {
        throw new IllegalArgumentException("Private key required for encryption");
    }

    ECPrivateKeyParameters ecPrivKey = (ECPrivateKeyParameters)key;
    ECDomainParameters ecParams = ecPrivKey.getParameters();
    ECCurve curve = ecParams.getCurve();
    BigInteger n = ecParams.getN();
    BigInteger h = ecParams.getH();

    // Decode the ephemeral public key
    byte[] C = new byte[inLen];
    System.arraycopy(in, inOff, C, 0, inLen);

    // NOTE: Decoded points are already normalized (i.e in affine form)
    ECPoint gTilde = curve.decodePoint(C);

    // Compute the static-ephemeral key agreement
    ECPoint gHat = gTilde;
    if ((CofactorMode) || (OldCofactorMode))
    {
        gHat = gHat.multiply(h);
    }

    BigInteger xHat = ecPrivKey.getD();
    if (CofactorMode)
    {
        xHat = xHat.multiply(h.modInverse(n)).mod(n);
    }

    ECPoint hTilde = gHat.multiply(xHat).normalize();

    // Encode the shared secret value
    byte[] PEH = hTilde.getAffineXCoord().getEncoded();

    return deriveKey(keyLen, C, PEH);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:51,代码来源:ECIESKeyEncapsulation.java


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