當前位置: 首頁>>代碼示例>>Java>>正文


Java X9ECParameters類代碼示例

本文整理匯總了Java中org.bouncycastle.asn1.x9.X9ECParameters的典型用法代碼示例。如果您正苦於以下問題:Java X9ECParameters類的具體用法?Java X9ECParameters怎麽用?Java X9ECParameters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


X9ECParameters類屬於org.bouncycastle.asn1.x9包,在下文中一共展示了X9ECParameters類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getByName

import org.bouncycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
public static X9ECParameters getByName(
    String  name)
{
    ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)objIds.get(Strings.toUpperCase(name));

    if (oid != null)
    {
        return getByOID(oid);
    }

    return null;
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:13,代碼來源:NISTNamedCurves.java

示例2: getSM2Z

import org.bouncycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
public static byte[] getSM2Z(byte[] userID, ASN1ObjectIdentifier curveOid,
        BigInteger pubPointX, BigInteger pubPointY) {
    SM3Digest digest = new SM3Digest();

    addUserID(digest, userID);

    X9ECParameters ecParams = GMNamedCurves.getByOID(curveOid);
    addFieldElement(digest, ecParams.getCurve().getA());
    addFieldElement(digest, ecParams.getCurve().getB());
    addFieldElement(digest, ecParams.getG().getAffineXCoord());
    addFieldElement(digest, ecParams.getG().getAffineYCoord());

    int fieldSize = (ecParams.getCurve().getFieldSize() + 7) / 8;
    byte[] bytes = BigIntegers.asUnsignedByteArray(fieldSize, pubPointX);
    digest.update(bytes, 0, fieldSize);

    bytes = BigIntegers.asUnsignedByteArray(fieldSize, pubPointY);
    digest.update(bytes, 0, fieldSize);

    byte[] result = new byte[digest.getDigestSize()];
    digest.doFinal(result, 0);
    return result;
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:24,代碼來源:GMUtil.java

示例3: getParameterSpec

import org.bouncycastle.asn1.x9.X9ECParameters; //導入依賴的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)
{
    X9ECParameters  ecP = X962NamedCurves.getByName(name);
    if (ecP == null)
    {
        return null;
    }

    return new ECNamedCurveParameterSpec(
                                    name,
                                    ecP.getCurve(),
                                    ecP.getG(),
                                    ecP.getN(),
                                    ecP.getH(),
                                    ecP.getSeed());

}
 
開發者ID:thangbn,項目名稱:Direct-File-Downloader,代碼行數:26,代碼來源:ECNamedCurveTable.java

示例4: getParametersForNamedCurve

import org.bouncycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
public static ECDomainParameters getParametersForNamedCurve(int namedCurve)
{
    String curveName = getNameOfNamedCurve(namedCurve);
    if (curveName == null)
    {
        return null;
    }

    // Lazily created the first time a particular curve is accessed
    X9ECParameters ecP = SECNamedCurves.getByName(curveName);

    if (ecP == null)
    {
        return null;
    }

    // It's a bit inefficient to do this conversion every time
    return new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:20,代碼來源:TlsECCUtils.java

示例5: createParameters

import org.bouncycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
protected X9ECParameters createParameters()
{
    // p = (2^128 - 3) / 76439
    BigInteger p = fromHex("DB7C2ABF62E35E668076BEAD208B");
    BigInteger a = fromHex("DB7C2ABF62E35E668076BEAD2088");
    BigInteger b = fromHex("659EF8BA043916EEDE8911702B22");
    byte[] S = Hex.decode("00F50B028E4D696E676875615175290472783FB1");
    BigInteger n = fromHex("DB7C2ABF62E35E7628DFAC6561C5");
    BigInteger h = BigInteger.valueOf(1);

    ECCurve curve = new ECCurve.Fp(p, a, b);
    //ECPoint G = curve.decodePoint(Hex.decode("02"
    //+ "09487239995A5EE76B55F9C2F098"));
    ECPoint G = curve.decodePoint(Hex.decode("04"
        + "09487239995A5EE76B55F9C2F098"
        + "A89CE5AF8724C0A23E0E0FF77500"));

    return new X9ECParameters(curve, G, n, h, S);
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:20,代碼來源:SECNamedCurves.java

示例6: getNamedCurveByOid

import org.bouncycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
public static X9ECParameters getNamedCurveByOid(
    ASN1ObjectIdentifier oid)
{
    X9ECParameters params = X962NamedCurves.getByOID(oid);
    
    if (params == null)
    {
        params = SECNamedCurves.getByOID(oid);
        if (params == null)
        {
            params = NISTNamedCurves.getByOID(oid);
        }
        if (params == null)
        {
            params = TeleTrusTNamedCurves.getByOID(oid);
        }
    }

    return params;
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:21,代碼來源:ECUtil.java

示例7: testExportImport

import org.bouncycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
@Test
public void testExportImport() throws GeneralSecurityException {

	// Create a curve25519 parameter spec
	X9ECParameters params = CustomNamedCurves.getByName("curve25519");
	ECParameterSpec ecParameterSpec = new ECParameterSpec(params.getCurve(), params.getG(), params.getN(), params.getH(), params.getSeed());

	// Create public key
	KeyAgreementPeer peer = new ECDHPeer(ecParameterSpec, null, "BC");
	ECPublicKey ecPublicKey = (ECPublicKey) peer.getPublicKey();

	// Export public key
	byte[] encoded = ecPublicKey.getQ().getEncoded(true);

	System.out.println(Arrays.toString(encoded));
	System.out.println("Encoded length: " + encoded.length);

	// Import public key
	ECPublicKey importedECPublicKey = loadPublicKey(encoded);

	Assert.assertArrayEquals(ecPublicKey.getEncoded(), importedECPublicKey.getEncoded());
}
 
開發者ID:martinwithaar,項目名稱:Encryptor4j,代碼行數:23,代碼來源:ECDHExportTest.java

示例8: getParametersForNamedCurve

import org.bouncycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
public static ECDomainParameters getParametersForNamedCurve(int namedCurve)
{
    String curveName = getNameOfNamedCurve(namedCurve);
    if (curveName == null)
    {
        return null;
    }

    // Parameters are lazily created the first time a particular curve is accessed

    X9ECParameters ecP = CustomNamedCurves.getByName(curveName);
    if (ecP == null)
    {
        ecP = ECNamedCurveTable.getByName(curveName);
        if (ecP == null)
        {
            return null;
        }
    }

    // It's a bit inefficient to do this conversion every time
    return new ECDomainParameters(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());
}
 
開發者ID:thedrummeraki,項目名稱:Aki-SSL,代碼行數:24,代碼來源:TlsECCUtils.java


注:本文中的org.bouncycastle.asn1.x9.X9ECParameters類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。