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


Java ECUtil.encodePoint方法代码示例

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


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

示例1: engineDoPhase

import sun.security.util.ECUtil; //导入方法依赖的package包/类
@Override
protected Key engineDoPhase(Key key, boolean lastPhase)
        throws InvalidKeyException, IllegalStateException {
    if (privateKey == null) {
        throw new IllegalStateException("Not initialized");
    }
    if (publicValue != null) {
        throw new IllegalStateException("Phase already executed");
    }
    if (!lastPhase) {
        throw new IllegalStateException
            ("Only two party agreement supported, lastPhase must be true");
    }
    if (!(key instanceof ECPublicKey)) {
        throw new InvalidKeyException
            ("Key must be a PublicKey with algorithm EC");
    }

    ECPublicKey ecKey = (ECPublicKey)key;
    ECParameterSpec params = ecKey.getParams();

    if (ecKey instanceof ECPublicKeyImpl) {
        publicValue = ((ECPublicKeyImpl)ecKey).getEncodedPublicValue();
    } else { // instanceof ECPublicKey
        publicValue =
            ECUtil.encodePoint(ecKey.getW(), params.getCurve());
    }
    int keyLenBits = params.getCurve().getField().getFieldSize();
    secretLen = (keyLenBits + 7) >> 3;

    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:ECDHKeyAgreement.java

示例2: getEncodedPublicValue

import sun.security.util.ECUtil; //导入方法依赖的package包/类
static byte[] getEncodedPublicValue(PublicKey key) throws InvalidKeyException {
    if (key instanceof ECPublicKey) {
        ECPublicKey ecKey = (ECPublicKey)key;
        ECPoint w = ecKey.getW();
        ECParameterSpec params = ecKey.getParams();
        return ECUtil.encodePoint(w, params.getCurve());
    } else {
        // should never occur
        throw new InvalidKeyException
            ("Key class not yet supported: " + key.getClass().getName());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:P11ECKeyFactory.java

示例3: generatePublic

import sun.security.util.ECUtil; //导入方法依赖的package包/类
private PublicKey generatePublic(ECPoint point, ECParameterSpec params)
        throws PKCS11Exception {
    byte[] encodedParams =
        ECUtil.encodeECParameterSpec(getSunECProvider(), params);
    byte[] encodedPoint =
        ECUtil.encodePoint(point, params.getCurve());

    // Check whether the X9.63 encoding of an EC point shall be wrapped
    // in an ASN.1 OCTET STRING
    if (!token.config.getUseEcX963Encoding()) {
        try {
            encodedPoint =
                new DerValue(DerValue.tag_OctetString, encodedPoint)
                    .toByteArray();
        } catch (IOException e) {
            throw new
                IllegalArgumentException("Could not DER encode point", e);
        }
    }

    CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
        new CK_ATTRIBUTE(CKA_CLASS, CKO_PUBLIC_KEY),
        new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_EC),
        new CK_ATTRIBUTE(CKA_EC_POINT, encodedPoint),
        new CK_ATTRIBUTE(CKA_EC_PARAMS, encodedParams),
    };
    attributes = token.getAttributes
            (O_IMPORT, CKO_PUBLIC_KEY, CKK_EC, attributes);
    Session session = null;
    try {
        session = token.getObjSession();
        long keyID = token.p11.C_CreateObject(session.id(), attributes);
        return P11Key.publicKey
            (session, keyID, "EC", params.getCurve().getField().getFieldSize(), attributes);
    } finally {
        token.releaseSession(session);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:P11ECKeyFactory.java

示例4: ECPublicKeyImpl

import sun.security.util.ECUtil; //导入方法依赖的package包/类
/**
 * Construct a key from its components. Used by the
 * ECKeyFactory.
 */
@SuppressWarnings("deprecation")
ECPublicKeyImpl(ECPoint w, ECParameterSpec params)
        throws InvalidKeyException {
    this.w = w;
    this.params = params;
    // generate the encoding
    algid = new AlgorithmId
        (AlgorithmId.EC_oid, ECParameters.getAlgorithmParameters(params));
    key = ECUtil.encodePoint(w, params.getCurve());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ECPublicKeyImpl.java

示例5: encodePoint

import sun.security.util.ECUtil; //导入方法依赖的package包/类
static byte[] encodePoint(ECPoint point, EllipticCurve curve) {
    return ECUtil.encodePoint(point, curve);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:JsseJce.java


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