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


Java ECAlgorithms.isF2mCurve方法代码示例

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


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

示例1: serializeECPoint

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static byte[] serializeECPoint(short[] ecPointFormats, ECPoint point) throws IOException
{
    ECCurve curve = point.getCurve();

    /*
     * RFC 4492 5.7. ...an elliptic curve point in uncompressed or compressed format. Here, the
     * format MUST conform to what the server has requested through a Supported Point Formats
     * Extension if this extension was used, and MUST be uncompressed if this extension was not
     * used.
     */
    boolean compressed = false;
    if (ECAlgorithms.isFpCurve(curve))
    {
        compressed = isCompressionPreferred(ecPointFormats, ECPointFormat.ansiX962_compressed_prime);
    }
    else if (ECAlgorithms.isF2mCurve(curve))
    {
        compressed = isCompressionPreferred(ecPointFormats, ECPointFormat.ansiX962_compressed_char2);
    }
    return point.getEncoded(compressed);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:22,代码来源:TlsECCUtils.java

示例2: main

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static void main(String[] args)
{
    SortedSet names = new TreeSet(enumToList(ECNamedCurveTable.getNames()));
    names.addAll(enumToList(CustomNamedCurves.getNames()));

    Iterator it = names.iterator();
    while (it.hasNext())
    {
        String name = (String)it.next();
        X9ECParameters x9 = CustomNamedCurves.getByName(name);
        if (x9 == null)
        {
            x9 = ECNamedCurveTable.getByName(name);
        }
        if (x9 != null && ECAlgorithms.isF2mCurve(x9.getCurve()))
        {
            System.out.print(name + ":");
            implPrintNonZeroTraceBits(x9);
        }
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:22,代码来源:TraceOptimizer.java

示例3: main

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static void main(String[] args)
{
    SortedSet names = new TreeSet(enumToList(ECNamedCurveTable.getNames()));
    names.addAll(enumToList(CustomNamedCurves.getNames()));

    Iterator it = names.iterator();
    while (it.hasNext())
    {
        String name = (String)it.next();
        X9ECParameters x9 = CustomNamedCurves.getByName(name);
        if (x9 == null)
        {
            x9 = ECNamedCurveTable.getByName(name);
        }
        if (x9 != null && ECAlgorithms.isF2mCurve(x9.getCurve()))
        {
            System.out.print(name + ":");
            implPrintRootZ(x9);
        }
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:22,代码来源:F2mSqrtOptimizer.java

示例4: DSTU4145ECBinary

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public DSTU4145ECBinary(ECDomainParameters params)
{
    ECCurve curve = params.getCurve();
    if (!ECAlgorithms.isF2mCurve(curve))
    {
        throw new IllegalArgumentException("only binary domain is possible");
    }

    // We always use big-endian in parameter encoding

    PolynomialExtensionField field = (PolynomialExtensionField)curve.getField();
    int[] exponents = field.getMinimalPolynomial().getExponentsPresent();
    if (exponents.length == 3)
    {
        f = new DSTU4145BinaryField(exponents[2], exponents[1]);
    }
    else if (exponents.length == 5)
    {
        f = new DSTU4145BinaryField(exponents[4], exponents[1], exponents[2], exponents[3]);
    }

    a = new ASN1Integer(curve.getA().toBigInteger());
    b = new DEROctetString(curve.getB().getEncoded());
    n = new ASN1Integer(params.getN());
    bp = new DEROctetString(DSTU4145PointEncoder.encodePoint(params.getG()));
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:27,代码来源:DSTU4145ECBinary.java

示例5: setFieldIdentifier

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
private void setFieldIdentifier()
{
    if (ECAlgorithms.isFpCurve(curve))
    {
        fieldIdentifier = prime_field;
    }
    else if (ECAlgorithms.isF2mCurve(curve))
    {
        fieldIdentifier = characteristic_two_field;
    }
    else
    {
        throw new IllegalArgumentException("This type of ECCurve is not implemented");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:16,代码来源:X9Curve.java

示例6: X9ECParameters

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public X9ECParameters(
    ECCurve     curve,
    X9ECPoint   g,
    BigInteger  n,
    BigInteger  h,
    byte[]      seed)
{
    this.curve = curve;
    this.g = g;
    this.n = n;
    this.h = h;
    this.seed = seed;

    if (ECAlgorithms.isFpCurve(curve))
    {
        this.fieldID = new X9FieldID(curve.getField().getCharacteristic());
    }
    else if (ECAlgorithms.isF2mCurve(curve))
    {
        PolynomialExtensionField field = (PolynomialExtensionField)curve.getField();
        int[] exponents = field.getMinimalPolynomial().getExponentsPresent();
        if (exponents.length == 3)
        {
            this.fieldID = new X9FieldID(exponents[2], exponents[1]);
        }
        else if (exponents.length == 5)
        {
            this.fieldID = new X9FieldID(exponents[4], exponents[1], exponents[2], exponents[3]);
        }
        else
        {
            throw new IllegalArgumentException("Only trinomial and pentomial curves are supported");
        }
    }
    else
    {
        throw new IllegalArgumentException("'curve' is of an unsupported type");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:40,代码来源:X9ECParameters.java

示例7: DSTU4145ECBinary

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public DSTU4145ECBinary(ECDomainParameters params)
{
    ECCurve curve = params.getCurve();
    if (!ECAlgorithms.isF2mCurve(curve))
    {
        throw new IllegalArgumentException("only binary domain is possible");
    }

    // We always use big-endian in parameter encoding

    PolynomialExtensionField field = (PolynomialExtensionField)curve.getField();
    int[] exponents = field.getMinimalPolynomial().getExponentsPresent();
    if (exponents.length == 3)
    {
        f = new DSTU4145BinaryField(exponents[2], exponents[1]);
    }
    else if (exponents.length == 5)
    {
        f = new DSTU4145BinaryField(exponents[4], exponents[1], exponents[2], exponents[3]);
    }
    else
    {
        throw new IllegalArgumentException("curve must have a trinomial or pentanomial basis");
    }

    a = new ASN1Integer(curve.getA().toBigInteger());
    b = new DEROctetString(curve.getB().getEncoded());
    n = new ASN1Integer(params.getN());
    bp = new DEROctetString(DSTU4145PointEncoder.encodePoint(params.getG()));
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:31,代码来源:DSTU4145ECBinary.java

示例8: printNonZeroTraceBits

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static void printNonZeroTraceBits(X9ECParameters x9)
{
    if (!ECAlgorithms.isF2mCurve(x9.getCurve()))
    {
        throw new IllegalArgumentException("Trace only defined over characteristic-2 fields");
    }

    implPrintNonZeroTraceBits(x9);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:10,代码来源:TraceOptimizer.java

示例9: printRootZ

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static void printRootZ(X9ECParameters x9)
{
    if (!ECAlgorithms.isF2mCurve(x9.getCurve()))
    {
        throw new IllegalArgumentException("Sqrt optimization only defined over characteristic-2 fields");
    }

    implPrintRootZ(x9);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:10,代码来源:F2mSqrtOptimizer.java

示例10: X9ECParameters

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public X9ECParameters(
    ECCurve     curve,
    ECPoint     g,
    BigInteger  n,
    BigInteger  h,
    byte[]      seed)
{
    this.curve = curve;
    this.g = g.normalize();
    this.n = n;
    this.h = h;
    this.seed = seed;

    if (ECAlgorithms.isFpCurve(curve))
    {
        this.fieldID = new X9FieldID(curve.getField().getCharacteristic());
    }
    else if (ECAlgorithms.isF2mCurve(curve))
    {
        PolynomialExtensionField field = (PolynomialExtensionField)curve.getField();
        int[] exponents = field.getMinimalPolynomial().getExponentsPresent();
        if (exponents.length == 3)
        {
            this.fieldID = new X9FieldID(exponents[2], exponents[1]);
        }
        else if (exponents.length == 5)
        {
            this.fieldID = new X9FieldID(exponents[4], exponents[1], exponents[2], exponents[3]);
        }
        else
        {
            throw new IllegalArgumentException("Only trinomial and pentomial curves are supported");
        }
    }
    else
    {
        throw new IllegalArgumentException("'curve' is of an unsupported type");
    }
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:40,代码来源:X9ECParameters.java

示例11: deserializeECPoint

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static ECPoint deserializeECPoint(short[] ecPointFormats, ECCurve curve, byte[] encoding) throws IOException
{
    if (encoding == null || encoding.length < 1)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }

    short actualFormat;
    switch (encoding[0])
    {
    case 0x02: // compressed
    case 0x03: // compressed
    {
        if (ECAlgorithms.isF2mCurve(curve))
        {
            actualFormat = ECPointFormat.ansiX962_compressed_char2;
        }
        else if (ECAlgorithms.isFpCurve(curve))
        {
            actualFormat = ECPointFormat.ansiX962_compressed_prime;
        }
        else
        {
            throw new TlsFatalAlert(AlertDescription.illegal_parameter);
        }
        break;
    }
    case 0x04: // uncompressed
    {
        actualFormat = ECPointFormat.uncompressed;
        break;
    }
    case 0x00: // infinity
    case 0x06: // hybrid
    case 0x07: // hybrid
    default:
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }

    if (actualFormat != ECPointFormat.uncompressed
        && (ecPointFormats == null || !Arrays.contains(ecPointFormats, actualFormat)))
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }

    return curve.decodePoint(encoding);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:48,代码来源:TlsECCUtils.java

示例12: writeExplicitECParameters

import org.bouncycastle.math.ec.ECAlgorithms; //导入方法依赖的package包/类
public static void writeExplicitECParameters(short[] ecPointFormats, ECDomainParameters ecParameters,
    OutputStream output) throws IOException
{
    ECCurve curve = ecParameters.getCurve();

    if (ECAlgorithms.isFpCurve(curve))
    {
        TlsUtils.writeUint8(ECCurveType.explicit_prime, output);

        writeECParameter(curve.getField().getCharacteristic(), output);
    }
    else if (ECAlgorithms.isF2mCurve(curve))
    {
        PolynomialExtensionField field = (PolynomialExtensionField)curve.getField();
        int[] exponents = field.getMinimalPolynomial().getExponentsPresent();

        TlsUtils.writeUint8(ECCurveType.explicit_char2, output);

        int m = exponents[exponents.length - 1];
        TlsUtils.checkUint16(m);
        TlsUtils.writeUint16(m, output);

        if (exponents.length == 3)
        {
            TlsUtils.writeUint8(ECBasisType.ec_basis_trinomial, output);
            writeECExponent(exponents[1], output);
        }
        else if (exponents.length == 5)
        {
            TlsUtils.writeUint8(ECBasisType.ec_basis_pentanomial, output);
            writeECExponent(exponents[1], output);
            writeECExponent(exponents[2], output);
            writeECExponent(exponents[3], output);
        }
        else
        {
            throw new IllegalArgumentException("Only trinomial and pentomial curves are supported");
        }
    }
    else
    {
        throw new IllegalArgumentException("'ecParameters' not a known curve type");
    }

    writeECFieldElement(curve.getA(), output);
    writeECFieldElement(curve.getB(), output);
    TlsUtils.writeOpaque8(serializeECPoint(ecPointFormats, ecParameters.getG()), output);
    writeECParameter(ecParameters.getN(), output);
    writeECParameter(ecParameters.getH(), output);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:51,代码来源:TlsECCUtils.java


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