本文整理汇总了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;
}
示例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]));
}
}
示例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
}