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