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


Java ECPrivateKey.setA方法代码示例

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


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

示例1: newKeyPair

import javacard.security.ECPrivateKey; //导入方法依赖的package包/类
static public KeyPair newKeyPair() {
	KeyPair kp = new KeyPair(KeyPair.ALG_EC_FP, (short) 256);

	ECPrivateKey ecPrv = (ECPrivateKey) kp.getPrivate();
	ECPublicKey ecPub = (ECPublicKey) kp.getPublic();

	ecPrv.setFieldFP(p, (short) 0, (short) p.length);
	ecPrv.setA(a, (short) 0, (short) a.length);
	ecPrv.setB(b, (short) 0, (short) b.length);
	ecPrv.setG(G, (short) 0, (short) G.length);
	ecPrv.setR(r, (short) 0, (short) r.length);

	ecPub.setFieldFP(p, (short) 0, (short) p.length);
	ecPub.setA(a, (short) 0, (short) a.length);
	ecPub.setB(b, (short) 0, (short) b.length);
	ecPub.setG(G, (short) 0, (short) G.length);
	ecPub.setR(r, (short) 0, (short) r.length);

	return kp;
}
 
开发者ID:Yubico,项目名称:ykneo-curves,代码行数:21,代码来源:SecP256k1.java

示例2: newKeyPair

import javacard.security.ECPrivateKey; //导入方法依赖的package包/类
static public KeyPair newKeyPair() {
	KeyPair key = new KeyPair(KeyPair.ALG_EC_FP, (short) 256);

	ECPrivateKey privKey = (ECPrivateKey) key.getPrivate();
	ECPublicKey pubKey = (ECPublicKey) key.getPublic();

	privKey.setFieldFP(q, (short) 0, (short) q.length);
	privKey.setA(a, (short) 0, (short) a.length);
	privKey.setB(b, (short) 0, (short) b.length);
	privKey.setG(G, (short) 0, (short) G.length);
	privKey.setR(r, (short) 0, (short) r.length);

	pubKey.setFieldFP(q, (short) 0, (short) q.length);
	pubKey.setA(a, (short) 0, (short) a.length);
	pubKey.setB(b, (short) 0, (short) b.length);
	pubKey.setG(G, (short) 0, (short) G.length);
	pubKey.setR(r, (short) 0, (short) r.length);

	return key;
}
 
开发者ID:Yubico,项目名称:ykneo-curves,代码行数:21,代码来源:Frp256v1.java

示例3: newKeyPair

import javacard.security.ECPrivateKey; //导入方法依赖的package包/类
static public KeyPair newKeyPair() {
	KeyPair key = new KeyPair(KeyPair.ALG_EC_FP, (short) 256);

	ECPrivateKey privKey = (ECPrivateKey) key.getPrivate();
	ECPublicKey pubKey = (ECPublicKey) key.getPublic();

	privKey.setFieldFP(p, (short) 0, (short) p.length);
	privKey.setA(a, (short) 0, (short) a.length);
	privKey.setB(b, (short) 0, (short) b.length);
	privKey.setG(G, (short) 0, (short) G.length);
	privKey.setR(r, (short) 0, (short) r.length);

	pubKey.setFieldFP(p, (short) 0, (short) p.length);
	pubKey.setA(a, (short) 0, (short) a.length);
	pubKey.setB(b, (short) 0, (short) b.length);
	pubKey.setG(G, (short) 0, (short) G.length);
	pubKey.setR(r, (short) 0, (short) r.length);

	return key;
}
 
开发者ID:Yubico,项目名称:ykneo-curves,代码行数:21,代码来源:SecP256r1.java

示例4: newKeyPair

