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


Java ECUtil.getNamedCurveByOid方法代码示例

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


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

示例1: getDomainParametersFromName

import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入方法依赖的package包/类
static X9ECParameters getDomainParametersFromName(String curveName)
{
    X9ECParameters domainParameters;
    try
    {
        if (curveName.charAt(0) >= '0' && curveName.charAt(0) <= '2')
        {
            ASN1ObjectIdentifier oidID = new ASN1ObjectIdentifier(curveName);
            domainParameters = ECUtil.getNamedCurveByOid(oidID);
        }
        else
        {
            if (curveName.indexOf(' ') > 0)
            {
                curveName = curveName.substring(curveName.indexOf(' ') + 1);
                domainParameters = ECUtil.getNamedCurveByName(curveName);
            }
            else
            {
                domainParameters = ECUtil.getNamedCurveByName(curveName);
            }
        }
    }
    catch (IllegalArgumentException ex)
    {
        domainParameters = ECUtil.getNamedCurveByName(curveName);
    }
    return domainParameters;
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:30,代码来源:ECUtils.java

示例2: checkEcSubjectPublicKeyInfo

import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入方法依赖的package包/类
private static void checkEcSubjectPublicKeyInfo(ASN1ObjectIdentifier curveOid,
        byte[] encoded) throws BadCertTemplateException {
    ParamUtil.requireNonNull("curveOid", curveOid);
    ParamUtil.requireNonNull("encoded", encoded);
    ParamUtil.requireMin("encoded.length", encoded.length, 1);

    Integer expectedLength = ecCurveFieldSizes.get(curveOid);
    if (expectedLength == null) {
        X9ECParameters ecP = ECUtil.getNamedCurveByOid(curveOid);
        ECCurve curve = ecP.getCurve();
        expectedLength = (curve.getFieldSize() + 7) / 8;
        ecCurveFieldSizes.put(curveOid, expectedLength);
    }

    switch (encoded[0]) {
    case 0x02: // compressed
    case 0x03: // compressed
        if (encoded.length != (expectedLength + 1)) {
            throw new BadCertTemplateException("incorrect length for compressed encoding");
        }
        break;
    case 0x04: // uncompressed
    case 0x06: // hybrid
    case 0x07: // hybrid
        if (encoded.length != (2 * expectedLength + 1)) {
            throw new BadCertTemplateException(
                    "incorrect length for uncompressed/hybrid encoding");
        }
        break;
    default:
        throw new BadCertTemplateException(
                String.format("invalid point encoding 0x%02x", encoded[0]));
    }
}
 
开发者ID:xipki,项目名称:xipki,代码行数:35,代码来源:BaseX509Certprofile.java

示例3: checkECSubjectPublicKeyInfo

import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil; //导入方法依赖的package包/类
private static void checkECSubjectPublicKeyInfo(ASN1ObjectIdentifier curveOid,
        byte[] encoded) throws BadCertTemplateException {
    Integer expectedLength = EC_CURVEFIELD_SIZES.get(curveOid);
    if (expectedLength == null) {
        X9ECParameters ecP = ECUtil.getNamedCurveByOid(curveOid);
        ECCurve curve = ecP.getCurve();
        expectedLength = (curve.getFieldSize() + 7) / 8;
        EC_CURVEFIELD_SIZES.put(curveOid, expectedLength);
    }

    switch (encoded[0]) {
    case 0x02: // compressed
    case 0x03: // compressed
        if (encoded.length != (expectedLength + 1)) {
            throw new BadCertTemplateException("incorrect length for compressed encoding");
        }
        break;
    case 0x04: // uncompressed
    case 0x06: // hybrid
    case 0x07: // hybrid
        if (encoded.length != (2 * expectedLength + 1)) {
            throw new BadCertTemplateException(
                    "incorrect length for uncompressed/hybrid encoding");
        }
        break;
    default:
        throw new BadCertTemplateException(
                "invalid point encoding 0x" + Integer.toString(encoded[0], 16));
    } // end switch
}
 
开发者ID:xipki,项目名称:xipki,代码行数:31,代码来源:PublicKeyChecker.java


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