import javacard.security.ECPrivateKey; //导入方法依赖的package包/类
static public KeyPair newKeyPair() {
	KeyPair key = new KeyPair(KeyPair.ALG_EC_FP, (short) 320);

	ECPrivateKey privKey = (ECPrivateKey) key.getPrivate();
	ECPublicKey pubKey = (ECPublicKey) key.getPublic();

	privKey.setFieldFP(q, (short) 0, (short) q.length);
	privKey.setA(a, (short) 0, (short) a.length);
	privKey.setB(b, (short) 0, (short) b.length);
	privKey.setG(G, (short) 0, (short) G.length);
	privKey.setR(r, (short) 0, (short) r.length);

	pubKey.setFieldFP(q, (short) 0, (short) q.length);
	pubKey.setA(a, (short) 0, (short) a.length);
	pubKey.setB(b, (short) 0, (short) b.length);
	pubKey.setG(G, (short) 0, (short) G.length);
	pubKey.setR(r, (short) 0, (short) r.length);

	return key;
}
 
开发者ID:Yubico,项目名称:ykneo-curves,代码行数:21,代码来源:BrainpoolP320r1.java

示例5: setParameter

import javacard.security.ECPrivateKey; //导入方法依赖的package包/类
/**
     * @param key
     * @param param
     * @param data
     * @param offset
     * @param length
     * @return
     */
    public short setParameter(KeyPair keypair, byte key, short param, byte[] data, short offset, short length) {
        try {
            sw = AppletUtil.keypairCheck(keypair);

            ECPublicKey ecPublicKey = (ECPublicKey) keypair.getPublic();
            ECPrivateKey ecPrivateKey = (ECPrivateKey) keypair.getPrivate();

            switch (param) {
                case EC_Consts.PARAMETER_FP:
                    if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setFieldFP(data, offset, length);
                    if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setFieldFP(data, offset, length);
                    break;
                case EC_Consts.PARAMETER_F2M:
                    if (length == 4) {
                        short i = Util.makeShort(data[(short) (offset + 2)], data[(short) (offset + 3)]);
                        if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setFieldF2M(i);
                        if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setFieldF2M(i);
                    } else if (length == 8) {
                        short i1 = Util.makeShort(data[(short) (offset + 2)], data[(short) (offset + 3)]);
                        short i2 = Util.makeShort(data[(short) (offset + 4)], data[(short) (offset + 5)]);
                        short i3 = Util.makeShort(data[(short) (offset + 6)], data[(short) (offset + 7)]);
//                        if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setFieldF2M(i1, i2, i3);
//                        if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setFieldF2M(i1, i2, i3);
                        // TODO: fix this, ^^ fails on jcardsim, but is up to spec
                        if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setFieldF2M(i3, i2, i1);
                        if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setFieldF2M(i3, i2, i1);
                    } else {
                        sw = ISO7816.SW_UNKNOWN;
                    }
                    break;
                case EC_Consts.PARAMETER_A:
                    if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setA(data, offset, length);
                    if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setA(data, offset, length);
                    break;
                case EC_Consts.PARAMETER_B:
                    if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setB(data, offset, length);
                    if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setB(data, offset, length);
                    break;
                case EC_Consts.PARAMETER_G:
                    if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setG(data, offset, length);
                    if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setG(data, offset, length);
                    break;
                case EC_Consts.PARAMETER_R:
                    if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setR(data, offset, length);
                    if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setR(data, offset, length);
                    break;
                case EC_Consts.PARAMETER_K:
                    short k = 0;
                    if (length > 2 || length <= 0) {
                        sw = ISO7816.SW_UNKNOWN;
                        break;
                    } else if (length == 2) {
                        k = Util.getShort(data, offset);
                    } else if (length == 1) {
                        k = data[offset];
                    }
                    if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setK(k);
                    if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setK(k);
                    break;
                case EC_Consts.PARAMETER_S:
                    if ((key & EC_Consts.KEY_PRIVATE) != 0) ecPrivateKey.setS(data, offset, length);
                    break;
                case EC_Consts.PARAMETER_W:
                    if ((key & EC_Consts.KEY_PUBLIC) != 0) ecPublicKey.setW(data, offset, length);
                    break;
                default:
                    ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED);
            }
        } catch (CardRuntimeException ce) {
            sw = ce.getReason();
        }
        return sw;
    }
 
开发者ID:crocs-muni,项目名称:ECTester,代码行数:82,代码来源:ECKeyGenerator.java


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